SlideShare una empresa de Scribd logo
1 de 41
Summary of Arithmetic Instructions
–ADD D,S
–ADC D,S
–SUB D,S
–SBB D,S
–CMP D,S
–NEG D
–DAA
–DAS
Summary of Arithmetic Instructions
– AAA
– AAS
– AAM
– AAD
– INC D
– DEC D
– DIV S
– IDIV S
– MUL S
– IMUL S
– CBW
– CWD
Logical Instructions
–These are the instructions used for basic
logic operations such as AND, OR, NOT and
XOR.
–These are also used for carrying out bit by
bit operations such as shift (SHR,SHL) or
rotate (ROL,ROR,RCR,RCL).
– One more Instruction under this category is
TEST instruction.
AND (Logical AND)
Syntax :-- AND destination, source
• This instruction is used to bit by bit AND the
contents of source to the destination.
•The result is stored in the destination.
•The source operand can be a immediate, a
register or a memory location.
•The destination can be a register or a memory
location, but not an immediate data.
•Both operands cannot be immediate data or
memory location.
•Flags affected : OF = 0 ,CF = 0 , AF is undefined.
• And other flags (SF, ZF, PF) are affected based on
the AND operation.
• Operation Performed :--
• Destination  Destination AND source
• Examples :--
1. AND BH,CL ;AND byte in CL with Byte in BH,
result in BH.
2. AND BX,00FFH ;AND word in BX with immediate
data 00ffH
3. AND [5000H], DX ;AND word in DX with a
word in memory with offset
5000 in DS.
AND (Logical AND) contd..
Numeric Example
If AX = 3F0F,
After Instruction,
AND AX,9078H ; AX  AX AND 9078H
;AX  3F0F AND 9078
3F0F  0011 1111 0000 1111
AND
9078  1001 0000 0111 1000
-------------------------------------
= 0001 0000 0000 1000
1008H in AX register
OR (Logical OR)
Syntax :-- OR destination, source
• This instruction is used to bit by bit OR the
contents of source to the destination.
•The result is stored in the destination.
•The source operand can be a immediate, a
register or a memory location.
•The destination can be a register or a memory
location, but not an immediate data.
•Both operands cannot be immediate data or
memory location.
•Flags affected : OF = 0 ,CF = 0 , AF is undefined.
• And other flags (SF, ZF, PF) are affected based on
the OR operation.
• Operation Performed :--
• Destination  Destination OR source
• Examples :--
1. OR BH,CL ;OR byte in CL with Byte in BH,
result in BH.
2. OR BX,00FFH ;OR word in BX with immediate
data 00ffH
3. OR [5000H], DX ; OR word in DX with a
word in memory with offset
5000 in DS.
OR (Logical OR) contd..
Numeric Example
If AX = 3F0F,
After Instruction,
OR AX,9078H ; AX  AX OR 9078H
;AX  3F0F OR 9078
3F0F  0011 1111 0000 1111
OR
9078  1001 0000 0111 1000
-------------------------------------
= 1011 1111 0111 1111
BF7FH in AX register
XOR (Logical XOR)
Syntax :-- XOR destination, source
• This instruction is used to bit by bit XOR the
contents of source to the destination.
•The result is stored in the destination.
•The source operand can be a immediate, a
register or a memory location.
•The destination can be a register or a memory
location, but not an immediate data.
•Both operands cannot be immediate data or
memory location.
•Flags affected : OF = 0 ,CF = 0 , AF is undefined.
• And other flags (SF, ZF, PF) are affected based on
the XOR operation.
• Operation Performed :--
• Destination  Destination XOR source
• Examples :--
1. XOR BH,CL ;XOR byte in CL with Byte in BH,
result in BH.
2. XOR BX,00FFH ;XOR word in BX with immediate
data 00ffH
3. XOR [5000H], DX ; XOR word in DX with a
word in memory with offset
5000 in DS.
XOR (Logical XOR) contd..
Numeric Example
If AX = 3F0F,
After Instruction,
XOR AX,9078H ; AX  AX XOR 9078H
;AX  3F0F XOR 9078
3F0F  0011 1111 0000 1111
XOR
9078  1001 0000 0111 1000
-------------------------------------
= 1010 1111 0111 0111
AF77H in AX register
NOT (Logical Invert )
Syntax :-- NOT destination
• This instruction complements (inverts) each
bit of the byte or word stored in the
destination.
•The result is stored in the destination.
•The destination can be a register or a memory
location.
•No Flags affected
• Operation Performed :--
• Destination  NOT Destination
• Examples :--
1. NOT BH ;Complement byte in BH, result in BH.
2. NOT BX ; Complement word in BX, result in BX.
3. NOT BYTE PTR [5000H] ; Complement byte
in memory with offset 5000 in DS.
NOT (Logical Invert ) contd..
Numeric Example
If AX = 3F0F,
After Instruction,
NOT AX ; AX  NOT AX
;AX  NOT 3F0F
3F0F  0011 1111 0000 1111
Complement
-------------------------------------
= 1100 0000 1111 0000
C0F0H in AX register
TEST (Logical compare )
Syntax :-- TEST destination, source
• This instruction is used to bit by bit AND the
contents of source to the destination.
•The result is not stored in the destination.
•The source operand can be a immediate, a
register or a memory location.
•The destination can be a register or a memory
location, but not an immediate data.
•Both operands cannot be immediate data or
memory location.
•Flags affected : OF = 0 ,CF = 0 , SF, ZF, PF.
•TEST instruction is used to set flags before a
conditional jump instruction
• Operation Performed :--
– Flags  set result of Destination AND source
• Examples :--
1. TEST BH,CL ;AND byte in CL with Byte in BH,
no result but flags are affected.
2. TEST BX,00FFH ;AND word in BX with immediate
data 00ffH, no result but flags are
affected.
3. TEST DX, [5000H];AND word in DX with a word in
memory with offset 5000 in DS,
no result but flags are affected.
TEST (Logical Compare) contd..
SHL / SAL (Shift Logical/Arithmetic Left)
Syntax :-- SHL/SAL destination, count
• SHL & SAL are the opcodes for the same
operation
•This instruction shifts the destination bit by bit to
the left and insert zeroes in the newly introduced
least significant bits.
•The shift operation is through carry.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF, SF, ZF, PF.
•These instructions can be used to multiply an
unsigned number by power of 2.
CF BX
0
0
1
CF BX
• Operation Performed :--
–CF  MSB ------------------ LSB  0
• Example :--
– If CF = 0, BX = E6D3H
– After SAL BX, 1 ; Shift the contents of BX
register by one towards left
SHL / SAL (Shift Logical/Arithmetic Left)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0
BX = CDA6
• Example :--
• Use of SHL instruction for Multiplication:-
– If CF = 0, BH = 04H
– MOV CL, 03 ; Load CL register for
the count
– SHL BH, CL ; Shift the contents
of BX register by one
towards left
– BH = 20H (32D) [ 04 * 23 = 32 D]
– Note :-- SHL can be used to multiply a number
with powers of 2.
SHL / SAL (Shift Logical/Arithmetic Left)Cntd..
0 0 0 1 0 0 0 0
CF BH
0
0
0
0
0
0
0
SHL / SAL (Shift Logical/Arithmetic Left)Cntd..
BH = 20H with CF = 0
0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0
0 0 1 0 0 0 0 0
SAR (Shift Arithmetic Right )
Syntax :-- SAR destination, count
• This instruction shifts the destination bit by bit to
the right and MSB position is kept in the old MSB
position
•The shift operation is through carry, LSB is shifted
to CF.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF, SF, ZF, PF.
•This instruction can be used to divide an unsigned
number by power of 2.
BX CF
0
1
BX CF
1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1
• Operation Performed :--
– MSB ----------------- LSB  CF
• Example :--
– If CF = 0, BX = E6D3H
– After SAR BX, 1 ; Shift the contents of BX
register by one towards right
SAR (Shift Arithmetic Right)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = F369H
• Example :--
• Use of SAR instruction for Division:-
– If CF = 0, BH = 14H
– MOV CL, 02 ; Load CL register for the
count
– SAR BH, CL ; Shift the contents
of BX register by one
towards right
– BH = 05H (20D) [ 20 / 22 = 05D]
– Note :-- SAR can be used to divide a number with
powers of 2 and get the quotient.
SAR (Shift Arithmetic Right )Cntd..
0 0 0 0 0 1 0 1
BH CF
0
0
0
SAR (Shift Arithmetic Right)Cntd..
BH = 05H with CF = 0
0 0 0 1 0 1 0 0
0 0 0 0 1 0 1 0
SHR (Shift Logical Right)
Syntax :-- SHR destination, count
•This instruction shifts the destination bit by
bit to the right and insert zeroes in the newly
introduced most significant bits.
•The shift operation is through carry.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF, SF, ZF, PF.
BX CF
0
0
1
BX CF
0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1
• Operation Performed :--
–0  MSB ------------------ LSB  CF
• Example :--
– If CF = 0, BX = E6D3H
– After SHR BX, 1 ; Shift the contents of BX
register by one towards right
SHR (Shift Logical Right)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = 7369H
ROR (Rotate Right without Carry)
Syntax :-- ROR destination, count
•This instruction rotates the destination bit by
bit to the right excluding the carry
•The bit moved out of LSB is rotated around
into the MSB and also copied to CF.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF
BX CF
0
1
BX CF
1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1
• Operation Performed :--
– MSB LSB  CF
• Example :--
– If CF = 0, BX = E6D3H
– After ROR BX, 1 ; Rotate the contents of BX
register by one towards right
ROR (Rotate Right without Carry)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = F369H
• Example :--
– If CF = 0, BH = 54H
– MOV CL, 02 ; Load CL register for the count
ROR BH, CL ; Rotate the contents of BH register by twice
towards right
ROR (Rotate Right without Carry)Cntd..
0 0 0 1 0 1 0 1
BH CF
0
0
0
0 1 0 1 0 1 0 0
0 0 1 0 1 0 1 0
BH = 15H with CF = 0
• Uses of ROR instruction:--
• This instruction can be used to swap the
nibbles in a byte or to swap the bytes in a
word.
– MOV CL,04H
ROR AL, CL
• It can also be used to rotate the bit into CF
which can be checked later for a conditional
jump. (JC or JNC)
ROL (Rotate Left without Carry)
Syntax :-- ROL destination, count
•This instruction rotates the destination bit by
bit to the left excluding the carry
•The bit moved out of MSB is rotated around
into the LSB and also copied to CF.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF
CF BX
0
1
CF BX
1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1
• Operation Performed :--
– CF MSB LSB
• Example :--
– If CF = 0, BX = E6D3H
– After ROL BX, 1 ; Rotate the contents of BX
register by one towards left
ROL (Rotate Left without Carry)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = CDA7H
• Example :--
– If CF = 0, BH = 54H
– MOV CL, 02 ; Load CL register for the count
ROL BH, CL ; Rotate the contents of BH register by twice
towards Left
ROL (Rotate Left without Carry)Cntd..
0 1 0 1 0 0 0 1
CF BH
0
0
1
0 1 0 1 0 1 0 0
1 0 1 0 1 0 0 0
BH = 51H with CF = 1
• Uses of ROL instruction:--
• This instruction can be used to swap the
nibbles in a byte or to swap the bytes in a
word.
– MOV CL,04H
ROL AL, CL
• It can also be used to rotate the bit into CF
which can be checked later for a conditional
jump. (JC or JNC)
RCR (Rotate Right with Carry)
Syntax :-- ROR destination, count
•This instruction rotates the destination bit by
bit to the right including the carry
•The bit moved out of LSB is rotated into CF
and the bit in CF is rotated into the MSB.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF
BX CF
0
1
BX CF
0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1
• Operation Performed :--
– MSB LSB  CF
• Example :--
– If CF = 0, BX = E6D3H
– After RCR BX, 1 ; Rotate the contents of BX
register by one towards right through
carry
RCR (Rotate Right with Carry)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = 7369H
• Example :--
– If CF = 0, BH = 54H
– MOV CL, 02 ; Load CL register for the count
RCR BH, CL ; Rotate the contents of BH register by twice
towards right through carry
RCR (Rotate Right with Carry)Cntd..
0 0 0 1 0 1 0 1
BH CF
0
0
0
0 1 0 1 0 1 0 0
0 0 1 0 1 0 1 0
BH = 15H with CF = 0
RCL (Rotate Left with Carry)
Syntax :-- RCL destination, count
•This instruction rotates the destination bit by
bit to the left including the carry
•The bit moved out of MSB is rotated into CF
and the bit in CF is rotated into the LSB.
•The count can be either 1 or specified by CL
register.
•The destination can be a byte or a word in
register or a memory location, but not an
immediate data.
•Flags affected : OF ,CF
CF BX
0
1
CF BX
1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0
• Operation Performed :--
– CF MSB LSB
• Example :--
– If CF = 0, BX = E6D3H
– After RCL BX, 1 ; Rotate the contents of BX
register by one towards left through
carry
RCL (Rotate Left with Carry)Cntd..
1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1
BX = CDA6H
• Example :--
– If CF = 0, BH = 54H
– MOV CL, 02 ; Load CL register for the count
RCL BH, CL ; Rotate the contents of BH register by twice
towards Left through carry
RCL (Rotate Left with Carry)Cntd..
0 1 0 1 0 0 0 0
CF BH
0
0
1
0 1 0 1 0 1 0 0
1 0 1 0 1 0 0 0
BH = 50H with CF = 1

