What's the difference between a hardware register and a memory-mapped register?

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).