SlideShare a Scribd company logo
Chapter 03
1
Instruction Set of 8086
An instruction is a binary pattern designed
inside a microprocessor to perform a specific
function.
The entire group of instructions that a
microprocessor supports is called
Instruction Set.
8086 has more than 20,000 instructions.
2
Classification of Instruction Set
1. Arithmetic Instructions and Logical Instruction
2. Data Transfer Instructions
3. Branch and Loop Instruction
4. M/C control Instruction
5. Flag Manipulation Instructions
6. Shift and Rotate Instruction
7. String Instructions
21-Nov-2010 3
ohmshankar.ece@act.edu.in
1. Arithmetic And Logical
Instructions
Arithmetic Instructions
ADD Des, Src:
It adds a byte to byte or a word to word.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
 ADD AL, 74H
 ADD DX, AX
 ADD AX, [BX]
21-Nov-2010 5
ohmshankar.ece@act.edu.in
Arithmetic Instructions
ADC Des, Src:
It adds the two operands with CF.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
 ADC AL, 74H
 ADC DX, AX
 ADC AX, [BX]
21-Nov-2010 6
ohmshankar.ece@act.edu.in
Arithmetic Instructions
SUB Des, Src:
 It subtracts a byte from byte or a word from word.
 It effects AF, CF, OF, PF, SF, ZF flags.
 For subtraction, CF acts as borrow flag.
 E.g.:
 SUB AL, 74H
 SUB DX, AX
 SUB AX, [BX]
21-Nov-2010 7
ohmshankar.ece@act.edu.in
Arithmetic Instructions
SBB Des, Src:
It subtracts the two operands and also the
borrow from the result.
It effects AF, CF, OF, PF, SF, ZF flags.
E.g.:
 SBB AL, 74H
 SBB DX, AX
 SBB AX, [BX]
21-Nov-2010 8
ohmshankar.ece@act.edu.in
Arithmetic Instructions
 MUL Src:
 It is an unsigned multiplication instruction.
 It multiplies two bytes to produce a word or two words to
produce a double word.
 AX = AL * Src
 DX : AX = AX * Src
 This instruction assumes one of the operand in AL or AX.
 Src can be a register or memory location. And Flags-OF, CF
 Unused bits of destination register is always filled with sign bit
 IMUL Src:
 It is a signed multiplication instruction.
21-Nov-2010 9
ohmshankar.ece@act.edu.in
Arithmetic Instructions
DIV Src:
It is an unsigned division instruction.
It divides word by byte or double word by word.
The operand is stored in AX, divisor is Src and
the result is stored as:
 AH = remainder, AL = quotient (for word/byte)
 DX=remainder, AX=quotient (for D-word/word)
IDIV Src:
It is a signed division instruction.
21-Nov-2010 10
ohmshankar.ece@act.edu.in
Arithmetic Instructions
 CBW (Convert Byte to Word):
 This instruction converts byte in AL to word in AX.
 The conversion is done by extending the sign bit of AL
throughout AH.
 CWD (Convert Word to Double Word):
 This instruction converts word in AX to double word in
DX : AX.
 The conversion is done by extending the sign bit of AX
throughout DX.
21-Nov-2010 11
ohmshankar.ece@act.edu.in
Arithmetic Instructions
INC Src:
It increments the byte or word by one.
The operand can be a register or memory
location.
E.g.: INC AX
INC [SI]
21-Nov-201 12
ohmshankar.ece@act.edu.in
Arithmetic Instructions
DEC Src:
It decrements the byte or word by one.
The operand can be a register or memory
location.
E.g.: DEC AX
DEC [SI]
21-Nov-2010 13
ohmshankar.ece@act.edu.in
Arithmetic Instructions
 CMP Des, Src:
 It compares two specified bytes or words.
 The Src and Des can be a constant, register or memory
location.
 Both operands cannot be a memory location at the same
time.
 The comparison is done simply by internally subtracting
the source from destination.
 The value of source and destination does not change, but
the flags CF, ZF, SF are modified to indicate the result.
21-Nov-2010 14
ohmshankar.ece@act.edu.in
Arithmetic Instructions
NEG Src:
It creates 2’s complement of a given
number.
That means, it changes the sign of a
number.
21-Nov-2010 15
ohmshankar.ece@act.edu.in
Arithmetic Instructions
 DAA (Decimal Adjust after Addition)
 It is used to make sure that the result of adding two BCD
