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.
I realize that there are changes in long mode when it comes to the GDT. I just want to make sure that all the descriptors are 4 bytes and there is a 4 byte null descriptor at the beginning of the GDT:
GDTR64:;what is loaded into the GDTR when entering long mode
limit dw gdtend64-gdtbeg64;size of the GDT
offset dq gdtbeg64;start address of the 64 bit gdt
gdtbeg64:;beginning of 64 bit gdt
dd 0
;etc...
gdtend64:;end of 64 bit gdt
you need to have your 32-bit GDT descriptors, and then your 64-bit one as well. The descriptor for the 64-bit cs is almost identical to the 32-bit one except that it has the L flag set.
GDTR: ; Global Descriptors Table Register
dw 4*8-1 ; limit of GDT (size minus one)
dq GDT ; linear address of GDT
GDT:
dw 0,0,0,0 ; null desciptor
dw 0FFFFh,0,9200h,08Fh ; flat data desciptor
dw 0FFFFh,0,9A00h,0CFh ; 32-bit code desciptor
dw 0FFFFh,0,9A00h,0AFh ; 64-bit code desciptor
then the GDT table gets loaded with the lgdt command before entering PMode, and then can be re-used when enterring 64-bit mode because the 64-bit descriptor is already there.