![](http://datasheet.mmic.net.cn/370000/UPD17120_datasheet_16743697/UPD17120_109.png)
CHAPTER 11 ARITHMETIC AND LOGIC UNIT
94
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 evaluation causes the CMP flag in the program status word to be reset.
(4) When an arithmetic operation, logical operation, bit evaluation, comparison evaluation, 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.
11.3 ARITHMETIC OPERATIONS (ADDITION AND SUBTRACTION IN 4-BIT BINARY AND BCD)
As shown in Table 11-3, arithmetic operations consist of addition, subtraction, addition with carry, and subtraction
with borrow. These instructions are ADD, ADDC, SUB, and SUBC.
The ADD, ADDC, SUB, and SUBC instructions are further divided into addition and subtraction of the general
register and data memory and addition and subtraction of data memory and immediate data. When the operands
r and m are used, addition or subtraction is performed using the general register and data memory. When the
operands m and #n4 are used, addition or subtraction is performed using data memory and immediate data.
Arithmetic operations are affected by the status flip-flop and the program status word (PSWORD) in the system
register. The BCD flag in the program status word is used to specify whether arithmetic operations are to be
performed in 4-bit binary or in BCD. The CMP flag is used to specify whether or not the results of arithmetic operations
are to be stored.
11.3.1
to
11.3.4
explain the relationship between each command and the program status word.
Table 11-3. Types of Arithmetic Operations
Arithmetic
Addition
Without carry ADD
General register and data memory
ADD r, m
operation
Data memory and immediate data
ADD m, #n4
With carry ADDC
General register and data memory
ADDC r, m
Data memory and immediate data
ADDC m, #n4
Subtraction
Without borrow SUB
General register and data memory
SUB r, m
Data memory and immediate data
SUB m, #n4
With borrow SUBC
General register and data memory
SUBC r, m
Data memory and immediate data
SUBC m, #n4