163
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 sub-
traction is not performed, and HR 2100 is not turned ON. HR 2100 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 recycled.
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 2100) and then turned back
ON.
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
CLC(41)
@SUB(31)
010
DM 0100
HR 20
CLC(41)
@SUB(31)
#0000
HR 20
HR 20
TR 0
25504
HR 2100
00002
25504
HR 2100
First
subtraction
Second
subtraction
Turned ON to indicate
negative result.
Address
Instruction
Operands
The first and second subtractions for this diagram are shown below using
example data for 010 and DM 0100.
The actual SUB(31) operation involves subtracting Su and CY from 10,000
plus Mi. For positive results the leftmost digit is truncated. For negative
results the 10s complement is obtained. The procedure for establishing the
correct answer is given below.
First Subtraction
IR 010
1029
DM 0100
– 3452
CY
–
0
HR 20
7577
(1029 + (10000 – 3452))
CY
1 (negative
result)
Note
BCD Calculations
Section 5-17
Содержание SYSMAC C1000H
Страница 1: ...Cat No W140 E1 04 Programmable Controllers SYSMAC C1000H C2000H...
Страница 2: ...C1000H C2000H Programmable Controllers Operation Manual Revised May 2003...
Страница 3: ...iv...
Страница 5: ...vi...
Страница 395: ...Cat No W140 E1 04 Note Specifications subject to change without notice Printed in Japan Authorized Distributor...
Страница 396: ...Cat No W140 E1 04 SYSMAC C1000H C2000H Programmable Controllers OPERATION MANUAL...