Microprocessors/Microcontrollers – Do registers have addresses

embeddedmemorymicrocontrollermicroprocessorregister

My Embedded Systems professor keeps referring to the memory locations of registers as their respective "addresses". I'm confused by this; I was always under the impression that in any microprocessor, the CPU registers don't have addresses since they don't reside in the main memory (they reside in the microprocessor itself). I am also confused about what we refer to when we say the "memory location of the register" – again, it's not in main memory.

With that said, why are we referring to the locations of the CPU registers by "addresses"? Do all/some registers have addresses?

I thought about this and reasoned that maybe they're "connected" to certain main memory locations, allowing access to the values stored in the registers. To extend this thought, is this what memory mapping is?

I should also add that we are working specifically with NXP's LPC1768 microcontroller, which uses the ARM Cortex-M3 microprocessor.

Best Answer

It depends on the particular processor whether "registers" are in the same address space as regular data memory or separate. In either case, if there are multiple of them each one still needs a address.

Let's say the processor has 16 registers that are tightly coupled to the CPU and implemented separately from data memory. Those registers still have to be identified somehow. In this case, a 4 bit address would be needed to distinguish individual registers. In a RISC architecture, the 4-bit address of whatever register(s) a instruction worked on would be included in the instruction code. For example, the ADD instruction might add the value of a source register into a destination register. That instruction would include 4 bits to identify the source register and another 4 bits to identify the destination register. The documentation may refer to these registers by "number" 0 to 15, but that's really the address of where the registers lives in a special small memory by the CPU.

In addition to the above, even when a processor has special dedicated registers, those registers might be mapped into the general purpose data address space. References to those addresses are trapped and referred to the internal registers.

There are lots of schemes out there, but if you have more than one register, those registers need to be distinguished from each other somehow, and inside the hardware that will be with a "address", whether it is called that in the documentation or not.

Related Topic