SlideShare a Scribd company logo
3
Most read
4
Most read
6
Most read
Microprocessor & its Applications
Module 3 Continued……
Dr. Girisha G S
Dept. of CSE
SoE, DSU, Bengaluru
1
Agenda
• Logical Instructions
- AND, OR. XOR, NOT, NEG
• Shift Instructions
- SHL, SHR, SAR
2
BASIC LOGIC INSTRUCTIONS
Logical instructions :AND, OR, NOT, XOR
AND – Logical AND
Syntax:
AND Dest, Source ; Dest <- (Dest) & (Source)
Affected Flag: OF,SF,ZF,PF,CF
Examples:
AND BH, CL
AND AL,F1H
AND BX,3135H
AND CX,DX
AND AX,[DI]
- AND clears bits of a binary number - called masking
- An ASCII number can be converted to BCD by using AND to mask off the leftmost
four binary bit positions.
E.g. MOV BX,3135H ; BH=31H, BL=35H
AND BX,0F0FH ; BH= 01, BL=05H
3
OR – Logical OR
Syntax:
OR Dest, Source ; Dest <- (Dest) | (Source)
Affected Flag: OF,SF,ZF,PF,CF
Examples:
OR BH, CL
OR AL,F1H
OR BX,3135H
OR SI,DX
OR DX,[BX]
56H = 0101 0110
0FH = 0000 1111
5FH = 0101 1111
- OR instruction is used to set a particular bit in a register to 1(BitSetting).
4
XOR - Exclusive-OR
Syntax:
XOR Dest, Source; Des <- (Dest) Ꚛ (Source)
Examples:
XOR BH, CL
XOR SI,BX
XOR DX,[SI]
XOR CX,1000h
Affected Flag: OF,SF,ZF,PF,CF
- A common use for the Exclusive-OR instruction is to clear a register to zero
5
NOT - Logical NOT
Syntax:
NOT Dest;
Affected Flag: None
Examples:
NOT AL ; AL← Complements AL
; Before: AL=5CH=0101 1100
; After : AL=93H=1010 0011
NOT CH ; CH is one’s complemented
NOT TEMP ; The contents of data segment memory location TEMP is one’s complemented
NEG - Negate
- NEG two’s complements a number.
Syntax:
NEG Dest;
Examples:
NEG DL ;DL is 2’s complement. Assume Before Execution DL=03H =0000 0011
; After Execution DL= FDH = 1111 1101
NEG BX
Affected Flag: None
6
Shift Instructions: SHL, SHR, SAR
SHL/SAL – Shift Logical/Arithmetic Left
Syntax:
SHL Dest, Count;
Examples:
SHL AL,1 ; AL is logically shifted left 1 place
; Before: AL=03H
; After ; AL= 06H
SHL BL,CL
- A shift left always multiplies by 2 for each bit position shifted
CF
CF
LSB
MSB
7
SHR – Shift Logical Right
Syntax:
SHR Dest, Count;
Examples:
SHR AL,1 ; AL is logically shifted right 1 place
; Before: AL=04H
; After: AL=02H
SHR BL,CL
- a shift right always divides by 2 for each position
8
SAR – Shift Arithmetic Right
Syntax:
SAR Dest, Count;
Examples:
SAR AL,1; AL is shifted right 1 place
; Before: AL=04H
; After: AL=02H
SAR BL,CL
9

More Related Content

PPTX
Chap3 8086 logical
PDF
Lab lect03 arith_control
PDF
8086 instruction set
PDF
8086 instruction set
PPTX
Logical Instructions used in 8086 microprocessor
PDF
Ch06
PPT
Context free languages
PDF
Ch03
Chap3 8086 logical
Lab lect03 arith_control
8086 instruction set
8086 instruction set
Logical Instructions used in 8086 microprocessor
Ch06
Context free languages
Ch03

What's hot (19)

PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
PDF
HKG15-405: Redundant zero/sign-extension elimination in GCC
PDF
Ch04
PPTX
Chap3 8086 artithmetic
PPTX
8086 ins2 math
PPTX
Context free grammar
PPTX
Instruction sets of 8086
PPTX
CNF & Leftmost Derivation - Theory of Computation
PPTX
Microprocessor:stack,shifting,looping
PDF
PPT
Logic, shift and rotate instruction
PPTX
Assembly language (addition and subtraction)
PPTX
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
PDF
Ch02
PPTX
3.1,2,3 pushdown automata definition, moves &amp; id
ODP
Recursion and Functional Programming
PDF
Aho corasick-lecture
PPT
Context free grammar
PPTX
microcomputer architecture-Instruction formats
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
HKG15-405: Redundant zero/sign-extension elimination in GCC
Ch04
Chap3 8086 artithmetic
8086 ins2 math
Context free grammar
Instruction sets of 8086
CNF & Leftmost Derivation - Theory of Computation
Microprocessor:stack,shifting,looping
Logic, shift and rotate instruction
Assembly language (addition and subtraction)
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Ch02
3.1,2,3 pushdown automata definition, moves &amp; id
Recursion and Functional Programming
Aho corasick-lecture
Context free grammar
microcomputer architecture-Instruction formats
Ad

