Page 1 of 1

Bootsector Help

Posted: Wed Sep 11, 2002 4:33 pm
by beyondsociety
[attachment deleted by admin]

Re:Bootsector Help

Posted: Thu Sep 12, 2002 2:01 am
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.

Re:Bootsector Help

Posted: Thu Sep 12, 2002 2:02 am
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 ?

Re:Bootsector Help

Posted: Thu Sep 12, 2002 2:39 pm
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

Re:Bootsector Help

Posted: Fri Sep 13, 2002 1:09 am
by Pype.Clicker
something like this, yes ...