SlideShare a Scribd company logo
Presentation Title
Your company information
1
Kashifshafqat25@yahoo.com
•Logic, Shift, and
Rotate
inStRuctionS
2
Kashifshafqat25@yahoo.com
pReSented
by
kaShif Shafqat
kaShifShafqat25@yahoo.com
3
Kashifshafqat25@yahoo.com
Logic inStRuction
• To manipulate individual bits
• Binary Value 0 treated as false
• Binary Value 1 treated as true
• AND
• OR
• XOR
• NOT
• TEST
4
Kashifshafqat25@yahoo.com
tRuth tabLe
a b a AND b a OR b a XOR b
0 0 0 0 0
0 1 0 1 1
1 0 0 1 1
1 1 1 1 0
a NOT a
0 1
1 0
5
Kashifshafqat25@yahoo.com
exampLeS
• AND
1010 1010
1111 0000
1010 0000
• OR
1010 1010
1111 0000
1111 1010
6
Kashifshafqat25@yahoo.com
• XOR
1010 1010
1111 0000
0101 1010
• NOT
1010 1010
0101 0101
7
Kashifshafqat25@yahoo.com
Syntax
AND destination,source
OR destination,source
XOR destination,source
• Destination:
• Store result
• Can be a Register or Memory Location
• Source:
• May be a Constant,Register or Memory Location
• Memory to memory operation not allowed
8
Kashifshafqat25@yahoo.com
EffEcts on flags
• SF,ZF,PF reflects the result
• AF is undefined
• CF,OF = 0
9
Kashifshafqat25@yahoo.com
MasK
• To modify only selective bits in destination, we construct
a source bit pattern known as MASK
• T o choose mask , use following properties:
• b AND 1 = b
• b AND 0 = 0
• b OR 1 = 1
• b OR 0 = b
• b XOR 0 = b
• b AND 1 = ~b ( complement of b)
• Where b represents a bit (0 or 1)
10
Kashifshafqat25@yahoo.com
contd…
1. The AND Instruction:
– May be used to clear specific destination bits
while preventing the others.
– A 0 mask bit clears the corresponding
destination bit.
– A 1 mask bit preserves the corresponding
destination bit.
11Kashifshafqat25@yahoo.com
ExaMplE:
• Clear the sign bit of AL while leaving the
other bits unchanged.
Solution:
AND AL,7Fh
Where 7Fh (0111 1111) is the mask.
12Kashifshafqat25@yahoo.com
contd…
 The OR Instruction:
 May be used to SET specific destination bits
while preventing the others.
– A 1 mask bit sets the corresponding
destination bit.
– A 0 mask bit preserves the corresponding
destination bit.
13Kashifshafqat25@yahoo.com
ExaMplE:
• Set the MSB and LSB of AL while
preserving the other bits.
• Solution:
OR AL,81h
Where 81h (1000 0001) is the mask.
14Kashifshafqat25@yahoo.com
contd…
 The XOR Instruction:
– May be used to Complement specific
destination bits while preventing the others.
– A 1 mask bit complements the
corresponding destination bit.
– A 0 mask bit preserves the corresponding
destination bit.
15Kashifshafqat25@yahoo.com
ExaMplE
• Change the sign bit of DX.
• Solution:
XOR DX,8000h
Where 80h ( 1000 0000 ) is the mask.
16Kashifshafqat25@yahoo.com
Clearing a register:
MOV AX,0 ;machine code 3 bytes
OR
SUB AX,AX ;machine code 2 bytes
OR
XOR AX,AX ;machine code 2 bytes
17Kashifshafqat25@yahoo.com
testing a register FOr ZerO:
•
CMP CX,0
Is same like :
OR CX,CX
;Sets ZF=1 if CX is 0
18Kashifshafqat25@yahoo.com
nOt instruCtiOn
• Performs the one’s complement operation
on the destination.
• Syntax:
• NOT destination
• No effects on flags
• example:
Complement the bit in AX:
NOT AX
19Kashifshafqat25@yahoo.com
sHiFt anD rOtate instruCtiOn:
• Shift the bits in destination operand by one
or more positions either to the left or right.
• sHiFt: Bit shifted out is lost
• rOtate: Bit shifted out from one end of
the destination operand is put back on the
other end.
• syntax:
• OPCODE destination,1
• OPCODE destination,CL
20Kashifshafqat25@yahoo.com
sHiFt instruCtiOn:
 SHL Instruction (left shift)
 SHR Instruction (right shift)
 SAL Instruction (shift Arithmetic left)
 SAR Instruction (shift Arithmetic right)
 ROL Instruction (shift left)
 ROR Instruction (shift right)
 RCL Instruction (shift Carry left)
 RCR Instruction (shift Carry Right)
