319
BCD Calculation Instructions
Section 5-21
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 sub-
traction 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
10.
If CY is set by executing SUB(31), the result in HR 10 is subtracted from zero
(note that CLC(41) is again required to obtain an accurate result), the result is
placed back in HR 10, and HR 1100 is turned ON to indicate a negative result.
If CY is not set by executing SUB(31), the result is positive, the second sub-
traction is not performed, and HR 1100 is not turned ON. HR 1100 is pro-
grammed as a self-maintaining bit so that a change in the status of CY will not
turn it OFF when the program is rescanned.
In this example, differentiated forms of SUB(31) are used so that the subtrac-
tion 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 1100) and then turned back ON.
CLC(41)
@SUB(31)
010
DM 0100
HR 10
CLC(41)
@SUB(31)
#0000
HR 10
HR 10
TR 0
25504
HR 1100
00002
25504
HR 1100
First
subtraction
Second
subtraction
Turned ON to indicate
negative result.
Содержание SYSMAC CQM1H Series
Страница 3: ...iv...
Страница 5: ...vi...
Страница 9: ......
Страница 11: ......
Страница 15: ...xvi...
Страница 87: ...62 Calculating with Signed Binary Data Section 1 7...
Страница 169: ...144 Serial Communications Board Section 2 6...
Страница 537: ......
Страница 565: ......
Страница 569: ......
Страница 573: ......
Страница 577: ......