SlideShare a Scribd company logo
1 of 29
Presentation Title
Your company information
1
Kashifshafqat25@yahoo.com
•Logic, Shift, and
Rotate
inStRuctionS
2
Kashifshafqat25@yahoo.com
pReSented
by
kaShif Shafqat(6905)
and
meeR jaLaL khan
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

What's hot

Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorAshita Agrawal
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...warda aziz
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085techbed
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086techbed
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1warda aziz
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programmingKartik Sharma
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086aviban
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language Usman Bin Saad
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Bilal Amjad
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operationsSanjeev Patel
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 MicroprocessorNahian Ahmed
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...Bilal Amjad
 

What's hot (20)

Instruction Set of 8086 Microprocessor
Instruction Set of 8086 MicroprocessorInstruction Set of 8086 Microprocessor
Instruction Set of 8086 Microprocessor
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
 
Assembly Language Programming Of 8085
Assembly Language Programming Of 8085Assembly Language Programming Of 8085
Assembly Language Programming Of 8085
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
8086 Instruction set
8086 Instruction set8086 Instruction set
8086 Instruction set
 
Assembly Langauge Chap 1
Assembly Langauge Chap 1Assembly Langauge Chap 1
Assembly Langauge Chap 1
 
Lecture2
Lecture2Lecture2
Lecture2
 
Unit 3 – assembly language programming
Unit 3 – assembly language programmingUnit 3 – assembly language programming
Unit 3 – assembly language programming
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Stack and its usage in assembly language
Stack and its usage in assembly language Stack and its usage in assembly language
Stack and its usage in assembly language
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
stack in assembally language
stack in assembally languagestack in assembally language
stack in assembally language
 
Logical and shift micro operations
Logical and shift micro operationsLogical and shift micro operations
Logical and shift micro operations
 
Presentation on 8086 Microprocessor
Presentation  on   8086 MicroprocessorPresentation  on   8086 Microprocessor
Presentation on 8086 Microprocessor
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 

Viewers also liked

Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
8254 Programmable Interval Timer by vijay
8254 Programmable Interval Timer by vijay8254 Programmable Interval Timer by vijay
8254 Programmable Interval Timer by vijayVijay Kumar
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with typesRavinder Rautela
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 80869840596838
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controllerTech_MX
 

Viewers also liked (7)

Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
Lec14
Lec14Lec14
Lec14
 
8254 Programmable Interval Timer by vijay
8254 Programmable Interval Timer by vijay8254 Programmable Interval Timer by vijay
8254 Programmable Interval Timer by vijay
 
8086 instruction set with types
8086 instruction set with types8086 instruction set with types
8086 instruction set with types
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
8237 dma controller
8237 dma controller8237 dma controller
8237 dma controller
 

Similar to Logic, shift and rotate instruction

Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instructionkashif Shafqat
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructionsRobert Almazan
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions setRobert Almazan
 
5 LogicAndShiftInstructions.pdf
5 LogicAndShiftInstructions.pdf5 LogicAndShiftInstructions.pdf
5 LogicAndShiftInstructions.pdfRoopaPatil24
 
Reverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesReverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesSmartDec
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptVEERA BOOPATHY E
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperationsNitesh Singh
 
Symbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSymbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSaurabh Mehta
 
8086 programming guide programs samples and string permutations.pptx
8086 programming guide programs samples and string permutations.pptx8086 programming guide programs samples and string permutations.pptx
8086 programming guide programs samples and string permutations.pptxrularofclash69
 

Similar to Logic, shift and rotate instruction (20)

Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
Arithmetic and logical instructions set
Arithmetic and logical instructions setArithmetic and logical instructions set
Arithmetic and logical instructions set
 
Chapter3 8086inst logical 2
Chapter3 8086inst logical 2Chapter3 8086inst logical 2
Chapter3 8086inst logical 2
 
Chap3 8086 logical
Chap3 8086 logicalChap3 8086 logical
Chap3 8086 logical
 
8086inst logical
8086inst logical8086inst logical
8086inst logical
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
Copy of 8086inst logical
Copy of 8086inst logicalCopy of 8086inst logical
Copy of 8086inst logical
 
Instruction types
Instruction typesInstruction types
Instruction types
 
5 LogicAndShiftInstructions.pdf
5 LogicAndShiftInstructions.pdf5 LogicAndShiftInstructions.pdf
5 LogicAndShiftInstructions.pdf
 
[ASM]Lab7
[ASM]Lab7[ASM]Lab7
[ASM]Lab7
 
Logic Micro Operation
Logic Micro OperationLogic Micro Operation
Logic Micro Operation
 
Reverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machinesReverse engineering of binary programs for custom virtual machines
Reverse engineering of binary programs for custom virtual machines
 
FF and Latches.ppt
FF and Latches.pptFF and Latches.ppt
FF and Latches.ppt
 
13.ppt
13.ppt13.ppt
13.ppt
 
Number_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.pptNumber_Systems_and_Boolean_Algebra.ppt
Number_Systems_and_Boolean_Algebra.ppt
 
Logic microoperations
Logic microoperationsLogic microoperations
Logic microoperations
 
Symbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSymbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processor
 
8086 programming guide programs samples and string permutations.pptx
8086 programming guide programs samples and string permutations.pptx8086 programming guide programs samples and string permutations.pptx
8086 programming guide programs samples and string permutations.pptx
 
02-gates-w.pptx
02-gates-w.pptx02-gates-w.pptx
02-gates-w.pptx
 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxMaryGraceBautista27
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Celine George
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 

Recently uploaded (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
Science 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptxScience 7 Quarter 4 Module 2: Natural Resources.pptx
Science 7 Quarter 4 Module 2: Natural Resources.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17Field Attribute Index Feature in Odoo 17
Field Attribute Index Feature in Odoo 17
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 

Logic, shift and rotate instruction

  • 1. Presentation Title Your company information 1 Kashifshafqat25@yahoo.com
  • 3. pReSented by kaShif Shafqat(6905) and meeR jaLaL khan 3 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