80286: How To Shut Off Pmode
Posted: Sat Jun 14, 2008 1:34 am
In some manuals I have read that in 80286's protected mode you couldn't switch it off (when returning to MS-DOS etc), but...
...just were browsing AThelp and I found a snippet of code, that used Windows 2.0 to 3.1 in 16-bit protected mode when returning to DOS:
Funny
...just were browsing AThelp and I found a snippet of code, that used Windows 2.0 to 3.1 in 16-bit protected mode when returning to DOS:
Code: Select all
Mov ax,[CodeBase]
Push offset def0400 - offset defgdt
Pop ds
assume ds:nothing;
Mov word ptr ds:[067h],offset real
Mov word ptr ds:[069h],ax
; in the shutdown address of BIOS - address of our program
; after the RESET it should begin there
Mov al,0fh
Out 70h,al
jmp delay2
delay2: Mov al,0ah
Out 71h,al ; write SHUTDOWN byte in CMOS
Mov al,0fch ; RESET the processor
Out 64h,al
halt: hlt ; RESET does take a while, we will halt the CPU
jmp halt ; what if NMI ?
nop
Real: Mov ax,seg stak
Mov ss,ax ; set the stack
Mov sp,[Storesp]
Push seg data
Pop ds
assume ds:data; ; Data segment
Mov al,0ffh ; enable keyboard
Out 64h,al
Sti ; and interrupts