SlideShare a Scribd company logo
1 of 60
VELTECH
DEPARTMENT OF ECE
INSTRUCTION SETS OF 8086
Prepared By,
V.Mahalakshmi,
Assistant Professor,
Department of ECE,
Veltech
DEFINITION
• 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.
• The entire group of instructions that a
microprocessor supports is called Instruction
Set.
INSTRUCTION FORMAT
• The instruction format of 8086 has one or
more number of fields associated with it.
• The first field is called operation code field or
opcode field, which indicates the type of
operation.
• The instruction format also contains other
fields known as operand fields.
• The Opcode or the operation code tells the
microprocessor which operation to perform
e.g. addition, subtraction.
• Operands are the data contents on which
the operation is to be performed.
Eg: ADD AX, BX
ADD: Opcode
AX, BX : Operands(Data contents)
TYPES OF INSTRUCTION SETS
The 8086 instructions are categorized into the following
main types.
i. Data transfer Instructions
ii. Arithmetic Instructions
iii. Bit Manipulation Instructions (Logical instruction)
iv. Branch Instructions
v. Loop Instructions
vi. Machine Control Instructions
vii. Flag Manipulation Instructions
viii. Shift and Rotate Instructions
ix. String Instructions
Data transfer Instructions
• These instructions are used to transfer the
data from the source operand to the
destination operand.
• The operand can be a constant, memory
location, register or I/O port address.
i. Instruction to transfer a word (7)
ii. Instructions for input and output port transfer (2)
iii. Instructions to transfer the address (3)
iv. Instructions to transfer flag registers (4)
Data transfer Instructions
Instruction to transfer a word (7)
1. MOV − Used to copy the byte or word from the
provided source to the provided destination.
2. PUSH − Used to put a word at the top of the stack.
3. POP − Used to get a word from the top of the stack to
the provided location.
4. XCHG − Used to exchange the data from two
locations.
5. XLAT − Used to translate a byte in AL using a table in
the memory.
6. PUSHA − Used to put all the registers into the stack.
7. POPA − Used to get words from the stack to all
registers.
Data transfer Instructions
1. Syntax: MOV Destination, Source:
• Source operand can be register, memory location
or immediate operand.
• Destination can be register or memory operand.
• Both Source and Destination cannot be memory
location at the same time.
• Example:
MOV CX, 037A H; The data 037A H is moved to CX Register
MOV AL, BL; The data in BL register is moved to AL Register
MOV BX, [0301 H]; The data in the memory location [0301 H]
is moved to BX Register
Data transfer Instructions
2. Syntax: PUSH Operand
• It pushes the operand into top of stack.
• The stack pointer is decremented by 2, after each
execution of the instruction.
E.g.: PUSH BX; The content of BX register is moved to the stack register
3. Syntax: POP Destination
• It pops the operand from top of stack to
Destination.
• Destination can be a general purpose register,
segment register(except CS) or memory location.
• The stack pointer is incremented by 2
E.g.: POP AX; The content of stack register is moved to AX register
Data transfer Instructions
4. Syntax: XCHG Destination, Source:
• This instruction exchange the contents of the
specified source and destination operands
• It cannot exchange two memory locations
directly.
E.g.
XCHG DX, AX; The content in AX and DX register is exchanged.
If AX contains 0234 H and DX contains 45AD H after execution AX contains 45AD H
and DX contains 0234 H
XCHG [5000H], AX;
Data transfer Instructions
5. Syntax: XLAT
• Translate byte using look-up table
• Locates a byte entry in a table in memory, using
the contents of the AL register as a table index,
then copies the contents of the table entry back
into the AL register. The index in the AL register is
treated as an unsigned integer.
• The XLAT and XLATB instructions get the base
address of the table in memory from either the
DS:EBX or the DS:BX registers
Eg. LEA BX, TABLE1; first load the offset part of the start address of
the table into BX register
MOV AL, 04H; load AL with the position of the byte in the table
XLAT; invoke the XLAT instruction
Data transfer Instructions
6. Syntax: PUSHA
• Push all general purpose registers AX, CX, DX,
BX, SP, BP, SI, DI in the stack.
• Original value of SP register (before PUSHA) is
used.
7. Syntax: POPA
• Pop all general purpose registers DI, SI, BP, SP,
BX, DX, CX, AX from the stack.
• SP value is ignored, it is Popped but not set to
SP register.
• No flags affected.
Data transfer Instructions
Instructions for input and output port transfer (2)
1. IN − Used to read a byte or word from the provided
port to the accumulator.
2. OUT − Used to send out a byte or word from the
accumulator to the provided port.
Syntax: IN Accumulator, Port Address:
It transfers the operand from specified port to
accumulator register.
E.g.: IN AX, 0028 H
Syntax: OUT Port Address, Accumulator:
It transfers the operand from accumulator to
specified port.
E.g.: OUT 0028 H, AX
Data transfer Instructions
Instructions to transfer the address (3)
1. LEA − Used to load the address of operand
into the provided register.
2. LDS − Used to load DS register and other
provided register from the memory
3. LES − Used to load ES register and other
provided register from the memory.
Data transfer Instructions
1. Syntax: LEA Register, Source
• Load effective address
• It loads a 16-bit register with the offset
address of the data specified by the Source.
E.g.: MOV BX, 35h
MOV DI, 12h
LEA SI, [BX+DI] ; SI = 35h + 12h = 47h
Data transfer Instructions
2. Syntax: LDS Destination, Source:
• It loads 32-bit pointer from memory source to
destination register and DS.
• The offset is placed in the destination register
and the segment is placed in DS.
• To use this instruction the word at the lower
memory address must contain the offset and the
word at the higher address must contain the
segment.
E.g.: LDS BX, [0301 H]
Data transfer Instructions
3. Syntax: LES Destination, Source:
• It loads 32-bit pointer from memory source to
destination register and ES.
• The offset 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]
Data transfer Instructions
Instructions to transfer flag registers (4)
1. LAHF − Used to load AH with the low byte of
the flag register.
2. SAHF − Used to store AH register to low byte
of the flag register.
3. PUSHF − Used to copy the flag register at the
top of the stack.
4. POPF − Used to copy a word at the top of the
stack to the flag register.
Arithmetic Instructions
• These instructions are used to perform
arithmetic operations like addition,
subtraction, multiplication, division, etc.
1. Syntax: ADD Destination, Source
• It adds a byte to byte or a word to word.
• It affects AF, CF, OF, PF, SF, ZF flags.
E.g.:
ADD AL, 74H
ADD DX, AX
ADD AX, [BX]
Arithmetic Instructions
2. Syntax: ADC Destination, Source
• It adds the two operands with CF.
• It affects AF, CF, OF, PF, SF, ZF flags.
E.g.:
ADC AL, 74H;
ADC DX, AX;
ADC AX, [BX];
Arithmetic Instructions
3. Syntax: SUB Destination, Source:
• It subtracts a byte from byte or a word from
word.
• It affects 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];
Arithmetic Instructions
4. Syntax: SBB Destination, Source:
• It subtracts the two operands and also the
borrow from the result.
• It affects AF, CF, OF, PF, SF, ZF flags.
E.g.:
SBB AL, 74H;
SBB DX, AX;
SBB AX, [BX];
Arithmetic Instructions
5. Syntax: INC Source:
• It increments the byte or word by one.
• The operand can be a register or memory
location.
• It affects AF, OF, PF, SF, ZF flags.
• CF is not effected.
E.g.: INC AX;
Arithmetic Instructions
6. Syntax: DEC Source:
• It decrements the byte or word by one.
• The operand can be a register or memory
location.
• It affects AF, OF, PF, SF, ZF flags.
• CF is not effected.
E.g.: DEC AX;
Arithmetic Instructions
7. AAA (ASCII Adjust after Addition):
• The data entered from the terminal is in ASCII
format.
• In ASCII, 0 – 9 are represented by 30H – 39H.
• This instruction allows us to add the ASCII codes.
• 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)
Arithmetic Instructions
8. 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.
DAS (Decimal Adjust after Subtraction)
• It is used to make sure that the result of
subtracting two BCD numbers is adjusted to be a
correct BCD number.
• It only works on AL register.
Arithmetic Instructions
9. Syntax: NEG Source:
• It creates 2’s complement of a given number.
• It changes the sign of a number.
• Invert all bits of the operand
• Add 1 to inverted operand
Example:
MOV AL, 5 ; AL = 05h
NEG AL ; AL = 0FBh (-5)
NEG AL ; AL = 05h (5)
Arithmetic Instructions
10. Syntax: CMP Destination, Source:
• It compares two specified bytes or words.
• The Source and Destination 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 are modified to indicate the result.
Example:
MOV AL, 5H;
MOV BL, 5H;
CMP AL, BL ; AL = 5, ZF = 1 (so equal!)
RET
Arithmetic Instructions
11. Syntax: MUL Source:
• It is an unsigned multiplication instruction.
• It multiplies two bytes to produce a word or two words to
produce a double word.
• when operand is a byte
AX = AL * operand.
• when operand is a word:
(DX : AX) = AX * operand.
• This instruction assumes one of the operand in AL or AX.
• Source can be a register or memory location.
Example:
MOV AL, 200 ; AL = 0C8h
MOV BL, 4
MUL BL ; AX = 0320h (800)
RET
Arithmetic Instructions
12. Syntax: IMUL Source:
• It is a signed multiplication instruction.
• Source can be a register or memory location.
Example:
MOV AL, -2
MOV BL, -4
IMUL BL ; AX = 8
RET
Arithmetic Instructions
13. Syntax: DIV Source:
• It is an unsigned division instruction.
• It divides word by byte or double word by word.
• when operand is a byte:
AL = AX / operand
AH = remainder (modulus)
• when operand is a word:
AX = (DX AX) / operand
DX = remainder (modulus)
Example:
MOV AX, 203 ; AX = 00CBh
MOV BL, 4;
DIV BL ; AL = 50 (32h), AH = 3
RET
Arithmetic Instructions
14. Syntax: IDIV Source:
• It is a signed division instruction.
• Source can be register or memory.
Example:
MOV AX, -203 ; AX = 0FF35h
MOV BL, 4
IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh)
RET
Arithmetic Instructions
15. 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.
• if high bit of AL = 1 then:
AH = 255 (0FFh)
else
AH = 0
Example:
MOV AX, 0 ; AH = 0, AL = 0
MOV AL, -5 ; AX = 000FBh (251)
CBW ; AX = 0FFFBh (-5)
RET
16. 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.
Bit Manipulation Instructions
Bit Manipulation (Logical) Instructions
• These instructions are used to perform
operations where data bits are involved, i.e.
operations like logical, shift, etc.
• Instructions to perform logical operation (5)
• Instructions to perform shift operations (4)
• Instructions to perform rotate operations (4)
Bit Manipulation Instructions
Instructions to perform logical operation (5)
1. NOT − Used to invert each bit of a byte or word.
2. AND − Used for adding each bit in a byte/word
with the corresponding bit in another byte/word.
3. OR − Used to multiply each bit in a byte/word
with the corresponding bit in another byte/word.
4. XOR − Used to perform Exclusive-OR operation
over each bit in a byte/word with the
corresponding bit in another byte/word.
5. TEST − Used to add operands to update flags,
without affecting operands.
Bit Manipulation Instructions
1. Syntax: NOT Source:
• It complements each bit of Source to produce 1’s
complement of the specified operand.
• The operand can be a register or memory
location.
• It does not affect the status flags.
Example:
MOV AL, 00011011b
NOT AL ; AL = 11100100b
RET
Bit Manipulation Instructions
2. Syntax: AND Destination, Source:
• It performs AND operation of Destination and Source.
• Source can be immediate number, register or memory
location.
• Destination 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.
Example:
MOV AL, 'a' ; AL = 01100001b
AND AL, 11011111b ; AL = 01000001b ('A')
RET
Bit Manipulation Instructions
3. Syntax: OR Destination, Source:
• It performs OR operation of Destination and Source.
• Source can be immediate number, register or memory
location.
• Destination 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.
Example:
MOV AL, 'A' ; AL = 01000001b
OR AL, 00100000b ; AL = 01100001b ('a')
RET
Bit Manipulation Instructions
4. Syntax: XOR Destination, Source
• It performs XOR operation of Destination and Source.
• Source can be immediate number, register or memory
location.
• Destination 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.
Example:
MOV AL, 00000111b
XOR AL, 00000010b ; AL = 00000101b
RET
Bit Manipulation Instructions
Instructions to perform shift operations (4)
• SHL/SAL − Used to shift bits of a byte/word
towards left and put zero(S) in LSBs.
• SHR − Used to shift bits of a byte/word towards
the right and put zero(S) in MSBs.
• SAR − Used to shift bits of a byte/word towards
the right and copy the old MSB into the new
MSB.
Bit Manipulation Instructions
1. Syntax: SAL/SHL Destination, 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 count desired to be shifted is
1, then the immediate number 1 can be
written in Count.
• However, if the number of count to be shifted
is more than 1, then the count is put in CL
register.
Bit Manipulation Instructions
2. Syntax: SHR Destination, Count:
• It shift bits of byte or word right, by count.
• It puts zero(s) 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.
Bit Manipulation Instructions
3. Syntax: SAR destination, count
• As a bit is shifted out of the MSB position, a copy
of the old MSB is put in the MSB position.
• The LSB will be shifted into CF.
• In the case of multiple shifts, CF will contain the
bit most recently shifted in from the LSB.
• Bits shifted into CF previously will be lost.
Bit Manipulation Instructions
Instructions to perform Rotate operations (4)
1. ROL − Used to rotate bits of byte/word towards
the left, i.e. MSB to LSB and to Carry Flag [CF].
2. ROR − Used to rotate bits of byte/word towards
the right, i.e. LSB to MSB and to Carry Flag [CF].
3. RCR − Used to rotate bits of byte/word towards
the right, i.e. LSB to CF and CF to MSB.
4. RCL − Used to rotate bits of byte/word towards
the left, i.e. MSB to CF and CF to LSB.
Bit Manipulation Instructions
• Syntax: ROL/ RCL Destination, Count:
• It rotates bits of byte or word left, 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
Bit Manipulation Instructions
Syntax: ROR/ RCR Destination, Count:
• It rotates bits of byte or word right, 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.
Program Execution Transfer
Instructions
• These instructions cause change in the
sequence of the execution of instruction.
• This change can be through a condition or
sometimes unconditional.
• The conditions are represented by flags.
Program Execution Transfer
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.
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.
JUMP Instructions
Program Execution Transfer
Instructions
• Syntax: Loop Destination:
• 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.
String 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.
CMPS Destination, Source:
• 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.
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 and destination string is in Extra
Segment.
• SI and DI store the offset values for source and
destination index.
REP (Repeat):
• This is an instruction prefix.
• It causes the repetition of the instruction until
CX becomes zero.
• E.g.: REP MOVSB STR1, STR2
• It copies byte by byte contents.
• REP repeats the operation MOVSB until CX
becomes zero.
Processor Control Instructions
• These instructions control the processor itself.
• 8086 allows to control certain control flags
that causes the processing in a certain
direction processor synchronization if more
than one microprocessor attached.
STC:
• It sets the carry flag to 1.
CLC:
• It clears the carry flag to 0.
CMC:
• It complements the carry flag.
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.
Instruction sets of 8086

