Page 1 of 1

Problem

Posted: Tue Aug 03, 2004 11:00 pm
by WK
;here is my code which goes into 32 bit protect mode now tell how will go back ;real mode
[org 0x0100]
              jmp  start

gdt:        dd   0x00000000, 0x00000000   ; null descriptor
              dd   0x0000FFFF, 0x00CF9A00   ; 32bit code descriptor
              dd   0x0000FFFF, 0x00CF9200   ; data descriptor

gdtreg:       dw   0x17                     ;
                    dd   0                        ; & the 32 bit base

strat:  
              mov  ax,0x2401
              int  0x15

            
              xor  eax, eax                 ;makes eax zero
              mov  ax, cs
              shl  eax, 4
              mov  [gdt+0x08+2], ax
              shr  eax, 16

              mov  [gdt+0x08+4], al         ; set base of code desc

              xor  eax, eax
              mov  ax, cs
              shl  eax, 4
              add  eax, gdt
              mov  [gdtreg+2], eax          ; set base of gdt
              lgdt [gdtreg]                 ; load gdtr

              mov  eax, cr0                 ;loading the control register 0 into eax
              or   eax, 1                   ;setting the least significant bit of eax to zero

              cli                           ; disableing the interrupts
              mov  cr0, eax                 ; enable's the protected mode
              jmp  0x08:pmode

[bits 32]

; 32bit protected mode code

pmode: mov  ax, 0x10            
              mov  ds, ax
              mov  es, ax
              mov  fs, ax
              mov  gs, ax
              mov  ss, ax

;now how will go back to real mode

RE:Problem

Posted: Sun Aug 29, 2004 11:00 pm
by Phibred
Just to start thank you, your tables finally got my pmode to be stable, with that said... and I have a lot of practice here. To get out of pmode diable the interrupts, then you ...
cli
mov ax,0x00 ; make sure they are in 16 bit registers
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov eax,cr0
xor eax,0x01 (makes the last bit 0 if in pmode, better than dec)
mov cr0,eax
jmp <16 bit proc> ; and we are in real mode again....

By leaving some registers untouched you can still access the 32 bit addresses also known as 'unreal' mode.

Thank you so much