numbers is adjusted to be a correct BCD number.
 It only works on AL register.
 For Subtraction : DAS (Decimal Adjust after
Subtraction)
21-Nov-2010 16
ohmshankar.ece@act.edu.in
Arithmetic Instructions
 AAA (ASCII Adjust after Addition):
 This Instruction Can be used to convert the contents of the
AL register to unpacked BCD result
 i.e. If lower nibble of AL>9 then
1. AL=AL+6 2. AH=AH+1
3. AL=AL AND 0FH
 This instruction does not have any operand.
 Other ASCII Instructions:
 AAS (ASCII Adjust after Subtraction)
 AAM (ASCII Adjust after Multiplication)
 AAD (ASCII Adjust Before Division)
21-Nov-2010 17
ohmshankar.ece@act.edu.in
 NOT Src:
 It complements each bit of Src to produce 1’s
complement of the specified operand.
 The operand can be a register or memory location.
 e,.g NOT AX
21-Nov-2010 18
ohmshankar.ece@act.edu.in
Logical Instructions
Logical Instructions
 AND Des, Src:
 It performs AND operation of Des and Src.
 Src can be immediate number, register or memory
location.
 Des can be register or memory location.
 Both operands cannot be memory locations at the same
time.
 CF and OF become zero after the operation.
 PF, SF and ZF are updated.
21-Nov-2010 19
ohmshankar.ece@act.edu.in
Bit Manipulation Instructions
 OR Des, Src:
 It performs OR operation of Des and Src.
 Src can be immediate number, register or memory
location.
 Des can be register or memory location.
 Both operands cannot be memory locations at the same
time.
 CF and OF become zero after the operation.
 PF, SF and ZF are updated.
21-Nov-2010 20
ohmshankar.ece@act.edu.in
Bit Manipulation Instructions
 XOR Des, Src:
 It performs XOR operation of Des and Src.
 Src can be immediate number, register or memory
location.
 Des can be register or memory location.
 Both operands cannot be memory locations at the same
time.
 CF and OF become zero after the operation.
 PF, SF and ZF are updated.
21-Nov-2010 21
ohmshankar.ece@act.edu.in
Bit Manipulation Instructions
 TEST Des, Src:
 It performs AND operation of Des and Src.
 Src can be immediate number, and src/Des can be
register or memory location.
 It is Non-Destructive And means Dest is not modified
only flags are affected.
 Both operands cannot be memory locations at the same
time.
 CF and OF become zero after the operation.
 PF, SF and ZF are updated.
21-Nov-2010 22
ohmshankar.ece@act.edu.in
2. Data Transfer Instructions
23
Data Transfer Instructions
 MOV Des, Src:
 It is used to copy the content of Src to Des
 Src operand can be register, memory location or immediate
operand.
 Des can be register or memory operand.
 Both Src and Des cannot be memory location at the same
time.
 E.g.:
 MOV CX, 037A H
 MOV AL, BL
 MOV BX, [0301 H]
24
Data Transfer Instructions
 PUSH Operand:
 It pushes the operand into top of stack.
 E.g.: PUSH BX
 POP Des:
 It pops the operand from top of stack to Des.
 Des can be a general purpose register, segment register
(except CS) or memory location.
 E.g.: POP AX
25
Data Transfer Instructions
 XCHG Des, Src:
 This instruction exchanges Src with Des.
 It cannot exchange two memory locations directly.
 E.g.: XCHG DX, AX
26
Data Transfer Instructions
 IN Accumulator, Port Address:
 It transfers the operand from specified port to accumulator
register.
 E.g.: IN AX, 0028 H
 OUT Port Address, Accumulator:
 It transfers the operand from accumulator to specified port.
 E.g.: OUT 0028 H, AX
27
Data Transfer Instructions
LEA Register, Src:
It loads a 16-bit register with the offset
address of the data specified by the Src.
E.g.: LEA BX, [DI]
This instruction loads the contents of DI
(offset) into the BX register.
28
Data Transfer Instructions
 LDS Des, Src:
 It loads 32-bit pointer from memory source to
destination register and DS.
 The word is placed in the destination register and the
segment is placed in DS.
 This instruction Copies the word at the lower memory
address to the Des reg and the word at the higher
address to the segment reg i.e. DS.
 E.g.: LDS BX, [0301 H]
29
Data Transfer Instructions
 LES Des, Src:
 It loads 32-bit pointer from memory source to
destination register and ES.
 The Word is placed in the destination register and the
segment is placed in ES.
 This instruction is very similar to LDS except that it
initializes ES instead of DS.
 E.g.: LES BX, [0301 H]