Más contenido relacionado

La actualidad más candente

Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorRabin BK
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorAshita Agrawal
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086aviban
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Vijay Kumar
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Irfan Anjum
 
Notes arithmetic instructions
Notes arithmetic instructionsNotes arithmetic instructions
Notes arithmetic instructionsHarshitParkar6677
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction setjemimajerome
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareInstruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareProf. Swapnil V. Kaware
 
Instructionset8085
Instructionset8085Instructionset8085
Instructionset8085Fawad Pathan
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085Shifali Sharma
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085Sumadeep Juvvalapalem
 
Instruction set-of-8085
Instruction set-of-8085Instruction set-of-8085
Instruction set-of-8085saleForce
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051logesh waran
 

La actualidad más candente (19)

Logical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessorLogical Instructions used in 8086 microprocessor
Logical Instructions used in 8086 microprocessor
 
Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)Logical instructions (and, or, xor, not, test)
Logical instructions (and, or, xor, not, test)
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
Notes arithmetic instructions
Notes arithmetic instructionsNotes arithmetic instructions
Notes arithmetic instructions
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil KawareInstruction set of 8085 Microprocessor By Er. Swapnil Kaware
Instruction set of 8085 Microprocessor By Er. Swapnil Kaware
 
Instructionset8085
Instructionset8085Instructionset8085
Instructionset8085
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
itft-Instruction set-of-8085
itft-Instruction set-of-8085itft-Instruction set-of-8085
itft-Instruction set-of-8085
 
Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor Instruction set of 8086 Microprocessor
Instruction set of 8086 Microprocessor
 
MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085MICROPROCESSOR INSTRUCTION SET OF 8085
MICROPROCESSOR INSTRUCTION SET OF 8085
 
8086 instruction set
8086  instruction set8086  instruction set
8086 instruction set
 
Instruction set-of-8085
Instruction set-of-8085Instruction set-of-8085
Instruction set-of-8085
 
Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051Addressing mode and instruction set using 8051
Addressing mode and instruction set using 8051
 

Similar a Chapter3 8086inst logical 2

Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructionsRobert Almazan
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionBadrul Alam
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086saurav kumar
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructionsihsanjamil
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Bilal Amjad
 
8085 instruction set (detailed)
8085 instruction set (detailed)8085 instruction set (detailed)
8085 instruction set (detailed)Ravi Anand
 
Addressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorAddressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorpal bhumit
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).pptKanikaJindal9
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086Dr. AISHWARYA N
 

Similar a Chapter3 8086inst logical 2 (20)

Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructions
 
Addressing modes
Addressing modesAddressing modes
Addressing modes
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
8085 instruction set (detailed)
8085 instruction set (detailed)8085 instruction set (detailed)
8085 instruction set (detailed)
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Addressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessorAddressing mode of 80286 microprocessor
Addressing mode of 80286 microprocessor
 
Hemanth143
Hemanth143 Hemanth143
Hemanth143
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt8085_Microprocessor(simar).ppt
8085_Microprocessor(simar).ppt
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Lec06
Lec06Lec06
Lec06
 

