Conversion Instructions
5-20-17 2'S COMPLEMENT – NEG(––)
Limitations
Description
Flags
Example
Ladder Symbols
NEG(−−)
S
R
000
DM 6144 to DM 6655 cannot be used for R.
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.
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.
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.
00100
@NEG(−−)
IR, SR, AR, DM, EM, HR, TIM/CNT, LR, #
S
R
000
Address Instruction
NEG(−−)
00000
DM 0005
00001
105
000
#0000
−
#001F
Content of DM 0005.
#FFE1
Output to IR 105.
Section 5-20
Operand Data Areas
S: Source word
R: Result word
IR, SR, AR, DM, EM, HR, LR
000
Not used. Set to 000.
Operands
LD
NEG(−−)
DM
00100
0005
105
000
315
Need help?
Do you have a question about the CQM1H - PROGRAM and is the answer not in the manual?