315
Conversion Instructions Section 5-20
5-20-17 2’S COMPLEMENT – NEG(––)
Limitations DM 6144 to DM 6655 cannot be used for R.
Description Converts the four-digit hexadecimal content of the source word (S) to its 2’s
complement and outputs the result to the result word (R). This operation is
effectively the same as subtracting S from 0000 and outputting the result to R;
it will calculate the absolute value of negative signed binary data.
If the content of S is 0000, the content of R will also be 0000 after execution
and EQ (SR 25506) will be turned on.
If the content of S is 8000, the content of R will also be 8000 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 is zero after execution; otherwise OFF.
UF: ON when the content of S is 8000; otherwise OFF.
Example The following example shows how to use NEG(––) to find the 2’s complement
of the content of DM 0005 and output the result to IR 105.
S: Source word
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
Ladder Symbols Operand Data Areas
R: Result word
IR, SR, AR, DM, EM, HR, LR
NEG(−− )
S
R
000
@NEG(−− )
S
R
000
000
Not used. Set to 000.
00000 LD 00100
00001 NEG(−−)
DM 0005
105
000
Address Instruction Operands
NEG(−−)
DM 0005
105
000
00100
#0000
#001F
#FFE1
−
Output to IR 105.
Content of DM 0005.