Microprocessor & Microcontroller (Module - 1)
Mr. Kaushik Neogi
DEPT. OF EE, ASANSOL ENGINEERING COLLEGE
Paper Code: PC-EE-602
Lecture 7
Contents: 2
8086 Instruction Set
References
Instruction Set of 8086:
(2). Arithmetic instructions.: 3
• These instructions perform the operations like:
• Addition,
• Subtraction,
• Increment,
• Decrement.
Instruction Set of 8086:
(2). Arithmetic instructions.: 4
• (1). ADD destination, source;
• This instruction adds the contents of source operand with the contents
of destination operand.
• The source may be immediate data, memory location or register.
• The destination may be memory location or register.
• The result is stored in destination operand.
• AX is the default destination register.
• E.g. (1). ADD AX, 2020H;
• (2). ADD AX, BX;
Instruction Set of 8086:
5
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 10 ADD AX,2020H AH 30 AL 30
1010
+2020
3030
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 10 AH 30 AL 30
BH 20 BL 20
ADD AX, BX BH 20 BL 20
Instruction Set of 8086:
(2). Arithmetic instructions.: 6
• (2). ADC destination, source
• This instruction adds the contents of source operand with the contents
of destination operand with carry flag bit.
• The source may be immediate data, memory location or register.
• The destination may be memory location or register.
• The result is stored in destination operand.
• AX is the default destination register.
• E.g. (1). ADC AX, 2020H;
• (2). ADC AX, BX;
Instruction Set of 8086:
7
BEFORE EXECUTION AFTER EXECUTION
ADC AX, 2020H
CY 1
AH 10 AL 10 AH 30 AL 31
1010
+2020
3030+1=3031
BEFORE EXECUTION AFTER EXECUTION
CY 1
AH 10 AL 10 AH 30 AL 31
BH 20 BL 20
ADC AX, BX BH 20 BL 20
Instruction Set of 8086:
(2). Arithmetic instructions.: 8
• (3). INC source
• This instruction increases the contents of source operand by 1.
• The source may be memory location or register.
• The source can not be immediate data.
• The result is stored in the same place.
• E.g. (1). INC AX;
• (2). INC [5000H];
Instruction Set of 8086:
9
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 10 INC AX AH 10 AL 11
BEFORE EXECUTION AFTER EXECUTION
5000H 1010 INC [5000H] 5000H 1011
Instruction Set of 8086:
(2). Arithmetic instructions.: 10
• (4). DEC source;
• This instruction decreases the contents of source operand by 1.
• The source may be memory location or register.
• The source can not be immediate data.
• The result is stored in the same place.
• E.g. (1). DEC AX;
• (2). DEC [5000H];
Instruction Set of 8086:
11
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 10 DEC AX AH 10 AL 0F
BEFORE EXECUTION AFTER EXECUTION
5000H 1010 DEC [5000H] 5000H 100F
Instruction Set of 8086:
(2). Arithmetic instructions.: 12
• (5). SUB destination, source;
• This instruction subtracts the contents of source operand from contents
of destination.
• The source may be immediate data, memory location or register.
• The destination may be memory location or register.
• The result is stored in the destination place.
• E.g. (1). SUB AX, 1000H;
• (2). SUB AX, BX;
Instruction Set of 8086:
BEFORE EXECUTION
13
AFTER EXECUTION
AH 20 AL 00 SUB AX, 1000H AH 10 AL 00
2000
-1000
=1000
BEFORE EXECUTION AFTER EXECUTION
AH 20 AL 00 AH 10 AL 00
BH 10 BL 00 SUB AX, BX BH 10 BL 00
Instruction Set of 8086:
(2). Arithmetic instructions.: 14
• (6). SBB destination, source;
• Also known as Subtract with Borrow.
• This instruction subtracts the contents of source operand & borrow
from contents of destination operand.
• The source may be immediate data, memory location or register.
• The destination may be memory location or register.
• The result is stored in the destination place.
• E.g. (1). SBB AX, 1000H;
• (2). SBB AX, BX;
Instruction Set of 8086:
15
BEFORE EXECUTION AFTER EXECUTION
SBB AX, 1000H
B 1
AH 20 AL 20 AH 10 AL 19
2020
- 1000
1020-1=1019
BEFORE EXECUTION AFTER EXECUTION
B 1
AH 20 AL 20 AH 10 AL 19
BH 10 BL 10
SBB AX, BX BH 10 BL 10
Instruction Set of 8086:
(2). Arithmetic instructions.: 16
• (7). CMP destination, source
• Also known as Compare.
• This instruction compares the contents of source operand with the
contents of destination operands.
• The source may be immediate data, memory location or register.
• The destination may be memory location or register.
• Then resulting carry & zero flag will be set or reset.
• E.g. (1). CMP AX, 1000H;
• (2). CMP AX, BX;
Instruction Set of 8086: D=S: CY=0,Z=1
BEFORE EXECUTION D>S: CY=0,Z=0
AFTER EXECUTION
17
D<S: CY=1,Z=0
AH 10 AL 00
CMP AX, BX CY 0 Z 1
BH 10 BL 00
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 00
CMP AX, BX CY 0 Z 0
BH 00 BL 10
BEFORE EXECUTION AFTER EXECUTION
AH 10 AL 00
CMP AX, BXH CY 1 Z 0
BH 20 BL 00
Instruction Set of 8086:
(2). Arithmetic instructions.: 18
• (8). AAA
• Also known as ASCII Adjust After Addition.
• This instruction is executed after ADD instruction.
• (1). IF lower bits of AL<=09 then,
• Higher bits of AL should loaded with zeroes.
• There should be no change in lower bits of AL.
• AH also must be cleared (AH=0000 0000).
• (2). IF lower bits of AL>09 then,
• Bits of AL must be incremented by 06 (i.e. AL+0110).
• Bits of AH must be incremented by 01 (i.e. AH+0001).
• Then higher bits of AL should be loaded with 0000.
• E.g. (1). AAA;
Instruction Set of 8086:
(1). FOR AL<=09H 19
AL 6 7 BEFORE EXECUTION
Hb Lb
AL 0 7 AFTER EXECUTION
Hb Lb
Hb=Higher bits,
Lb=Lower bits.
(1). FOR AL>09H
AL 6 A BEFORE EXECUTION
Hb Lb
(A)1010 +(06)0110=0001 0000
HB LB
AL 0 0 AFTER EXECUTION
Hb Lb
Instruction Set of 8086:
(2). Arithmetic instructions.: 20
• (9). AAS
• Also known as ASCII Adjust After Subtraction.
• This instruction is executed after SUB instruction.
• (1). IF lower bits of AL<=09 then,
• Higher bits of AL should loaded with zeroes.
• There should be no change in lower bits of AL.
• AH also must be cleared (AH=0000 0000).
• (2). IF lower bits of AL>09 then,
• Bits of AL must be decremented by 06 (i.e. AL-0110).
• Bits of AH must be decremented by 01 (i.e. AH-0001).
• Then higher bits of AL should be loaded with 0000.
• E.g. (1). AAS;
Instruction Set of 8086:
(1). FOR AL<=09H 21
AL 6 7 BEFORE EXECUTION
Hb Lb
AL 0 7 AFTER EXECUTION
Hb Lb
Hb=Higher bits,
Lb=Lower bits.
(1). FOR AL>09H
AL 6 A BEFORE EXECUTION
Hb Lb
(A)1010 -(06)0110=0000 0100
Hb Lb
AL 0 4 AFTER EXECUTION
Hb Lb
Instruction Set of 8086:
(2). Arithmetic instructions.: 22
• (10). AAM
• Also known as ASCII Adjust After Multiplication.
• This instruction is executed after MUL instruction.
• Then AH=AL/10 & AL=Remainder.
• E.g. MOV AL,04 // AL=04
• MOV BL,09 // BL=09
• MUL BL // 04*09=36 (i.e. BL*AL)
• AAM // AH=03 & AL=06
• E.g. (1). AAM;
Instruction Set of 8086:
(2). Arithmetic instructions.: 23
• (11). AAD;
• Also known as ASCII Adjust before Division.
• Then AL=AH*10 +AL & AH=0.
• E.g. MOV AX, 0105 // AH=01, AL=05
• AAD // AL=15 (i.e.0FH) & AH=00
• E.g. (1). AAD;
References: 24
1. Advanced Microprocessors and Peripheral, Koshor M Bhurchandi, Ajay
Kumar Ray, 3rd Edition, MC Graw hill education.
2. Microprocessor & Interfacing, D.V. Hall, Mc Graw Hill.
3. Microprocessor & Peripherals, S.P. Chowdhury & S. Chowdhury, Scitech.
4. The 8086 Microprocessors: Programming & Interfacing the PC, K.J.Ayala,
Thomson.