21Kashifshafqat25@yahoo.com
sHl instruCtiOn (leFt sHiFt)
• The SHL (shift left) instruction performs a
logical left shift on the destination
operand, filling the lowest bit with 0.
• Operand types:
SHL reg,imm8
SHL mem,imm8
SHL reg,CL
SHL mem,CL
22Kashifshafqat25@yahoo.com
sHr instruCtiOn (rigHt sHiFt)
• The SHR (shift right) instruction performs
a logical right shift on the destination
operand. The highest bit position is filled
with a zero.
mov dl,80
shr dl,1 ; DL = 40
shr dl,2 ; DL = 10
23Kashifshafqat25@yahoo.com
sal anD sar instruCtiOns
• SAL (shift arithmetic left) is identical to SHL.
• SAR (shift arithmetic right) performs a right
arithmetic shift on the destination operand.
mov dl,-80
sar dl,1 ; DL = -40
sar dl,2 ; DL = -10
24Kashifshafqat25@yahoo.com
ROL InstRuctIOn (shIft Left)
• ROL (rotate) shifts each bit to the left
• The highest bit is copied into both the
Carry flag and into the lowest bit
• No bits are lost
mov al,11110000b
rol al,1 ; AL = 11100001b
mov dl,3Fh
rol dl,4 ; DL = F3h
25Kashifshafqat25@yahoo.com
ROR InstRuctIOn (shIft RIght)
• ROR (rotate right) shifts each bit to the right
• The lowest bit is copied into both the Carry
flag and into the highest bit
• No bits are lost
mov al,11110000b
ror al,1 ; AL = 01111000b
mov dl,3Fh
ror dl,4 ; DL = F3h
26Kashifshafqat25@yahoo.com
RcL InstRuctIOn (shIft caRRy Left)
• RCL (rotate carry left) shifts each bit to the left
• Copies the Carry flag to the least significant bit
• Copies the most significant bit to the Carry flag
clc ; CF = 0
mov bl,88h ; CF,BL = 0 10001000b
rcl bl,1 ; CF,BL = 1 00010000b
rcl bl,1 ; CF,BL = 0 00100001b
27Kashifshafqat25@yahoo.com
RcR InstRuctIOn (shIft caRRy RIght)
• RCR (rotate carry right) shifts each bit to the right
• Copies the Carry flag to the most significant bit
• Copies the least significant bit to the Carry flag
stc ; CF = 1
mov ah,10h ; CF,AH = 00010000 1
rcr ah,1 ; CF,AH = 10001000 0
28
Kashifshafqat25@yahoo.com
29
Kashifshafqat25@yahoo.com

More Related Content

PPT
Logic, shift and rotate instruction
PPTX
Logical, Shift, and Rotate Instruction
PDF
Instruction types
PPT
Copy of 8086inst logical
PPTX
Copy of 8086inst logical
PDF
8086 instruction set with types
PPTX
Winter training,Readymade Projects,Buy Projects,Corporate Training
PPT
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...
Logic, shift and rotate instruction
Logical, Shift, and Rotate Instruction
Instruction types
Copy of 8086inst logical
Copy of 8086inst logical
8086 instruction set with types
Winter training,Readymade Projects,Buy Projects,Corporate Training
Lec15 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Re...

What's hot (7)

PPTX
Describe the register
PPTX
Microoperations
PDF
PPT
Mba admission in india
PPTX
New microsoft office power point presentation
PPT
Lec16 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Fi...
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Describe the register
Microoperations
Mba admission in india
New microsoft office power point presentation
Lec16 Intro to Computer Engineering by Hsien-Hsin Sean Lee Georgia Tech -- Fi...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Ad

Similar to Logic, shift and rotate instruction (20)

PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
PPTX
Arithmetic instructions
PPTX
8086inst logical
PPTX
Chap3 8086 logical
PPTX
Chapter3 8086inst logical 2
PPTX
[ASM]Lab7
PPTX
Arithmetic and logical instructions set
PPT
Data manipulation instructions
PPT
Data manipulation instructions
PPT
Cha_2b_8086-Instruction-set-ppt microprocessor
PDF
Unit 3 – assembly language programming
PPTX
Logical instructions (and, or, xor, not, test)
PPTX
MPMC-3.pptxMicroprocessor and microcontroller programming
PDF
Assembly language-lab9
PPT
Unit 2 8086 Instruction set.ppt notes good
PPT
8086-instruction-set-ppt
PPT
Al2ed chapter9
PDF
Computer Organization & Assembly Language Logic Instructions
PPT
Computer Organization & Assembly Language Logic Instructions
PDF
Arthimatic_logical like the subtraction and additional.pdf
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Arithmetic instructions
8086inst logical
Chap3 8086 logical
Chapter3 8086inst logical 2
[ASM]Lab7
Arithmetic and logical instructions set
Data manipulation instructions
Data manipulation instructions
Cha_2b_8086-Instruction-set-ppt microprocessor
Unit 3 – assembly language programming
Logical instructions (and, or, xor, not, test)
MPMC-3.pptxMicroprocessor and microcontroller programming
Assembly language-lab9
Unit 2 8086 Instruction set.ppt notes good
8086-instruction-set-ppt
Al2ed chapter9
Computer Organization & Assembly Language Logic Instructions
Computer Organization & Assembly Language Logic Instructions
Arthimatic_logical like the subtraction and additional.pdf
Ad

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
top salesforce developer skills in 2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
L1 - Introduction to python Backend.pptx
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
history of c programming in notes for students .pptx
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
System and Network Administration Chapter 2
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
medical staffing services at VALiNTRY
PPTX
ai tools demonstartion for schools and inter college
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
top salesforce developer skills in 2025.pdf
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
L1 - Introduction to python Backend.pptx
Design an Analysis of Algorithms II-SECS-1021-03
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PTS Company Brochure 2025 (1).pdf.......
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
history of c programming in notes for students .pptx
Navsoft: AI-Powered Business Solutions & Custom Software Development
Which alternative to Crystal Reports is best for small or large businesses.pdf
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
System and Network Administration Chapter 2
Upgrade and Innovation Strategies for SAP ERP Customers
Design an Analysis of Algorithms I-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
medical staffing services at VALiNTRY
ai tools demonstartion for schools and inter college

