7-21
Section
BCD Calculation Instructions
458
If 00002 is ON, the program represented by the following diagram clears CY with
CLC(41), adds the content of IR 200 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.
TR 0
MOV(21)
#0001
DM 0101
00002
CLC(41)
ADD(30)
200
#6103
DM 0100
MOV(21)
#0000
DM 0101
25504
25504
Address
Instruction
Operands
00000
LD
00002
00001
OUT
TR
0
00002
CLC(41)
00003
ADD(30)
200
#
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
Although two ADD(30) can be used together to perform eight-digit BCD addition,
ADDL(54) is designed specifically for this purpose.
7-21-4
BCD SUBTRACT – SUB(31)
Mi
: Minuend word (BCD)
IR, SR, AR, DM, HR, TC, LR, #
Su
: Subtrahend word (BCD)
IR, SR, AR, DM, HR, TC, LR, #
Ladder Symbols
Operand Data Areas
R
: Result word
IR, SR, AR, DM, HR, LR
SUB(31)
Mi
Su
R
@SUB(31)
Mi
Su
R
Limitations
DM 6144 to DM 6655 cannot be used for R.
When the execution condition is OFF, SUB(31) is not executed. When the
execution 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).
Mi – Su – CY
CY
R
Flags
ER:
Mi and/or Su is not BCD.
Indirectly addressed DM word is non-existent. (Content of
*
DM word is
not BCD, or the DM area boundary has been exceeded.)
CY:
ON when the result is negative, i.e., when Mi is less than Su plus CY.
EQ
:
ON when the result is 0.
Example
Description