my pmode code resets the cpu
Posted: Mon Nov 26, 2001 9:11 pm
hi, can anyone help me?
;after booted
cli
lgdt qword ptr gdtr
mov eax,cr0
or al,1
mov cr0,eax
jmp gdt1:do_pm
do_pm:
mov ax,gdt0
mov ds,ax ;<-this line will reset
mov es,ax
; mov ax,gdt2
mov ss,ax
mov esp,5000h
xor edi,edi
xor esi,esi
lea esi,msg_ined
mov edi,0b8000h+(80*4+1)*2
mov ecx,21
cld
rep movsb
looop:
jmp looop
gdtr:
dw gdtend-gdt-1
dd gdt ;base
gdt:
dq 0 ;NULL descriptor
gdt0 equ $-gdt
dw 01fffh ;limit 32m
dw 0 ;base addr L16
db 0 ;base addr M8
db 92h ;(ds)data descriptor
db 0cfh ;G/D
db 0 ;base addr H8
gdt1 equ $-gdt
dw 01fffh
dw 0
db 0
db 9ah ;(cs)code descriptor
db 0cfh
db 0
gdt2 equ $-gdt
dw 01fffh
dw 0
db 0
db 96h ;(ss)data descriptor
db 0cfh
db 0
gdtend:
;after booted
cli
lgdt qword ptr gdtr
mov eax,cr0
or al,1
mov cr0,eax
jmp gdt1:do_pm
do_pm:
mov ax,gdt0
mov ds,ax ;<-this line will reset
mov es,ax
; mov ax,gdt2
mov ss,ax
mov esp,5000h
xor edi,edi
xor esi,esi
lea esi,msg_ined
mov edi,0b8000h+(80*4+1)*2
mov ecx,21
cld
rep movsb
looop:
jmp looop
gdtr:
dw gdtend-gdt-1
dd gdt ;base
gdt:
dq 0 ;NULL descriptor
gdt0 equ $-gdt
dw 01fffh ;limit 32m
dw 0 ;base addr L16
db 0 ;base addr M8
db 92h ;(ds)data descriptor
db 0cfh ;G/D
db 0 ;base addr H8
gdt1 equ $-gdt
dw 01fffh
dw 0
db 0
db 9ah ;(cs)code descriptor
db 0cfh
db 0
gdt2 equ $-gdt
dw 01fffh
dw 0
db 0
db 96h ;(ss)data descriptor
db 0cfh
db 0
gdtend: