Open In App

Logical Instructions in AVR Microcontroller

Last Updated : 24 Sep, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report
Logical Instructions are the instructions which perform basic arithmetic operations such as AND, OR, XOR, etc. In AVR micro-controller, the destination operand is always a register. The following table shows the logical instructions :
Instruction Operand Explanation Example
AND D, S D = D AND S Performs a AND operation on the operands and stores the result in the left hand operand AND D, S
ANDI D, k(constant) D = D AND k Performs a AND operation on the operands and stores the result in the left hand operand with the right hand operand being a constant ANDI D, k
OR D, S D = D OR S Performs a OR operation on the operands and stores the result in the left hand operand OR D, S
ORI D, k D = D OR k Performs a OR operation on the operands and stores the result in the left hand operand with the right hand operand being a constant ORI D, k
EOR D, S D = D XOR S Performs a EX-OR operation on the operands and stores the result in the left hand operand EOR D, S
COM D. D = 1's complement of D The complement action changes '1's to '0's and '0's to '1's COM D
NEG D D = 2's complement of D This instruction takes the 2's complement NEG D
CP D, S Compares D and S This instruction is really a subtraction action. The only difference is that the values of registers don't change CP D, S
CPI D, k Compares D and k The only difference between CP an CPI is that CPI has one of the operands as a constant CP D, k
Note : D and S are Destination and Source respectively. Both are registers. k is a constant.

Next Article

Similar Reads