Entering 32bit (un)real mode

If you are needing help, or have questions for the different assembly languages available.

Moderator: Moderators

Post Reply
michael
Posts: 29
Joined: Thu Nov 15, 2007 12:06 am

Entering 32bit (un)real mode

Post by michael » Fri Jan 04, 2008 12:44 am

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?

Andyhhp
Moderator
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1
Contact:

Post by Andyhhp » Fri Jan 04, 2008 9:14 pm

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
Last edited by Andyhhp on Sat Jan 12, 2008 3:14 pm, edited 1 time in total.
Image

michael
Posts: 29
Joined: Thu Nov 15, 2007 12:06 am

Post by michael » Fri Jan 04, 2008 10:51 pm

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?

Andyhhp
Moderator
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1
Contact:

Post by Andyhhp » Wed Jan 09, 2008 12:18 pm

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
Image

Post Reply