Page 1 of 1

simple question, but please answer

Posted: Wed Oct 23, 2002 9:16 am
by elias
ive seen many boot loaders with either ORG [0] or ORG [07C0], if might not be 07C0, but some other numbers, btu ims ure you guys know wat i mean. now i question is, where is the boot coded loaded to? 07C0:0000 or 0000:07C0?

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 9:21 am
by dronkit
In real mode an absolute memory address is calculated multiplying the segment value by 16 and adding the offset, so:

0000:7c00 = (0000h * 16) + 7c00h = 7c00h
07c0:0000 = (07c0h * 16) + 0h = 7c00h

they reference to the exact same memory position

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 9:59 am
by Friend
Basically, there are many different segment:offset pairs that the bios might load the code to, the best idea is to simply do a jmp at the start of your boot code and this will force cs=segment for example

jmp 0x0000:Start_Boot

would force cs=0x0000 and then jump to Start_Boot, so whatever segment you want to have simply put that first and it should load cs with that value.

hope this helps.

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 10:03 am
by Tom
org 0 tellsNASM that the FritzOS bootsector is at org 0 - but it's not. So I do a jump from 0x7c00:start i.e. jump from 0x7C00 to the start lable.

That's just one way to load a bootsector...

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 4:30 pm
by elias
so i can have either
ORG [0]
or
ORG [07C0]?
as long as i jump to the first portion of code?

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 5:30 pm
by Tom
if you have a org 0 you have to do a "jmp 0x7C00:start"

if have a org 0x7c00 you can just do "jmp start"

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 6:06 pm
by elias
ok thanx, now jsut one more thing. is the address 7C00 or 07C0?

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 6:38 pm
by Tom
I typed it in correctly "0x7C00"

Re:simple question, but please answer

Posted: Wed Oct 23, 2002 10:37 pm
by grey wolf
the correct addresses are 0x07C0:0x0000 and 0x0000:0x7C00.

so with ORG 0x0, you need your CS to be 0x07C0 ( jmp 0x07C0:start ) and with ORG 0x7C00 your CS will be 0x0 ( jmp 0x0000:0x7C00 )