I've been trying to write a Master Boot Record (MBR) in the Netwide Assembler (NASM) for Intel's x86 architecture that saves a `memory map' on the 3.5" floppy disk it booted from. The data that will be written to the floppy is in the range R=[0x00_00_00, 0x16_7F_FF]. This `odd' range is because, to my knowledge, a 3.5" floppy disk consists of 0x16_80_00 bytes.
I designed it in such a way that the code only works once, because the MBR gets overwritten as well. I know this MBR gives no guarantee that it gives an accurate dump of the memory in R: this is because by the time or during the time a sector is being read, the data in the read sector or upcoming sectors may be changed.
Problem
I couldn't figure out how to read memory in range T=[0x10_00_00, 0x16_7F_FF]. As you can see, the normalized segment R's limit (absolute 0x16_80_00 <-> normalized segment 0x01_68_00:0) does not fit in a 16 bit register (my copy/write subroutine uses ES:BX - that `int ah=3' uses - to store this normalized segment).
If I run my MBR with Virtual Box (VBox), the printed arguments that will be passed to `int ah=3' match my expectations:
(underlined text are my annotations)the format is as follows:
ES cylinder/track head sector write_status
(numbers are all in hexadecimal)
...
FFC0 0038 0001 000D ok
FFE0 0038 0001 000E ok
overflow ES overflows
0000 0038 0001 000F ok
...
67C0 004F 0001 0011 ok <- `67C0' should be `01 67C0' but ES is 16bit so that won't fit
67E0 004F 0001 0012 ok
succcess
Questions
What I want to know is two things:
- Is it useful to try fix my 16bit overflow problem?
- Or should I ignore the 16bit overflow and use range T rather than R?
Host Environment
I'm running Windows 8.1 64bit and developing my MBR in Vi IMproved (VIM) using Cygwin 64bit. I use GNU Make to build my project. I use disk dump (dd) to create the floppy image and put the binaries into the final image that I run through VBox.
Source code
Makefile:
Code: Select all
.PHONY: clean
mmcpy.img: mmcpy.flp mmcpy.bin
cp mmcpy.flp mmcpy.img
dd if=mmcpy.bin of=mmcpy.img conv=notrunc
mmcpy.flp:
dd if=/dev/zero of=mmcpy.flp bs=1K count=1440
mmcpy.bin: mmcpy.s
nasm -f bin -o mmcpy.bin mmcpy.s
clean:
rm -f mmcpy.img mmcpy.flp mmcpy.bin
sha1: e62dc54a02676bdad32a8251f830954e668074cf
md5: f9894126b5f70ce692f48012a227210e