Bootsector Help
Re:Bootsector Help
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=csstart_code:
mov [bootdrv],dl
make your stack word aligned 0x1FFE or 0x2000.mov sp, 0x1FFF ; 8 KB
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 --
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Bootsector Help
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 ?
[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
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
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
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact: