Page 1 of 1

Entering 32bit (un)real mode

Posted: Fri Jan 04, 2008 12:44 am
by michael
Ive been searching on the net for like a week now and I havn't found any resource that teaches the basics as good as this site... So I thought id ask here.

Ive fiddled with the code from the tutorials here and came up with this:

Code: Select all

EnterStage3:

	cli				; clear interrupts
	mov	eax, cr0		; set bit 0 in cr0--enter pmode
	or	eax, 1
	dec	eax
	mov	cr0, eax

	mov	si, JumpMsg
	call	Puts16
	
	jmp	08h:Stage3		; far jump to fix CS. Remember that the code selector is 0x8!
Ive also commented out:

Code: Select all

	;-------------------------------;
	;   Install our GDT		;
	;-------------------------------;

	;call	InstallGDT		; install our GDT

	;-------------------------------;
	;   Enable A20			;
	;-------------------------------;

	;call	_EnableA20


The thing is is that this does not work... :shock: :cry: what have I done wrong?

Posted: Fri Jan 04, 2008 9:14 pm
by Andyhhp
As far as I am aware (and I might be totally wrong), to enter unreal mode, you have to enable the A20 line, enter Pmode, load the GDT so you can access all of memory, then switch back into Realmode.

This should allow you to use realmode except that it uses Pmode addressing, which allows you all memory if you set up your GDT correctly.

I believe that this started as a bug in the 386 that people found and programmed code that exploited it. As a result, the bug has had to have been kept to allow legacy running of these programs.

As I say, I am by no means certain of this but I hope this helps,

Andrew

Posted: Fri Jan 04, 2008 10:51 pm
by michael
So does this mean that I would then actully be in pmode but just have basically turned off all the different things that "protect" me from myself?.. I mean would the um whats it called Interupt Vector Table (I think) be the one that just has a simple list of 255 pointers starting from address 0?

Posted: Wed Jan 09, 2008 12:18 pm
by Andyhhp
I dont think so.

From what I understand, unreal mode is exactly the same as real mode except for the fact that it uses Pmode addressing so that if you set up the GDT correctly, you can access all memory.

Therefore, you should be able to use all the BIOS interupts, in the same way as you did in your bootloader to load your kernal.

Andrew