Hi,
saltlamp wrote:
some bootloaders don't set the lower half of the DX register correctly
That's because the lower half of the DX register is the DL register, which is set by the BIOS and contains the drive code from where your code was loaded. It's 00h if your code was loaded from a floppy, 80h if loaded from the first (master) hard disk, 81h for the second (slave) disk, and in some cases could be E0h if the sector loaded from CD-ROM. If a bootloader sets DL, then it will most certainly loose this information.
saltlamp wrote:
some implicitly (so I've heard) do a CLI/STI wrap around a SS and SP register change, and some don't set the carry flag properly after an interrupt.
It is always a good idea to start a bootloader with CLI+CLC to clear interrupts and set up direction flag until you finish with setting up the segment registers and the stack.
saltlamp wrote:
In all of this, it was making me worried about the portability of the boot-loader, lol, but if that address is not a problem, then I won't treat it as one!
But it is a problem. Consider this: you assume CS=0 and you make a jump to 7C80 for example. If BIOS has loaded the CS:IP registers with 7C0:0, then you'll jump to 7C0:7C80, which is a different physical address than 0:7C80 (or 7C0:80).
Take @Solar's and @MichaelPetch's advice and first thing set up your segment registers correctly. Not only CS, but DS, ES and SS too.
Code:
boot_sector_prologue:
cli
clc
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, 7C00h
jmp far 0:start
start:
sti
mov byte [bootdrive], dl
Cheers,
bzt