More Related Content

What's hot

8086 modes
8086 modes8086 modes
8086 modesPDFSHARE
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086Jismy .K.Jose
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086Dr. AISHWARYA N
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor Mustapha Fatty
 
Special of 80386 registers
Special of 80386 registersSpecial of 80386 registers
Special of 80386 registersTanmoy Mazumder
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386yash sawarkar
 
8086 class notes-Y.N.M
8086 class notes-Y.N.M8086 class notes-Y.N.M
8086 class notes-Y.N.MDr.YNM
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085ShivamSood22
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorAshita Agrawal
 
8086 pin diagram description
8086 pin diagram description8086 pin diagram description
8086 pin diagram descriptionAkhil Singal
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptxMemonaMemon1
 

What's hot (20)

8086 modes
8086 modes8086 modes
8086 modes
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086Minimum mode and Maximum mode Configuration in 8086
Minimum mode and Maximum mode Configuration in 8086
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor  Architecture of 8086 Microprocessor
Architecture of 8086 Microprocessor
 
Special of 80386 registers
Special of 80386 registersSpecial of 80386 registers
Special of 80386 registers
 
8086 String Instructions.pdf
8086 String Instructions.pdf8086 String Instructions.pdf
8086 String Instructions.pdf
 
Microprocessor 8086
Microprocessor 8086Microprocessor 8086
Microprocessor 8086
 
