News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Problem on entering PMODE

Started by wizard00, September 13, 2006, 09:14:53 PM

Previous topic - Next topic

wizard00

People said entering PMODE is easy

mov eax, cr0
or eax, 01h
mov cr0, eax

I try the line of codes but it always reboot my system.  No I don't have a autoexec.bat or config.sys on my boot disk. So no Himem.sys loaded or that sorts.
Still everytime I execute the instruction, it reboot on (mov cr0, eax).

thanks

Tedd

ENTERING pmode is easy -- that's what that code will do. The problem is staying there without causing a triple-fault, which will reboot your system (as you found) :bdg
You need to do a bit of setting up before, and after, you enter pmode to make sure you don't go crashing on the next instruction.
So, you'll need to set up a valid GDT, and an IDT, and that's the minimum you can get away with (you'll have to look these up if you don't know what they are, it's too much to explain here.)
Once you've got that sorted, you can enter pmode (safely!) by:

- cli
- disable NMIs (you'll have to look this up to, though it's not essential, I'm just being safe)
- enable A20
- lgdt
- set PE bit on CR0
- far jump to the code-segment-descriptor:offset of your nice new shiny 32-bit pmode code entry

and then...

your_nice_new_shiny_32-bit_pmode_code_entry:
- reload the segment registers with valid descriptors
- set up a valid stack
- reprogram the PICs (if needed)
- lidt
- re-enable NMIs
- sti
- and now you're pretty much safe :wink
No snowflake in an avalanche feels responsible.