Similar to Logic instructions part 1 (20)

PPTX
Copy of 8086inst logical
PPT
Copy of 8086inst logical
PPTX
8086inst logical
PPTX
Chapter3 8086inst logical 2
PPT
Al2ed chapter9
PPTX
Arithmetic instructions
PPTX
Arithmetic and logical instructions set
PPT
MICROPROCESSOR INSTRUCTION SET OF 8085
PPT
instruction-set-of-8086-mr-binu-joy3.ppt
PPTX
8085 instruction set.pptx
PPTX
Logical, Shift, and Rotate Instruction
PPT
8086-instruction-set-ppt
PPT
Chap 3_2.ppt
PPT
Logic, shift and rotate instruction
PPT
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
PPT
Cha_2b_8086-Instruction-set-ppt microprocessor
PPTX
Microprocessors-based systems (under graduate course) Lecture 4 of 9
PPT
Instruction set Madha Insstitute of Engineering
PPT
Unit 2 8086 Instruction set.ppt notes good
Copy of 8086inst logical
Copy of 8086inst logical
8086inst logical
Chapter3 8086inst logical 2
Al2ed chapter9
Arithmetic instructions
Arithmetic and logical instructions set
MICROPROCESSOR INSTRUCTION SET OF 8085
instruction-set-of-8086-mr-binu-joy3.ppt
8085 instruction set.pptx
Logical, Shift, and Rotate Instruction
8086-instruction-set-ppt
Chap 3_2.ppt
Logic, shift and rotate instruction
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
Cha_2b_8086-Instruction-set-ppt microprocessor
Microprocessors-based systems (under graduate course) Lecture 4 of 9
Instruction set Madha Insstitute of Engineering
Unit 2 8086 Instruction set.ppt notes good
Ad

More from Dr. Girish GS (14)

PPTX
Unix- the process
PPTX
unix- Sort, uniq,tr,grep
PPTX
unix- the process states, zombies, running jobs in background
PPTX
Unix - Filters
PPTX
Customizing the unix environment
PPTX
File systems and inodes
PPTX
Basic regular expression, extended regular expression
PPTX
Loop instruction, controlling the flow of progam
PPTX
Bcd arithmetic instructions
PPTX
Bcd and ascii arithmetic instructions
PPTX
Ascii arithmetic instructions
PPT
Rotate instructions
PPTX
Program control instructions
PPTX
Memory interface
Unix- the process
unix- Sort, uniq,tr,grep
unix- the process states, zombies, running jobs in background
Unix - Filters
Customizing the unix environment
File systems and inodes
Basic regular expression, extended regular expression
Loop instruction, controlling the flow of progam
Bcd arithmetic instructions
Bcd and ascii arithmetic instructions
Ascii arithmetic instructions
Rotate instructions
Program control instructions
Memory interface

Recently uploaded (20)

PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
additive manufacturing of ss316l using mig welding
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
OOP with Java - Java Introduction (Basics)
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPT
Project quality management in manufacturing
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPT
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
DOCX
573137875-Attendance-Management-System-original
PPTX
UNIT 4 Total Quality Management .pptx
PDF
composite construction of structures.pdf
PDF
Digital Logic Computer Design lecture notes
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
CYBER-CRIMES AND SECURITY A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
additive manufacturing of ss316l using mig welding
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
OOP with Java - Java Introduction (Basics)
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Project quality management in manufacturing
Operating System & Kernel Study Guide-1 - converted.pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Model Code of Practice - Construction Work - 21102022 .pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Introduction, IoT Design Methodology, Case Study on IoT System for Weather Mo...
573137875-Attendance-Management-System-original
UNIT 4 Total Quality Management .pptx
composite construction of structures.pdf
Digital Logic Computer Design lecture notes
R24 SURVEYING LAB MANUAL for civil enggi
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks

Logic instructions part 1

  • 1. Microprocessor & its Applications Module 3 Continued…… Dr. Girisha G S Dept. of CSE SoE, DSU, Bengaluru 1
  • 2. Agenda • Logical Instructions - AND, OR. XOR, NOT, NEG • Shift Instructions - SHL, SHR, SAR 2
  • 3. BASIC LOGIC INSTRUCTIONS Logical instructions :AND, OR, NOT, XOR AND – Logical AND Syntax: AND Dest, Source ; Dest <- (Dest) & (Source) Affected Flag: OF,SF,ZF,PF,CF Examples: AND BH, CL AND AL,F1H AND BX,3135H AND CX,DX AND AX,[DI] - AND clears bits of a binary number - called masking - An ASCII number can be converted to BCD by using AND to mask off the leftmost four binary bit positions. E.g. MOV BX,3135H ; BH=31H, BL=35H AND BX,0F0FH ; BH= 01, BL=05H 3
  • 4. OR – Logical OR Syntax: OR Dest, Source ; Dest <- (Dest) | (Source) Affected Flag: OF,SF,ZF,PF,CF Examples: OR BH, CL OR AL,F1H OR BX,3135H OR SI,DX OR DX,[BX] 56H = 0101 0110 0FH = 0000 1111 5FH = 0101 1111 - OR instruction is used to set a particular bit in a register to 1(BitSetting). 4
  • 5. XOR - Exclusive-OR Syntax: XOR Dest, Source; Des <- (Dest) Ꚛ (Source) Examples: XOR BH, CL XOR SI,BX XOR DX,[SI] XOR CX,1000h Affected Flag: OF,SF,ZF,PF,CF - A common use for the Exclusive-OR instruction is to clear a register to zero 5
  • 6. NOT - Logical NOT Syntax: NOT Dest; Affected Flag: None Examples: NOT AL ; AL← Complements AL ; Before: AL=5CH=0101 1100 ; After : AL=93H=1010 0011 NOT CH ; CH is one’s complemented NOT TEMP ; The contents of data segment memory location TEMP is one’s complemented NEG - Negate - NEG two’s complements a number. Syntax: NEG Dest; Examples: NEG DL ;DL is 2’s complement. Assume Before Execution DL=03H =0000 0011 ; After Execution DL= FDH = 1111 1101 NEG BX Affected Flag: None 6
  • 7. Shift Instructions: SHL, SHR, SAR SHL/SAL – Shift Logical/Arithmetic Left Syntax: SHL Dest, Count; Examples: SHL AL,1 ; AL is logically shifted left 1 place ; Before: AL=03H ; After ; AL= 06H SHL BL,CL - A shift left always multiplies by 2 for each bit position shifted CF CF LSB MSB 7
  • 8. SHR – Shift Logical Right Syntax: SHR Dest, Count; Examples: SHR AL,1 ; AL is logically shifted right 1 place ; Before: AL=04H ; After: AL=02H SHR BL,CL - a shift right always divides by 2 for each position 8
  • 9. SAR – Shift Arithmetic Right Syntax: SAR Dest, Count; Examples: SAR AL,1; AL is shifted right 1 place ; Before: AL=04H ; After: AL=02H SAR BL,CL 9

Editor's Notes

  • #4: This instruction ANDs each bit in a source byte or word with the same numbered bit in a destination byte or word. The result is put in the specified destination. The content of the specified source is not changed. The source can be an immediate number, the content of a register, or the content of a memory location. The destination can be a register or a memory location. The source and the destination cannot both be memory locations. The AND operation is used for masking.We can set a particular bit in a register to 0 without changing other bits.
  • #5: This instruction ORs each bit in a source byte or word with the same numbered bit in a destination byte or word. The result is put in the specified destination. The content of the specified source is not changed. The source can be an immediate number, the content of a register, or the content of a memory location. The destination can be a register or a memory location. The source and destination cannot both be memory locations. OR instruction is used to set a particularbit in a register to 1(BitSetting).
  • #6: This instruction Exclusive-ORs each bit in a source byte or word with the same numbered bit in a destination byte or word. The result is put in the specified destination. The content of the specified source is not changed. The source can be an immediate number, the content of a register, or the content of a memory location. The destination can be a register or a memory location. The source and destination cannot both be memory locations. XOR is used to complement a particular bits (Bit Complementing).
  • #7: The NOT instruction inverts each bit (forms the 1’s complement) of a byte or word in the specified destination. The destination can be a register or a memory location. This instruction does not affect any flag. NOT is a logical inversion. NEG is an arithmetic inversion(2’scomplement) This instruction replaces the number in a destination with its 2’s complement. The destination can be a register or a memory location. It gives the same result as the invert each bit and add one
  • #8: SAL and SHL are two mnemonics for the same instruction. This instruction shifts each bit in the specified destination some number of bit positions to the left. As a bit is shifted out of the LSB operation, a 0 is put in the LSB position. The MSB will be shifted into CF. If you want to shift the operand by one bit position, you can specify this by putting a 1 in the count position of the instruction. For shifts of more than 1 bit position, load the desired number of shifts into the CL register, and put “CL” in the count position of the instruction.
  • #9: This instruction shifts each bit in the specified destination some number of bit positions to the right. As a bit is shifted out of the MSB position, a 0 is put in its place. The bit shifted out of the LSB position goes to CF.
  • #10: SAR: This instruction shifts each bit in the specified destination some number of bit positions to the right. As a bit is shifted out of the MSB position, a copy of the old MSB is put in the MSB position. In other words, the sign bit is copied into the MSB. The LSB will be shifted into CF.