Más de HarshitParkar6677 (20)

Wi fi hacking
Wi fi hackingWi fi hacking
Wi fi hacking
 
D dos attack
D dos attackD dos attack
D dos attack
 
Notes chapter 6
Notes chapter  6Notes chapter  6
Notes chapter 6
 
Interface notes
Interface notesInterface notes
Interface notes
 
Chapter6 2
Chapter6 2Chapter6 2
Chapter6 2
 
Chapter6
Chapter6Chapter6
Chapter6
 
8086 cpu 1
8086 cpu 18086 cpu 1
8086 cpu 1
 
Chapter 6 notes
Chapter 6 notesChapter 6 notes
Chapter 6 notes
 
Chapter 5 notes
Chapter 5 notesChapter 5 notes
Chapter 5 notes
 
Chap6 procedures & macros
Chap6 procedures & macrosChap6 procedures & macros
Chap6 procedures & macros
 
Chapter 5 notes new
Chapter 5 notes newChapter 5 notes new
Chapter 5 notes new
 
Notes aaa aa
Notes aaa aaNotes aaa aa
Notes aaa aa
 
Notes 8086 instruction format
Notes 8086 instruction formatNotes 8086 instruction format
Notes 8086 instruction format
 
Misc
MiscMisc
Misc
 
Chapter3 program flow control instructions
Chapter3 program flow control instructionsChapter3 program flow control instructions
Chapter3 program flow control instructions
 
