Chase@OSDev wrote:
The short jmp followed by the nop *precedes* the BPB(not sure if you meant layout or position when you said "follows").
Sorry, I'm actually a bad speller and in grammer. I ment that you usually see a jmp short followed by a nop, which BPB is followed after those two instructions. Pretty sure everyone knows that the BPB has to start
after the third byte. Also means the
nop is just padding so that BPB is where is suppose to be.
Chase@OSDev wrote:
Most systems will work without the jump being short and most systems require the boot signature at the end but not all.
Personally I have troubles sinking this in my brain. The 3 bytes in FAT12 boot sector was dedicated so you can jump to entry point. This may be the jmp short + nop or a jmp near (which I don't recommend). If you don't wish to follow FAT12 then can very well be a jmp far which will take up 5 bytes or even no jump at all. I am clueless what IBM does, but I just don't see how not being a jmp short would make it unsupported by any x86 compatible system. And for the boot signature, if it is not required by some systems, I'm just seeing a very poor implementation on the BIOS side to be a compatible system. I'm pretty sure everyone once has left a non-bootable floppy disk in the drive one time or another, this would mean that system would try to boot from the unknown boot sector anyway, and can be very unpleasant effects.
Chase@OSDev wrote:
You are right about the code segment. Lots of people make the mistake of doing something like this:
Code: Select all
Start:
mov ax,cs
mov ds,ax
mov es,ax
After I took a look at the boot sector you given us, I think theres some misunderstandings (must be my grammer
). Your code does not do DS=ES=CS which is what StormBoy have but insted does DS=ES=7C0h and left CS alone. What I've tried to say was, if you do jmp far 7C0:start prior, DS=ES=CS is safe. And the other hand, something like DS=ES=7C0h and leaving CS alone, would be unsafe. Basically because you have assumed CS would be something.
To explain a bit, this goes back to differnt jmps and calls. For jumps specifically, the jump near operand is relative with CS segment, ex. jmp near 0004h which the processor will jmp to addess CS:0004h. Now, because no one ever stated any standard to set at a particular segment, CS is ambigous on differnt systems. Which means if the BIOS runs the boot sector with CS=0, your boot sector will run into problems, while a jmp far before hand to set CS would assure that its on the right track. Hope this makes any sense.
edit: some fixups.
edit: woah, it was es=ds=7C0h first then I fixed it up to es=ds=7C00h and now I changed it back, I was right just ot a bit confused. I found that thread which I also tried to explain this:
http://www.mega-tokyo.com/forum/index.p ... eadid=9533