I've just quickly browsed over your code and saw a:
[tt]ORG 0[/tt]
That needs to be:
[tt]ORG 0x7C00[/tt]
Anyway, looking over the second code u posted, try something like this for setting up the GDT and enabling PMode:
[tt]
[org 0x7C00]
[section .text]
[bits 16]
; code for enabling the A20 line goes here
lgdt [gdt_ptr]
mov ax,LINEAR_DATA_SEL
mov ds,ax
mov es,ax
mov ss,ax
mov fs,ax
mov gs,ax
mov eax, CR0
or eax, 0x1 ; set protected bit to 1
move CR0, eax
jmp LINEAR_CODE_SEL:gdt_done ; this sets up CS
[bits 32]
pmode_time:
; more code goes here
[section .data]
gdt: ;our descriptors
; NULL descriptor
dw 0 ; limit 15:0
dw 0 ; base 15:0
db 0 ; base 23:16
db 0 ; type
db 0 ; limit 19:16, flags
db 0 ; base 31:24
; unused descriptor
dw 0
dw 0
db 0
db 0
db 0
db 0
LINEAR_DATA_SEL equ $-gdt
dw 0FFFFh
dw 0
db 0
db 92h ; present, ring 0, data, expand-up, writable
db 0CFh ; page-granular (4 gig limit), 32-bit
db 0
LINEAR_CODE_SEL equ $-gdt
dw 0FFFFh
dw 0
db 0
db 9Ah ; present,ring 0,code,non-conforming,readable
db 0CFh ; page-granular (4 gig limit), 32-bit
db 0
gdt_end:
gdt_ptr:
dw gdt_end - gdt - 1
dd gdt
[/tt]
The only thing about this code is that the descriptors are assuming the A20 line is enabled(thus the "code for enabling the A20 line goes here" comment). I've not tested this code, but it
should work. This code does not however setup a stack.
I hope this helps(and that there are no bugs in my code there),
K.J.