Microprocessor 80386
Microprocessor 80386Microprocessor 80386
Microprocessor 80386
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
8086 class notes-Y.N.M
8086 class notes-Y.N.M8086 class notes-Y.N.M
8086 class notes-Y.N.M
 
Addressing modes 8085
Addressing modes 8085Addressing modes 8085
Addressing modes 8085
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
8086 pin diagram description
8086 pin diagram description8086 pin diagram description
8086 pin diagram description
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
8085 instruction set
8085 instruction set8085 instruction set
8085 instruction set
 
8051 MICROCONTROLLER ARCHITECTURE.pptx
 8051 MICROCONTROLLER ARCHITECTURE.pptx 8051 MICROCONTROLLER ARCHITECTURE.pptx
8051 MICROCONTROLLER ARCHITECTURE.pptx
 

Similar to Instruction sets of 8086

8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)Aswini Dharmaraj
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086sravanithonta79
 
All-addressing-modes of the 80386 /microprocessor.pptx
All-addressing-modes of the 80386 /microprocessor.pptxAll-addressing-modes of the 80386 /microprocessor.pptx
All-addressing-modes of the 80386 /microprocessor.pptxVidyaAshokNemade
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
 
Notes arithmetic instructions
Notes arithmetic instructionsNotes arithmetic instructions
Notes arithmetic instructionsHarshitParkar6677
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGFrankie Jones
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessoradnanqayum
 
Addressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorAddressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorpal bhumit
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd yearBharghavteja1
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programmingKartik Sharma
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfIntel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfAnonymous611358
 
Intrl 8086 instruction set
Intrl 8086 instruction setIntrl 8086 instruction set
Intrl 8086 instruction setedwardkiwalabye1
 

Similar to Instruction sets of 8086 (20)

8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
 
All-addressing-modes of the 80386 /microprocessor.pptx
All-addressing-modes of the 80386 /microprocessor.pptxAll-addressing-modes of the 80386 /microprocessor.pptx
All-addressing-modes of the 80386 /microprocessor.pptx
 
Notes all instructions
Notes all instructionsNotes all instructions
Notes all instructions
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
Notes arithmetic instructions
Notes arithmetic instructionsNotes arithmetic instructions
Notes arithmetic instructions
 
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
mm_1.pdf
mm_1.pdfmm_1.pdf
mm_1.pdf
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Addressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorAddressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessor
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year
 
Instruction set
Instruction setInstruction set
Instruction set
 
Unit 2 assembly language programming
Unit 2   assembly language programmingUnit 2   assembly language programming
Unit 2 assembly language programming
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfIntel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
 
Intrl 8086 instruction set
Intrl 8086 instruction setIntrl 8086 instruction set
Intrl 8086 instruction set
 

