8086/8088 Architecture
8086/8088 Architecture
8086/8088 Architecture
The programming model contains 8, 16, and 32-bit registers. The Pentium 4 and Core2 also
contain 64-bit registers when operated in the 64-bit mode as illustrated in the programming
model.
The 8-bit registers are AH, AL, BH, BL, CH, CL, DH, and DL and are referred to when an
instruction is formed using these two-letter designations. For example, an ADD AL,AH
instruction adds the 8-bit contents of AH to AL. (Only AL changes due to this instruction.)
The 16-bit registers are AX, BX, CX, DX, SP, BP, DI, SI, IP, FLAGS, CS, DS, ES, SS, FS, and GS.
Note that the first 4 registers contain a pair of 8-bit registers. An example is AX, which contains
AH and AL. The 16-bit registers are referenced with the two-letter designations such as AX. For
example, an ADD DX, CX instruction adds the 16-bit contents of CX to DX. (Only DX changes
due to this instruction.)
Some registers are general-purpose or multipurpose registers, while some have special
purposes. The multipurpose registers include AX, BX, CX, DX, BP, DI, and SI. These registers
hold various data sizes (bytes or words) and are used for almost any purpose, as dictated by a
program.
Multipurpose Registers:
AX(accumulator): AX is referenced as a 16-bit register, or as either of two 8-bit registers (AH
and AL). Note that if an 8-bit register is addressed, only that portion of the 16-bit register
changes without affecting the remaining bits. The accumulator is used for instructions such as
multiplication, division, and some of the adjustment instructions.
BX(base index): BX, BH, or BL register sometimes holds the offset address of a location in the
memory system in all versions of the microprocessor.
CX(count): CX, CH, or CL, is a general-purpose register that also holds the count for various
instructions. Instructions that use a count are the repeated string instructions
(REP/REPE/REPNE); and shift, rotate, and LOOP instructions.
DX(data): DX, DH, or DL, is a general-purpose register that holds a part of the result from a
multiplication or part of the dividend before a division. In the 80386
and above, this register can also address memory data.
BP(base pointer): BP, points to a memory location in all versions of the microprocessor for
memory data transfers.
DI(destination index): DI, often addresses string destination data for the string instructions.
SI(source index): The source index register often addresses source string data for the string
instructions.
Special-Purpose Registers:
The special-purpose registers include IP, SP, and FLAGS; and the segment registers include CS,
DS and ES.
IP(instruction pointer): IP addresses the next instruction in a section of memory defined as
a code segment. This register is IP (16 bits) when the microprocessor operates in the real
mode and EIP (32 bits) when the 80386 and above operate in the protected mode. Note that
the 8086, 8088, and 80286 do not contain an EIP register and only the 80286 and above
operate in the protected mode. The instruction pointer, which points to the next instruction in
a program, is used by the microprocessor to find the next sequential instruction in a program
located within the code segment. The instruction pointer can be modified with a jump or a call
instruction.
SP(stack pointer): SP addresses an area of memory called the stack. The stack memory
stores data through this pointer and is explained later in the text with the instructions that
address stack data. This register is referred to as SP.
FLAGS: FLAGS indicate the condition of the microprocessor and control its operation. Figure
shows the flag registers of all versions of the microprocessor. (Note the flags are upwardcompatible from the 8086/8088 through the Core2 microprocessors.) The 808680286 contain
a FLAG register (16 bits) and the 80386 and above contain an EFLAG register (32-bit extended
flag register). The 64-bit RFLAGS contain the EFLAG register, which is unchanged in the 64-bit
version.
The rightmost five flag bits and the overflow flag change after many arithmetic and logic
instructions execute. The flags never change for any data transfer or program control
operation. Some of the flags are also used to control features found in the microprocessor.
Following is a list of each flag bit, with a brief description of their function.
C (carry): Carry holds the carry after addition or the borrow after subtraction. Then carry flag
also indicates error conditions, as dictated by some programs and procedures.
P (parity): Parity is a logic 0 for odd parity and a logic 1 for even parity. Parity is the count of
ones in a number expressed as even or odd. For example, if a number contains three binary
one bits, it has odd parity. If a number contains no one bits, it has even parity. Today parity
checking is often accomplished by the data communications equipment instead of the
microprocessor.
A (auxiliary carry): The auxiliary carry holds the carry (half-carry) after addition or the borrow
after subtraction between bit positions 3 and 4 of the result. This highly specialized flag bit is
tested by the DAA and DAS instructions to adjust the value of AL after a BCD addition or
subtraction. Otherwise, the A flag bit is not used by the microprocessor or any other
instructions.
Z (zero): The zero flag shows that the result of an arithmetic or logic operation is zero. If , the
result is zero; if , the result is not zero. This may be confusing, but that is how Intel decided to
name this flag.
S (sign): The sign flag holds the arithmetic sign of the result after an arithmetic or logic
instruction executes. If , the sign bit (leftmost bit of a number) is set or negative; if , the sign
bit is cleared or positive.
T (trap): The trap flag enables trapping through an on-chip debugging feature. (A program is
debugged to find an error or bug.) If the T flag is enabled (1), the microprocessor interrupts the
flow of the program on conditions as indicated by the debug registers and control registers. If
the T flag is a logic 0, the trapping (debugging) feature is disabled. The Visual C++ debugging
tool uses the trap feature and debug registers to debug faulty software.
I (interrupt): The interrupt flag controls the operation of the INTR (interrupt request) input
pin. If , the INTR pin is enabled; if , the INTR pin is disabled. The state of the I flag bit is
controlled by the STI (set I flag) and CLI (clear I flag) instructions.
D (direction): The direction flag selects either the increment or decrement mode for the DI
and/or SI registers during string instructions. If , the registers are automatically decremented;
if , the registers are automatically incremented. The D flag is set with the STD (set direction)
and cleared with the CLD (clear direction) instructions.
O (overflow): Overflows occur when signed numbers are added or subtracted. An overflow
indicates that the result has exceeded the capacity of the machine. For example, if 7FH (+127 )
is addedusing an 8-bit additionto 01H (+1 ), the result is 80H (128). This result represents
an overflow condition indicated by the overflow flag for signed addition. For unsigned
operations, the overflow flag is ignored.
Segment Registers:
Additional registers, called segment registers, generate memory addresses when combined
with other registers in the microprocessor. There are either four or six segment registers in
various versions of the microprocessor. A segment register functions differently in the real
mode when compared to the protected mode operation of the microprocessor.
CS (code): The code segment is a section of memory that holds the code (programs and
procedures) used by the microprocessor. The code segment register defines the starting
address of the section of memory holding code. In real mode operation, it defines the start of
a 64K-byte section of memory; in protected mode, it selects a descriptor that describes the
starting address and length of a section of memory holding code. The code segment is limited
to 64K bytes in the 808880286, and 4G bytes in the 80386 and above when these
microprocessors operate in the protected mode.
DS (data): The data segment is a section of memory that contains most data used by a
program. Data are accessed in the data segment by an offset address or the contents of other
registers that hold the offset address. As with the code segment and other segments, the
length is limited to 64K bytes in the 808680286, and 4G bytes in the 80386 and above.
ES (extra): The extra segment is an additional data segment that is used by some of the string
instructions to hold destination data.
SS (stack): The stack segment defines the area of memory used for the stack. The stack entry
point is determined by the stack segment and stack pointer registers. The BP register also
addresses data within the stack segment.
Real mode segmented model was mainstream programming model throughout the MSDOS era.
Program has access to 1MB of memory.
The CPU handles transformations of segment:offset combinations into a full 20-bit
address.
CS always points to the current code segment
The next instruction to be executed is pointed to by the CS:IP register pair.
Machine instructions called jumps can change CS to another code segment if necessary.
The program can span several code segments.
There is no direct CS manipulation to change from one code segment to another: when a
jump instruction needs to take execution into a different code segment, it changes CS
value for you.