Chapter3 8086inst stringsl
Chapter3 8086inst stringslChapter3 8086inst stringsl
Chapter3 8086inst stringsl
 
Chap3 program flow control instructions
Chap3 program flow control instructionsChap3 program flow control instructions
Chap3 program flow control instructions
 
Chap3 8086 logical
Chap3 8086 logicalChap3 8086 logical
Chap3 8086 logical
 
Chap3 8086 data transfer
Chap3 8086 data transferChap3 8086 data transfer
Chap3 8086 data transfer
 
Chap 8086 string
Chap 8086 stringChap 8086 string
Chap 8086 string
 

Último

Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Romil Mishra
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Sumanth A
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
Industrial Applications of Centrifugal Compressors
Industrial Applications of Centrifugal CompressorsIndustrial Applications of Centrifugal Compressors
Industrial Applications of Centrifugal CompressorsAlirezaBagherian3
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Erbil Polytechnic University
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdfAkritiPradhan2
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxStephen Sitton
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating SystemRashmi Bhat
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming languageSmritiSharma901052
 

Último (20)

Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________Gravity concentration_MI20612MI_________
Gravity concentration_MI20612MI_________
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
Stork Webinar | APM Transformational planning, Tool Selection & Performance T...
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
Robotics-Asimov's Laws, Mechanical Subsystems, Robot Kinematics, Robot Dynami...
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
Industrial Applications of Centrifugal Compressors
Industrial Applications of Centrifugal CompressorsIndustrial Applications of Centrifugal Compressors
Industrial Applications of Centrifugal Compressors
 
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
Comparative study of High-rise Building Using ETABS,SAP200 and SAFE., SAFE an...
 
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdfDEVICE DRIVERS AND INTERRUPTS  SERVICE MECHANISM.pdf
DEVICE DRIVERS AND INTERRUPTS SERVICE MECHANISM.pdf
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
Turn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptxTurn leadership mistakes into a better future.pptx
Turn leadership mistakes into a better future.pptx
 
List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Virtual memory management in Operating System
Virtual memory management in Operating SystemVirtual memory management in Operating System
Virtual memory management in Operating System
 
OOP concepts -in-Python programming language
OOP concepts -in-Python programming languageOOP concepts -in-Python programming language
OOP concepts -in-Python programming language
 

