316
Conversion Instructions
Section 5-20
5-20-18 DOUBLE 2’S COMPLEMENT – NEGL(––)
Limitations
DM 6143 to DM 6655 cannot be used for R.
S and S+1 must be in the same data area, as must R and R+1.
Description
Converts the eight-digit hexadecimal content of the source words (S and S+1)
to its 2’s complement and outputs the result to the result words (R and R+1).
This operation is effectively the same as subtracting the eight-digit content S
and S+1 from $0000 0000 and outputting the result to R and R+1; it will calcu-
late the absolute value of negative signed binary data.
If the content of S is 0000 0000, the content of R will also be 0000 0000 after
execution and EQ (SR 25506) will be turned on.
If the content of S is 8000 0000, the content of R will also be 8000 0000 after
execution and UF (SR 25405) will be turned on.
Note
Refer to
1-7 Calculating with Signed Binary Data
for more details.
Flags
ER
Indirectly addressed EM/DM word is non-existent.
(Content of
*
EM/
*
DM word is not BCD, or the EM/DM area boundary
has been exceeded.)
EQ:
ON when the content of R+1, R is zero after execution; otherwise
OFF.
UF:
ON when the content of S+1, S is 8000 0000; otherwise OFF.
Example
The following example shows how to use NEGL(––) to find the 2’s comple-
ment of the hexadecimal value in IR 151, IR 150 (001F FFFF) and output the
result to HR 04, HR 03.
S
: First source word
IR, SR, AR, DM, EM, HR, TIM/CNT, LR
Ladder Symbols
Operand Data Areas
R
:
First result word
IR, SR, AR, DM, EM, HR, LR
NEGL(
−−
)
S
R
000
@NEGL(
−−
)
S
R
000
000
Not used. Set to 000.
00000
LD
00000
00001
NEGL(
−−
)
150
LR
03
000
Address Instruction
Operands
NEGL(
−−
)
150
LR 03
000
00000
0000
001F
FFE0
−
0000
FFFF
0001
S+1: IR 151
S: IR 150
R+1: LR 04
R: LR 03