Computational Units
2 – 7
2
Any of the registers associated with the ALU can be both read and written in
the same cycle. Registers are read at the beginning of the cycle and written at
the end of the cycle. A register read, therefore, reads the value loaded at the
end of a previous cycle. A new value written to a register cannot be read out
until a subsequent cycle. This allows an input register to provide an operand to
the ALU at the beginning of the cycle and be updated with the next operand
from memory at the end of the same cycle. It also allows a result register to be
stored in memory and updated with a new result in the same cycle. See the
discussion of “Multifunction Instructions” in Chapter 15, “Instruction Set
Reference” for an illustration of this same-cycle read and write.
The ALU contains a duplicate bank of registers, shown in Figure 2.2 behind the
primary registers. There are actually two sets of AR, AF, AX, and AY register
files. Only one bank is accessible at a time. The additional bank of registers can
be activated (such as during an interrupt service routine) for extremely fast
context switching. A new task, like an interrupt service routine, can be
executed without transferring current states to storage.
The selection of the primary or alternate bank of registers is controlled by bit 0
in the processor mode status register (MSTAT). If this bit is a 0, the primary
bank is selected; if it is a 1, the secondary bank is selected.
2.2.2
Standard Functions
The standard ALU functions are listed below.
R = X + Y
Add X and Y operands
R = X + Y + CI
Add X and Y operands and carry-in bit
R = X – Y
Subtract Y from X operand
R = X – Y + CI - 1
Subtract Y from X operand with “borrow”
R = Y – X
Subtract X from Y operand
R = Y – X + CI - 1
Subtract X from Y operand with “borrow”
R = – X
Negate X operand (twos-complement)
R = – Y
Negate Y operand (twos-complement)
R = Y + 1
Increment Y operand
R = Y – 1
Decrement Y operand
R = PASS X
Pass X operand to result unchanged
R = PASS Y
Pass Y operand to result unchanged
R = 0 (PASS 0)
Clear result to zero
R = ABS X
Absolute value of X operand
R = X AND Y
Logical AND of X and Y operands
R = X OR Y
Logical OR of X and Y operands
R = X XOR Y
Logical Exclusive OR of X and Y operands
R = NOT X
Logical NOT of X operand (ones-complement)
R = NOT Y
Logical NOT of Y operand (ones-complement)