I have make progress in my stage2 bootloader, with a notable snag. My lgdt instruction appears to have triple faulted, leaving the program to not actually print the following message.
I was on another forum site, and someone told me to try setting the ORG directive to 7E00h (where I have this code loaded at). That didn't work so well, with the code not appearing to execute the printing instructions, and yet a simple "debug instruction" (which had been made by writing directly to video ram) outputing until the instruction to enable protected mode.
The exact piece of GDT setup code is shown:
Code: Select all
gdtset: ;function to setup and load the Global Descriptor Table
xor ax, ax ;clear ax register
mov es, ax
mov si, gdt ;start of GDT table into SI register
mov di, [gdtbse] ;locate GDT at 500h in memory
mov cx, [gdtsze] ;size of the GDT (defined my fancy footwork)
push ds ;remember pre-modified DS register
mov ds, ax
cld ;clear the direction flag
rep movsb ;move byte from DS:SI to ES:DI
pop ds ;restore pre-modified DS register
lgdt[gdtr] ;load the Global Descriptor Table
lea si, [gdtmess] ;load the address of the GDT Setup Message into SI
call prntstr ;print the string
ret
My primary question is, why is lgdt not working? Am I not setting it up correctly. Does the ORG directive have anything to do with this?
Also, why, when I set the ORG directive to flat zero, does the program not execute any printing code, up until the protected mode enabler when it triple faults? Is this due to a GDT not being loaded?
To aide in information, my information layout is as such:
7C00 -> 7E00 :bootsector (stage 1)
7E00 -> 8200 :bootloader (stage 2)
7A00 -> 7C00 :stack (growing down from 7C00 towards 7A00)
9200 -> _undetermined_ :kernel
500 -> 5C0 :GDT
Many thanks for your help, your wisdom is appreciated.