Page 1 of 1

pmode rmode ???

Posted: Thu Nov 13, 2008 8:54 am
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.

Re: pmode rmode ???

Posted: Thu Nov 13, 2008 10:18 am
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.

Re: pmode rmode ???

Posted: Thu Nov 13, 2008 12:28 pm
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

Re: pmode rmode ???

Posted: Thu Nov 13, 2008 2:36 pm
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.

Re: pmode rmode ???

Posted: Fri Nov 14, 2008 8:57 am
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

Re: pmode rmode ???

Posted: Fri Nov 14, 2008 10:49 am
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.