What is the purpose of a register in a CPU and what are special purpose registers?

A CPU register is a small and temporary storage containing a set of data holding places that are part of the computer processor. A register holds an instruction, a storage address, or any kind of data.

Before trying to understand some special purpose registers, let us try to understand the difference between General purpose and special purpose registers.

  • Special purpose registers hold the status of a program. These registers are designated for a special purpose. Some of these registers are stack pointer, program counter etc.

  • General purpose registers hold the temporary data while performing different operations. Some of these registers are accumulator, BX etc.

Special Purpose Registers

Let us see some of the special purpose registers used in CPUs.

Instruction Register (IR)

The Instruction Register (IR) stores the instruction currently being executed. In simple processors each instruction to be executed is loaded into the instruction register which holds it while it is decoded, prepared and ultimately executed.

BRANCH (unconditional), BRANCH IF ZERO (conditional) takes the place of the instruction register in the LMC.

Status register

A Status register or flag register or condition code register is a collection of status flags based on a processor. Status register is also a hardware register that contains the information about the state of the processor.

This register has a size of 16 bits with each bit having a flag. Status register is used in different conditions like if the result is negative, result is zero etc. There are different types of status registers such as Program Status registers is the register which holds the status of current execution of the program.

It also controls the enabling and disabling of interrupts and sets the processor operating mode.

Program status register is divided into following −

  • Application program status registers (APSR)

  • Interrupt program status registers (IPSR)

  • Execution program status registers (EPSR)

If the flag is Z − It indicates that the result of the arithmetic operations which were loaded is zero.

If the flag is N − It indicates that the result of mathematical operation is negative.

If the flag is V/O − It indicates that the result of the operation is too large to fit in the register. That is the reason it overflows the result.

If the flag is P − It indicates that the number of sets of bits the last result is odd or even.

Shift register

A Shift Register is a kind of sequential logic circuit that have ability of both storing and transferring data, made up of flip-flops and connected in such manner that the output of one flip-flop will work as the input of other flip-flop (depending upon which type of shift register is used)

There are six types of shift register which are as follows −

  • Serial in - Serial out Shift Register − It streams-in data serially one after the other and streams-out in similar manner.

  • Serial in - Parallel Out Shift Register − It converts the data in serial manner and out the data in parallel manner

  • Parallel in - Serial Out Shift Register − It takes data in parallel and streamsout in serial manner (one after other).

  • Parallel in - Parallel Out Shift Register − Input data fed-in parallel and output data is streams-out simultaneously parallel.

  • Bidirectional Shift Register − This shift register can perform either right or left data shift or could perform in both directions.

  • Counters − It feedbacks their output into the device as input in such a manner that creates a particular pattern or sequence.

Accumulator Register (AC)

It is used for storing the results that are produced by the system. When the CPU gives the results after the executing then all the results are Stored into the AC Register.

Memory Address Register (MAR)

It is used to hold the memory addresses of data and instructions. It accesses data and instructions from memory during the execution phase of an instruction. For example, the CPU wants to store some data in the memory or to read the data from the memory. It places the address of the-required memory location in the MAR.

Program Counter (PC)

It contains the address of the next instruction to be executed. In other words, it holds the address of the memory location of the next instruction when the current instruction is executed by the microprocessor.