pmode rmode ???

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
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

pmode rmode ???

Post by Sam111 »

Is real mode = 16 bit mode or can you use 32 bit registers in real mode just that you are limited in memory addresses ?

If you can use 32 bit registers in 16 bit mode can you use 32 bit in/out commands as well

example

Code: Select all

mov dx , 0xCF8                      ; move the configuration address for the pci into dx 
out dx , eax                        ;  send the data in eax to the configuration address port
Or can you just use 32 bit registers and 32 bit in/out commands in pmode.

I am also wondering if you would get the same effect if you send two 16 bit in/out commands for a 32 bit in/out command?

Thanks for any clarity on these questions.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: pmode rmode ???

Post by Combuster »

Sam111 wrote:Is real mode = 16 bit mode or can you use 32 bit registers in real mode just that you are limited in memory addresses ?
Real mode -> Default operand size is 16 bits. That means you can use 32 bit registers and addresses, as long as they respect real mode segmentation limits.
If you can use 32 bit registers in 16 bit mode can you use 32 bit in/out commands as well
Yes
I am also wondering if you would get the same effect if you send two 16 bit in/out commands for a 32 bit in/out command?
You should always use the size prescribed by the hardware.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Sam111
Member
Member
Posts: 385
Joined: Mon Nov 03, 2008 6:06 pm

Re: pmode rmode ???

Post by Sam111 »

as long as they respect real mode segmentation limits.
What happen if it didn't?

And sense you can use 32 bit registers in real mode.
What is stoping you from doing 32 bit in/out commands?

And I am assuming two 16 bit in/out commands are not equivalent to one 32 bit in/out command. So you won't get the same effect? Is this an affirmative.

thanks for the help
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: pmode rmode ???

Post by CodeCat »

I'm guessing if you don't, you get a general protection fault like you would in protected mode. Though I'm not sure if real mode even has GPF, but the only way to know is to try. :P

Nothing is stopping you from using in/out with 32 bit registers or with any other register size. But devices usually require that you read/write in a given quantity, whether that is 8, 16 or 32 bits at a time. And if a device mandates that 32 bits must be read/written to an I/O address, then you have to do it that way even if you're using 16-bit mode. Of course, to actually get a usable value, you need to rotate the 32 bit register by 16 after you read it from the device so you can grab the other half from the lower 16 bits as well.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: pmode rmode ???

Post by jal »

CodeCat wrote:Of course, to actually get a usable value, you need to rotate the 32 bit register by 16 after you read it from the device so you can grab the other half from the lower 16 bits as well.
Errr... why would you want to do that??? You just explained the guy that yes, he can use 32 bit registers, and then you tell him to chunk them down to 16 bit?


JAL
CodeCat
Member
Member
Posts: 158
Joined: Tue Sep 23, 2008 1:45 pm
Location: Eindhoven, Netherlands

Re: pmode rmode ???

Post by CodeCat »

Well, if he's using 16 bit mode, then it's likely that at some point he'll want to scale it down to a 16 bit value. For pushing it onto a 16 bit stack for example, or any other reason you can think of. So I just explained how to get to the top 16 bits if he ever wanted to do that.
Post Reply