This has been puzzling, so I'll lay it all out here. Apparently, through MMIO, you can access external devices using a certain memory-mapped address, which would then be re-routed to that device itself(through a write, command packet, etc.). However, I've been hearing mixed descriptions of both hardware registers(e.g. like a CPU/GPU register, or even sound chips), and memory-mapped registers used interchangeably. Are they the same thing?

When you say a "memory-mapped register", aren't you referring to the address from which a data byte is re-routed to a specific address inside that device(e.g. theoretical: GPU's 0x500 address is for register TEXTURE_BUFFER). However, a memory-mapped device can't map a physical register inside RAM.

So basically, what is the difference between a memory-mapped register and just a hardware register?

  • If it is the case that this question isn't suitable, I suggest migrating this to cs.stackexchange.com or that the poster posts it there. – barlop Dec 31 '13 at 22:15

Memory mapped hardware registers are accessed like RAM. All CPUs have specific instructions for reading/writing RAM and these same instructions are used to access memory-mapped registers.

Hardware registers in general do not have to be memory mapped, this is simply a common convention.

x86 provides two address spaces in which two separate groups of instructions are used to read and write - the first is RAM or memory space (all the MOV instructions), the second is I/O space (using the IN and OUT instructions). On x86, hardware registers may appear in either space.

You also may need to go through a level of indirection to really reach a hardware register. A device may only expose a "port" in memory or I/O space. You then need to write a register number to the address, and then the data you want to actually write to another address. The write then occurs. The old 8563 VDC in the Commodore 128 worked like this. The CMOS RAM and some PCI registers also work like this.

CPU hardware registers are of course not memory mapped (not on x86 or any common CPU anyway), that is another example of a hardware register.

Modern CPU's have "model specific registers" (MSRs) and these are read/written using their own instructions (RDMSR, WRMSR). Other CPU registers have their own instruction (LGDT, MOV xx, CR2, the basic EAX/RAX, etc.)


Memory-mapped I/O and memory-mapped registers are not the same thing and are not that closely related.

Memory-mapped I/O was used, eg, in early PCs, where part of the RAM address space was mapped to the display buffer. (And in some products regular RAM was actually used for the display buffer, vs having the buffer on the display adapter card.) In other cases a hardware device such as a disk drive controller would use memory-mapped addressing for setting/reading its control registers. (And I would guess that modern graphics cards still map display memory into the graphics processor's address space, though I don't know this to be a fact.)

"Memory-mapped registers" can mean several things. One would be the above example of the disk drive controller with memory-mapped control registers. Another, entirely different case would be a processor that actually has its registers in RAM. This was fairly common with early (50s through early 70s) processors, since it reduced parts count considerably, and it also permitted some "clever" programming practices. In a few cases the processor was available in two models, one with memory-mapped registers and the other with (faster) "hardware" registers.

And in some cases it was ambiguous as to what was a register and what wasn't, as in the Burroughs "stack" machines, where a "stack" was used in place of standard registers (with, IIRC, several different schemes for "shadowing" the registers in RAM).


My educated guess based on something Computer science lecturer told us from a basic book but it matches what that wikipedia page on MMIO says. CPU doesn't know what device it is writing to. As far as it is concerned it may as well all be RAM-memory. Some devices use a particular RAM-memory location. I suppose that'd be what hardware mapped means. But there can be a memory location in the hardware device itself, there probably must be in fact.. to transfer the data to. The CPU doesn't have to wait it writes to the location in RAM which is mapped to a register on the devie. A register is a memory location in CPU or in a hardware device. not in ram.

To be more specific to your question. A register is in CPU or in a hardware peripheral-device. Not in RAM/main memory. The location in RAM/main memory, is just called a location never a register. A location in CPU or a peripheral device isn't generally called a location or memory location, and is always called a register, that's its special and proper name. If a register is mapped to memory as no doubt many hardware peripheral device registers are, then i'd be pretty sure that is what is meant by a memory-mapped register.

So, If a hardware register isn't memory mapped.. e.g. if the CPU writes to it directly then it's not memory mapped. It seems from that wikipedia article that maybe if those addresses are located in a special space and they require special pins or a special bus then the locations may be in memory, but not MMIO, not memory mapped.

Looking at that wikipedia page.. PMIO i.e. considered to not be memory mapped. Is when CPU registers are not mapped to regular memory locationss, but to a special address space. So rather than a general purpose CPU register that can write to a device or memory, depending on what address is put on the address bus. With PMIO, (i.e. not a memory mapped register), the register is mapped to a device specific memory location which I guess they are calling a port.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy