!
208
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.
Caution Be
sure to clear the carry flag with CLC(41) before executing SUB(31) if its previous status is not
required,
and check the status of CY after doing a subtraction with SUB(31).
If CY is ON as a result
of
executing SUB(31) (i.e., if the result is negative), the result is output as the 10’
s complement of
the true answer. To convert the output result to the true value, subtract the value in R from 0.
Example When
00002 is ON, the following ladder program clears CY
,
subtracts the con
-
tents
of DM 0100 and
CY from the content of 010 and places the result in HR 20.
If CY is set by executing SUB(31), the result in HR 20 is subtracted from zero
(note that CLC(41) is again required to obtain an accurate result), the result is
placed
back in HR 20, and HR 2100 is turned ON to indicate a negative result.
If
CY is not set by executing SUB(31), the result is positive, the second subtrac
-
tion
is not
performed, and HR 2100 is not turned ON. HR 2100 is programmed as
a self-maintaining bit so that a change in the status of CY will not turn it OFF
when the program is recycled.
In
this example, dif
ferentiated forms of SUB(31) are used so that the subtraction
operation
is
performed only once each time 00002 is turned ON. When another
subtraction
operation
is to be performed, 00002 will need to be turned OFF for at
least one cycle (resetting HR 2100) and then turned back ON.
CLC(41)
@SUB(31)
010
DM 0100
HR 20
CLC(41)
@SUB(31)
#0000
HR 20
HR 21
TR 0
25504
HR 2100
00002
25504
HR 2100
First
subtraction
Second
subtraction
T
urned ON to indicate
negative result.
00000 LD 00002
00001 OUT TR 0
00002 CLC(41)
00003 @SUB(31)
010
DM 0100
HR 20
00004 AND 25504
00005 CLC(41)
00006 @SUB(31)
# 0000
HR 20
HR 20
00007 LD TR 0
00008 AND 25504
00009 OR HR 2100
00010 OUT HR 2100
Address Instruction Operands
The
first and second subtractions for this diagram are shown below using exam
-
ple data for 010 and DM 0100.
BCD Calculations Section 5-19