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.
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 ]
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.
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.
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.
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?
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.