Logic, shift and rotate instruction

  • 1. Presentation Title Your company information 1 Kashifshafqat25@yahoo.com
  • 4. Logic inStRuction • To manipulate individual bits • Binary Value 0 treated as false • Binary Value 1 treated as true • AND • OR • XOR • NOT • TEST 4 Kashifshafqat25@yahoo.com
  • 5. tRuth tabLe a b a AND b a OR b a XOR b 0 0 0 0 0 0 1 0 1 1 1 0 0 1 1 1 1 1 1 0 a NOT a 0 1 1 0 5 Kashifshafqat25@yahoo.com
  • 6. exampLeS • AND 1010 1010 1111 0000 1010 0000 • OR 1010 1010 1111 0000 1111 1010 6 Kashifshafqat25@yahoo.com
  • 7. • XOR 1010 1010 1111 0000 0101 1010 • NOT 1010 1010 0101 0101 7 Kashifshafqat25@yahoo.com
  • 8. Syntax AND destination,source OR destination,source XOR destination,source • Destination: • Store result • Can be a Register or Memory Location • Source: • May be a Constant,Register or Memory Location • Memory to memory operation not allowed 8 Kashifshafqat25@yahoo.com
  • 9. EffEcts on flags • SF,ZF,PF reflects the result • AF is undefined • CF,OF = 0 9 Kashifshafqat25@yahoo.com
  • 10. MasK • To modify only selective bits in destination, we construct a source bit pattern known as MASK • T o choose mask , use following properties: • b AND 1 = b • b AND 0 = 0 • b OR 1 = 1 • b OR 0 = b • b XOR 0 = b • b AND 1 = ~b ( complement of b) • Where b represents a bit (0 or 1) 10 Kashifshafqat25@yahoo.com
  • 11. contd… 1. The AND Instruction: – May be used to clear specific destination bits while preventing the others. – A 0 mask bit clears the corresponding destination bit. – A 1 mask bit preserves the corresponding destination bit. 11Kashifshafqat25@yahoo.com
  • 12. ExaMplE: • Clear the sign bit of AL while leaving the other bits unchanged. Solution: AND AL,7Fh Where 7Fh (0111 1111) is the mask. 12Kashifshafqat25@yahoo.com
  • 13. contd…  The OR Instruction:  May be used to SET specific destination bits while preventing the others. – A 1 mask bit sets the corresponding destination bit. – A 0 mask bit preserves the corresponding destination bit. 13Kashifshafqat25@yahoo.com
  • 14. ExaMplE: • Set the MSB and LSB of AL while preserving the other bits. • Solution: OR AL,81h Where 81h (1000 0001) is the mask. 14Kashifshafqat25@yahoo.com
  • 15. contd…  The XOR Instruction: – May be used to Complement specific destination bits while preventing the others. – A 1 mask bit complements the corresponding destination bit. – A 0 mask bit preserves the corresponding destination bit. 15Kashifshafqat25@yahoo.com
  • 16. ExaMplE • Change the sign bit of DX. • Solution: XOR DX,8000h Where 80h ( 1000 0000 ) is the mask. 16Kashifshafqat25@yahoo.com
  • 17. Clearing a register: MOV AX,0 ;machine code 3 bytes OR SUB AX,AX ;machine code 2 bytes OR XOR AX,AX ;machine code 2 bytes 17Kashifshafqat25@yahoo.com
  • 18. testing a register FOr ZerO: • CMP CX,0 Is same like : OR CX,CX ;Sets ZF=1 if CX is 0 18Kashifshafqat25@yahoo.com
  • 19. nOt instruCtiOn • Performs the one’s complement operation on the destination. • Syntax: • NOT destination • No effects on flags • example: Complement the bit in AX: NOT AX 19Kashifshafqat25@yahoo.com
  • 20. sHiFt anD rOtate instruCtiOn: • Shift the bits in destination operand by one or more positions either to the left or right. • sHiFt: Bit shifted out is lost • rOtate: Bit shifted out from one end of the destination operand is put back on the other end. • syntax: • OPCODE destination,1 • OPCODE destination,CL 20Kashifshafqat25@yahoo.com
  • 21. sHiFt instruCtiOn:  SHL Instruction (left shift)  SHR Instruction (right shift)  SAL Instruction (shift Arithmetic left)  SAR Instruction (shift Arithmetic right)  ROL Instruction (shift left)  ROR Instruction (shift right)  RCL Instruction (shift Carry left)  RCR Instruction (shift Carry Right) 21Kashifshafqat25@yahoo.com
  • 22. sHl instruCtiOn (leFt sHiFt) • The SHL (shift left) instruction performs a logical left shift on the destination operand, filling the lowest bit with 0. • Operand types: SHL reg,imm8 SHL mem,imm8 SHL reg,CL SHL mem,CL 22Kashifshafqat25@yahoo.com
  • 23. sHr instruCtiOn (rigHt sHiFt) • The SHR (shift right) instruction performs a logical right shift on the destination operand. The highest bit position is filled with a zero. mov dl,80 shr dl,1 ; DL = 40 shr dl,2 ; DL = 10 23Kashifshafqat25@yahoo.com
  • 24. sal anD sar instruCtiOns • SAL (shift arithmetic left) is identical to SHL. • SAR (shift arithmetic right) performs a right arithmetic shift on the destination operand. mov dl,-80 sar dl,1 ; DL = -40 sar dl,2 ; DL = -10 24Kashifshafqat25@yahoo.com
  • 25. ROL InstRuctIOn (shIft Left) • ROL (rotate) shifts each bit to the left • The highest bit is copied into both the Carry flag and into the lowest bit • No bits are lost mov al,11110000b rol al,1 ; AL = 11100001b mov dl,3Fh rol dl,4 ; DL = F3h 25Kashifshafqat25@yahoo.com
  • 26. ROR InstRuctIOn (shIft RIght) • ROR (rotate right) shifts each bit to the right • The lowest bit is copied into both the Carry flag and into the highest bit • No bits are lost mov al,11110000b ror al,1 ; AL = 01111000b mov dl,3Fh ror dl,4 ; DL = F3h 26Kashifshafqat25@yahoo.com
  • 27. RcL InstRuctIOn (shIft caRRy Left) • RCL (rotate carry left) shifts each bit to the left • Copies the Carry flag to the least significant bit • Copies the most significant bit to the Carry flag clc ; CF = 0 mov bl,88h ; CF,BL = 0 10001000b rcl bl,1 ; CF,BL = 1 00010000b rcl bl,1 ; CF,BL = 0 00100001b 27Kashifshafqat25@yahoo.com
  • 28. RcR InstRuctIOn (shIft caRRy RIght) • RCR (rotate carry right) shifts each bit to the right • Copies the Carry flag to the most significant bit • Copies the least significant bit to the Carry flag stc ; CF = 1 mov ah,10h ; CF,AH = 00010000 1 rcr ah,1 ; CF,AH = 10001000 0 28 Kashifshafqat25@yahoo.com