The Programming The 8086 Microprocessor
The Programming The 8086 Microprocessor
The Programming The 8086 Microprocessor
Assignment Name
سيطرة:الفرع
الثالثة:المرحلة
) ( صباحية:نوع الدراسة
1
The instruction of 8086 Processor:
1. Data Transfer Instructions: The Data Transfer Instructions are those,
which transfers the DATA from any one source to any one destination. The data’s
may be of any type. They are again classified into four groups as table 1:
From table 1-(a) , we see that data can be moved between general purpose registers,
between a general purpose – register and a segment register, between a general
purpose-register or segment register and memory, or between a memory location and
the accumulator. Note that memory-to-memory transfers are not allowed.
ii-PUSH / POP Instruction: The PUSH and POP instructions are important
instructions that are store and retrieve data from the LIFO (Last In First Out) stack
memory. The general forms of PUSH and POP instructions are as shown below:
The LEA instruction is used to load a specified register with a 16 – bit effective
address(EA).
The LDS instruction is used to load a specified register with the contents of PA and
PA+1 memory locations, and load DS with the contents of PA+2 and PA+3 memory
locations.
The LES instruction is used to load a specified register with the contents of PA and
PA+1 memory locations, and load LES with the contents of PA+2 and PA+3 memory
locations.
iv- IN & OUT instructions: The IN instruction will copy data from a port to the
accumulator. If 8 bit is read the data will go to AL and if 16 bit then to AX. Similarly
OUT instruction is used to copy data from accumulator to an output port. Both IN
and OUT instructions can be done using direct and indirect addressing modes.
2. Arithmetic Instructions:
These instructions are those which are useful to perform Arithmetic calculations,
such as addition, subtraction, multiplication and division. They are again classified
into four groups. They are:
3
General Format:
ADD Destination, Source , SUB Destination, Source , MUL OP , Div op and the list
goes on.
Source Index (SI): is a 16-bit register. SI is used foe indexed, based indexed
and register indirect addressing. As well as source data address in string manipulation
instructions. Used in conjunction with DS register to point to data locations in the
data segment.
ADD AX,BX
Opcode
Addressing Modes:
•Addressing mode provide different ways for access an address to given data to a
processor.
•When 8086 executes an instruction, it performs the specified function on data.
Operated data is stored in the memory location. There are various techniques to
specify address of data. These techniques are called Addressing Modes.
Register addressing
•Register addressing transfers a copy of a byte or word from the source register to destination
register. Register addressing is the most common form of data addressing and once the register
names are learned, is the easiest to apply.
•8-bit register names with register addressing: AH, AL, BH, BL, CH, CL, DH, DL.
•16-bit register names: AX, BX, CX, DX, SP, BP, SI ,DI, IP, CS, SS, DS and ES.
•Never mix an 8-bit register with 16-bit, it is not allowed in microprocessor.
•Code segment register (CS) is never used as destination.
•Segment to segment MOV instruction is not allowed.
Immediate addressing
•Immediate addressing transfers the source, an immediate byte or word data, into the
destination register.
5
•Immediate data means constant data, whereas data transferred from a register or memory
location are variable data.
Displacement addressing:
•Direct addressing with a MOV instruction transfers data between a memory location, located
within the data segment, and registers other than AL or AX.
•It is almost identical to direct addressing except that the instruction is four byte wide instead
of three.
Base-Plus-Index addressing
•Base-plus-index addressing transfer a byte or word between a register and a memory location
addressed by a base register (BP or BX) plus an index register (DI or SI).
•The base register often holds the beginning location of a memory array, whereas the index
register holds the relative position of an element in the array.
•When BP addresses memory, stack segment is selected by default and when BX addresses
memory data segment is selected by default.
6
Register Relative addressing
•Register relative addressing moves a byte or word between a register and the memory
location addressed by an index or base register (BP, BX, DI or SI) plus a displacement.
•Remember that BX, DI or SI addresses data segment and BP addresses the stack segment.
The programs
1- Program to add 3byte of data stored at 4000:0600 use Bx as a pointer for memory
location subsitude the given value ?
Sol:
MOV AX,4000
MOV DS,AX
MOV BX,0600
MOV AL,[BX]
INC BX
ADD AL,[BX]
INC BX
ADD AL,[BX]
INT A5
ADD AX,0001
ADC BX,0000
ADD AX,60FF
ADC BX,132F
7
3- program to subtract two 16-bit numbers where the numbers are at 3000 and 3002
memory address and store result into 3004 and 3006 memory address.
Sol: