Registry memory is internal memory used in processors to store values that the processor must have direct access to in order to complete its work.
A processor, as normally found in computers, is a Von Neumann machine that continuously executes Von Neumann’s three steps: Get the following instruction – decode the instruction – execute the instruction.
All data in the computer is encoded in the form of bit rows – rows of 1’s and 0’s. In order to perform the above steps, the processor must retrieve an instruction in the form of a bit row, then deduce from this bit row which instruction represents the bit row, and finally execute the instruction. While performing this work, the processor needs a place to store the input and any intermediate results. This is necessary, for example, for adding or multiplying two values: input, output and intermediate results all have to be stored somewhere, until the processor puts the result away and can start with the next instruction. A part of the RAM, the so-called working memory, with which every computer is equipped, could be used for this. This memory is connected to the processor via a bus. However, the distance between the processor and this memory (which can be bridged via the bus) makes such a solution impossible: for every microstep of the processor, the bits would have to be fed in and out over that extremely long bus. For this reason, the processor has an amount of integrated memory that it can access more directly. These groups of cells are called registers and together form the register memory.
Costs and benefits
As noted earlier, the submaster memory resides directly on the processor. This allows the processor to access the data stored in its registers much faster – the data paths between the registers and the processor’s processing units are extremely short. The use of submaster memory is therefore several times faster than the use of RAM, both in the access time to the memory and in the lookup time (which is equal to 0 μs).
On the other hand, the registers are integrated in the processor; registers are thus many times more expensive per unit of storage than RAM and much more expensive than, for example, storage space on a hard disk. In addition, the number of registers is limited by the available surface area of the processor, although progressive miniaturization increases the possible amount of memory on the processor. It is therefore primarily important for the control of the computer (both in the hardware sense and in the sense of the programs) to achieve an optimal distribution of the required memory capacity between register memory and RAM memory.
Broadly speaking, there are two types of bit rows that a processor has to deal with while working:
- Information-carrying bit rows: These are bit rows that contain pure data, such as a character to appear on the monitor or a number to be added to something
- Control-sensitive bit rows: These are bit rows that affect the operation of the processor. They contain instructions to the processor and pointers to cells in RAM where the processor can find other bit rows that are important for performing its job. These references are called addresses.
Although both bit rows are actually no more than rows 1’s and 0’s (strictly on the John von Neumann principle), there are still several processors that “specialize” their available registers according to application (addresses or data). Although the physical structure of the two types of registers is not different, this subdivision often makes it possible to achieve better performance in the operation of the processor, because some instructions in the processor may be implemented on the assumption that certain registers contain certain types of data.
Incidentally, the aforementioned separation is not absolute. There are enough processors on the market that do not make such a distinction, or that do make a distinction, but also have a third group of registers that may contain both types of data, or whose address registers are purely for addresses and the data registers are data or may contain addresses.
Overview of types
There are different types of registers:
- Data registers store integers. In some older architectures and simple modern processors, there is a special data register, the accumulator, which is implicitly used for many operations.
- Address registers contain memory addresses and are used to access computer memory. In some processors there is a special address register, the index register.
- General purpose registers (GPRs) These registers can contain numbers as well as addresses.
- Floating point registers (FPRs) are used to store floating point numbers.
- Constant registers contain values that are constant (zero, one, pi, …).
- Vector registers contain data for vector processors implemented with SIMD instructions.
- Special purpose registers contain the status of a program. Generally, this is where the instruction pointer, stack pointer, and status register are kept.
- Instruction registers contain the instructions that are currently being executed.
- Index registers are used to adjust operand addresses during the execution of a program.
- Registers used to read data from main memory, a collection of storage registers residing on chips other than the processor:
- Memory buffer register
- Memory data register
- Memory address register
Registers and compiler construction
This proliferation of capabilities presents a significant challenge to compiler writers. Their compilers translate programs into machine instructions, also building up a division of storage of data across registers and memory, called register allocation. It is a great challenge for the programmer to translate programs in such a way that the built-up distribution is optimal and thus gets the best performance from the entire system.