Professional Documents
Culture Documents
Instruction Set Architecture
Instruction Set Architecture
2
Instruction Format
Format of a typical microprocessor instruction
Op-code Operands
4
Classes of 8086 instruction set
1. Data movement
– MOV,PUSH,POP
2. Conversion
– CBW,CWD
3. Arithmetic
– ADD,SUB,MUL,DIV,CMP
4. Logical,shift,rotate and bit instructions
– AND,OR,SHL,SHR,RCL,RCR
5. Input/output instructions
– IN,OUT
6. String instructions
– MOVS ,STOS,LODS
7. Program flow control
– JMP,CALL,RET,Conditional JUMP
8. Miscellaneous 5
Addressing modes of 8086
• Addressing mode refers to valid form of the operand or
operands of an instruction.
6
Register Addressing mode
• For an instruction if all the operands are internal registers of
8086 microprocessor then it is in register addressing mode.
E.g.
ADD AX,BX
MOV AX,BX
INC AX
• Not all register conditions are valid addressing mode.
There are some conditions.
• Conditions
1. The size of the operands should match.
Byte registers AL,BL,CL,DL,AH,BH,….(8
bits)
Word registers AX,BX,CX,DX….(16 bits)
7
Register Addressing mode…
ADD AL,BL Valid
ADD AX,BL Invalid
ADD AX,BX Valid
ADD AL,BX Invalid
MOV AX,CS
MOV DS,AX
8
Immediate Addressing mode
MOV AX,100
• Source is a constant value. It is a part of this instruction. Not
stored in a register or memory location. So operand is called as
an immediate operand.
MOV AL,300
Invalid
MOV AX,300
Valid
a db 100
a dw 1000
a dd 100000
11
Memory Addressing mode
• If a memory location is used for an operand then it is in memory
addressing mode.
12
Memory Addressing mode…
1. Direct memory addressing mode
one operand is refers to a memory location directly and
other operand refers to a register
MOV AL,a
ADD AL,a
SUB AL,a
a dd 169772160
0A
Highest addressed word
1E
84
a Lowest addressed word
80
(refers to the 1st
byte)
14
Memory Addressing mode…
MOV AL,a AL=80H(AL store only the lowest
byte of a)
• Registers used
BX
SI with data segment
DI
BP - with stack segment
16
Memory Addressing mode…
Examples
1. a db 100
MOV BX,OFFSET a
MOV AL,[BX]
AL=100
a 100 1 byte
offset
DS
INC BX 3
LOOP NEXT 2
ARR
1
Offset
DS
18
Memory Addressing mode…
3. Base memory addressing mode
This is similar to register indirect memory addressing
mode, except that the displacement can be added to the
register value, forming the offset to be used as the memory
address.
e.g. 4
MOV BX,OFFSET ARR 3
Displacement
MOV AL,[BX+3] 2
ARR
1
AL=4 Offset
DS
19
Memory Addressing mode…
The displacement can be specified
MOV AX,[reg+disp]
MOV AX,[reg][disp]
MOV AX,disp[reg]
MOV AX,[reg]+disp
Example
ARR db 1,2,3,4,5
MOV BX,OFFSET ARR
MOV AL,[BX+2]
MOV AL,[BX][2]
MOV AL,2[BX]
MOV AL,[BX]+2
20
Memory Addressing mode…
4. Index memory addressing mode
Index addressing works in a similar manner to base
addressing except the displacement is placed in a register and
the offset of the data structure specified in the name itself.
MOV AL,ARR[SI+1] DS
21
Memory Addressing mode…
Calculate the sum of two byte arrays
ARR1 db 1,2,3,4,5
ARR2 db 2,4,6,8,10
MOV SI,0
MOV CX,5
NEXT:MOV AL,ARR1[SI]
ADD ARR2[SI],AL
INC SI
LOOP NEXT
22
Memory Addressing mode…
5. Base Index memory addressing mode
This addressing mode is a combination of both base and
index addressing modes.
MOV AL,[BX+SI]
MOV AL,[BX][SI]
MOV AL,[BX]+[SI]
MOV AL,[SI][BX]
24
Stack Segment
The stack segment is a special area of memory designed for quick
temporary storage of program data and the subroutine return
addresses. SP
Register
It is a LIFO (Last In First Out) memory.
BP
Register
SS
Register
SP Register – Points to the top of the stack. Contains the offset of
next memory location to be access in the stack segment.
SS Register – Points to the base of the stack.
BP Register – Contains the offset from the base any other memory
location in stack segment. 25
PUSH and POP instructions
In Assembly programming data is push on to the stack by the
PUSH instruction and data is pop out from the stack by POP
instruction.
Operands must be 16 bit registers.
26
PUSH and POP instructions…
AH AL
Example –
MOV AX, 100 00 64
AH comes first
PUSH AX AH AL
AH
SP Register AL
AL comes first
SP Register AH AL
POP AX AH
AL
27
PUSH and POP instructions…
In Assembly programming we should allocate memory space to
stack segment.
db 100 dup(?) ; Allocate 100 bytes for the stack segment
Example
MOV AX, 100
PUSH AX
MOV BX, 200
PUSH BX
MOV CX, 300
PUSH CX
POP CX
POP BX
AH
MOV BX, 200 AL BH BL
PUSH BX BH
SP Register BL
29
PUSH and POP instructions…
AH
MOV CX, 300 AL
PUSH CX BH
BL CH CL
CH
SP Register CL
POP CX AH
AL CH CL
BH
SP Register BL
30
PUSH and POP instructions…
BH BL
POP BX
AH
SP Register AL
31
Use of stack segment
• Can use as a stack data structure
32
Use of stack segment…
In Assembly language program, before ‘INT21H’ instruction we have
different values in registers (SS, CS, DS and AX).
When we execute ‘INT21H’ instruction what will happen is, it delete all
the contents in these registers and use them to perform operations
within the ‘INT21H’.