Return to real mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Return to real mode

Post by lukem95 »

Could any body give me a hand moving from PMODE to real mode?

I want to create a function to execute BIOS interupts but can't find anything simple enough for me to understand (i have tried many sources and articles but cant find anything that has it in detail)

Thankyou, Luke

EDIT: Well since writing this i've found some more information and from what i can tell i have to disable interupts, disable A20 and then put 0 in the PM bit.

To do this i tried:

__asm__ __volatile__ ("cli");
outportb(0x60,0xdf);

__asm__ __volatile__ ("mov %%eax, %%cr0\n"
"dec %%al" /* Decrease the Pmode bit */
"mov %%cr0, %%eax\n"
"db 0eah");

I know the inline ASM fails but thats not a problem, as i can just put it into my start.asm
User avatar
lode
Posts: 15
Joined: Tue Oct 17, 2006 6:28 pm
Location: Oulu, Finland

Post by lode »

If you use paging you should also deactivate it before disabling protected mode.

Also the contents of the bios data areas and real mode interrupt vectors should be preserved during your adventures in pmode. The easiest way to do this is not to touch the first megabyte of physical memory at all.
Post Reply