Skip to content
Related Articles

Related Articles

Improve Article

Logical Instructions in AVR Microcontroller

  • Last Updated : 24 Sep, 2020

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 :

InstructionOperandExplanationExample
ANDD, SD = D AND S
Performs a AND operation on the operands
and stores the result in the left hand operand
AND D, S
ANDID, 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
ORD, SD = D OR S
Performs a OR operation on the operands
and stores the result in the left hand operand
OR D, S
ORID, kD = 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
EORD, SD = D XOR S
Performs a EX-OR operation on the operands
and stores the result in the left hand operand
EOR D, S
COMD.D = 1’s complement of D
The complement action changes ‘1’s to ‘0’s
and ‘0’s to ‘1’s
COM DNEGDD = 2’s complement of D
This instruction takes the 2’s complement
NEG D
CPD, SCompares 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
CPID, kCompares 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.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

 

My Personal Notes arrow_drop_up
Recommended Articles
Page :