14.2 Register Organization

COS2621 - Computer Organisation · 14. Processor Structure and Function

Processor Structure and Function

14.2 Register Organization

Registers are small, high-speed storage locations within the central processing unit (CPU). They provide storage internal to the CPU and temporarily hold data during processing. Registers are faster than main memory (RAM) and are essential for efficient CPU operation.

Types of Registers

Registers can be classified into several types:

  • General-Purpose Registers: Used for a wide range of operations. Examples include AX, BX, CX, and DX in the Intel architecture.
  • Special Purpose Registers: Serve specific functions. For example, the instruction pointer (IP) keeps track of the next instruction to execute.
  • Accumulator Register: A special register that stores intermediate arithmetic and logic results. In the Intel architecture, AX is often used as the accumulator.

Remember: The accumulator register is essential for arithmetic operations.

Register Size

The size of a register determines how much data it can hold. Common sizes include 8-bit, 16-bit, 32-bit, and 64-bit. For example, a 32-bit register can hold values from 0 to 4,294,967,295.

Register Operations

Registers perform various operations, including:

  • Loading: Moving data from memory to a register.
  • Storing: Moving data from a register to memory.
  • Arithmetic Operations: Performing calculations using data in registers.

Example of Register Operations

Consider the following assembly instruction:

MOV AX, 10 ; Load the value 10 into the AX register

This instruction moves the value 10 into the AX register. Next, if we want to add another value, say 5, we can use:

ADD AX, 5 ; Add 5 to the value in AX

After executing this instruction, AX will hold the value 15.

Watch out: Ensure you understand the difference between loading and storing data in registers. Loading brings data into the register, while storing sends it back to memory.

Register Organization in x86 Architecture

The x86 architecture includes several registers that serve different purposes:

  • Data Registers: AX, BX, CX, DX.
  • Pointer Registers: SP (Stack Pointer), BP (Base Pointer).
  • Index Registers: SI (Source Index), DI (Destination Index).

Understanding register organization is crucial for assembly language programming and CPU architecture. Registers are at the heart of data storage and processing within the CPU.

Addressing Registers

To address a specific register in machine code, you need enough bits to represent the number of registers available. For example, if a machine has 12 registers, you need 4 bits to address any of these registers. This is calculated using the formula:

Number of bits = log2(Number of registers)

In this case, log2(12) is approximately 3.58, which rounds up to 4 bits.

Summary

  • Registers are high-speed storage locations in the CPU.
  • Different types of registers serve various functions.
  • Understanding register operations is crucial for assembly language programming.

Check your understanding

  • What provides storage internal to the CPU?
  • Explain the difference between general-purpose and special-purpose registers.
  • What happens when you execute the instruction ADD AX, 5 if AX currently holds the value 10?
  • How many bits are needed to address 12 registers?

Test yourself

5 quick questions on this lesson. Pick an answer to see if you're right.

  1. 1. What is the primary function of the instruction pointer (IP) register?

  2. 2. ________ provide storage internal to the CPU.

  3. 3. What is the size of a register that can hold values from 0 to 4,294,967,295?

  4. 4. ________ provide storage internal to the CPU

  5. 5. Which of the following registers in the Intel architecture is primarily used as the accumulator register?