30
Data Transfer Instructions
 LAHF:
 It copies the lower byte of flag register to AH.
 SAHF:
 It copies the contents of AH to lower byte of flag register.
 PUSHF:
 Pushes flag register to top of stack.
 POPF:
 Pops the stack top to flag register.
31
3. Branch/Program Execution Transfer
Instructions
 These instructions cause change in the sequence of the
execution of instruction.
 This change can be a conditional or sometimes
unconditional.
 The conditions are represented by flags.
32
Branch Instructions
 CALL Des:
 This instruction is used to call a subroutine or function
or procedure.
 The address of next instruction after CALL is saved onto
stack.
 RET:
 It returns the control from procedure to calling program.
 Every CALL instruction should have a RET.
33
Branch Instructions
 JMP Des:
 This instruction is used for unconditional jump from
one place to another.
 Jxx Des (Conditional Jump):
 All the conditional jumps follow some conditional
statements or any instruction that affects the flag.
34
Conditional Jump Table
Mnemonic Meaning Jump Condition
JA Jump if Above CF = 0 and ZF = 0
JAE Jump if Above or Equal CF = 0
JB Jump if Below CF = 1
JBE Jump if Below or Equal CF = 1 or ZF = 1
JC Jump if Carry CF = 1
JE Jump if Equal ZF = 1
JNC Jump if Not Carry CF = 0
JNE Jump if Not Equal ZF = 0
JNZ Jump if Not Zero ZF = 0
JPE Jump if Parity Even PF = 1
35
Loop Instructions
 Loop Des:
 This is a looping instruction.
 The number of times looping is required is placed in the
CX register.
 With each iteration, the contents of CX are
decremented.
 ZF is checked whether to loop again or not.
36
Program Execution Transfer Instructions
 INTO (Interrupt on overflow):
 This instruction generates type 4 interrupt (i.e.
interrupt for overflow) and causes the 8086 to do an
indirect far call a procedure which is written by the
user to handle the overflow condition.
 IRET
 To return the execution to the interrupted program
37
4. Machine Control
Instructions
Machine Control Instructions
HLT (Halt) :- It causes the processor to enter in to the halt
state. It can be stop by INTR,NMI or RESET pin
NOP (No Opration) :- It causes the processor to enter in
to the wait state for 3 Clock cycles.
WAIT :- It causes the processor to enter in to the ideal state.
Can be stop by TEST, INTR OR NMI pin
LOCK :- This instruction prevents other processors to
take the control of shared resources. For e.g LOCK IN
AL,80H
21-Nov-2010 39
ohmshankar.ece@act.edu.in
5. Flag Manipulation
Instructions
 STC:
 It sets the carry flag to 1.
 CLC:
 It clears the carry flag to 0.
 CMC:
 It complements the carry flag.
41
Flag Manipulation Instructions
 STD:
 It sets the direction flag to 1.
 If it is set, string bytes are accessed from higher memory
address to lower memory address.
 CLD:
 It clears the direction flag to 0.
 If it is reset, the string bytes are accessed from lower
memory address to higher memory address.
42
Flag Manipulation Instructions
 STI:
 It sets the Interrupt flag to 1.
 CLI:
 It clears the Interrupt flag to 0.
21-Nov-2010 43
ohmshankar.ece@act.edu.in
Flag Manipulation Instructions
6. Shift And Rotate Instructions
 SHL/SAL Des, Count:
 It shift bits of byte or word left, by count.
 It puts zero(s) in LSBs.
 MSB is shifted into carry flag.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
45
Shift And Rotate Instructions
 SHR/SAR Des, Count:
 It shift bits of byte or word right, by count.
 It puts zero(s)(for SHL) and Sign bit (for SAL) in MSBs.
 LSB is shifted into carry flag.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
46
Shift And Rotate Instructions
 ROL Des, Count:
 It rotates bits of byte or word left, by count.
 LSB is transferred to MSB and also to CF.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
47
Shift And Rotate Instructions
 ROR Des, Count:
 It rotates bits of byte or word right, by count.
 MSB is transferred to LSB and also to CF.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
21-Nov-2010 48
ohmshankar.ece@act.edu.in
Shift And Rotate Instructions
 RCL Des, Count:
 It rotates bits of byte or word right, by count.
 LSB to MSB then MSB is transferred to CF and CF to
LSB.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
49
Shift And Rotate Instructions
 RCR Des, Count:
 It rotates bits of byte or word left, by count.
 MSB to LSB then LSB is transferred to CF and CF to
MSB.
 If the number of bits desired to be shifted is 1, then the
immediate number 1 can be written in Count.
 However, if the number of bits to be shifted is more than
