SlideShare a Scribd company logo
1 of 21
ARITHMETIC LOGIC
INSTRUCTIONS
IRFAN.ANJUM@UCP.EDU.
PK
LOGICAL INSTRUCTIONS
• NOT instruction
• AND instruction
• OR instruction
• XOR instruction
• Test instruction
TRUTH TABLE
3
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
SYNTAX
• AND destination, source
• OR destination, source
• XOR destination, source
• NOT destination
• Destination
• Result is stored in destination
• Can be a Register or Memory Location
• Source:
May be a Constant, Register or Memory Location
• Source and destination can not be memory operand
in single instruction.
4
AND INSTRUCTION-EXAMPLE
MOV AL,0xAA
AND AL, 0xF0
1010 0000
1010 1010
1111 0000
OR INSTRUCTION-EXAMPLE
MOV AL,0xAA
OR AL,0xF0
1010 1010
1111 0000
1111 1010
XOR INSTRUCTION-EXAMPLE
7
MOV AL,0xAA
XOR AL, 0xF0
0101 1010
1010 1010
1111 0000
EFFECTS ON FLAGS
 SF,ZF,PF gets set or reset depending
upon the result produced.
 AF is undefined
 CF,OF = 0
8
NOT INSTRUCTION-EXAMPLE
• Performs the one’s complement operation on the
destination
MOV AX, 0X00FF; AX=0000 0000 1111 1111
NOT AX; AX=1111 1111 0000 0000
• Doesn’t effect any flag.
9
MASK OPERATIONS
• To modify only selective bits in destination, we construct
a source bit pattern known as MASK
To choose mask, use following properties:
• b AND 1 = b (Unchanged)
• b AND 0 = 0 (Clear)
• b OR 1 = 1 (Set)
• b OR 0 = b (Unchanged)
• b XOR 0 = b (Unchanged)
• b XOR 1 = b’ (Complement)
10
MASK OPERATIONS-CLEAR
11
–
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.
EXAMPLE
• Task: Clear the sign bit of AL while leaving
the other bits unchanged?
• Solution:
AND AL,7Fh
Where 7Fh (0111 1111) is the mask.
12
MASK OPERATIONS-SET
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.
13
EXAMPLE:
• Set the MSB and LSB of AL while
preserving the other bits?
• Solution:
OR AL,81h
Where 81h (1000 0001) is the mask.
14
MASK OPERATIONS-
COMPLEMENT
15
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.
EXAMPLE
16
• Change the sign bit of DX?
• Solution:
XOR DX,8000h
Where 80h ( 1000 0000 ) is the mask.
CLEARING A REGISTER-
EFFICIENT WAY TO IT
17
;Takes 3 bytes in memory
; Takes 2 bytes
MOV AX,0
OR
SUB AX,AX
OR
XOR AX,AX
; Takes 2 bytes
Choose operation wisely; Above three
instructions does the same operation;
Initialize register value to ZERO but takes
different bytes in memory.
TESTING A REGISTER
FOR ZERO:
18
• CMP CX,0
• This instruction is same like :
• OR CX,CX
• In both instructions, ZF becomes 1 if CX is 0
• CMP instruction takes three bytes in
memory whereas OR instruction with
register operands takes two bytes and
destination is also unchanged.
CHECK A SPECIFIC BIT
STATUS
For example, you want to check the
status of 7th bit in a 16-bit register, how
to do that?
AND instruction?
AND ax, 0080h;
If 7th bit is zero, zero flag will be set
otherwise zero flag will be reset to zero.
Any problem with this instruction?
It changes destination register.
TEST INSTRUCTION
Test instruction works like AND
instruction
With the difference that this
instruction only updates flags
without changing the destination.
Syntax
Test destination, source
Destination can be register/memory
Source can be register/memory/immediate.
TEST INSTRUCTION-
APPLICATION
Can be used to check the status of one or
more specific bits
For example, if you are required to check the
status of 7th bit in a 16-bit register, you can
write
Test ax, 0x0080;
ZF will be set if 7th bit in AX is zero. ZF will be
zero if 7th bit in AX is 1.
Only ZF is updated keeping ax unchanged.

More Related Content

What's hot

Addressing Modes Of 8086
Addressing Modes Of 8086Addressing Modes Of 8086
Addressing Modes Of 8086Ikhlas Rahman
 
Types of instructions
Types of instructionsTypes of instructions
Types of instructionsihsanjamil
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionDheeraj Suri
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086Dr. AISHWARYA N
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instructionkashif Shafqat
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086saurav kumar
 
Clock-8086 bus cycle
Clock-8086 bus cycleClock-8086 bus cycle
Clock-8086 bus cycleRani Rahul
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086John Cutajar
 
