mainly, when your bootloader gets started, you have no idea of what the BIOS left in the data segment registers. All you know is that you're running code that lies at physical address 0x7c00. You don't even know if the BIOS used "jmp 0x7c0:0" or "jmp 0:0x7c00". Both are valid and both are met in different BIOSes
so
may not be that helpful ...
E.g.
Code: Select all
org 0 ; we're assuming jmp 0x7c0:0,
; thus program starts at offset 0 in code segment
mov ax, cs
mov ds, ax ; loads ds with 0x7c0 ... hopefully
mov es, ax ; data access will get wrong if BIOS used 0:0x7c00
So the proper way would rather be
Code: Select all
org 0 ; we're assuming jmp 0x7c0:0,
; thus program starts at offset 0 in code segment
jmp 0x7c0:here
here:
; enforce cs = 7c0 in case BIOS used 0:0x7c00
mov ax, cs
mov ds, ax ; loads ds with 0x7c0 ...
mov es, ax ; data access will be ok, now :)
And it's somehow a short way to say
Code: Select all
org 0
jmp 0x7c0:here
mov ax,0x7c0 ; takes 3 bytes
mov ds,ax ; takes 2 bytes, such as "mov ax,cs"
mov es,ax ; you can't load immediates to segments anyway