It contains all the types of instruction required for performing logical operation in 8086 microprocessor. It is useful from the examination point of view as well.
3. The first operand in all the cases could be either in register or in
memory, the second operand could be either in register/memory or
an immediate (constant) value
Memory-to-memory operations are not possible
These instructions compare or match bits of the operands and set
the CF, OF, PF, SF and ZF flags.
3
Introduction to logical operations
4. AND operation can be used for clearing one or more bits
Flags are affected
The result is stored in the destination operand /register
The general format of the AND instruction is
oAND destination, source
Example:
AND AX, 0008H
AND AX, BX
4
Logical AND
Register AND register
Register AND immediate value
5. This instruction bit by bit ORs the source operand with the destination
operand
The result is stored in the destination operand
The general format of the OR instruction is
oOR destination, source
Eg. OR AX, 0008H
OR AX, BX
5
Logical OR
Register OR register
Register OR immediate value
6. This instruction complements the contents of an operand register or
a memory location, bit by bit
The NOT instruction does not affect the flag register
Eg. NOT AX
NOT [5000H]
6
Logical Invert
NOT immediate value
NOT Register
7. This instruction bit by bit XORs the source operand to the
destination operand
The result is stored in the destination operand
XORing an operand with itself changes the operand to 0. This is
also used to clear a register
Eg. XOR AX, 0098H
XOR AX, BX
7
Logical Exclusive OR
Register XOR register
Register XOR immediate value
8. The TEST instruction performs a bit by bit logical AND operation
on the two operands.
It does not change the first operand but it only affects the condition
of the flag register, which indicates the result of the test
The general format of the TEST instruction is
oTEST destination, source
Eg. TEST AX, BX
TEST [0500], 06H
8
TEST: Logical Compare Instruction
Register TEST register
Register TEST immediate value