My bootloader appears to relocate itself and run correctly, is anyone able (and willing, thanks in advance ) to verify that the code does what I think it does?
It should relocate some of itself (the main loop and some functions) to just before where it used to be (i.e. just before the boot sector, 0x7c00). The function of the relocated main loop should be to read and parse bytes from the serial port, store them to the (now free to overwrite) boot sector and then execute them.
Basically I've written the relocation as if it were position independent (i.e. works with just a simple copy), but I'm not actually sure that it is. How do I know whether the assembler is creating absolute or relative jumps/calls?
You can always disassemble the output and check the jump opcodes to see if they are absolute (FF) or relative (EB/E9). Most assemblers default to the latter though because it's always the shorter encoding.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
schilds wrote:My bootloader appears to relocate itself and run correctly, is anyone able (and willing, thanks in advance ) to verify that the code does what I think it does?
You forgot to make sure that the "direction" flag is clear. If the BIOS left it set, then the copy will work backwards and copy the wrong thing.
schilds wrote:Basically I've written the relocation as if it were position independent (i.e. works with just a simple copy), but I'm not actually sure that it is. How do I know whether the assembler is creating absolute or relative jumps/calls?
It's much easier to do the reverse. For example, use "org 0x7A00" at the start so that after relocation everything is as the assembler expects, and do the relocation first so that you don't need to care about "position independent" for almost all of your code.
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.