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

Bootsector Help

Post by beyondsociety »

[attachment deleted by admin]
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Bootsector Help

Post by df »

start_code:
mov [bootdrv],dl
first, you assume DS will be setup correctly, there is no garuntee here. so put in a cs: override to be sure, or setup ds/es=cs
mov sp, 0x1FFF ; 8 KB
make your stack word aligned 0x1FFE or 0x2000.

hmm also i think your GDT is setup wrong, (or could be correct).

you read sectors into segment 0x1000, but your GDT is org'd at 0

and your jump to clear pipe, you've hit your CR0 bit, so your jump code is still in 16bit opcode notation, yu might need to do a hand coded jump (or not).

its been a while since i looked over this type of code.
-- Stu --
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bootsector Help

Post by Pype.Clicker »

okay. it will be the last time i say it:
[ORG xyz] is just a command for defining the OFFSET of your code (i.e. the ip for the first byte you type). Having [org 0000] means that you will have to set your segment registers so that the first byte of your code is at offset 0 (and that you promise nasm you *will* do it)

now, if you're doing things about protected mode, there are some addresses that are 32 bits ABSOLUTES address, like the base address for the GDT or any base address *in* the GDT. Those addresses are dependent on both the segment and offset of the referred stuff ... so if you know that your code is loaded at 0x1000:0x0000, you should not have

gdtr : dd gdt
dw gdt_end - gdt

but rather
gdtr: dd gdt + 0x1000*16+0x0000
dw gdt_end - gdt

did i made myself clear enough ?
beyondsociety

Re:Bootsector Help

Post by beyondsociety »

How would I set up the jump to protected mode?

Would I have to add the offset that you told me to set up to the jump or do I not need it:

gdtr:

dd gdt + 0x1000 * 16 + 0x0000

So it would be:

jmp 0x08:clear_pipe + 0x1000 * 16 + 0x0000
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:Bootsector Help

Post by Pype.Clicker »

something like this, yes ...
Post Reply