Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 896
bytefire Avatar asked Dec 19 '22 05:12

bytefire


2 Answers

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.

like image 174
Chris Stratton Avatar answered Feb 10 '23 02:02

Chris Stratton


I/O or special-function registers are typically memory mapped but they remain registers in the sense that they are not general-purpose memory, but rather I/O peripheral control and status registers.

Unlike memory-mapped random-access read/write or read-only memory, registers typically possess characteristics such as defined power-on/reset states, and may be r/w, r/o, or w/o at the individual bit level. Further their values may change independently of any value written to them as they are also writeable by the associated peripheral; this is most often reciprocal - the processor writes while the peripheral reads, or vice-versa; often at the bit level rather than the word level. It is even common that a single address can refer to two registers, one read-only, and the other write-only.

like image 38
Clifford Avatar answered Feb 10 '23 02:02

Clifford