Page 1 of 1

I'm confused :(

Posted: Mon Mar 08, 2010 9:05 pm
by MeNguyen
Hi,

I find this in tutorial 4
msg db "Welcome to My Operating System!", 0

;*************************************************;
; Bootloader Entry Point
;*************************************************;

loader:

; Error Fix 1 ------------------------------------------

xor ax, ax ; Setup segments to insure they are 0. Remember that
mov ds, ax ; we have ORG 0x7c00. This means all addresses are based
mov es, ax ; from 0x7c00:0. Because the data segments are within the same
; code segment, null em.


mov si, msg
call Print

cli ; Clear all Interrupts
hlt ; halt the system

Why is it you say "Setup segments to insure they are 0. Remember that we have ORG 0x7c00. This means all addresses are based from 0x7c00:0. Because the data segments are within the same code segment, null em.

why all addresses are based from 0x7c00:0? I thought we loaded our bootloader at 0x7c00

Thanks in advance

Re: I'm confused :(

Posted: Mon Mar 08, 2010 10:48 pm
by Mike
Hello,

That tutorial is planned for an update. The 0x7c00:0 should actually be 0x0:0x7c00 but that doesnt matter; Because the bootloader uses ORG 0x7c00, the segments must be 0 as the assembler will add 0x7c00 offset to all addresses. So, if ds=0, ds:0 + 0x7c00 = 0x7c00 = 0x7c0:0.

We are at 0x7c00 (ie 0x7c0:0). I apologize for the confusion.