The 8086 microprocessor has a powerful set of registers. The register organization of the 8086 microprocessor is also known as the programmer’s model. These different internal registers are accessed by the programmers programming the 8086 microprocessor. All the registers are 16-bit and are grouped into several categories as follows,
- General-purpose registers,
- Segment registers,
- Special purpose registers, and
- Flag register.
Let us see briefly each register in the 8086 microprocessor.
General Purpose Registers :
The 8086 microprocessor has 8 registers each of 8 bits, AH, AL, BH, BL, CH, CL, DH, DL as shown below. Each register can store 8 bits. To store more than 8 bits, we have to use two registers in pairs. There are 4 register pairs AX, BX, CX, DX. Each register pair can store a maximum of 16-bit data. General-purpose registers are used for holding variables or data. They can be also used as counters or as temporary storage for intermediate results during any operation.
These registers perform the following functions,
- Accumulator (AX) Register → When the microprocessor performs any arithmetic or logical operations, the accumulator provides one of the operands and it also holds the result of the operation. The user can access this register. It is denoted by A. The accumulator register AX can collect a total of 16-bit data i.e., 8-bit of data in register AL (lower byte of AX) and 8-bit of data in register AH (higher byte of AX).
- Base (BX) Register → For reading data from memory or writing data into memory, 8086 microprocessor has to select one memory location, 16-bit effective address of this memory location can be stored in register BX.
- Counter (CX) Register → In rotate and shift instructions, register CL is used as 8 bit counter i.e., it used to store 8-bit count. In some instructions like REP (repeat), Loop, register CX is used as 16-bit implicit counter.
- Data (DX) Register → In multiplication and division instruction, if data or result is of 32-bits, then register DX is used to store 16 MSB, and register AX is used to store 16 LSB i.e., register DX is concatenated with register AX to store 32-bit data or result. In 8086, the input port address is 16-bit and it is stored in register DX. The name of register DX is given along with IN and OUT instructions as shown in the below example.
- MOV DL, 0001H (port address)
- IN AL, DX
Segment Registers :
The 8086 microprocessor has a 20-bit wide physical address to access 1MB memory location. But the registers of the 8086 microprocessor that holds the logical address are only 16-bits wide. Thus 8086 microprocessor implements memory segmentation for 1MB physical memory where the memory is divided into sections or segments as shown below. So that each memory location in the segment can be accessed by the 16-bit logical address.
The 8086 microprocessor allows only four segments to work at a time and are provided by the bus interface unit (BIU) of the 8086 microprocessor. The four-segment registers and their functions are,
- Data Segment Register (DS) → It is used to point to the base address of the data segment.
- Code Segment Register (CS) → It is used to point to the base address of the code segment.
- Stack Segment Register (SS) → This register is used to store the base address of the stack memory segment.
- Extra Segment Register (ES) → This register is used to store the base address of the extra memory segment.
Special Purpose Registers :
Special purpose registers are pointer and index registers, instruction pointer, and program counter. These are 16-bit registers used by the CPU for specific purposes. Since they are 16-bit, one or more registers are associated with each segment register in order to generate a 20-bit physical address on the address bus. The special-purpose registers are used as memory pointers and are belongs to the pointer and index group shown below.
Stack Pointer (SP) :
It is used to hold the address of the stack top. Stack top is the uppermost filled memory location in stack memory. There is no access to these register directly, the modifications are done depending on the contents of the stack.
Base Pointer (BP) :
The use of BP as a pointer to a memory location is similar to the use of SI and DI registers. BP register acts as a memory pointer to the stack segment register. The BP register is mainly used to access any location directly in the stack.
Source Index (SI) and Destination Index (DI) :
SI and DI act as memory pointers relative to segment register DS. The microprocessor will take the effective address of the data from SI and store it in DI.
Instruction Pointer (IP) :
The IP gives the offset address of the next instruction to be executed i.e., IP stores the address of the next instruction to be fetched from the code segment. When reset is activated, the instruction pointer is set to the address of the first instruction to be fetched.
Flag Register :
The flag register of 8086 is a flip-flop. It is 16-bit wide with a collection of 1-bit values that indicates the current state of the execution of arithmetic or logical instruction in the processor. Out of 16 bits, 9 bits are used in the 8086 as shown below.
The nine active flags are divided into two groups namely status flags and control flags. The status flags include, carry flag, parity flag, auxiliary flag, zero flag, sign flag, and overflow flag that indicates the status of the instruction. The control flags used to control certain operation of the processor, it includes the interrupt flag, direction flag, and trap flag.
Default and Specified Segment Registers :
For selecting any memory location, the microprocessor will transfer a 20-bit physical address. For generating a physical address microprocessor will add the base address and effective address. The effective address will be present in memory pointers. For each memory pointer, there are fixed segment registers for the base address. This, fixed segment register of memory pointers is called default segment registers.
Apart from the actual segment register microprocessor can take the base address from other segment registers. But, the programmer has to specify the name of these registers in the instruction. Hence these registers are called specified segment registers. The default and specified segment registers for each memory pointer are tabulated as shown below.
|Operation of Microprocessor||Memory Pointer (logical address)||Default Segment||Specified Segment|
|Microprocessor reading instruction from memory||IP||CS||None|
|Microprocessor storing stack of data (PUSH/POP)||SP, BP||SS||None|
|Source of string data||SI||DS||CS, ES, SS|
|Destination of string data||DI||ES||None|
|General data access||Effective address||DS||CS, ES, SS|
|BX used as a pointer||Effective address||DS||CS, ES, SS|
|BP used as a pointer||Effective address||SS||CS, ES, DS|
1 thought on “Registers in 8086 Microprocessor – General Purpose, Segment & Flag Registers”
super..it is very useful for my subject grading purpose.thank u..