Logic Micro-operations

Last Updated : 9 Oct, 2025

Logic Micro-Operations are fundamental bitwise operations performed on data stored in CPU registers. Unlike arithmetic operations that involve numerical calculations, logic micro-operations manipulate individual bits using logical functions. By operating directly on bits, logic micro-operations enable efficient hardware-level control and data processing critical to computer performance and functionality.

NOT Operation

It inverts each bit of a register, turning 1s into 0s and 0s into 1s. It is used for bitwise complementation and toggling bits.

11

For instance, if A is 1010, the result after inversion is 0101.
→ All bits are flipped.

AND Operation

The AND operation performs a bitwise logical AND between two registers, producing a result where each bit is 1 only if both corresponding bits are 1. This operation is commonly used for bit masking to clear unwanted bits.

9

For example, f register A is 1101 and register B is 1011, the result will be 1001.
→ Only the positions where both A and B have 1s are preserved.

OR Operation

The OR operation performs a bitwise logical OR between two registers, setting each bit to 1 if at least one corresponding bit is 1. This operation is useful for setting specific bits.

10

For instance, if A is 1100 and B is 1010, the result is 1110.
→ Any bit that is 1 in either A or B becomes 1 in the output.

XOR Operation

XOR compares each bit of two registers and sets the result to 1 only if the bits are different, making it useful for toggling bits, error detection, and cryptographic applications.

15

For example, if A is 1100 and B is 1010, the result is 0110.
→ Only bits that differ between A and B become 1.

TRANSFER Operation

The TRANSFER operation copies the content of one register directly into another without modification. It is mainly used for moving data within the CPU.

12

For example, if A is 1100, and you transfer it to R, then R becomes 1100.
→ The value in A is now stored in R.

CLEAR Operation

The CLEAR operation resets all bits in a register to 0, effectively clearing its content. This is used to initialize or reset registers before new data is loaded.

13

For example, if register R is 1010, after clearing it, R becomes 0000.
→ All bits are set to 0.

SET Operation

The SET operation sets all bits of a register to 1, commonly used for initialization, testing, or activating all flags and status bits.

14

For instance, if R is 0000, after setting it, R becomes 1111.
→ All bits are now 1.

Hardware Implementation

Here is a simple hardware implementation of the most commonly used logic micro-operations along with their function table.

HI_LMO

S0

S1

Output

0

0

E = A ∧ B

0

1

E = A ∨ B

1

0

E = A⊕B

1

1

E = ¬A

Selective Logic Micro-Operations

Selective Set

Selective Set is used to set specific bits of a register to 1, while leaving the other bits unchanged. A mask is used where bits set to 1 indicate which positions in the register should be set.

  • The operation is performed using a bitwise OR between the register and the mask.

Let’s say:

  • Register R = 1010
  • Mask M = 0101

After Selective Set:

  • Perform R OR M = 1010 OR 0101 = 1111
  • Final result in R = 1111

Selective Reset

Selective Reset clears (sets to 0) only the bits specified in the mask (where the mask has 1s). All other bits remain unchanged.

  • This is done by ANDing the register with the bitwise complement of the mask.

Let’s say:

  • Register R = 1111
  • Mask M = 0101
  • Complement of mask = 1010

Now:

  • Perform R AND complement of M = 1111 AND 1010 = 1010
  • Final result in R = 1010

Selective Complement

Selective Complement flips (toggles) only the bits in the register where the mask has 1s. The rest remain unchanged.

  • This is achieved using a bitwise XOR between the register and the mask.

Let’s say:

  • Register R = 1010
  • Mask M = 0101

After XOR:

  • Perform R XOR M = 1010 XOR 0101 = 1111
  • Final result in R = 1111

Selective Insert

Selective Insert replaces certain bits of a register with bits from another source operand (S), only in positions where the mask has 1s. Bits where the mask is 0 stay the same as in the original register.

  • This is done in two steps: clear the bits in R where the mask is 1, then, insert bits from S in those cleared positions.

Let’s say:

  • Register R = 1010
  • Source S = 1100
  • Mask M = 0101
  • Complement of mask = 1010

Now:

  • Step 1: R AND complement of M = 1010 AND 1010 = 1010
  • Step 2: S AND M = 1100 AND 0101 = 0100
  • Final: 1010 OR 0100 = 1110
  • Final result in R = 1110

Logic Micro-Operations and Assembly Instructions

Logic Micro-OperationAssembly-like Instruction
ANDAND R, A, B
OROR R, A, B
NOTNOT R, A
XORXOR R, A, B
NANDNAND R, A, B
NORNOR R, A, B
XNORXNOR R, A, B
TRANSFERMOV R, A
CLEARCLR R
SET (All bits 1)SET R
Comment

Explore