247
NEG, NEGP, DNEG, DNEGP
1
2
3
4
6
7
8
6.3
D
ata conversio
n instru
ctions
6.3.11
NEG, NEGP, D
N
EG,
DNEGP
Function
NEG
(1) Reverses the sign of the 16-bit device designated by and stores at the device designated by .
(2) Used when reversing positive and negative signs.
DNEG
(1) Reverses the sign of the 32-bit device designated by and stores at the device designated by .
(2) Used when reversing positive and negative signs.
Operation Error
(1) There is no operation error in the NEG(P) or DNEG(P) instruction.
Program Example
(1) The following program calculates a total for the data at D10 through D20 when XA goes ON, and seeks an absolute
value if the result is negative.
[Ladder Mode]
[List Mode]
D
D
16
b
i
t
Before
execut
i
on
S
i
gn
convers
i
on
b15
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
b0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
b15
1
1
1
1
1
1
1
b0
-
218
4
6
0
0
0
0
0
0
0
1
D
D
0
After
execut
i
on
218
4
6
D
D
32 bit
b31
1
Before
execution
1
1
1
1
1
1
0
1
0
0
1
0
0
b0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
0
1
0
0
1
0
0
1
b31
0
0
0
1
1
1
0
b0
Sign
conversion -
After
execution
0
0
0
0
0
1
0
D
D
-218460
218460
M3 is turned ON if D10
<
D20.
Executes "D10 - D20".
Calculates the absolute value
(
complement of 2
)
when M3 is ON.
Step
Instruction
Device