318
BCD Calculation Instructions
Section 5-21
Example
If 00002 is ON, the program represented by the following diagram clears CY
with CLC(41), adds the content of IR 030 to a constant (6103), places the
result in DM 0100, and then moves either all zeros or 0001 into DM 0101
depending on the status of CY (25504). This ensures that any carry from the
last digit is preserved in R+1 so that the entire result can be later handled as
eight-digit data.
Although two ADD(30) can be used together to perform eight-digit BCD addi-
tion, ADDL(54) is designed specifically for this purpose.
5-21-4 BCD SUBTRACT – SUB(31)
Limitations
DM 6144 to DM 6655 cannot be used for R.
Description
When the execution condition is OFF, SUB(31) is not executed. When the exe-
cution condition is ON, SUB(31) subtracts the contents of Su and CY from Mi,
and places the result in R. If the result is negative, CY is set and the 10’s com-
plement of the actual result is placed in R. To convert the 10’s complement to
the true result, subtract the content of R from zero (see example below).
Flags
ER:
Mi and/or Su is not BCD.
Indirectly addressed EM/DM word is non-existent.
(Content of
*
EM/
*
DM word is not BCD, or the EM/DM area boundary
has been exceeded.)
MOV(21)
#0001
DM 0101
TR 0
00002
CLC(41)
ADD(30)
030
#6103
DM 0100
MOV(21)
#0000
DM 0101
25504
25504
Address Instruction
Operands
00000
LD
00002
00001
OUT
TR
0
00002
CLC(41)
00003
AND(30)
030
#
6103
DM
0100
00004
AND
25504
00005
MOV(21)
#
0001
DM
0101
00006
LD
TR
0
00007
AND NOT
25504
00008
MOV(21)
#
0000
DM
0101
Mi
:
Minuend word (BCD)
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
Su
:
Subtrahend word (BCD)
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
Ladder Symbols
Operand Data Areas
R
:
Result word
IR, SR, AR, DM, EM, HR, LR
SUB(31)
Mi
Su
R
@SUB(31)
Mi
Su
R
Mi
−
Su
−
CY
CY
R