← Back to Articles

Bitwise Operations

Bitwise Instructions

Bitwise operations manipulate individual bits.

AND Operation

AND Rd, Rn, operand

Sets bits where both operands have 1:

MOV R0, #12      // 1100 in binary\nMOV R1, #10      // 1010 in binary\nAND R2, R0, R1   // R2 = 8 (1000 in binary)

OR Operation

ORR Rd, Rn, operand

Sets bits where either operand has 1:

MOV R0, #12      // 1100\nMOV R1, #10      // 1010\nORR R2, R0, R1   // R2 = 14 (1110)

XOR Operation

EOR Rd, Rn, operand

Sets bits where operands differ:

MOV R0, #12      // 1100\nMOV R1, #10      // 1010\nEOR R2, R0, R1   // R2 = 6 (0110)