Recently uploaded

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756dollysharma2066
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...SUHANI PANDEY
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityMorshed Ahmed Rahath
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Bookingroncy bisnoi
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 

Recently uploaded (20)

Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Ramesh Nagar Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
A Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna MunicipalityA Study of Urban Area Plan for Pabna Municipality
A Study of Urban Area Plan for Pabna Municipality
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 

Instruction sets of 8086

  • 1. VELTECH DEPARTMENT OF ECE INSTRUCTION SETS OF 8086 Prepared By, V.Mahalakshmi, Assistant Professor, Department of ECE, Veltech
  • 2.
  • 3. DEFINITION • 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. • The entire group of instructions that a microprocessor supports is called Instruction Set.
  • 4. INSTRUCTION FORMAT • The instruction format of 8086 has one or more number of fields associated with it. • The first field is called operation code field or opcode field, which indicates the type of operation. • The instruction format also contains other fields known as operand fields.
  • 5. • The Opcode or the operation code tells the microprocessor which operation to perform e.g. addition, subtraction. • Operands are the data contents on which the operation is to be performed. Eg: ADD AX, BX ADD: Opcode AX, BX : Operands(Data contents)
  • 6. TYPES OF INSTRUCTION SETS The 8086 instructions are categorized into the following main types. i. Data transfer Instructions ii. Arithmetic Instructions iii. Bit Manipulation Instructions (Logical instruction) iv. Branch Instructions v. Loop Instructions vi. Machine Control Instructions vii. Flag Manipulation Instructions viii. Shift and Rotate Instructions ix. String Instructions
  • 7. Data transfer Instructions • These instructions are used to transfer the data from the source operand to the destination operand. • The operand can be a constant, memory location, register or I/O port address. i. Instruction to transfer a word (7) ii. Instructions for input and output port transfer (2) iii. Instructions to transfer the address (3) iv. Instructions to transfer flag registers (4)
  • 8. Data transfer Instructions Instruction to transfer a word (7) 1. MOV − Used to copy the byte or word from the provided source to the provided destination. 2. PUSH − Used to put a word at the top of the stack. 3. POP − Used to get a word from the top of the stack to the provided location. 4. XCHG − Used to exchange the data from two locations. 5. XLAT − Used to translate a byte in AL using a table in the memory. 6. PUSHA − Used to put all the registers into the stack. 7. POPA − Used to get words from the stack to all registers.
  • 9. Data transfer Instructions 1. Syntax: MOV Destination, Source: • Source operand can be register, memory location or immediate operand. • Destination can be register or memory operand. • Both Source and Destination cannot be memory location at the same time. • Example: MOV CX, 037A H; The data 037A H is moved to CX Register MOV AL, BL; The data in BL register is moved to AL Register MOV BX, [0301 H]; The data in the memory location [0301 H] is moved to BX Register
  • 10. Data transfer Instructions 2. Syntax: PUSH Operand • It pushes the operand into top of stack. • The stack pointer is decremented by 2, after each execution of the instruction. E.g.: PUSH BX; The content of BX register is moved to the stack register 3. Syntax: POP Destination • It pops the operand from top of stack to Destination. • Destination can be a general purpose register, segment register(except CS) or memory location. • The stack pointer is incremented by 2 E.g.: POP AX; The content of stack register is moved to AX register
  • 11. Data transfer Instructions 4. Syntax: XCHG Destination, Source: • This instruction exchange the contents of the specified source and destination operands • It cannot exchange two memory locations directly. E.g. XCHG DX, AX; The content in AX and DX register is exchanged. If AX contains 0234 H and DX contains 45AD H after execution AX contains 45AD H and DX contains 0234 H XCHG [5000H], AX;
  • 12. Data transfer Instructions 5. Syntax: XLAT • Translate byte using look-up table • Locates a byte entry in a table in memory, using the contents of the AL register as a table index, then copies the contents of the table entry back into the AL register. The index in the AL register is treated as an unsigned integer. • The XLAT and XLATB instructions get the base address of the table in memory from either the DS:EBX or the DS:BX registers Eg. LEA BX, TABLE1; first load the offset part of the start address of the table into BX register MOV AL, 04H; load AL with the position of the byte in the table XLAT; invoke the XLAT instruction
  • 13. Data transfer Instructions 6. Syntax: PUSHA • Push all general purpose registers AX, CX, DX, BX, SP, BP, SI, DI in the stack. • Original value of SP register (before PUSHA) is used. 7. Syntax: POPA • Pop all general purpose registers DI, SI, BP, SP, BX, DX, CX, AX from the stack. • SP value is ignored, it is Popped but not set to SP register. • No flags affected.
  • 14. Data transfer Instructions Instructions for input and output port transfer (2) 1. IN − Used to read a byte or word from the provided port to the accumulator. 2. OUT − Used to send out a byte or word from the accumulator to the provided port. Syntax: IN Accumulator, Port Address: It transfers the operand from specified port to accumulator register. E.g.: IN AX, 0028 H Syntax: OUT Port Address, Accumulator: It transfers the operand from accumulator to specified port. E.g.: OUT 0028 H, AX
  • 15. Data transfer Instructions Instructions to transfer the address (3) 1. LEA − Used to load the address of operand into the provided register. 2. LDS − Used to load DS register and other provided register from the memory 3. LES − Used to load ES register and other provided register from the memory.
  • 16. Data transfer Instructions 1. Syntax: LEA Register, Source • Load effective address • It loads a 16-bit register with the offset address of the data specified by the Source. E.g.: MOV BX, 35h MOV DI, 12h LEA SI, [BX+DI] ; SI = 35h + 12h = 47h
  • 17. Data transfer Instructions 2. Syntax: LDS Destination, Source: • It loads 32-bit pointer from memory source to destination register and DS. • The offset is placed in the destination register and the segment is placed in DS. • To use this instruction the word at the lower memory address must contain the offset and the word at the higher address must contain the segment. E.g.: LDS BX, [0301 H]
  • 18. Data transfer Instructions 3. Syntax: LES Destination, Source: • It loads 32-bit pointer from memory source to destination register and ES. • The offset 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]
  • 19. Data transfer Instructions Instructions to transfer flag registers (4) 1. LAHF − Used to load AH with the low byte of the flag register. 2. SAHF − Used to store AH register to low byte of the flag register. 3. PUSHF − Used to copy the flag register at the top of the stack. 4. POPF − Used to copy a word at the top of the stack to the flag register.
  • 20. Arithmetic Instructions • These instructions are used to perform arithmetic operations like addition, subtraction, multiplication, division, etc. 1. Syntax: ADD Destination, Source • It adds a byte to byte or a word to word. • It affects AF, CF, OF, PF, SF, ZF flags. E.g.: ADD AL, 74H ADD DX, AX ADD AX, [BX]
  • 21. Arithmetic Instructions 2. Syntax: ADC Destination, Source • It adds the two operands with CF. • It affects AF, CF, OF, PF, SF, ZF flags. E.g.: ADC AL, 74H; ADC DX, AX; ADC AX, [BX];
  • 22. Arithmetic Instructions 3. Syntax: SUB Destination, Source: • It subtracts a byte from byte or a word from word. • It affects 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];
  • 23. Arithmetic Instructions 4. Syntax: SBB Destination, Source: • It subtracts the two operands and also the borrow from the result. • It affects AF, CF, OF, PF, SF, ZF flags. E.g.: SBB AL, 74H; SBB DX, AX; SBB AX, [BX];
  • 24. Arithmetic Instructions 5. Syntax: INC Source: • It increments the byte or word by one. • The operand can be a register or memory location. • It affects AF, OF, PF, SF, ZF flags. • CF is not effected. E.g.: INC AX;
  • 25. Arithmetic Instructions 6. Syntax: DEC Source: • It decrements the byte or word by one. • The operand can be a register or memory location. • It affects AF, OF, PF, SF, ZF flags. • CF is not effected. E.g.: DEC AX;
  • 26. Arithmetic Instructions 7. AAA (ASCII Adjust after Addition): • The data entered from the terminal is in ASCII format. • In ASCII, 0 – 9 are represented by 30H – 39H. • This instruction allows us to add the ASCII codes. • 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)
  • 27. Arithmetic Instructions 8. 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. DAS (Decimal Adjust after Subtraction) • It is used to make sure that the result of subtracting two BCD numbers is adjusted to be a correct BCD number. • It only works on AL register.
  • 28. Arithmetic Instructions 9. Syntax: NEG Source: • It creates 2’s complement of a given number. • It changes the sign of a number. • Invert all bits of the operand • Add 1 to inverted operand Example: MOV AL, 5 ; AL = 05h NEG AL ; AL = 0FBh (-5) NEG AL ; AL = 05h (5)
  • 29. Arithmetic Instructions 10. Syntax: CMP Destination, Source: • It compares two specified bytes or words. • The Source and Destination 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 are modified to indicate the result. Example: MOV AL, 5H; MOV BL, 5H; CMP AL, BL ; AL = 5, ZF = 1 (so equal!) RET
  • 30. Arithmetic Instructions 11. Syntax: MUL Source: • It is an unsigned multiplication instruction. • It multiplies two bytes to produce a word or two words to produce a double word. • when operand is a byte AX = AL * operand. • when operand is a word: (DX : AX) = AX * operand. • This instruction assumes one of the operand in AL or AX. • Source can be a register or memory location. Example: MOV AL, 200 ; AL = 0C8h MOV BL, 4 MUL BL ; AX = 0320h (800) RET
  • 31. Arithmetic Instructions 12. Syntax: IMUL Source: • It is a signed multiplication instruction. • Source can be a register or memory location. Example: MOV AL, -2 MOV BL, -4 IMUL BL ; AX = 8 RET
  • 32. Arithmetic Instructions 13. Syntax: DIV Source: • It is an unsigned division instruction. • It divides word by byte or double word by word. • when operand is a byte: AL = AX / operand AH = remainder (modulus) • when operand is a word: AX = (DX AX) / operand DX = remainder (modulus) Example: MOV AX, 203 ; AX = 00CBh MOV BL, 4; DIV BL ; AL = 50 (32h), AH = 3 RET
  • 33. Arithmetic Instructions 14. Syntax: IDIV Source: • It is a signed division instruction. • Source can be register or memory. Example: MOV AX, -203 ; AX = 0FF35h MOV BL, 4 IDIV BL ; AL = -50 (0CEh), AH = -3 (0FDh) RET
  • 34. Arithmetic Instructions 15. 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. • if high bit of AL = 1 then: AH = 255 (0FFh) else AH = 0 Example: MOV AX, 0 ; AH = 0, AL = 0 MOV AL, -5 ; AX = 000FBh (251) CBW ; AX = 0FFFBh (-5) RET 16. 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.
  • 35. Bit Manipulation Instructions Bit Manipulation (Logical) Instructions • These instructions are used to perform operations where data bits are involved, i.e. operations like logical, shift, etc. • Instructions to perform logical operation (5) • Instructions to perform shift operations (4) • Instructions to perform rotate operations (4)
  • 36. Bit Manipulation Instructions Instructions to perform logical operation (5) 1. NOT − Used to invert each bit of a byte or word. 2. AND − Used for adding each bit in a byte/word with the corresponding bit in another byte/word. 3. OR − Used to multiply each bit in a byte/word with the corresponding bit in another byte/word. 4. XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with the corresponding bit in another byte/word. 5. TEST − Used to add operands to update flags, without affecting operands.
  • 37. Bit Manipulation Instructions 1. Syntax: NOT Source: • It complements each bit of Source to produce 1’s complement of the specified operand. • The operand can be a register or memory location. • It does not affect the status flags. Example: MOV AL, 00011011b NOT AL ; AL = 11100100b RET
  • 38. Bit Manipulation Instructions 2. Syntax: AND Destination, Source: • It performs AND operation of Destination and Source. • Source can be immediate number, register or memory location. • Destination 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. Example: MOV AL, 'a' ; AL = 01100001b AND AL, 11011111b ; AL = 01000001b ('A') RET
  • 39. Bit Manipulation Instructions 3. Syntax: OR Destination, Source: • It performs OR operation of Destination and Source. • Source can be immediate number, register or memory location. • Destination 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. Example: MOV AL, 'A' ; AL = 01000001b OR AL, 00100000b ; AL = 01100001b ('a') RET
  • 40. Bit Manipulation Instructions 4. Syntax: XOR Destination, Source • It performs XOR operation of Destination and Source. • Source can be immediate number, register or memory location. • Destination 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. Example: MOV AL, 00000111b XOR AL, 00000010b ; AL = 00000101b RET
  • 41. Bit Manipulation Instructions Instructions to perform shift operations (4) • SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in LSBs. • SHR − Used to shift bits of a byte/word towards the right and put zero(S) in MSBs. • SAR − Used to shift bits of a byte/word towards the right and copy the old MSB into the new MSB.
  • 42. Bit Manipulation Instructions 1. Syntax: SAL/SHL Destination, 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 count desired to be shifted is 1, then the immediate number 1 can be written in Count. • However, if the number of count to be shifted is more than 1, then the count is put in CL register.
  • 43. Bit Manipulation Instructions 2. Syntax: SHR Destination, Count: • It shift bits of byte or word right, by count. • It puts zero(s) 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.
  • 44. Bit Manipulation Instructions 3. Syntax: SAR destination, count • As a bit is shifted out of the MSB position, a copy of the old MSB is put in the MSB position. • The LSB will be shifted into CF. • In the case of multiple shifts, CF will contain the bit most recently shifted in from the LSB. • Bits shifted into CF previously will be lost.
  • 45. Bit Manipulation Instructions Instructions to perform Rotate operations (4) 1. ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to Carry Flag [CF]. 2. ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to Carry Flag [CF]. 3. RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF to MSB. 4. RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to LSB.
  • 46. Bit Manipulation Instructions • Syntax: ROL/ RCL Destination, Count: • It rotates bits of byte or word left, 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
  • 47. Bit Manipulation Instructions Syntax: ROR/ RCR Destination, Count: • It rotates bits of byte or word right, 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.
  • 48.
  • 49. Program Execution Transfer Instructions • These instructions cause change in the sequence of the execution of instruction. • This change can be through a condition or sometimes unconditional. • The conditions are represented by flags.
  • 50. Program Execution Transfer 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.
  • 51. 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.
  • 53. Program Execution Transfer Instructions • Syntax: Loop Destination: • 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.
  • 54. String 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.
  • 55. CMPS Destination, Source: • 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.
  • 56. 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 and destination string is in Extra Segment. • SI and DI store the offset values for source and destination index.
  • 57. REP (Repeat): • This is an instruction prefix. • It causes the repetition of the instruction until CX becomes zero. • E.g.: REP MOVSB STR1, STR2 • It copies byte by byte contents. • REP repeats the operation MOVSB until CX becomes zero.
  • 58. Processor Control Instructions • These instructions control the processor itself. • 8086 allows to control certain control flags that causes the processing in a certain direction processor synchronization if more than one microprocessor attached.
  • 59. STC: • It sets the carry flag to 1. CLC: • It clears the carry flag to 0. CMC: • It complements the carry flag. 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.