Chapter3 8086inst logical 2

  • 1. Summary of Arithmetic Instructions –ADD D,S –ADC D,S –SUB D,S –SBB D,S –CMP D,S –NEG D –DAA –DAS
  • 2. Summary of Arithmetic Instructions – AAA – AAS – AAM – AAD – INC D – DEC D – DIV S – IDIV S – MUL S – IMUL S – CBW – CWD
  • 3. Logical Instructions –These are the instructions used for basic logic operations such as AND, OR, NOT and XOR. –These are also used for carrying out bit by bit operations such as shift (SHR,SHL) or rotate (ROL,ROR,RCR,RCL). – One more Instruction under this category is TEST instruction.
  • 4. AND (Logical AND) Syntax :-- AND destination, source • This instruction is used to bit by bit AND the contents of source to the destination. •The result is stored in the destination. •The source operand can be a immediate, a register or a memory location. •The destination can be a register or a memory location, but not an immediate data. •Both operands cannot be immediate data or memory location. •Flags affected : OF = 0 ,CF = 0 , AF is undefined. • And other flags (SF, ZF, PF) are affected based on the AND operation.
  • 5. • Operation Performed :-- • Destination  Destination AND source • Examples :-- 1. AND BH,CL ;AND byte in CL with Byte in BH, result in BH. 2. AND BX,00FFH ;AND word in BX with immediate data 00ffH 3. AND [5000H], DX ;AND word in DX with a word in memory with offset 5000 in DS. AND (Logical AND) contd..
  • 6. Numeric Example If AX = 3F0F, After Instruction, AND AX,9078H ; AX  AX AND 9078H ;AX  3F0F AND 9078 3F0F  0011 1111 0000 1111 AND 9078  1001 0000 0111 1000 ------------------------------------- = 0001 0000 0000 1000 1008H in AX register
  • 7. OR (Logical OR) Syntax :-- OR destination, source • This instruction is used to bit by bit OR the contents of source to the destination. •The result is stored in the destination. •The source operand can be a immediate, a register or a memory location. •The destination can be a register or a memory location, but not an immediate data. •Both operands cannot be immediate data or memory location. •Flags affected : OF = 0 ,CF = 0 , AF is undefined. • And other flags (SF, ZF, PF) are affected based on the OR operation.
  • 8. • Operation Performed :-- • Destination  Destination OR source • Examples :-- 1. OR BH,CL ;OR byte in CL with Byte in BH, result in BH. 2. OR BX,00FFH ;OR word in BX with immediate data 00ffH 3. OR [5000H], DX ; OR word in DX with a word in memory with offset 5000 in DS. OR (Logical OR) contd..
  • 9. Numeric Example If AX = 3F0F, After Instruction, OR AX,9078H ; AX  AX OR 9078H ;AX  3F0F OR 9078 3F0F  0011 1111 0000 1111 OR 9078  1001 0000 0111 1000 ------------------------------------- = 1011 1111 0111 1111 BF7FH in AX register
  • 10. XOR (Logical XOR) Syntax :-- XOR destination, source • This instruction is used to bit by bit XOR the contents of source to the destination. •The result is stored in the destination. •The source operand can be a immediate, a register or a memory location. •The destination can be a register or a memory location, but not an immediate data. •Both operands cannot be immediate data or memory location. •Flags affected : OF = 0 ,CF = 0 , AF is undefined. • And other flags (SF, ZF, PF) are affected based on the XOR operation.
  • 11. • Operation Performed :-- • Destination  Destination XOR source • Examples :-- 1. XOR BH,CL ;XOR byte in CL with Byte in BH, result in BH. 2. XOR BX,00FFH ;XOR word in BX with immediate data 00ffH 3. XOR [5000H], DX ; XOR word in DX with a word in memory with offset 5000 in DS. XOR (Logical XOR) contd..
  • 12. Numeric Example If AX = 3F0F, After Instruction, XOR AX,9078H ; AX  AX XOR 9078H ;AX  3F0F XOR 9078 3F0F  0011 1111 0000 1111 XOR 9078  1001 0000 0111 1000 ------------------------------------- = 1010 1111 0111 0111 AF77H in AX register
  • 13. NOT (Logical Invert ) Syntax :-- NOT destination • This instruction complements (inverts) each bit of the byte or word stored in the destination. •The result is stored in the destination. •The destination can be a register or a memory location. •No Flags affected
  • 14. • Operation Performed :-- • Destination  NOT Destination • Examples :-- 1. NOT BH ;Complement byte in BH, result in BH. 2. NOT BX ; Complement word in BX, result in BX. 3. NOT BYTE PTR [5000H] ; Complement byte in memory with offset 5000 in DS. NOT (Logical Invert ) contd..
  • 15. Numeric Example If AX = 3F0F, After Instruction, NOT AX ; AX  NOT AX ;AX  NOT 3F0F 3F0F  0011 1111 0000 1111 Complement ------------------------------------- = 1100 0000 1111 0000 C0F0H in AX register
  • 16. TEST (Logical compare ) Syntax :-- TEST destination, source • This instruction is used to bit by bit AND the contents of source to the destination. •The result is not stored in the destination. •The source operand can be a immediate, a register or a memory location. •The destination can be a register or a memory location, but not an immediate data. •Both operands cannot be immediate data or memory location. •Flags affected : OF = 0 ,CF = 0 , SF, ZF, PF. •TEST instruction is used to set flags before a conditional jump instruction
  • 17. • Operation Performed :-- – Flags  set result of Destination AND source • Examples :-- 1. TEST BH,CL ;AND byte in CL with Byte in BH, no result but flags are affected. 2. TEST BX,00FFH ;AND word in BX with immediate data 00ffH, no result but flags are affected. 3. TEST DX, [5000H];AND word in DX with a word in memory with offset 5000 in DS, no result but flags are affected. TEST (Logical Compare) contd..
  • 18. SHL / SAL (Shift Logical/Arithmetic Left) Syntax :-- SHL/SAL destination, count • SHL & SAL are the opcodes for the same operation •This instruction shifts the destination bit by bit to the left and insert zeroes in the newly introduced least significant bits. •The shift operation is through carry. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF, SF, ZF, PF. •These instructions can be used to multiply an unsigned number by power of 2.
  • 19. CF BX 0 0 1 CF BX • Operation Performed :-- –CF  MSB ------------------ LSB  0 • Example :-- – If CF = 0, BX = E6D3H – After SAL BX, 1 ; Shift the contents of BX register by one towards left SHL / SAL (Shift Logical/Arithmetic Left)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0 BX = CDA6
  • 20. • Example :-- • Use of SHL instruction for Multiplication:- – If CF = 0, BH = 04H – MOV CL, 03 ; Load CL register for the count – SHL BH, CL ; Shift the contents of BX register by one towards left – BH = 20H (32D) [ 04 * 23 = 32 D] – Note :-- SHL can be used to multiply a number with powers of 2. SHL / SAL (Shift Logical/Arithmetic Left)Cntd..
  • 21. 0 0 0 1 0 0 0 0 CF BH 0 0 0 0 0 0 0 SHL / SAL (Shift Logical/Arithmetic Left)Cntd.. BH = 20H with CF = 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0
  • 22. SAR (Shift Arithmetic Right ) Syntax :-- SAR destination, count • This instruction shifts the destination bit by bit to the right and MSB position is kept in the old MSB position •The shift operation is through carry, LSB is shifted to CF. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF, SF, ZF, PF. •This instruction can be used to divide an unsigned number by power of 2.
  • 23. BX CF 0 1 BX CF 1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 • Operation Performed :-- – MSB ----------------- LSB  CF • Example :-- – If CF = 0, BX = E6D3H – After SAR BX, 1 ; Shift the contents of BX register by one towards right SAR (Shift Arithmetic Right)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = F369H
  • 24. • Example :-- • Use of SAR instruction for Division:- – If CF = 0, BH = 14H – MOV CL, 02 ; Load CL register for the count – SAR BH, CL ; Shift the contents of BX register by one towards right – BH = 05H (20D) [ 20 / 22 = 05D] – Note :-- SAR can be used to divide a number with powers of 2 and get the quotient. SAR (Shift Arithmetic Right )Cntd..
  • 25. 0 0 0 0 0 1 0 1 BH CF 0 0 0 SAR (Shift Arithmetic Right)Cntd.. BH = 05H with CF = 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0
  • 26. SHR (Shift Logical Right) Syntax :-- SHR destination, count •This instruction shifts the destination bit by bit to the right and insert zeroes in the newly introduced most significant bits. •The shift operation is through carry. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF, SF, ZF, PF.
  • 27. BX CF 0 0 1 BX CF 0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 • Operation Performed :-- –0  MSB ------------------ LSB  CF • Example :-- – If CF = 0, BX = E6D3H – After SHR BX, 1 ; Shift the contents of BX register by one towards right SHR (Shift Logical Right)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = 7369H
  • 28. ROR (Rotate Right without Carry) Syntax :-- ROR destination, count •This instruction rotates the destination bit by bit to the right excluding the carry •The bit moved out of LSB is rotated around into the MSB and also copied to CF. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF
  • 29. BX CF 0 1 BX CF 1 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 • Operation Performed :-- – MSB LSB  CF • Example :-- – If CF = 0, BX = E6D3H – After ROR BX, 1 ; Rotate the contents of BX register by one towards right ROR (Rotate Right without Carry)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = F369H
  • 30. • Example :-- – If CF = 0, BH = 54H – MOV CL, 02 ; Load CL register for the count ROR BH, CL ; Rotate the contents of BH register by twice towards right ROR (Rotate Right without Carry)Cntd.. 0 0 0 1 0 1 0 1 BH CF 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 BH = 15H with CF = 0
  • 31. • Uses of ROR instruction:-- • This instruction can be used to swap the nibbles in a byte or to swap the bytes in a word. – MOV CL,04H ROR AL, CL • It can also be used to rotate the bit into CF which can be checked later for a conditional jump. (JC or JNC)
  • 32. ROL (Rotate Left without Carry) Syntax :-- ROL destination, count •This instruction rotates the destination bit by bit to the left excluding the carry •The bit moved out of MSB is rotated around into the LSB and also copied to CF. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF
  • 33. CF BX 0 1 CF BX 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 1 • Operation Performed :-- – CF MSB LSB • Example :-- – If CF = 0, BX = E6D3H – After ROL BX, 1 ; Rotate the contents of BX register by one towards left ROL (Rotate Left without Carry)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = CDA7H
  • 34. • Example :-- – If CF = 0, BH = 54H – MOV CL, 02 ; Load CL register for the count ROL BH, CL ; Rotate the contents of BH register by twice towards Left ROL (Rotate Left without Carry)Cntd.. 0 1 0 1 0 0 0 1 CF BH 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 0 0 BH = 51H with CF = 1
  • 35. • Uses of ROL instruction:-- • This instruction can be used to swap the nibbles in a byte or to swap the bytes in a word. – MOV CL,04H ROL AL, CL • It can also be used to rotate the bit into CF which can be checked later for a conditional jump. (JC or JNC)
  • 36. RCR (Rotate Right with Carry) Syntax :-- ROR destination, count •This instruction rotates the destination bit by bit to the right including the carry •The bit moved out of LSB is rotated into CF and the bit in CF is rotated into the MSB. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF
  • 37. BX CF 0 1 BX CF 0 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 • Operation Performed :-- – MSB LSB  CF • Example :-- – If CF = 0, BX = E6D3H – After RCR BX, 1 ; Rotate the contents of BX register by one towards right through carry RCR (Rotate Right with Carry)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = 7369H
  • 38. • Example :-- – If CF = 0, BH = 54H – MOV CL, 02 ; Load CL register for the count RCR BH, CL ; Rotate the contents of BH register by twice towards right through carry RCR (Rotate Right with Carry)Cntd.. 0 0 0 1 0 1 0 1 BH CF 0 0 0 0 1 0 1 0 1 0 0 0 0 1 0 1 0 1 0 BH = 15H with CF = 0
  • 39. RCL (Rotate Left with Carry) Syntax :-- RCL destination, count •This instruction rotates the destination bit by bit to the left including the carry •The bit moved out of MSB is rotated into CF and the bit in CF is rotated into the LSB. •The count can be either 1 or specified by CL register. •The destination can be a byte or a word in register or a memory location, but not an immediate data. •Flags affected : OF ,CF
  • 40. CF BX 0 1 CF BX 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0 • Operation Performed :-- – CF MSB LSB • Example :-- – If CF = 0, BX = E6D3H – After RCL BX, 1 ; Rotate the contents of BX register by one towards left through carry RCL (Rotate Left with Carry)Cntd.. 1 1 1 0 0 1 1 0 1 1 0 1 0 0 1 1 BX = CDA6H
  • 41. • Example :-- – If CF = 0, BH = 54H – MOV CL, 02 ; Load CL register for the count RCL BH, CL ; Rotate the contents of BH register by twice towards Left through carry RCL (Rotate Left with Carry)Cntd.. 0 1 0 1 0 0 0 0 CF BH 0 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 0 0 BH = 50H with CF = 1