1, then the count is put in CL register. And recent bit to
the CF (Carry flag)
50
Shift And Rotate Instructions
7. String Manipulation
Instructions
String Manipulation
Instructions
 String in assembly language is just a sequentially
stored bytes or words.
 There are very strong set of string instructions in 8086.
 By using these string instructions, the size of the
program is considerably reduced.
52
String Manipulation Instructions
53
8086 Microprocessor
 String : Sequence of bytes or words
 8086 instruction set includes instruction for string movement, comparison, scan, load and
store.
 REP instruction prefix : used to repeat execution of string instructions
 String instructions end with S or SB or SW. S represents string, SB string byte and
SW string word.
 Offset or effective address of the source operand is stored in SI register and that of the
destination operand is stored in DI register.
 Depending on the status of DF, SI and DI registers are automatically updated.
 DF = 0  SI and DI are incremented by 1 for byte and 2 for word.
 DF = 1  SI and DI are decremented by 1 for byte and 2 for word.
String Manipulation
Instructions
 MOVS / MOVSB / MOVSW:
 It causes moving of byte or word from one string to
another.
 In this instruction, the source string is in Data Segment
referred by DS:SI and destination string is in Extra
Segment referred by ES:DI.
 For e.g. movs str1,str2
 Movsb
 Movsw
54
String Manipulation
Instructions
 LODS / LODSB / LODSW:
 It causes TRANSFER of byte or word from one string to
another.
 In this instruction, the source string is in Data Segment
referred by DS:SI transferred to Accumulator.
 For e.g. lods string
 lodsb
 lodsw
55
String Manipulation
Instructions
 STOS / STOSB / STOSW:
It causes TRANSFER of byte or word from one string to
another.
In this instruction, the string is in Extra Segment referred by
ES:DI transferred to Accumulator.
 For e.g. stos string
 stosb
 stosw
56
String Manipulation
Instructions
 CMPS Des, Src:
 It compares the string bytes or words.
 SCAS String:
 It scans a string.
 It compares the String with byte in AL or with word in
AX.
21-Nov-2010 57
ohmshankar.ece@act.edu.in
String Manipulation
Instructions
 REP (Repeat):
 This is an instruction prefix.
 It causes the repetition of the instruction until CX
becomes zero.
 E.g.: REP MOVSB
 It copies byte by byte contents.
 REP repeats the operation MOVSB until CX becomes zero.
21-Nov-2010 58
ohmshankar.ece@act.edu.in
59
8086 Microprocessor
REP
REPZ/ REPE
(Repeat CMPS or SCAS
until ZF = 0)
REPNZ/ REPNE
(Repeat CMPS or SCAS
until ZF = 1)
While CX  0 and ZF = 1, repeat execution of
string instruction and
(CX)  (CX) – 1
While CX  0 and ZF = 0, repeat execution of
string instruction and
(CX)  (CX) - 1
String Manipulation
Instructions
60

More Related Content

PPT
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
PPT
An instruction is a binary pattern designed inside a microprocessor to perfor...
PPT
Microprocessor 8086 PPT1.4 instruction set.ppt
PPTX
Instruction set of 8086
PPT
Instruction set
PDF
Instruction set-of-8086
PDF
unit1.pdf
PPTX
Microprocessor.pptx
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
An instruction is a binary pattern designed inside a microprocessor to perfor...
Microprocessor 8086 PPT1.4 instruction set.ppt
Instruction set of 8086
Instruction set
Instruction set-of-8086
unit1.pdf
Microprocessor.pptx

Similar to Chap 3_2.ppt (20)

PPTX
Instruction Set of 8086 Microprocessor
PPT
instruction_set_8051_microcontroller.ppt
PPT
microcontroller_instruction_set for ENGINEERING STUDENTS
PPTX
Instructionsetof8086 by Alwani
DOCX
Microprocessor
PPTX
Instruction sets of 8086
PPTX
instructionsetsofjdtufgmictfgfjh8086.pptx
PDF
PDF
Lecture5(1)
PPT
instruction-set-of-8086-mr-binu-joy3.ppt
DOCX
Assembly language
PPT
8086 instruction set
PPT
Instruction set of 8051.ppt
PPT
Instruction set class
PPT
Instruction set of 8085
PDF
Intruction Set & Assembler Directives of 8086.pdf
DOCX
Instruction set of 8086 Microprocessor
PPT
8085 instruction set (detailed)
PPTX
8086 instruction set
PPT
Microcontroller instruction set
Instruction Set of 8086 Microprocessor
instruction_set_8051_microcontroller.ppt
microcontroller_instruction_set for ENGINEERING STUDENTS
Instructionsetof8086 by Alwani
Microprocessor
Instruction sets of 8086
instructionsetsofjdtufgmictfgfjh8086.pptx
Lecture5(1)
instruction-set-of-8086-mr-binu-joy3.ppt
Assembly language
8086 instruction set
Instruction set of 8051.ppt
Instruction set class
Instruction set of 8085
Intruction Set & Assembler Directives of 8086.pdf
Instruction set of 8086 Microprocessor
8085 instruction set (detailed)
8086 instruction set
Microcontroller instruction set
Ad

