Вы находитесь на странице: 1из 5

Intel 8088/80286 Register Architecture

General Purpose Registers Special Purpose Registers

AX - accumulator IP – instruction pointer


BX – base index FLAGS – flags
CX – counter
DX – data
(SP) – stack pointer Base Index Registers
(BP) – base pointer
(SI) – source index BX
(DI) – destination index BP

Segment Registers Index Registers

CS – code segment SI
DS – data segment DI
ES – extra segment
SS – stack segment

71
16-bit General Purpose Registers

There are eight general purpose registers: AX, BX, CX, DX, SP, BP, SI, and DI. These can be used as
the left or right operand in any of the ALU operations and can be loaded from a memory cell and
stored back into a memory cell. They can also be loaded with a chosen number.

Most of the calculations in a program are done using the general purpose registers.

Note: SP, BP, SI, and DI have other special purposes and normally should not be used as general
purpose registers.

8-bit General Purpose Register Names

There are eight 8-bit general purpose register names: AH, AL, BH, BH, CH, CL, DH, and DL. Note
that these are NOT extra registers but only sub-divisions of the 16-bit registers.

AX = (AH) + (AL) where AH is the high byte and AL is the lower byte of the 2-byte register AX
BX = (BH) + (BL) where BH is the high byte and BL is the lower byte of the 2-byte register BX
CX = (CH) + (CL) where CH is the high byte and CL is the lower byte of the 2-byte register CX
DX = (DH) + (DL) where DH is the high byte and DL is the lower byte of the 2-byte register DX

Segment Registers

There are four segment registers: CS, DS, SS, and ES. They are specifically designed to store the
starting addresses for the segments that make up your program and its data. There are special machine
language instructions designed to use these registers and therefore you cannot use these registers in
most general instructions.

Index Registers

There are four index registers: BX, BP, SI, and DI. They can be used to help select a memory cell for
loading, storing, or calculations. When used as index registers, they simulate the action of a pointer
variable in C++.

Additionally, your instructions can add to the contents of these registers so that the register’s contents
does not change, but you do access a different memory cell; much like array indexing command in
C++, array[2], where “array” is your pointer variable and 2 is a calculation added to the pointer
variable to access a memory cell which is some number of bytes away from “array”.

Base Registers

There are two base registers: BX, and BP. The contents of these registers can be added to the contents
of the SI and DI registers to form the “base-plus-index addressing mode”. This mode is similar to the
C++ array indexing command, array[x], where a variable is used for array indexing rather than a hard-
coded literal like array[2].

72
AX (Accumulator Register) General Purpose (efficient register)
The most often used general purpose register. There are special instructions versions of some general
instructions which are coded differently, to be more efficient, when this register is used. This register
is automatically affected when doing multiplication and division and for certain adjustment
instructions. This register is also used by many programming languages to hold the return value from
a function. You may use all 16 bits of this register at once, or may independently use one or both of
the two bytes that make up this register. Note that if an operation uses the AL register, the results of
the operation will NOT affect the AH register and vice versa.

BX (Base Index Register) General Purpose / Base Index


Used as a general purpose register. This register can also be used as a pointer for memory addressing.
This is referred to as “Register Indirect” addressing, or just simply “indirect” addressing. A constant
number can be added to this pointer and is referred to as “Register Relative” addressing. When used
as a pointer, it is assumed to reference data in the data segment.

CX (Counter Register) General Purpose


Used as a general purpose register. This register also acts as a counter variable in many looping
instructions. The shift and rotate instructions use CL as a counter variable.

DX (Data Register) General Purpose


Used as a general purpose register. This register is automatically affected when doing multiplication
and division.

SI (Source Index Register) Index


Can be used as a general purpose register but normally isn’t. This register is used to hold the starting
address for a string when executing most string instructions. For example, if you wanted to copy a
string of data from one memory location to another, this register holds the address of the string you are
copying. Since this operation requires indirect memory addressing, this register is also an index
register. Its contents can also be added to BX or BP when doing indirect addressing. This is called the
“base-plus-index” addressing mode. You can also add a literal in the base-plus-index mode to form
the “base relative-plus-index” addressing mode. When used as a pointer, it is assumed to reference
data in the data segment.

DI (Destination Index Register) Index


Can be used as a general purpose register but normally isn’t. This register is used to hold the
destination address for a string when executing most string instructions. For example, if you wanted to
copy a string of data from one memory location to another, this register holds the memory address to
where you are copying. This register is an index register. Its contents can also be added to BX or BP
when doing indirect addressing. When used as a pointer, it is assumed to reference data in the data
segment except in some string instructions which assume the extra segment.

73
SP (Stack Pointer Register) Special Purpose
Can be used as a general purpose register but SHOULD NOT be! This register is used to keep track of
how much memory has been used in a portion of memory called the stack. The stack is used to keep
track procedure return addresses, procedure parameters and local variables. It generally starts by
holding the highest (last) address in the segment. As data is added to the stack, SP decreases so that it
always points to the last data item added. As data is removed from the stack, SP increases.

