embeddedcpu-registersmemory-mapped-io

Why are memory locations also called registers?


In embedded systems and systems programming, the term register is used to refer to

  1. a CPU register inside the micro-controller, e.g. R1, R2, PC in ARM micro-controllers, and
  2. certain 'special' locations inside memory address space.

Is there a reason or history behind the term 'register' being overloaded this way?


Solution

  • Functionally speaking, a register is an element (such as a multi-bit array of D-type flop flops or equivalent) where you can store a value.

    In addition to the traditional CPU registers used to hold operands and results from ALU computations, there can be Special Function Registers (on-chip or off) dedicated to other purposes. For example, a UART peripheral implementing a serial port probably has a register to hold the divisor which derives the baud rate from its clock, one for the outgoing data, one for the received data, and one that is a bitmap of mode settings.

    On a machine with Memory-mapped I/O special function register appear in memory space and are accessed with memory access instructions (though sometimes there are constraints, such as only a particular width of access being legal). In contrast, on an I/O mapped machine, there are special instructions just for accessing I/O port addresses, and (at least on a dual purpose external bus) a control signal which indicates if an access is to memory or I/O space.

    Further confusing things, there are a few legacy processor designs like the 8051 where the CPU registers can also be accessed as ordinary memory locations. And in many other machines, while CPU registers are stored in a register file rather than memory, they functionally have "addresses" in a bitfield of the instruction word, which specifies which register is an operand or result - RISC architectures with their numbered registers make this particularly obvious.