CHAPTER 11 ARITHMETIC AND LOGIC UNIT
96
11.3.4 Addition and Subtraction When CMP=1 and BCD=1
BCD operations are performed.
The result is not stored in either the general register or data memory.
In other words, the operations specified by CMP=1 and BCD=1 are both performed at the same time.
Example
MOV
RPL, #0001B
; Sets the BCD flag (BCD=1).
MOV
PSW, #1010B
; Sets the CMP and Z flag (CMP=1, Z=1) and resets the CY flag
; (CY=0).
SUB
M1, #0001B
; <1>
SUBC
M2, #0010B
; <2>
SUBC
M3, #0011B
; <3>
By executing the instructions in steps numbered <1>, <2>, and <3>, the twelve bits in memory
locations M1, M2, and M3 and the immediate data (321) can be compared in decimal.
11.3.5 Cautions on Use of Arithmetic Operations
When performing arithmetic operations with the program status word (PSWORD), caution should be taken with
regard to the result of the operation being stored in the program status word.
Normally, the CY and Z flags in the program status word are set (1) or reset (0) according to the result of the
arithmetic operation being executed. However, when an arithmetic operation is performed on the program status
word itself, the result is stored in the program status word. This means that there is no way to determine if there
is a carry or borrow in the result of the operation nor if the result of the operation is zero.
However, when the CMP flag is set (1), results of arithmetic operations are not stored. Therefore, even in the
above case, the CY and Z flags will be properly set (1) or reset (0) according to the result of the operation.
11.4 LOGICAL OPERATIONS
As shown in Table 11-4, logical operations consist of logical OR, logical AND, and logical XOR. Accordingly, the
logical operation instructions are OR, AND, and XOR.
The OR, AND, and XOR instructions can be performed on either the general register and data memory, or on data
memory and immediate data. The operands of these instructions are specified in the same way as for arithmetic
operations ("r, m" or "m, #n4").
Logical operations are not affected by the BCD or CMP flags in the program status word (PSWORD). Logical
operations do not cause either the CY or Z flag in the program status word (PSWORD) to be set. However, when
the index enable flag (IXE) is set (1), index modification is performed using the index register.
Summary of Contents for mPD17120 Subseries
Page 15: ... x MEMO ...
Page 23: ... MEMO 8 ...
Page 45: ... MEMO 30 ...
Page 49: ... MEMO 34 ...
Page 55: ... MEMO 40 ...
Page 93: ... MEMO 78 ...
Page 99: ... MEMO 84 ...
Page 102: ...CHAPTER 11 ARITHMETIC AND LOGIC UNIT 87 MEMO ...
Page 119: ... MEMO 104 ...
Page 175: ... MEMO 160 ...
Page 199: ... MEMO 184 ...
Page 265: ... MEMO 250 ...
Page 281: ...266 MEMO ...
Page 285: ... MEMO 270 ...
Page 289: ... MEMO 274 ...