Omron SYSMAC C2000H Operation Manual page 169

Hide thumbs Also See for SYSMAC C2000H:
Table of Contents

Advertisement

BCD Calculations
TR 0
00002
25504
25504
HR 2100
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.
Turned ON to indicate
negative result.
The first and second subtractions for this diagram are shown below using
example data for 010 and DM 0100.
Note
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
DM 0100
CY
HR 20
CY
First
CLC(41)
subtraction
@SUB(31)
010
DM 0100
HR 20
Second
CLC(41)
subtraction
Address Instruction
@SUB(31)
00000
#0000
00001
HR 20
00002
HR 20
00003
HR 2100
00004
00005
00006
00007
00008
00009
00010
1029
– 3452
– 0
7577
(1029 + (10000 – 3452))
1
(negative result)
Section 5-17
Operands
LD
00002
OUT
TR
CLC(41)
@SUB(31)
DM
0100
HR
AND
25504
CLC(41)
@SUB(31)
#
0000
HR
HR
LD
TR
AND
25504
OR
HR
2100
OUT
HR
2100
0
010
20
20
20
0
163

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac c1000h

Table of Contents