A CPU is primarily a circuit that reads instructions, and data, from a storage device, decodes those instructions, and performs calculations or input/output based upon those instructions. To a large extent the process is controlled by loading, transferring, and manipulating the contents of registers.
Different processors have a different set of registers, and the size of registers varies between different processors. Some registers have specific functions, and other registers are general purpose. The easiest way to learn about registers is to study an early 16-bit microprocessor. Shown below is the register set of the Intel 8086 microprocessor.
The 8086 microprocessor has fourteen 16-bit registers. Eight of the registers are known as General Purpose Registers because they can be used by the programmer for data manipulation. The general registers can be treated as 16-bit registers, or they can each be treated as two 8-bit registers that can be used independently.
The AX register can be accessed as a 16-bit register, or as AH an 8-bit register (H referring to the high-order byte of AX), and AL an 8-bit register (L referring to the low-order byte of AX). Similarly BX can be accessed as BH and BL, CX can be accessed as CH and CL, DX can be accessed as DH and DL.
The four index registers are used primarily with operations related to the memory addressing modes of the 8086 microprocessor.
The Instruction Pointer, sometimes called the program counter, is used to store the memory location of the next instruction to be executed. After that instruction is executed, the IP is updated to point to the next instruction. The IP will always point to the next instruction to be executed.
The Flags Register (sometimes called the Status Register) uses 9 individual bits to indicate the status of arithmetic, logical, and program instructions. A flag can take on a values of 0 or 1. A flag is set if it has the value 1. The remaining 7 bits of the Flags Register are not used. Below is a description of the purpose of individual flags.
•Overflow Flag (OF) Set when the result of an arithmetic operation is too large or is too small a negative number to fit into destination register.
•Direction Flag (DF) Set when string manipulation instructions will auto-decrement index registers. Cleared when the index registers will be auto-incremented.
•Interrupt-enable Flag (IF) Setting to enable maskable interrupts.
•Single-step Flag (TF) Set to indicate single-step interrupt will occur after the next instruction.
•Sign Flag (SF) Set when the most significant bit of the result of an arithmetic operation is set.
•Zero Flag (ZF) Set if the result of an arithmetic operation is zero.
•Auxiliary carry Flag (AF) Set if the result of an arithmetic operation is a carry from or borrow to bits 0-3 in the AL register.
•Parity Flag (PF) Set if parity (the number of 1 bits) in the low-order byte of the result of an operation is even.
•Carry Flag (CF) Set if there was a carry from, or borrow to, the most significant bit during last operation.
To a large extent the operation of a microprocessor involves loading, transferring, and manipulating the contents of registers. In this article you learn about the functions, and purposes of the register set of the Intel 8086 microprocessor.