
CHAPTER 11 ARITHMETIC AND LOGIC UNIT (ALU)
90
11.2.6 Operations in the ALU Block
When arithmetic operations, logical operations, bit judgements, comparison judgements or rotations in a program
are executed, the first data operand is stored in temporary register A and the second data operand is stored in
temporary register B.
The first data operand is 4-bit data used to specify the contents of an address in the general register or data memory.
The second data operand is 4-bit data used to either specify the contents of an address in data memory or to be used
as an immediate value. For example, in the instruction
ADD r, m
Second operand
First operand
the first operand, r, is used to specify the contents of an address in the general register. The second operand, m,
is used to specify the contents of an address in data memory. In the instruction
ADD m, #n4
the first operand, m, is used to specify an address in data memory. The second operand, #n4, is immediate data.
In the rotation instruction
RORC r
only the first operand, r (used to specify the contents of an address in the general register) is used.
Next, using the data stored in temporary registers A and B, the ALU executes the operation specified by the
instruction (arithmetic operation, logical operation, bit judgement, comparison judgement, or rotation). When the
instruction being executed is an arithmetic operation, logical operation, or rotation, the data processed by the ALU
is stored in the location specified by the first operand (general register address or data memory address) and the
operation terminates. When the instruction being executed is a bit judgement or comparison judgement, the result
processed by the ALU is used to determine whether or not to skip the next instruction (whether to treat next instruction
as a NOP instruction) and the operation terminates.
Caution should be taken with regard to the following points:
(1) Arithmetic operations are affected by the CMP and BCD flags in the program status word.
(2) Logical operations are not affected by the CMP or BCD flag in the program status word. Logical operations
do not affect the Z or CY flags.
(3) Bit judgement causes the CMP flag in the program status word to be reset.
(4) When an arithmetic operation, logical operation, bit judgement, comparison judgement, or rotation is being
executed and the IXE flag in the program status word is set (1), address modification is performed using the
index register.