Arithmetic logic unit

From ScienceZero
Jump to: navigation, search

The arithmetic logic unit/arithmetic-logic unit (ALU) of a computer's central processing unit (CPU) is a part of the execution unit, a core component of all CPUs. ALUs are capable of calculating the results of a wide variety of basic arithmetical computations. A CPU may have more than one ALU, either identical or of different types.

For convenience and speed of execution the ALU usually is capable of many different arithmetic and logical operations but all operations can be done with just two basic instructions. For example it can be shown that subtraction and bitwise AND is enough to perform any arithmetic operation.

  • A + B = A - (0 - B)
  • NOT A = A - -1
  • A EOR B = ((A AND B) - -1) AND A
  • A << 1 = A - (0 - A)
  • A >> 1 = wordlength -- for dup signbit and swap << swap if 1 or endif next signbit bic ;