Pentium Processors include in excess of 30 registers, some of which are
completely invisible to the operating system.
Assemblers (software to assemble instructions into programs) are
designed to use the 8086 Instruction Set. This set is able to reference
registers only available in the original 8086/8088 Intel CPUs.
To access these registers, 20 register names are used.
|
Register Type |
Register Name |
|||
|
8-bit high registers |
AH |
BH |
CH |
DH |
|
8-bit low registers |
AL |
BL |
CL |
DL |
|
16-bit general purpose |
AX |
BX |
CX |
DX |
|
16-bit pointer & index |
SP |
BP |
SI |
DI |
|
16-bit segment |
CS |
DS |
SS |
ES |
The General Purpose Registers have many important uses, including:
Storing the values most frequently used (Operations on registers are
much faster than operations on memory). A program's principal values are
usually placed in registers for faster operation
Supporting operations with 2 or more variables. Direct memory-to-memory
operations are illegal with 8086 processors. To operate on 2 memory locations
at the same time, the value of one of them must be loaded into a register.
Enabling full use of all the instructions. Many instructions require the
use of a particular register only.
Passing or returning values in a procedure or interrupt call.
Returning values back to the operating system (eg: errorlevels)
Each of the general-purpose registers (AX, BX, CX and DX) can be
accessed as single 16-bit registers or as 2 8-bit registers. AH, BH, CH and DH
represent the high-order 8 bits of the registers, while AL, BL, CL and DL
represent the low-order 8 bits.
Programs are, therefore, able to operate on 1 or 2 byte data objects.
The AX (Accumulator) register is ideal for repeated calculations. It accumulates
totals as well as the results of multiplication and division. Some instructions
have special encodings optimised for use with AX.
Multiplication instructions always use AX. Using the MUL instruction
(Multiply), you specifiy one 16-bit value. The processor multiplies this value
by the value already placed in AX, and stores the result as follows: the least
significant 16 bits go into AX, the most significant 16 bits go into DX.
The DX register is often used to contain any overflow from AX processing.
In port I/O instructions AX holds the data to write to a port and
receives data from a port.
High-level languages expect AX to contain a function's return value. The
AL portion is used to return an errorlevel to DOS after a program terminates.
The combination of DX and AX registers may contain an address that
points to a return value from a program.
The BX (Base) register has great importance as a pointer or address
register. All 16-bit registers can hold addresses, but not all can be used to
retrieve the contents of an address.
The CX (Count) register has special meaning to instructions with a
repeat-operation feature. The contents of CX indicate how many times to repeat
instructions. Loops, string operations, certain Jump instructions, and shifts
and rotates all use CX in this way.
The Loop instruction is analagous to the FOR instruction in high-level
languages.
The DX (Data) register often is used only for storage of temporary
values. DX is located next to AX in the physical layout of the 8086 chip for
speed.
The two index registers are SI (Source Index) and DI (Destination
Index). These registers are similar to the general-purpose registers, but can
only be accessed one byte at a time.
They are efficient places to store general data, pointers, array
indexes, and pointers to blocks of memory.
They are usefule for preparing for string operations. SI would hold a
source address and DI would hold the destination address for the operation.
The pointer registers (BP, SP and IP) are all special purpose registers
that help implement procedure calls. The processor alters SP (Stack Pointer)
and IP (Instruction Pointer) whenever you call a procedure, and you can use BP
(Base Pointer) to access parameters placed on the stack.
They are not used for pointer variables or other general data.
BP is used to retrieve contents pointed to by an address. BP by default
points into the stack segment and is typically used to retrieve items on the
stack.
SP points to the current location within the stack segment. This values
changes to always point to the top of the stack. The processor stack works like
a stack of dishes; you PUSH dishes onto the stack, and POP them off the top of
the stack, working on a last-in-first-out basis.
IP cannot be adjusted directly and contains the address of the next
instruction to execute.
This is a 16-bit register made up of bits that indicate each has some
specific condition. Most of the flags help determine the behaviour of
conditional jump instructions (these operate much like IF..ELSE in high-level languages).
Some flags (Trap, Interrupt Enable, and Direction) control the
processor's general operation.
Many instructions (especially CMP) set the other flags in a meaningful
way.
The CS (Code Segment) register is used as the segment address of the
next instruction to execute. IP holds the offset address within the segment, so
CS:IP represents the full address.
By default, the processor uses the DS (Data Segment) register as the
segment address for program data. Most programs place the most frequently used
data in an area pointed to by DS (64K). The ES register is used to reference
data outside the default data area (DS).
The SS (Stack Segment) register is used to access data on the stack. SP
is used with SS (SS:SP) to point to the current stack position.
The ES (Extra Segment) register is convenient for accessing data outside
of the default data area. It plays a role in string instructions, where the DI
(Destination Index) is always relative to the segment address in ES.
There are four types of addressing modes (called operands).
|
Operand Type |
Description |
|
Immediate |
A constant value contained in the instruction itself. There is no need to reference a register to get the value |
|
Register |
A 16-bit or 8-bit register. The value required is stored in a register |
|
Direct Memory |
A fixed location in memory. One value in an instruction can be fetched directly from memory
instead of from a register. |
|
Indirect Memory |
A memory location determined at the time the program is run by using
an address stored in one or two registers. |