Simple processes are performed by the Arithmetic Logic Unit (ALU for short). The ALU is made up of devices called gates that receive one or more inputs and, based upon what function they are designed to perform, output a result. This Unit performs the fundamental arithmetic and logical operations (+, -, x, /, OR, AND, NOT, etc), including comparisons (=, <, <=, >, <=), on data values sent to it from memory. Support for this activity is provided by one or more special ALU registers called accumulators, which can receive initial values from memory, hold the cumulative results of arithmetic and logical operations and transmit final result values back to memory. The operations concerned may be unary (monadic) - acting on the accumulator alone, e.g. negate the value in the accumulator - or binary (dyadic) - between the accumulator value and a value from memory, leaving the result in the accumulator, e.g. to add a value into the accumulator. A group of binary indicators (or "flags") associated with the ALU provide control feedback information in the form of a summary of the Unit's status after each operation. This might typically include indications of whether or not the operation was in error, e.g. due to arithmetic overflow, and whether the result produced was positive or negative and zero or non-zero, respectively (the latter pair of flags is sufficient to record the result of any comparison operation.
FUNCTIONS |
DESCRIPTION |
EXAMPLE |
|
Every bit in a word is changed
into its opposite. Ones become zeros, and zeros become ones.
|
|
|
All of the bits in a word are shifted
one position to their left. The left-most bit is lost, and the right-most
bit is set to zero.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The ALU takes two inputs,
loaded from registers on the chip. For the commands Not through Right Shift,
only the first input is used. The second is completely ignored. The ALU
can also let its first input pass through unchanged. The function executed
is determined by three additional input bits, specifying the number of
the function. Depending on the result of the function, the ALU outputs
two bits, called N and Z. N is a one when the result is negative (i.e.
the left-moat bit is a one), and Z is a one when the result is zero. These
bits are helpful for determining what the computer should do next. Then
the answer is routed back to a register to be stored for future use.
It is not unusual for
modern computers to have a second, separate, Arithmetic Unit for floating
point ("REAL") value calculations. Many small computers do not have hardware
for this purpose at all but use programmed simulation of floating point
operations instead. Some 8-bit microprocessor chips do not even have integer
multiplication and division capability - these operations have then to
be simulated by means of repeated addition and subtraction, respectively.
General purpose integer arithmetic requires an ALU bandwidth of at least
16 bits and must therefore be done in two parts (least and most significant
halves with a possible carry or borrow from the former to the latter) by
an 8-bit microprocessor ALU, in much the same way as human beings do manual
arithmetic one digit position at a time.