BP (Base Pointer / Stack Frame Register) Base Index


Can be used as a general purpose register but SHOULD NOT be! This register is used to hold an
address in the stack frame for the current procedure. This address is usually one in the middle of the
stack frame. A stack frame is all of the data (parameters, local variables, return address) that is used by
an executing procedure. Since the SP changes rapidly, even during a procedure’s execution, the BP
provides a more stable pointer that can be used to reference variables and parameters. Since it is
normally used as a pointer for memory reference (indirect addressing), it is also an index register.
When used as a pointer, it is assumed to reference data in the stack segment. When combined with SI
or DI for “base-plus-index” or “base relative-plus-index” addressing, the calculated address still
references the stack segment.

CS (Code Segment Register) Special Purpose


This register is used to hold the starting address of the segment of memory containing your machine
language instructions. This register’s value is loaded automatically by DOS and there are no
instructions which allow you to directly change its value. Your program can change the value of this
register indirectly by jumping to an instruction that is outside of the current 64K code segment. This is
referred to as a far jump or a far procedure call. The value of IP is combined with the value of CS to
calculate the address of the next instruction.

DS (Data Segment Register) Special Purpose


This register is used to hold the starting address of the segment of memory containing the global data
that your program needs. DOS reserves space for your global data (and loads their values if they have
been initialized) at the same time it loads your program into memory. It does not, however, load DS
with the correct value; your program must do this and will generally do so by loading DS with the first
paragraph boundary address after the end of your program code. Most instructions that reference
memory automatically assume the data comes from the data segment. Note: the amount of space that
is reserved is specifically requested by your program through variables that you declare and commands
that you type.

ES (Extra Segment Register) Special Purpose


This register is used to hold the starting address of the segment of memory containing the extra global
data that your program needs. DOS reserves space for variables in this area at the same time it loads
your program into memory. Your program must load ES with the correct value if you are using this
segment. Most instructions default to using the data segment, so when you need data from the extra
segment, you have to specifically state so. Some string instructions use ES by default for the
destination segment.

74
SS (Stack Segment Register) Special Purpose
This register is used to hold the starting (lowest numbered) address of the segment of memory with
space reserved for local variables and parameters needed by the functions in your program. DOS
reserves the amount of space that you specify at the same time it loads your program into memory.
Your program must load SS with the correct value if you are using this segment. Your program must
also load SP with the address of the memory cell at the end of your reserved block of segment
memory. For example, if SS starts at address 5 and you reserve 10 bytes, then SP is loaded with the
address 14 because you reserved 10 bytes of memory starting at address 5 and so address 14 is the last
reserved block. There are specific instructions designed to use the stack segment. General instructions
only use the stack segment when going through the BP register, so if you need stack data otherwise,
you have to specifically state so.

IP (Instruction Pointer Register) Special Purpose


This register is only used for one purpose – to hold the offset address of the next instruction that your
program must execute. This register’s value is loaded automatically by DOS and there are no
instructions which allow you to directly change or even read its value. Your program can change the
value of this register indirectly by jumping to an instruction other than the one that would normally
follow the current one. You can jump to an address inside the current segment with a short or near
jump or you can change the value of CS at the same time you change IP’s value through a far jump
which allows you to go to a different segment. After an instruction is fetched, IP is automatically
incremented by some number of bytes so that it is holding the address of the first byte after the last one
fetched.

FLAGS Special Purpose


This very special register is used to store certain information about the results of comparisons and
arithmetic/logic operations. It is very special in that it is not normally treated as a whole register, but
its individual bits are considered instead. When an arithmetic operation is performed, it will change
the value of one or more bits in this register. There are certain instructions which allow you to change
individual FLAGS bits, but they are normally changed indirectly through the use of various basic
instructions. You will normally test the values of the individual bits in FLAGS through the use of
certain jump operations. The flag bits have their own names and are as follows:

Bit Flag Name Purpose Set Clear


# Symbol Symbol
11 O Overflow Signed number arithmetic has produced an incorrect value OV NV
10 D Direction Determines if SI/DI count up or down in string operations DN UP
9 I Interrupt Enables or disables hardware interrupts EI DI
8 T Trap Allows program to execute line by line for debugging not visible in debug
7 S Sign Indicates negative or positive arithmetic answer NG PL
6 Z Zero Indicates zero or non-zero arithmetic answer ZR NZ
4 A Auxiliary Carry Indicates carry/borrow after BCD addition/subtraction AC NA
2 P Parity Even parity or odd parity PE PO
0 C Carry Indicates carry/borrow after normal addition/subtraction; CY NC
Also indicates an error for some instructions

75

Вам также может понравиться