Logical Instructions in 8086 Micro Processor
Logical Instructions in 8086 Micro Processor
SlideMake.com
Introduction to Logical Instructions in 8086 Micro Processor
• It sets the result to 1 if both corresponding bits are 1; otherwise, it sets the
result to 0.
• It inverts all the bits of the operand, changing 1s to 0s and vice versa.
• Shift instructions are used to shift the bits of a value left or right.
• The SHL (shift left) instruction shifts the bits to the left, filling the empty
positions with zeros.
• The SHR (shift right) instruction shifts the bits to the right, filling the
empty positions with zeros.
Rotate Instructions
• Rotate instructions are similar to shift instructions but with a circular shift
behavior.
• The ROL (rotate left) instruction shifts the bits to the left, moving the
leftmost bit to the rightmost position.
• The ROR (rotate right) instruction shifts the bits to the right, moving the
rightmost bit to the leftmost position.
Flags Affected by Logical Instructions
• The logical instructions in 8086 micro processor affect various flags in the
FLAGS register.
• The flags affected include the carry flag (CF), zero flag (ZF), sign flag
(SF), parity flag (PF), and overflow flag (OF).
• These flags are updated based on the result of the logical operation
performed.
AND Instruction Example
• The result is stored back in AX, preserving the original value of the lower
8 bits.
OR Instruction Example
• The result is stored back in BX, preserving the original value of the higher
8 bits.
XOR Instruction Example
• The result is stored back in CX, changing the bits that correspond with the
1s in 0xAAAA.
NOT Instruction Example
• Example: NOT DL
• The result is stored back in DL, inverting all the bits of the original value.
Shift Instructions Example
• The empty positions are filled with zeros, and the shifted result is stored
back in SI.
Rotate Instructions Example
• The rightmost 3 bits are moved to the leftmost positions, and the rotated
result is stored back in DI.
Logical Instructions and Conditional Branching
• Conditional branches allow the program to change its flow based on the
result of a logical operation.
• They include AND, OR, XOR, NOT, shift, and rotate instructions.