The CPU wont change to Pmode. And reseting it self. Can somebody Tell me what's wrong with this.



#make_COM#

; COM file is loaded at CS:0100h
; (the value of CS is set by Operating System)
ORG 100h

;CSPMode is Header For 32-Bit Exe.
;Kernel for 32-Bit.

jmp start

CSPmode:
smsw_cx db 0fh,01,0e1h ;SMSW cx byte
mov ax,cx ;At Pmode this will be mov eax,ecx
and al,1
cmp al,1
jz trs
inc cx
lmsw_cx db 0fh,01,0f1h ;lmsw cx byte
trs:
ret

; Entry Point Here.
start:
call CSPMode
cmp al,0
jz trs2
mov ah,9
mov dx,offset tes
int 21h
jmp brs
trs2:
mov ah,9
mov dx,offset tes2
int 21h

mov dx,060h
dloop:
in al,dx
cmp al,1
jnz dloop

brs:
ret

Tes db 'Prosessor already at Pmode!$'
tes2 db 'Prosessor setted to Pmode!$'
Posted on 2003-04-23 07:05:44 by realvampire
Well, you have to set up a GDT first, and disable interrupts. Before you enable interrupts again, you must execute a far jump so that the loaded segment will correspond to the value in the segment register. You must also set up an IDT.
Of course, you can't call DOS code in protected mode. You have to go back to real mode or V86 mode to call DOS. If the P-mode flag is already set, then it means you were already in V86 mode.
Posted on 2003-04-23 11:50:10 by Sephiroth3
Can you give me example? I cannot understand the LGDT etc.
Posted on 2003-04-23 22:06:48 by realvampire