A register is a hardware element in a computer that holds a number that can be added to (or, in some cases, subtracted from) the address portion of a computer instruction. Typically, the address portion is a hexadecimal value evenly divisible by 16 or by hexadecimal 10. In some processor designs, there are also smaller registers – for example, half-registers – that hold shorter instructions.
A register holds data in memory and stores it until it is ready to be read out by the CPU, a central processing unit that performs most of the computing tasks on a computer. It also contains control signals for executing commands sent from the computer’s main memory.
There are several different types of registers, based on the function they perform. They include an accumulator, which collects the results of computations; an address register, which keeps track of where a particular piece of data or a computer instruction is stored in memory; and a stack pointer register, which points to the location in memory where a specific item is located.
The accumulator can be used for arithmetic and logic operations, but is often mainly reserved for holding intermediate results of computations. There are two kinds of accumulator registers: the zero (Z) register, which stores a value of zero when no operation has been performed; and the carry (C) register, which stores a value of one if an operation has produced a carry from the most significant bit of the accumulator’s content.
An accumulator can be set or reset by the ALU to change the sequence of arithmetic and logic operations that it performs. During these operations, the accumulator can contain a series of flip-flops that are set and reset by the ALU to indicate different conditions that might be encountered during arithmetic and logic calculations. These flags can be monitored and tested by the control circuitry to alter the sequence of computations that are carried out.
During arithmetic or logic operations, the accumulator can also be set and reset by the ALU to indicate the outcome of the operation. For example, a zero (Z) flag indicates that the accumulator content is zero after an operation has been performed. The carry (C) flag indicates that the accumulator has been carried by an arithmetic operation, which can be useful in testing whether a particular arithmetic or logic operation is correct.
In addition to the accumulator, there are also other kinds of registers in a computer’s CPU, including the index register and segment registers. The index register is an important type of register because it is used to alter the address of the operands when the program instruction is in execution.
A segment register is an important type of register because it stores the starting addresses of a memory segment, which are typically addressed using an offset or displacement value. For example, all memory locations within a segment begin at an address evenly divisible by 16 or by hexadecimal 10, but the rightmost hex digit in such a memory location is 0. The processor then combines the segment address in a segment register with the offset value to locate the actual starting address of any data or instruction in a memory segment.