Recently uploaded (20)

PDF
Digital Logic Computer Design lecture notes
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
Lecture Notes Electrical Wiring System Components
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PPT
Project quality management in manufacturing
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
DOCX
573137875-Attendance-Management-System-original
PPTX
Construction Project Organization Group 2.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
composite construction of structures.pdf
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
additive manufacturing of ss316l using mig welding
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Digital Logic Computer Design lecture notes
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
bas. eng. economics group 4 presentation 1.pptx
Internet of Things (IOT) - A guide to understanding
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
CH1 Production IntroductoryConcepts.pptx
Embodied AI: Ushering in the Next Era of Intelligent Systems
Lecture Notes Electrical Wiring System Components
Arduino robotics embedded978-1-4302-3184-4.pdf
Project quality management in manufacturing
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CYBER-CRIMES AND SECURITY A guide to understanding
573137875-Attendance-Management-System-original
Construction Project Organization Group 2.pptx
Foundation to blockchain - A guide to Blockchain Tech
composite construction of structures.pdf
Lesson 3_Tessellation.pptx finite Mathematics
additive manufacturing of ss316l using mig welding
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Ad

Chap 3_2.ppt

  • 2. Instruction Set of 8086 An instruction is a binary pattern designed inside a microprocessor to perform a specific function. The entire group of instructions that a microprocessor supports is called Instruction Set. 8086 has more than 20,000 instructions. 2
  • 3. Classification of Instruction Set 1. Arithmetic Instructions and Logical Instruction 2. Data Transfer Instructions 3. Branch and Loop Instruction 4. M/C control Instruction 5. Flag Manipulation Instructions 6. Shift and Rotate Instruction 7. String Instructions 21-Nov-2010 3 ohmshankar.ece@act.edu.in
  • 4. 1. Arithmetic And Logical Instructions
  • 5. Arithmetic Instructions ADD Des, Src: It adds a byte to byte or a word to word. It effects AF, CF, OF, PF, SF, ZF flags. E.g.:  ADD AL, 74H  ADD DX, AX  ADD AX, [BX] 21-Nov-2010 5 ohmshankar.ece@act.edu.in
  • 6. Arithmetic Instructions ADC Des, Src: It adds the two operands with CF. It effects AF, CF, OF, PF, SF, ZF flags. E.g.:  ADC AL, 74H  ADC DX, AX  ADC AX, [BX] 21-Nov-2010 6 ohmshankar.ece@act.edu.in
  • 7. Arithmetic Instructions SUB Des, Src:  It subtracts a byte from byte or a word from word.  It effects AF, CF, OF, PF, SF, ZF flags.  For subtraction, CF acts as borrow flag.  E.g.:  SUB AL, 74H  SUB DX, AX  SUB AX, [BX] 21-Nov-2010 7 ohmshankar.ece@act.edu.in
  • 8. Arithmetic Instructions SBB Des, Src: It subtracts the two operands and also the borrow from the result. It effects AF, CF, OF, PF, SF, ZF flags. E.g.:  SBB AL, 74H  SBB DX, AX  SBB AX, [BX] 21-Nov-2010 8 ohmshankar.ece@act.edu.in
  • 9. Arithmetic Instructions  MUL Src:  It is an unsigned multiplication instruction.  It multiplies two bytes to produce a word or two words to produce a double word.  AX = AL * Src  DX : AX = AX * Src  This instruction assumes one of the operand in AL or AX.  Src can be a register or memory location. And Flags-OF, CF  Unused bits of destination register is always filled with sign bit  IMUL Src:  It is a signed multiplication instruction. 21-Nov-2010 9 ohmshankar.ece@act.edu.in
  • 10. Arithmetic Instructions DIV Src: It is an unsigned division instruction. It divides word by byte or double word by word. The operand is stored in AX, divisor is Src and the result is stored as:  AH = remainder, AL = quotient (for word/byte)  DX=remainder, AX=quotient (for D-word/word) IDIV Src: It is a signed division instruction. 21-Nov-2010 10 ohmshankar.ece@act.edu.in
  • 11. Arithmetic Instructions  CBW (Convert Byte to Word):  This instruction converts byte in AL to word in AX.  The conversion is done by extending the sign bit of AL throughout AH.  CWD (Convert Word to Double Word):  This instruction converts word in AX to double word in DX : AX.  The conversion is done by extending the sign bit of AX throughout DX. 21-Nov-2010 11 ohmshankar.ece@act.edu.in
  • 12. Arithmetic Instructions INC Src: It increments the byte or word by one. The operand can be a register or memory location. E.g.: INC AX INC [SI] 21-Nov-201 12 ohmshankar.ece@act.edu.in
  • 13. Arithmetic Instructions DEC Src: It decrements the byte or word by one. The operand can be a register or memory location. E.g.: DEC AX DEC [SI] 21-Nov-2010 13 ohmshankar.ece@act.edu.in
  • 14. Arithmetic Instructions  CMP Des, Src:  It compares two specified bytes or words.  The Src and Des can be a constant, register or memory location.  Both operands cannot be a memory location at the same time.  The comparison is done simply by internally subtracting the source from destination.  The value of source and destination does not change, but the flags CF, ZF, SF are modified to indicate the result. 21-Nov-2010 14 ohmshankar.ece@act.edu.in
  • 15. Arithmetic Instructions NEG Src: It creates 2’s complement of a given number. That means, it changes the sign of a number. 21-Nov-2010 15 ohmshankar.ece@act.edu.in
  • 16. Arithmetic Instructions  DAA (Decimal Adjust after Addition)  It is used to make sure that the result of adding two BCD numbers is adjusted to be a correct BCD number.  It only works on AL register.  For Subtraction : DAS (Decimal Adjust after Subtraction) 21-Nov-2010 16 ohmshankar.ece@act.edu.in
  • 17. Arithmetic Instructions  AAA (ASCII Adjust after Addition):  This Instruction Can be used to convert the contents of the AL register to unpacked BCD result  i.e. If lower nibble of AL>9 then 1. AL=AL+6 2. AH=AH+1 3. AL=AL AND 0FH  This instruction does not have any operand.  Other ASCII Instructions:  AAS (ASCII Adjust after Subtraction)  AAM (ASCII Adjust after Multiplication)  AAD (ASCII Adjust Before Division) 21-Nov-2010 17 ohmshankar.ece@act.edu.in
  • 18.  NOT Src:  It complements each bit of Src to produce 1’s complement of the specified operand.  The operand can be a register or memory location.  e,.g NOT AX 21-Nov-2010 18 ohmshankar.ece@act.edu.in Logical Instructions
  • 19. Logical Instructions  AND Des, Src:  It performs AND operation of Des and Src.  Src can be immediate number, register or memory location.  Des can be register or memory location.  Both operands cannot be memory locations at the same time.  CF and OF become zero after the operation.  PF, SF and ZF are updated. 21-Nov-2010 19 ohmshankar.ece@act.edu.in
  • 20. Bit Manipulation Instructions  OR Des, Src:  It performs OR operation of Des and Src.  Src can be immediate number, register or memory location.  Des can be register or memory location.  Both operands cannot be memory locations at the same time.  CF and OF become zero after the operation.  PF, SF and ZF are updated. 21-Nov-2010 20 ohmshankar.ece@act.edu.in
  • 21. Bit Manipulation Instructions  XOR Des, Src:  It performs XOR operation of Des and Src.  Src can be immediate number, register or memory location.  Des can be register or memory location.  Both operands cannot be memory locations at the same time.  CF and OF become zero after the operation.  PF, SF and ZF are updated. 21-Nov-2010 21 ohmshankar.ece@act.edu.in
  • 22. Bit Manipulation Instructions  TEST Des, Src:  It performs AND operation of Des and Src.  Src can be immediate number, and src/Des can be register or memory location.  It is Non-Destructive And means Dest is not modified only flags are affected.  Both operands cannot be memory locations at the same time.  CF and OF become zero after the operation.  PF, SF and ZF are updated. 21-Nov-2010 22 ohmshankar.ece@act.edu.in
  • 23. 2. Data Transfer Instructions 23
  • 24. Data Transfer Instructions  MOV Des, Src:  It is used to copy the content of Src to Des  Src operand can be register, memory location or immediate operand.  Des can be register or memory operand.  Both Src and Des cannot be memory location at the same time.  E.g.:  MOV CX, 037A H  MOV AL, BL  MOV BX, [0301 H] 24
  • 25. Data Transfer Instructions  PUSH Operand:  It pushes the operand into top of stack.  E.g.: PUSH BX  POP Des:  It pops the operand from top of stack to Des.  Des can be a general purpose register, segment register (except CS) or memory location.  E.g.: POP AX 25
  • 26. Data Transfer Instructions  XCHG Des, Src:  This instruction exchanges Src with Des.  It cannot exchange two memory locations directly.  E.g.: XCHG DX, AX 26
  • 27. Data Transfer Instructions  IN Accumulator, Port Address:  It transfers the operand from specified port to accumulator register.  E.g.: IN AX, 0028 H  OUT Port Address, Accumulator:  It transfers the operand from accumulator to specified port.  E.g.: OUT 0028 H, AX 27
  • 28. Data Transfer Instructions LEA Register, Src: It loads a 16-bit register with the offset address of the data specified by the Src. E.g.: LEA BX, [DI] This instruction loads the contents of DI (offset) into the BX register. 28
  • 29. Data Transfer Instructions  LDS Des, Src:  It loads 32-bit pointer from memory source to destination register and DS.  The word is placed in the destination register and the segment is placed in DS.  This instruction Copies the word at the lower memory address to the Des reg and the word at the higher address to the segment reg i.e. DS.  E.g.: LDS BX, [0301 H] 29
  • 30. Data Transfer Instructions  LES Des, Src:  It loads 32-bit pointer from memory source to destination register and ES.  The Word is placed in the destination register and the segment is placed in ES.  This instruction is very similar to LDS except that it initializes ES instead of DS.  E.g.: LES BX, [0301 H] 30
  • 31. Data Transfer Instructions  LAHF:  It copies the lower byte of flag register to AH.  SAHF:  It copies the contents of AH to lower byte of flag register.  PUSHF:  Pushes flag register to top of stack.  POPF:  Pops the stack top to flag register. 31
  • 32. 3. Branch/Program Execution Transfer Instructions  These instructions cause change in the sequence of the execution of instruction.  This change can be a conditional or sometimes unconditional.  The conditions are represented by flags. 32
  • 33. Branch Instructions  CALL Des:  This instruction is used to call a subroutine or function or procedure.  The address of next instruction after CALL is saved onto stack.  RET:  It returns the control from procedure to calling program.  Every CALL instruction should have a RET. 33
  • 34. Branch Instructions  JMP Des:  This instruction is used for unconditional jump from one place to another.  Jxx Des (Conditional Jump):  All the conditional jumps follow some conditional statements or any instruction that affects the flag. 34
  • 35. Conditional Jump Table Mnemonic Meaning Jump Condition JA Jump if Above CF = 0 and ZF = 0 JAE Jump if Above or Equal CF = 0 JB Jump if Below CF = 1 JBE Jump if Below or Equal CF = 1 or ZF = 1 JC Jump if Carry CF = 1 JE Jump if Equal ZF = 1 JNC Jump if Not Carry CF = 0 JNE Jump if Not Equal ZF = 0 JNZ Jump if Not Zero ZF = 0 JPE Jump if Parity Even PF = 1 35
  • 36. Loop Instructions  Loop Des:  This is a looping instruction.  The number of times looping is required is placed in the CX register.  With each iteration, the contents of CX are decremented.  ZF is checked whether to loop again or not. 36
  • 37. Program Execution Transfer Instructions  INTO (Interrupt on overflow):  This instruction generates type 4 interrupt (i.e. interrupt for overflow) and causes the 8086 to do an indirect far call a procedure which is written by the user to handle the overflow condition.  IRET  To return the execution to the interrupted program 37
  • 39. Machine Control Instructions HLT (Halt) :- It causes the processor to enter in to the halt state. It can be stop by INTR,NMI or RESET pin NOP (No Opration) :- It causes the processor to enter in to the wait state for 3 Clock cycles. WAIT :- It causes the processor to enter in to the ideal state. Can be stop by TEST, INTR OR NMI pin LOCK :- This instruction prevents other processors to take the control of shared resources. For e.g LOCK IN AL,80H 21-Nov-2010 39 ohmshankar.ece@act.edu.in
  • 41.  STC:  It sets the carry flag to 1.  CLC:  It clears the carry flag to 0.  CMC:  It complements the carry flag. 41 Flag Manipulation Instructions
  • 42.  STD:  It sets the direction flag to 1.  If it is set, string bytes are accessed from higher memory address to lower memory address.  CLD:  It clears the direction flag to 0.  If it is reset, the string bytes are accessed from lower memory address to higher memory address. 42 Flag Manipulation Instructions
  • 43.  STI:  It sets the Interrupt flag to 1.  CLI:  It clears the Interrupt flag to 0. 21-Nov-2010 43 ohmshankar.ece@act.edu.in Flag Manipulation Instructions
  • 44. 6. Shift And Rotate Instructions
  • 45.  SHL/SAL Des, Count:  It shift bits of byte or word left, by count.  It puts zero(s) in LSBs.  MSB is shifted into carry flag.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 45 Shift And Rotate Instructions
  • 46.  SHR/SAR Des, Count:  It shift bits of byte or word right, by count.  It puts zero(s)(for SHL) and Sign bit (for SAL) in MSBs.  LSB is shifted into carry flag.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 46 Shift And Rotate Instructions
  • 47.  ROL Des, Count:  It rotates bits of byte or word left, by count.  LSB is transferred to MSB and also to CF.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 47 Shift And Rotate Instructions
  • 48.  ROR Des, Count:  It rotates bits of byte or word right, by count.  MSB is transferred to LSB and also to CF.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 21-Nov-2010 48 ohmshankar.ece@act.edu.in Shift And Rotate Instructions
  • 49.  RCL Des, Count:  It rotates bits of byte or word right, by count.  LSB to MSB then MSB is transferred to CF and CF to LSB.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 49 Shift And Rotate Instructions
  • 50.  RCR Des, Count:  It rotates bits of byte or word left, by count.  MSB to LSB then LSB is transferred to CF and CF to MSB.  If the number of bits desired to be shifted is 1, then the immediate number 1 can be written in Count.  However, if the number of bits to be shifted is more than 1, then the count is put in CL register. And recent bit to the CF (Carry flag) 50 Shift And Rotate Instructions
  • 52. String Manipulation Instructions  String in assembly language is just a sequentially stored bytes or words.  There are very strong set of string instructions in 8086.  By using these string instructions, the size of the program is considerably reduced. 52
  • 53. String Manipulation Instructions 53 8086 Microprocessor  String : Sequence of bytes or words  8086 instruction set includes instruction for string movement, comparison, scan, load and store.  REP instruction prefix : used to repeat execution of string instructions  String instructions end with S or SB or SW. S represents string, SB string byte and SW string word.  Offset or effective address of the source operand is stored in SI register and that of the destination operand is stored in DI register.  Depending on the status of DF, SI and DI registers are automatically updated.  DF = 0  SI and DI are incremented by 1 for byte and 2 for word.  DF = 1  SI and DI are decremented by 1 for byte and 2 for word.
  • 54. String Manipulation Instructions  MOVS / MOVSB / MOVSW:  It causes moving of byte or word from one string to another.  In this instruction, the source string is in Data Segment referred by DS:SI and destination string is in Extra Segment referred by ES:DI.  For e.g. movs str1,str2  Movsb  Movsw 54
  • 55. String Manipulation Instructions  LODS / LODSB / LODSW:  It causes TRANSFER of byte or word from one string to another.  In this instruction, the source string is in Data Segment referred by DS:SI transferred to Accumulator.  For e.g. lods string  lodsb  lodsw 55
  • 56. String Manipulation Instructions  STOS / STOSB / STOSW: It causes TRANSFER of byte or word from one string to another. In this instruction, the string is in Extra Segment referred by ES:DI transferred to Accumulator.  For e.g. stos string  stosb  stosw 56
  • 57. String Manipulation Instructions  CMPS Des, Src:  It compares the string bytes or words.  SCAS String:  It scans a string.  It compares the String with byte in AL or with word in AX. 21-Nov-2010 57 ohmshankar.ece@act.edu.in
  • 58. String Manipulation Instructions  REP (Repeat):  This is an instruction prefix.  It causes the repetition of the instruction until CX becomes zero.  E.g.: REP MOVSB  It copies byte by byte contents.  REP repeats the operation MOVSB until CX becomes zero. 21-Nov-2010 58 ohmshankar.ece@act.edu.in
  • 59. 59 8086 Microprocessor REP REPZ/ REPE (Repeat CMPS or SCAS until ZF = 0) REPNZ/ REPNE (Repeat CMPS or SCAS until ZF = 1) While CX  0 and ZF = 1, repeat execution of string instruction and (CX)  (CX) – 1 While CX  0 and ZF = 0, repeat execution of string instruction and (CX)  (CX) - 1 String Manipulation Instructions
  • 60. 60