Page 1 of 1

80286: How To Shut Off Pmode

Posted: Sat Jun 14, 2008 1:34 am
by inflater
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:

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
Funny :D

Posted: Sat Jun 14, 2008 3:03 am
by cyr1x
I might be wrong but I think this is what the Intel manuals say. The 286 can only be switchted to realmode with resetting the cpu.

Posted: Sat Jun 14, 2008 12:09 pm
by AJ
That's right - you have to reset the CPU to switch back to real mode, making it an even slower process than doing a PM-->RM task switch on a 386+ CPU. What manual says you can't switch back to RM?

Cheers,
Adam