Difference between revisions of "Register"

From CDOT Wiki
Jump to: navigation, search
(Created page with 'Category:Computer Architecture{{Chris Tyler Draft}}A register is a high-speed memory location within a CPU. Various types of registers are used in combination in various com…')
 
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Computer Architecture]]{{Chris Tyler Draft}}A register is a high-speed memory location within a CPU.
+
[[Category:Computer Architecture]]A register is a high-speed memory location within a CPU.
  
Various types of registers are used in combination in various computer architectures:
+
 
* '''General-purpose registers''' are used to temporarily store values.
+
== Common Types of CPU Registers ==
* '''Accumulators''' hold the results of mathematical operations (originally add/subtracts, but now any numerical operation).
+
Various types of registers are used in combination in computer architecture. The set of all registers present in a processor is called the ''Register Set'' or ''Register File''.
* '''Status registers''' (or Flag registers, or Condition code registers) contain flag bits, which are set/cleared/tested either explicitly (by instructions) or implicitly (as the result of other operations). For example, the ARM aarch32 "Z" flag is set ("1") if an operation has a non-zero result, and cleared ("0") if an operation has a non-zero result. This flag is one bit within the Application Processor Status Register (APSR).
+
 
* '''Control registers''' alter the operation of the processor, such as by enabling binary coded decimal (BCD) math or toggling [[Endian|little-endian/big-endian]] mode.
+
The types of registers present will vary by processor family, but in general consist of some combination of:
 +
 
 +
=== General-purpose registers ===
 +
Used to temporarily store values. Most modern architectures have several dozen general-purpose registers.
 +
 
 +
==== Accumulator ====
 +
A special designation of general-purpose register, used to hold the results of mathematical operations (originally add/subtracts, but now any numerical operation).
 +
 
 +
==== Index Register ====
 +
A special designation of general-purpose register, used to hold an index (offset) into an array or memory space. The x86_64 Source Index (SI) and Destination Index (DI) registers are examples of this. Similarly, the [[6502#Registers|6502]] Y and X registers are Index registers.
 +
 
 +
=== Status Register ===
 +
A ''status register'' (or ''Flag register'', or ''Condition code register'') contains [[Flags|flag]] [[Word#Bit|bits]], which are set/cleared/tested either explicitly (by instructions) or implicitly (as the result of other operations). For example, the ARM AArch32 "Z" flag is set ("1") if an operation has a zero result, and cleared ("0") if an operation has a non-zero result. This flag is one bit within the Application Processor Status Register (APSR).
 +
 
 +
=== Control Registers ===
 +
''Control registers'' contain control [[Flags|flags]] which alter some aspect of the operation of the processor, such as enabling binary coded decimal ([[BCD]]) math or toggling [[Endian|little-endian/big-endian]] mode.
 +
 
 +
=== Stack Pointer ===
 +
A ''stack pointer'' is a register used for indirect access to the ''stack'', and is automatically incremented or decremented on each access.
 +
 
 +
=== Program Counter ===
 +
The ''program counter'' or ''instruction pointer'' keeps track of the address of the currently-executing instruction.
 +
 
 +
A jump is performed by writing the destination address to the program counter.
 +
 
 +
A subroutine (function) call is performed by pushing the program counter onto the [[Stack|stack]] or saving it in a designated ''Link Register'' and then writing the subroutine address to the program counter. Upon completion of the subroutine, the return address is popped from the stack or retrieved from the Link Register and written to the program counter.
 +
 
 +
Relative [[Addressing Mode|addressing modes]] add a signed value to the program counter to calculate the effective address.
 +
 
 +
== Other Uses of the Term "Register" ==
 +
 
 +
The term ''register'' may also be used to refer to an IO port or a memory address within a memory-mapped input/output device, used to set/read device status and parameters or send/receive small amounts of data.
 +
 
 +
== References ==
 +
* [[6502#Registers|6502 Registers]]
 +
* [[AArch64 Register and Instruction Quick Start]]
 +
* [[x86_64 Register and Instruction Quick Start]]

Latest revision as of 17:18, 13 September 2022

A register is a high-speed memory location within a CPU.


Common Types of CPU Registers

Various types of registers are used in combination in computer architecture. The set of all registers present in a processor is called the Register Set or Register File.

The types of registers present will vary by processor family, but in general consist of some combination of:

General-purpose registers

Used to temporarily store values. Most modern architectures have several dozen general-purpose registers.

Accumulator

A special designation of general-purpose register, used to hold the results of mathematical operations (originally add/subtracts, but now any numerical operation).

Index Register

A special designation of general-purpose register, used to hold an index (offset) into an array or memory space. The x86_64 Source Index (SI) and Destination Index (DI) registers are examples of this. Similarly, the 6502 Y and X registers are Index registers.

Status Register

A status register (or Flag register, or Condition code register) contains flag bits, which are set/cleared/tested either explicitly (by instructions) or implicitly (as the result of other operations). For example, the ARM AArch32 "Z" flag is set ("1") if an operation has a zero result, and cleared ("0") if an operation has a non-zero result. This flag is one bit within the Application Processor Status Register (APSR).

Control Registers

Control registers contain control flags which alter some aspect of the operation of the processor, such as enabling binary coded decimal (BCD) math or toggling little-endian/big-endian mode.

Stack Pointer

A stack pointer is a register used for indirect access to the stack, and is automatically incremented or decremented on each access.

Program Counter

The program counter or instruction pointer keeps track of the address of the currently-executing instruction.

A jump is performed by writing the destination address to the program counter.

A subroutine (function) call is performed by pushing the program counter onto the stack or saving it in a designated Link Register and then writing the subroutine address to the program counter. Upon completion of the subroutine, the return address is popped from the stack or retrieved from the Link Register and written to the program counter.

Relative addressing modes add a signed value to the program counter to calculate the effective address.

Other Uses of the Term "Register"

The term register may also be used to refer to an IO port or a memory address within a memory-mapped input/output device, used to set/read device status and parameters or send/receive small amounts of data.

References