CPU Registers

This section will cover the programmable CPU registers. The Assembly language programmer must be familiar with the references and uses of each register in order to program effectively. Other registers are discussed in the section on different 80X86 processors.

The following is a list of the 16-bit registers and their references:
AX Accumulator
FL Flags
BX Base Index
BP Base Pointer
CX Counter
DX Data I/O Index
DI Destination Index
SI Source Index
SP Stack Pointer
IP Instruction Pointer
CS Code Segment
SS Stack Segment
DS Data Segment
ES Extra Segment

Some registers can be divided and accessed as two eight-bit registers for byte operations. They are referenced as follows:
AH AX High byte
AL AX Low byte, eight bit accumulator
BH BX High byte
BL BX Low byte
CH CX High byte
CL CX Low byte, shift counter
DH DX High byte
DL DX Low byte
AX and AL are the Accumulator
AX = AH+AL. AX is the 16-bit reference for the accumulator; AL is the 8-bit reference. AL is the low half of AX with AH as the high half. The accumulator is the primary data register. Most instructions for handling data execute faster if the data is in the accumulator.
FL Flag Register
The Flag register is a 16-bit data register used to keep track of CPU activity. This includes all logical, arithmetic, and comparing results as well as interrupt controls, debug tracing, string direction flags, etc.
Most conditional jumping instructions use the contents of this register to determine if branch conditions are true or not true.

The bit positions with X are not defined for the 8086/8088 CPU but are reserved by Intel for use with other processors in the series.

OF Overflow Flag
This bit is set if the last data manipulation caused the high bit to change.
DF Direction Flag
This bit is used by the CPU to decide the direction of string operations. Clearing the bit causes string operations to go forward and setting the bit causes string operations to go backward.
IF Interrupt Flag
This bit can be set or cleared by the programmer to prevent or allow maskable interrupts to occur.
TF Trace Flag
This bit is used in the debugging mode for single stepping through program logic.
SF Sign Flag
This bit is reset by logical operations to be equal to the high bit of the resulting data.
ZF Zero Flag
This bit is set if the last data manipulation produced a zero condition.
AF Aux Carry Flag
This bit is used by logical instructions that deal with data in nibbles (four bit).
PF Parity Flag
This bit is reset by the last data manipulation instruction to reflect if the operation produced an even or odd parity condition. A 1 means even parity and a 0 means odd parity.
CF Carry Flag
When adding, the carry bit is set if an overflow occurs. If subtracting, the bit is set if it had to borrow a bit because the subtraction resulted in a sign flip.
BX Base Index
BX is the most flexible of the indexing registers. It is a 16-bit register that can also be addressed in 8-bit format as BH (high) and BL (low) where BX = BH+BL. BX may beadded to other index registers for working with morecomplex indexing offsets. Examples: [BX+offset], [BX+SI+offset], [BX+DI+offset]
BP Base Pointer
BP is the base pointer register used to index data in the stack area. This register is used by many compilers to index data frames in the stack area. BP may be combined with DI or SI to index data in the stack area. Examples: [BP+SI+offset], [BP+DI+offset]
SI Source Index
SI is the source index register used by the string instructions. It may be combined with BX or BP to index data. Example: [SI+BX+offset]
DI Destination Index
DI is the destination index register used by the string instructions. It may be combined with BX or BP to index data. Example: [DI+BX+offset]
SP Stack Pointer
SP is the stack pointing register used by the push, pop, call, interrupt, and return instructions. It always indexes the last word pushed onto the stack.
CX Counter
CX is the counter register used by the string, repeat, and loop instructions.
DX Data Register, I/O index
DX is the data register. DX is only used as an index for I/O port functions. It is used for the 16 by 16 bit multiply and the 32 by 16 bit divide instructions. The results from a 16 bit multiply are put into DX:AX where DX holds the high 16 bits and AX holds the low 16 bits. For a 32 bit by 16 bit divide, DX will hold the leftover (modulo) data resulting from the divide.
IP Instruction Pointer
IP is used to index the next instruction to execute. It is reset by call and jump instructions.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s