15CS44 MP & MC Module 1
15CS44 MP & MC Module 115CS44 MP & MC Module 1
15CS44 MP & MC Module 1RLJIT
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copymkazree
 
Memory mapped I/O and Isolated I/O
Memory mapped I/O and Isolated I/OMemory mapped I/O and Isolated I/O
Memory mapped I/O and Isolated I/OBharat Kharbanda
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 

What's hot (20)

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
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction description
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Logic, shift and rotate instruction
Logic, shift and rotate instructionLogic, shift and rotate instruction
Logic, shift and rotate instruction
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Clock-8086 bus cycle
Clock-8086 bus cycleClock-8086 bus cycle
Clock-8086 bus cycle
 
Assembly language 8086
Assembly language 8086Assembly language 8086
Assembly language 8086
 
8086 microprocessor lab manual
8086 microprocessor lab manual8086 microprocessor lab manual
8086 microprocessor lab manual
 
15CS44 MP & MC Module 1
15CS44 MP & MC Module 115CS44 MP & MC Module 1
15CS44 MP & MC Module 1
 
Chp6 assembly language programming for pic copy
Chp6 assembly language programming for pic   copyChp6 assembly language programming for pic   copy
Chp6 assembly language programming for pic copy
 
Memory mapped I/O and Isolated I/O
Memory mapped I/O and Isolated I/OMemory mapped I/O and Isolated I/O
Memory mapped I/O and Isolated I/O
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8086 instruction set
8086 instruction set8086 instruction set
8086 instruction set
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
8086 String Instructions.pdf
8086 String Instructions.pdf8086 String Instructions.pdf
8086 String Instructions.pdf
 
Microoperations
MicrooperationsMicrooperations
Microoperations
 

Similar to Arithmetic Logic Instructions

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
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptxNishatNishu5
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptssuser2b759d
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructionsRobert Almazan
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxishitasabrincse
 
Conditional Processing Boolean and Comparison Instructions-converted.pptx
Conditional Processing Boolean and Comparison Instructions-converted.pptxConditional Processing Boolean and Comparison Instructions-converted.pptx
Conditional Processing Boolean and Comparison Instructions-converted.pptxJawadHaider36
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptxHebaEng
 

Similar to Arithmetic Logic Instructions (20)

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,...
 
Boolean and comparison_instructions
Boolean and comparison_instructionsBoolean and comparison_instructions
Boolean and comparison_instructions
 
Microprocessor.pptx
Microprocessor.pptxMicroprocessor.pptx
Microprocessor.pptx
 
instruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.pptinstruction-set-of-8086-mr-binu-joy3.ppt
instruction-set-of-8086-mr-binu-joy3.ppt
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
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
 
Arithmetic instructions
Arithmetic instructionsArithmetic instructions
Arithmetic instructions
 
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
 
Assembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptxAssembly Lab Sheet 5 About Status of Flag Register.pptx
Assembly Lab Sheet 5 About Status of Flag Register.pptx
 
8086inst logical
8086inst logical8086inst logical
8086inst logical
 
Conditional Processing Boolean and Comparison Instructions-converted.pptx
Conditional Processing Boolean and Comparison Instructions-converted.pptxConditional Processing Boolean and Comparison Instructions-converted.pptx
Conditional Processing Boolean and Comparison Instructions-converted.pptx
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
 
Uc 2(vii)
Uc 2(vii)Uc 2(vii)
Uc 2(vii)
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Chapt 06
Chapt 06Chapt 06
Chapt 06
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 

More from Irfan Anjum

DLD Lec 8 multiplexers.pptx
DLD Lec 8 multiplexers.pptxDLD Lec 8 multiplexers.pptx
DLD Lec 8 multiplexers.pptxIrfan Anjum
 
Control hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxControl hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxIrfan Anjum
 
BitCoin Price Predictor.pptx
BitCoin Price Predictor.pptxBitCoin Price Predictor.pptx
BitCoin Price Predictor.pptxIrfan Anjum
 
Kalman filter partilce tracking
Kalman filter partilce trackingKalman filter partilce tracking
Kalman filter partilce trackingIrfan Anjum
 
Report kalman filtering
Report kalman filteringReport kalman filtering
Report kalman filteringIrfan Anjum
 
Moore and Mealy machines
Moore and Mealy machinesMoore and Mealy machines
Moore and Mealy machinesIrfan Anjum
 

More from Irfan Anjum (7)

DLD Lec 8 multiplexers.pptx
DLD Lec 8 multiplexers.pptxDLD Lec 8 multiplexers.pptx
DLD Lec 8 multiplexers.pptx
 
