Bootloader Help

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Warrior

Re:Bootloader Help

Post by Warrior »

Do I need to do a far jump to start my second stage or are you talking about when I transfer control?
AR

Re:Bootloader Help

Post 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.
Warrior

Re:Bootloader Help

Post by Warrior »

Yea I far jumped to 0000:800


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

Re:Bootloader Help

Post 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.
Warrior

Re:Bootloader Help

Post by Warrior »

Holy wow, that fixed it. I was putting 0x0000 for the segment :[

Thanks alot AR!
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:Bootloader Help

Post 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..
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
DennisCGc

Re:Bootloader Help

Post 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. :)
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:Bootloader Help

Post 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.
Post Reply