Omron SYSMAC CJ - REFERENCE MANUAL 01-2008 Reference Manual page 485

Sysmac cs/cj/one nsj series programmable controllers
Table of Contents

Advertisement

Symbol Math Instructions
Signed data
Example 1
FFFF Hex
)
0001 Hex
)
FFFE Hex
Negative Flag ON
Carry Flag OFF
Signed data
Example 2
FFFD Hex
)
FFFF Hex
)
FFFE Hex
Negative Flag ON
Carry Flag OFF
Program Example
446
Unsigned data
1
65535
+1
1
)
2 Note 1
65534 Note 2
Unsigned data
3
65533
1
)
65535
2 Note 3
65534 Note 4
20F55A10 – B8A360E3 = –97AE06D3.
In this example, the eight-digit binary value in CIO 0121 and CIO 0120 is sub-
tracted from the value in CIO 0201 and CIO 0200, and the result is output in
eight-digit binary to D00101 and D00100. If the result is negative, the instruc-
tion at (2) will be executed, and the actual result will then be output to D00101
and D00100.
000000
Subtraction at 1
Mi+1:
CIO 0201
2 0 F 5
Su+1:
CIO 0121
B
8
A
3
R+1: D00101
CY
1
6
8
5 1
The Carry Flag (CY) is ON, so the result is subtracted from 0000 0000 to
obtain the actual number.
Note
1.
Since the Negative Flag is ON, the result (FFFE hex) is a
negative value (2's complement) and is thus 2.
2.
Since the Carry Flag is OFF, the result (FFFE hex) is an
unsigned positive value of 65534.
3.
Since the Negative Flag is ON, the result (FFFE hex) is a
negative value (2's complement) and is thus
4.
Since the Carry Flag is ON, the result (FFFE hex) is a
negative value (2's complement) and becomes 2 when
converted to a true value.
CY
CY
Mi:
CIO 0200
5 A
1
0
Su:
CIO 0120
6
0
E
3
R+1: D00100
F 9 2 D
Section 3-11
2.
RSET
002100
L
(1)
0200
0120
D00100
L
(2)
#00000000
D00100
D00100
SET
" "display
002100

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents