Omron CJ - REFERENCE MANUAL 10-2009 Reference Manual page 418

Table of Contents

Advertisement

3. Instructions
Function
NEG
NEG(160) calculates the 2's complement of S and writes the result to R. The
2's complement calculation basically reverses the status of the bits in S and
adds 1.
Note The result for 8000 hex will be 8000 hex.
NEGL
NEGL(161) calculates the 2's complement of S+1 and S and writes the
result to R+1 and R. The 2's complement calculation basically reverses the
status of the bits in S+1 and S and adds 1.
Note The result for 8000 0000 hex will be 8000 0000 hex.
Hint
• This operation (reversing the status of the bits and adding 1) is equivalent to subtracting the content
of S/S+1 and S from 0000/0000 0000.
Sample program
When CIO 0.00 is ON in the following example, NEG(160) calculates the 2's complement of the content
of D100 and writes the result to D200.
0.00
When CIO 0.00 is ON in the following example, NEGL(161) calculates the 2's complement of the
content of D101 and D100 and writes the result to D201 and D200.
0.00
D100
D200
D101
D201
380
D100
D200
Actual
calculation
D100
Reverse bit status
Add 1
D200
Actual
calculation
D100
Reverse bit status
Add 1
D200
Equivalent
subtraction
)
)
CS/CJ/NSJ Series Instructions Reference Manual (W474)
2's complement
(Complement + 1)
(S)
(R)
2's complement
(Complement + 1)
(S+1, S)
(R+1, R)
Equivalent
subtraction

Advertisement

Table of Contents
loading

Table of Contents