Você está na página 1de 4

care4you http://www.care4you.in/Tutorials/8086mp/l9-instruction-set.

html

Login as:- Administrator or Faculty or Guest

Help | Contact Us

Tutorial Contribute Feedback Signup Search

Lecture-9
Previous Main menu Next

Instruction Set of 8086


The first generation of computer language was the machine language in
which to get an operation from the microprocessor it was to be instructed
by supplying a sequence of zeros(0) and ones (1), but remembering the
binary code for different operations was cumbersome. So some symbolic
names called 'mnemonic' were developed which are easy to remember by
the programmer. These mnemonics are called the instructions of the
microprocessor. The set of different mnemonics used for programming the
microprocessor are called the instruction set, and the language using the
mnemonics is called assembly language. The instruction set of the 8086
fall under the following groups according to their functionality.
1. Data Transfer Instructions
2. Arithmetic Instructions
3. Logical Instructions/ Bit Manipulation Instruction
4. Program Execution Transfer Instructions
5. String Instructions
6. Processor Control Instructions
Data Transfer Instructions
1. MOV instruction
The data transfer instructions transfer the data from one operand to
another. The source operand in many cases remain unchanged, the
operand could be a literal, a register, or even an i/o port, as the case may
be. The different instructions in this group are: MOV, XCHG, XLAT, LEA,
LDS, LES, PUSH, POP, IN and OUT.
a. MOV : Move byte or word to register or memory location. The source can
be a register, memory location or an immediate number, the destination
can be a register or memory location. But bot the source and destination
cannot be memory locations. The general usage of the MOV instruction is
shown in table.
Instruction Format Examples Comments

MOV MOV dest., src MOV CX, 023Bh Initialize CX with immediate
MOV AX, BX number
MOV AX, [SI][BX] Transfers the content of BX
MOV BX, array into AX

The following figure give an example of exchanging the contents of two


operands. The assembly code is also written on RHS in the figure.

© Care4you.in | All rights Reserved Home | About Us | Contribite | Feedback | Contact Us

1 of 4 1/11/2018, 10:23 AM
care4you http://www.care4you.in/Tutorials/8086mp/l9-instruction-set.html

Figure : Example of exchange of value of two operand using MOV


instruction
b. XCHG instruction
XCHG instruction exchanges two operands that are of same type i.e. byte
type or word type. This instruction cannot exchange directly two memory
locations, and also operands cannot be segment registers.

Format Examples Comments


Instruction
XCHG XCHG dest., XCHG DX, AX Exchanges the content of AX
src XCHG AL,BL and DX
Exchanges the content of BL
and AL

c. XLAT instruction: This instruction is used to translate the byte in AL


using a table in memory. i.e. it replaces the content of AL with the content
from the top of the lookup table.
d. LEA: This instruction is used to load the effective address in the register
specified in the instruction. The general format and usage of this
instruction is given below:

Instruction Format Examples Comments

LEA LEA dest., LEA SI, ARRAY Load the 16 bit offset of array in
src LEA BX, reg. SI
MyName Loads 16 bit offset of MyName in
reg. SI
This instruction is equivalent to
the instruction:
MOV SI, offset ARRAY
or
MOV BX, offset MyName

e. LDS / LES: These two instructions are used to load the Data
Segment(DS) or the Extra Segment (ES) registers and the register
specified in the instruction from memory.

Instruction Format Examples Comments

LDS LDS dest., LDS SI, ARRAY Loads DS and SI from locations
src starting from offset ARRAY:
© Care4you.in | All rights Reserved Home | About Us | Contribite | Feedback | Contact Us
ARRAY+1 and then loads DS
from offset ARRAY+2 and

2 of 4 1/11/2018, 10:23 AM
care4you http://www.care4you.in/Tutorials/8086mp/l9-instruction-set.html

LES LES dest., LES BX, ARRAY+3


src MyName
Loads ES and BX from locations
starting from offset MyName:
Load SI from offset MyName and
MyName +1 and then loads DS
from offset MyName +2 and
MyName +3

Stack Operation Instructions in 8086:


It is called a stack, because you "stack" things on it. The philosophy is that
you retrieve (pop) things in the opposite order of storing (push) them.
Items are placed on the stack using the PUSH instruction and removed
from the stack using the POP instruction. When an item is pushed onto the
stack, the processor decrements the SP register, then writes the item at the
new top of stack. When an item is popped off the stack, the processor reads
the item from the top of stack, then increments the SP register. In this
manner, the stack grows down in memory (towards lesser addresses)
when items are pushed on the stack and shrinks up (towards greater
addresses) when the items are popped from the stack.
In the 8086/8088, the stack pointer is SS:SP, which is a 16 bit pointer into
a 20 bit address space. It, at any point of time, points to the last item
pushed on the stack. If the stack is empty, it points to the highest address
of the stack plus one.
a. PUSH and POP instruction: These instructions are used to copy a word
on top of the stack or remove the word from top of the stack in the register
specified. The following table gives an example of the PUSH and the POP
operation. The operand in both (PUSH and POP) instructions can be a
general purpose register, segment register(except CS) or a memory
location.

Instruction Format Examples Comments

PUSH PUSH PUSH BX Copies the BH at SP-1 and BL at


operand SP-2. Thus after the complete
execution of PUSH instruction
SP is decremented by 2, this new
value (SP-2) is the new top of
POP POP CX
stack.
POP operand
Copies byte from the top of stack
in CL and sets SP to SP+1, copies
the byte from this location to CH
and sets the SP to SP+1. Thus
after the complete execution of
POP instruction SP is increments
by 2, this new value (SP+2) is the
new top of stack.

© Care4you.in | All rights Reserved Home | About Us | Contribite | Feedback | Contact Us

3 of 4 1/11/2018, 10:23 AM
care4you http://www.care4you.in/Tutorials/8086mp/l9-instruction-set.html

Figure (a) shows the stack before any operation. Here SP contains FFFFH
which is the top of the stack. The first PUSH AX instruction decrements
the pointer by two, at SP-1 it copies the AH register(High Byte) and the SP
is further decremented by one, now SP is at SP-2, the low byte (AL
content) is copied at this address. Now top of stack is at SP-2 i.e. at
3FFFDH as shown in figure (b).
Similarly the second instruction PUSH CX, decrements the SP by 2, i.e. at
SP-1 (3FFFC) it copies the CH register and at SP-2 (3FFFB) copies the CL
register and now top of the stack is 3FFFBH.
The POP instruction first reads the word from the stack starting at top of
stack and the increments the SP by two. The instruction first fetches the
byte from top of stack(where SP is currently pointing) and sets SP to SP+1,
then fetches the second byte from this address and increments SP further
by 1. Thus net effect is POP fetches a word from top of stack and
increments the SP by 2.
b. LAHF: loads the AH register with the low byte of the Flag. The
instruction does not require any operand.
c. SAHF: Stores the AH register content to the low byte of the flag register.
As it copies into the low byte of flag register the five flags are affected.
d. PUSHF: This instruction copies the flag register to top of stack.
e. POPF: This instruction copies the top of flag into the flag register, thus
this instruction affects all the flags.

© Care4you.in | All rights Reserved Home | About Us | Contribite | Feedback | Contact Us

4 of 4 1/11/2018, 10:23 AM

Você também pode gostar