Chapter 3 Programming and Instruction Set - 2022
Chapter 3 Programming and Instruction Set - 2022
Lecture 2
INSTRUCTION SET
8086 Microprocessor
Instruction Set
2. Arithmetic Instructions
3. Logical Instructions
3
8086 Microprocessor
Instruction Set
ports.
Generally involve two operands
✔ Source operand and
✔ Destination operand of the same size.
Source: Register or a memory location or an
immediate data
Destination : Register or a memory location.
The size should be a either a byte or a word.
A 8-bit data can only be moved to 8-bit register/
memory and
A 16-bit data can be moved to 16-bit register/ memory.
4
8086 Microprocessor
Instruction Set
Examples
✔ MOV
1. Data Transfer Instructions
5
8086 Microprocessor
Instruction Set
;(reg2) ← (reg1)
6
8086 Microprocessor
Instruction Set
✔
1. Data Transfer Instructions
(reg1)
(reg1)
7
8086 Microprocessor
Instruction Set
MA S = (SS) x 16 10 + SP
(MA S ; MA S + 1) ← (reg16)
IN A, [DX]
1. Data Transfer Instructions
IN A, addr8
IN AL, addr8 (AL) ← (addr8)
9
8086 Microprocessor
Instruction Set
OUT [DX], A
1. Data Transfer Instructions
OUT addr8, A
Examples
✔ ADD Addition
✔ ADC Addition with carry
2. Arithmetic Instructions
✔ SUB Subtraction
✔ SBB Subtraction with borrow
✔ INC Increment
✔ DEC Decrement
✔ MUL Multiplication
✔ DIV Division
✔ CMP Compare
11
8086 Microprocessor
Instruction Set
ADD A, data
✔ ADD AL, data8 (AL) ← (AL) + data8
12
8086 Microprocessor
Instruction Set
(mem)+CF
(mem)+(reg1)+CF
ADC A, data 13
8086 Microprocessor
Instruction Set
SUB A, data
✔ SUB AL, data8 (AL) ← (AL) - data8
SBB A, data
✔ SBB AL, data8 (AL) ← (AL) - data8 - CF
16
8086 Microprocessor Instruction Set
DIV reg
2. Arithmetic Instructions
DIV mem
For 16-bit :- 8-bit :
(AL) ← (AX) :- (mem8) Quotient
(AH) ← (AX) MOD(mem8) Remainder
For 32-bit :- 16-bit :
(AX) ← (DX)(AX) :- (mem16) Quotient
(DX) ← (DX)(AX) MOD(mem16) Remainder
18
8086 Microprocessor Instruction Set
IDIV mem
For 16-bit :- 8-bit :
(AL) ← (AX) :- (mem8) Quotient
(AH) ← (AX) MOD(mem8) Remainder
For 32-bit :- 16-bit :
(AX) ← (DX)(AX) :- (mem16) Quotient
(DX) ← (DX)(AX) MOD(mem16) Remainder
19
8086 Microprocessor Instruction Set
20
8086 Microprocessor Instruction Set
21
8086 Microprocessor Instruction Set
22
8086 Microprocessor Instruction Set
CMP A, data
23
8086 Microprocessor Instruction Set
AND A , data
AND AL, data8 ; (AL) (AL) & data8
AND AX, data16 ; (AX) (AX) & data8
3. Logical Instructions
OR A, data
OR AL, data8 ; (AL) (AL)|(data8)
OR AX, data16 ;(AX) (AX)|(data16)
3. Logical Instructions
OR reg/mem, data
OR reg, data ; (reg) (reg)|(data)
OR mem, data ;(mem) (mem)|(data)
OR reg2/mem, reg1/mem
OR reg2, reg1 ; (reg2) (reg2)|(reg1)
OR reg2, mem ; (reg2) (reg2)|(mem)
OR mem, Reg1 ;(mem) (mem)|(reg1)
25
8086 Microprocessor Instruction Set
TEST A, data
TEST AL, data8 ;Modify flags (AL)&(data8)
SHR reg
SHR reg, 1 ; Shift to the right only once
SHR reg, CL
SHR mem
SHR mem, 1
SHR mem, CL
27
8086 Microprocessor Instruction Set
SHL reg
SHL reg, 1
SHL reg, CL
SHL mem
SHL mem, 1
SHL mem, CL
28
8086 Microprocessor Instruction Set
B7 B6 B5 B4 B3 B2 B1 B0 CF
RCR reg
RCR reg, 1
RCR reg, CL
RCR mem
RCR mem, 1
RCR mem, CL
29
8086 Microprocessor Instruction Set
CF B7 B6 B5 B4 B3 B2 B1 B0
RCL reg
RCL reg, 1
RCL reg, CL
RCL mem
RCL mem, 1
RCL mem, CL
30
8086 Microprocessor Instruction Set
Reading assignment
instructions
32
8086 Microprocessor Instruction Set
33
8086 Microprocessor Instruction Set
REP Repeat
4. String Manipulation Instructions
34
8086 Microprocessor Instruction Set
;(MA D) ← (MAs)
35
8086 Microprocessor Instruction Set
CMPSB
CMPSW ;MAs = (DS) x 1610 + (SI)
;MA D = (ES) x 1610 + (DI)
36
8086 Microprocessor Instruction Set
LODSW
MA = (DS) x 1610 + (SI)
(AX) ← (MA ; MA + 1)
38
8086 Microprocessor Instruction Set
STOSB
MAE = (ES) x 1610 + (DI)
(MAE) ← (AL)
STOSW
MAE = (ES) x 1610 + (DI)
(MAE ; MAE + 1 ) ← (AX)
39
8086 Microprocessor Instruction Set
Mnemonics Explanation
5. Processor Control Instructions
STC Set CF ← 1
CLC Clear CF ← 0
40
8086 Microprocessor Instruction Set
Mnemonics Explanation
5. Processor Control Instructions
NOP No operation
HLT Halt after interrupt is set
1. Unconditional transfers
Mnemonics Explanation
CALL reg/mem/disp16 Call subroutine
RET Return from subroutine
JMP reg/ mem/ disp8/ disp16 Unconditional jump
42
8086 Microprocessor Instruction Set
43
8086 Microprocessor Instruction Set
name name
JE disp8 JZ disp8 JE disp8 JZ disp8
Jump if Jump if Jump if Jump if
equal result is 0 equal result is 0
44
8086 Microprocessor Instruction Set
name name
JGE disp8 JNL disp8 JAE disp8 JNB disp8
Jump if Jump if not Jump if Jump if not
greater than less above or below
or equal equal
45
8086 Microprocessor Instruction Set
Mnemonics Explanation
JC disp8 Jump if CF = 1
JNC disp8 Jump if CF = 0
JP disp8 Jump if PF = 1
JNP disp8 Jump if PF = 0
JO disp8 Jump if OF = 1
JNO disp8 Jump if OF = 0
JS disp8 Jump if SF = 1
JNS disp8 Jump if SF = 0
JZ disp8 Jump if result is zero, i.e, Z = 1
JNZ disp8 Jump if result is not zero, i.e, Z = 0
46