I've been writing a somewhat basic bootloader and it works like a peach in bochs. However, on my actual machine, a few instructions get scrambled and the bootloader fails. I've diagnosed the disease but don't have a good cure. It seems that the BIOS (UEFI in compatibility mode, by the way) is looking for a Bios Parameter Block (BPB), cannot find one (because I didn't make one), and outrageously overwrites certain bytes, thereby messing up the bootloader. My current way to fix it is to start my assembly off by reserving (zeroing) the first 50 bytes of my program with
resb 50
This is not a good solution, however. It's a huge waste of space, considering a bootloader is only 512 bytes. That's about 10% of space wasted! So here's my question:
Is there a better way to circumvent/stop/disable the bios from overwriting parts of the bootloader? What's the best way to get the most bytes out of my bootloader?