Lec 04 DLD.pptx
Lec 04 DLD.pptxLec 04 DLD.pptx
Lec 04 DLD.pptx
 
Control hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptxControl hazards MIPS pipeline.pptx
Control hazards MIPS pipeline.pptx
 
BitCoin Price Predictor.pptx
BitCoin Price Predictor.pptxBitCoin Price Predictor.pptx
BitCoin Price Predictor.pptx
 
Kalman filter partilce tracking
Kalman filter partilce trackingKalman filter partilce tracking
Kalman filter partilce tracking
 
Report kalman filtering
Report kalman filteringReport kalman filtering
Report kalman filtering
 
Moore and Mealy machines
Moore and Mealy machinesMoore and Mealy machines
Moore and Mealy machines
 

Recently uploaded

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

Arithmetic Logic Instructions

  • 2. LOGICAL INSTRUCTIONS • NOT instruction • AND instruction • OR instruction • XOR instruction • Test instruction
  • 3. TRUTH TABLE 3 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
  • 4. SYNTAX • AND destination, source • OR destination, source • XOR destination, source • NOT destination • Destination • Result is stored in destination • Can be a Register or Memory Location • Source: May be a Constant, Register or Memory Location • Source and destination can not be memory operand in single instruction. 4
  • 5. AND INSTRUCTION-EXAMPLE MOV AL,0xAA AND AL, 0xF0 1010 0000 1010 1010 1111 0000
  • 6. OR INSTRUCTION-EXAMPLE MOV AL,0xAA OR AL,0xF0 1010 1010 1111 0000 1111 1010
  • 7. XOR INSTRUCTION-EXAMPLE 7 MOV AL,0xAA XOR AL, 0xF0 0101 1010 1010 1010 1111 0000
  • 8. EFFECTS ON FLAGS  SF,ZF,PF gets set or reset depending upon the result produced.  AF is undefined  CF,OF = 0 8
  • 9. NOT INSTRUCTION-EXAMPLE • Performs the one’s complement operation on the destination MOV AX, 0X00FF; AX=0000 0000 1111 1111 NOT AX; AX=1111 1111 0000 0000 • Doesn’t effect any flag. 9
  • 10. MASK OPERATIONS • To modify only selective bits in destination, we construct a source bit pattern known as MASK To choose mask, use following properties: • b AND 1 = b (Unchanged) • b AND 0 = 0 (Clear) • b OR 1 = 1 (Set) • b OR 0 = b (Unchanged) • b XOR 0 = b (Unchanged) • b XOR 1 = b’ (Complement) 10
  • 11. MASK OPERATIONS-CLEAR 11 – 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.
  • 12. EXAMPLE • Task: Clear the sign bit of AL while leaving the other bits unchanged? • Solution: AND AL,7Fh Where 7Fh (0111 1111) is the mask. 12
  • 13. MASK OPERATIONS-SET 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. 13
  • 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. 14
  • 15. MASK OPERATIONS- COMPLEMENT 15 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.
  • 16. EXAMPLE 16 • Change the sign bit of DX? • Solution: XOR DX,8000h Where 80h ( 1000 0000 ) is the mask.
  • 17. CLEARING A REGISTER- EFFICIENT WAY TO IT 17 ;Takes 3 bytes in memory ; Takes 2 bytes MOV AX,0 OR SUB AX,AX OR XOR AX,AX ; Takes 2 bytes Choose operation wisely; Above three instructions does the same operation; Initialize register value to ZERO but takes different bytes in memory.
  • 18. TESTING A REGISTER FOR ZERO: 18 • CMP CX,0 • This instruction is same like : • OR CX,CX • In both instructions, ZF becomes 1 if CX is 0 • CMP instruction takes three bytes in memory whereas OR instruction with register operands takes two bytes and destination is also unchanged.
  • 19. CHECK A SPECIFIC BIT STATUS For example, you want to check the status of 7th bit in a 16-bit register, how to do that? AND instruction? AND ax, 0080h; If 7th bit is zero, zero flag will be set otherwise zero flag will be reset to zero. Any problem with this instruction? It changes destination register.
  • 20. TEST INSTRUCTION Test instruction works like AND instruction With the difference that this instruction only updates flags without changing the destination. Syntax Test destination, source Destination can be register/memory Source can be register/memory/immediate.
  • 21. TEST INSTRUCTION- APPLICATION Can be used to check the status of one or more specific bits For example, if you are required to check the status of 7th bit in a 16-bit register, you can write Test ax, 0x0080; ZF will be set if 7th bit in AX is zero. ZF will be zero if 7th bit in AX is 1. Only ZF is updated keeping ax unchanged.