Arithmetic Logic Unit

1 min read Last updated Sat Jun 27 2026 08:46:52 GMT+0000 (Coordinated Universal Time)

A combinational circuit inside a CPU that performs arithmetic and logical operations. Takes 2 operands and a function-select input; outputs 1 result. Multiplexers select between operation circuits based on the function-select input.

Supported Operations

Arithmetic:

  • ADD, SUB (via adder-subtractor)
  • INC, DEC
  • NEG (two’s complement negation)

Logical:

  • AND, OR, NOT, XOR
  • NAND, NOR

Shift:

  • SHL, SHR (logical shift left/right)
  • SAR (arithmetic shift right, sign-extends)
  • ROL, ROR (rotate)

Flags Register

The ALU sets status flags alongside each result:

  • Zero (Z)
    Set when result = 0.
  • Carry (C)
    Set on unsigned overflow (carry out of MSB).
  • Overflow (V)
    Set on signed overflow.
  • Sign (N)
    Set when result is negative (MSB = 1).

Overflow Detection

Overflow occurs when the result falls outside the representable range.

Detected when:

  • 2 positive operands produce a negative result
  • 2 negative operands produce a positive result
Was this helpful?