Sunteți pe pagina 1din 8

Republic of Iraq

Ministry of Higher Education


and Scientific Research
University of Technology
Control and Systems Engineering
Department

Assignment Name

The Programming The 8086 Microprocessor

Microprocessor Techniques :‫اسم المادة‬

Yamama A. Shafeek & Noor Ayad :‫اسم التدريسي‬

‫ علي نوري ذاكر‬:‫اسم الطالب‬

‫ سيطرة‬:‫الفرع‬

‫ الثالثة‬:‫المرحلة‬

)‫ ( صباحية‬:‫نوع الدراسة‬

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:

i-The MOV instruction: The function of MOV instruction is to transfer a byte or


word of data from a source location to a destination location. The general form of
MOV instruction is as shown below:

Mnemonic meaning Format Operation Flags affected


MOV move MOV D,S (S) (D) None

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:

Mnemonic Meaning Format Operation Flags Operand (S


or D)
PUSH PUSH word PUSH S ((SP)) (S) None Register
onto stack Seg reg (CS
(SP) (SP)-2 illegal
Memory
Flag register
POP POP word POP D (D) ((SP)) None
onto stack
(SP) (SP)-2
2
iii-LEA, LDS, and LES(load – effective address) INSTRUCTIONS:
These instructions load a segment and general purpose registers with an address
directly from memory. The general forms of these instructions are as shown below:

Mnemonic Meaning Format Operation Flags


LEA Load effective LEA reg16,EA EA (reg16) None
address
LDS Load register LDS reg16,EA [PA] (reg16) None
and DS
[PA+2] (DS)
LES Load register LES reg16,EA [PA] (reg16) None
and ES
[PA+2] (ES)

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.

Destination Index (DI): is a 16-bit register. Used with the ES register in


string operations. DI is used for indexed, based indexed and register indirect
addressing, as well as a destination data address in string manipulation instructions.
In short, Destination Index and SI Source Index registers are used to hold address.

ADD AX,BX

Opcode

Destination operand source operand

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.

Classification of Addressing Modes: Data-Addressing


Modes:
This mode is related to data transfer operation, that is, data is transferred either from
the memory to internal registers of 8086 processors or from one register to another
register.
Example: MOV AX, DX
Program Memory addressing Modes:
This mode involves program memory addresses during various operations.
Example: JMP AX, in this instruction, the code execution control jumps to the
current code segment location addressed by the contents of AX register.
4
Stack memory addressing Modes:
This mode involves stack registry operations.
Example: PUSH AX, this instruction copies the contents of AX register to the stack.

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.

Direct data addressing


•Direct addressing moves a byte or word between a data segment memory location and
register.
•The instruction set does not support a memory to memory transfer except with the MOVS
instruction.
•There are two basic form of direct data addressing: (1) Direct addressing (2) Displacement
addressing
Direct addressing:
•Direct addressing with a MOV instruction transfers data between a memory location, located
within the data segment, and the AL (8-bit) or, AX (16-bit).
•A MOV instruction using this type of addressing is usually a three byte long instruction.

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.

Register Indirect addressing


•Register addressing transfers a byte or word between a register and memory location
addressed by an index or base register.
•The index and base registers are BP, BX, DI and SI. These registers hold the offset address of
the memory location.
•The data segment is used by default with register indirect addressing or any other addressing
modes that uses BX, DI or, SI to address memory.
•If BP register addresses memory, the stack segment is used by default.
•The [ ] symbol denote indirect addressing in assembly language.

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.

Base Relative plus Index addressing


•Base relative plus index addressing transfers a byte or word between a register and a memory
location addressed by a base and an index register plus displacement.
•It is similar to base plus index addressing, but it adds a displacement beside using a base
register and an index register.
•This type of addressing mode often addresses a two-dimensional array of memory data.

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

2- Program to perform multiword subtraction by adding the 2’S complement of the


subtract and to the minued
Sol: 5574 60FF
132F F100
MOV AX,F100
MOV BX,132F
NOT AX BX AX

NOT BX 0000 0001

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:

MOV CX, 0000


MOV AX, [3000]
MOV BX, [3002]
SUB AX, BX
INC CX
MOV [3004], AX
MOV [3006], CX

S-ar putea să vă placă și