Page 2 of 2

Re:Bootloader Help

Posted: Sun May 15, 2005 10:40 pm
by Warrior
Do I need to do a far jump to start my second stage or are you talking about when I transfer control?

Re:Bootloader Help

Posted: Sun May 15, 2005 11:42 pm
by AR
You are using [ORG 0x0000] which to me implys that you are far jumping so that CS=0x800 (or wherever you put the next stage), unless you have physically loaded the next stage at 0000:0000 which would be very very bad (Override the Interrupt Vector Table and the BIOS)

If you are merely tacking a second bootsector onto the end of the first sector and saying that they are part of the same "program" then your ORG is the problem.

Re:Bootloader Help

Posted: Mon May 16, 2005 4:25 am
by Warrior
Yea I far jumped to 0000:800


I added what you said and I'm still getting bad output :[

Re:Bootloader Help

Posted: Mon May 16, 2005 4:30 am
by AR
If your far jump is jmp 0000:8000 then the ORG should be [ORG 0x8000], ORG is the offset from the start of the CS segment (and implicitly the DS segment as well), since CS=0 you want to tell the assembler that your are at offset 0x8000 from 0.

Re:Bootloader Help

Posted: Mon May 16, 2005 4:43 am
by Warrior
Holy wow, that fixed it. I was putting 0x0000 for the segment :[

Thanks alot AR!

Re:Bootloader Help

Posted: Mon May 16, 2005 4:46 am
by bubach
0000:8000 then the ORG should be [ORG 0x8000]
Isn't it like this:
0x8000:0x0000 then the ORG should be [ORG 0x8000]
0x0000:0x8000 then the ORG should be [ORG 0x800]
?
And using something like [ORG 0x10000] in realmode, does that really work? I doubt it..

Re:Bootloader Help

Posted: Mon May 16, 2005 5:59 am
by DennisCGc
bubach wrote:
0000:8000 then the ORG should be [ORG 0x8000]
Isn't it like this:
0x8000:0x0000 then the ORG should be [ORG 0x8000]
0x0000:0x8000 then the ORG should be [ORG 0x800]
?
No. In realmode 0x8000:0x0000 should be [ORG 0x0], because it's at offset 0. Now in protected mode it should be like [ORG 0x80000] because 0x8000*0x10+0x0=0x80000
Just try to distinguish the difference of realmode and protected mode. (also with offsets)
Now you can see why the second is also wrong. :)

Re:Bootloader Help

Posted: Tue May 17, 2005 2:05 am
by Candy
Generic:

location <segment>:<offset> -> ORG is offset.

So, for 0x800:0x0 -> ORG 0x0
0x0:0x8000 -> ORG 0x8000
0x400:0x4000 -> ORG 0x4000
0x3FF:0x4010 -> ORG 0x4010

All the same address btw.