Compare logical operation instruction with suitable examples
Answers
Answered by
2
Apart from I/O and arithmetic instructions, logic instructions are some of most widely used instructions. In this section we cover Boolean logic instructions such as AND, OR, exclusive-or (XOR), and complement. We will also study the compare instruction
This instruction will perform a logical AND on the two operands and place the result in the destination. The destination is normally the accumulator. The source operand can be a register, in memory, or immediate. See Appendix A.I for more on the addressing modes for this instruction. The ANL instruction for byte-size operands has no effect on any of the flags. The ANL instruction is often used to mask.
The destination and source operands are ORed, and the result is placed in the destination. The ORL instruction can be used to set certain bits of an operand to 1. The destination is normally the accumulator. The source operand can be a register, in memory, or immediate. See Appendix A for more on the addressing modes supported by this instruction. The ORL instruction for byte-size operands has no effect on any of the flags. See Example 6-18.
Example 6-18
XOR
XRL destination,source ;dest = dest XOR source
This instruction will perform the XOR operation on the two operands, and place the result in the destination. The destination is
normally the accumulator. The source operand can Logical XQR Function be a register, in memory, or immediate. See Appendix A.I for the addressing modes of this instruction. The XRL instruction for byte-size operands has no effect on any of the flags. See Examples 6-19 and 6-20.
XRL can also be used to see if two registers have the same value. “XRL A, Rl” will exclusive-or register A and register Rl, and put the result in A. If both registers have the same value, 00 is placed in A. Then we can use the JZ instruction to make a deci sion based on the result.
This instruction will perform a logical AND on the two operands and place the result in the destination. The destination is normally the accumulator. The source operand can be a register, in memory, or immediate. See Appendix A.I for more on the addressing modes for this instruction. The ANL instruction for byte-size operands has no effect on any of the flags. The ANL instruction is often used to mask.
The destination and source operands are ORed, and the result is placed in the destination. The ORL instruction can be used to set certain bits of an operand to 1. The destination is normally the accumulator. The source operand can be a register, in memory, or immediate. See Appendix A for more on the addressing modes supported by this instruction. The ORL instruction for byte-size operands has no effect on any of the flags. See Example 6-18.
Example 6-18
XOR
XRL destination,source ;dest = dest XOR source
This instruction will perform the XOR operation on the two operands, and place the result in the destination. The destination is
normally the accumulator. The source operand can Logical XQR Function be a register, in memory, or immediate. See Appendix A.I for the addressing modes of this instruction. The XRL instruction for byte-size operands has no effect on any of the flags. See Examples 6-19 and 6-20.
XRL can also be used to see if two registers have the same value. “XRL A, Rl” will exclusive-or register A and register Rl, and put the result in A. If both registers have the same value, 00 is placed in A. Then we can use the JZ instruction to make a deci sion based on the result.
Similar questions