AH500 Programming Manual 
6-90 
API 
Instruction code  Operand  Function 
0210  D  NEG  P 
D 
Two’s complement 
Device
X  Y  M  S  T  C  HC  D  L  SM  SR  E  PR  K  16#
“$”  DF 
  Pulse instruction  16-bit instruction (3 steps)
32-bit instruction (3 steps)
  AH500  AH500  AH500 
Symbol: 
D 
:
Device in which the two’s 
complement is stored 
Word/Double word 
Explanation: 
1.  The instruction is used to convert the negative binary value into the absolute value. 
2.  Only the instruction DNEG can use the 32-bit counter. 
3.  Generally, the pulse instructions NEGP and DNEGP are used. 
Example 1: 
When X0.0 is switched from OFF to ON, all bits in D0 are inverted (0 becomes 1, and 1 becomes 0), 
and 1 is added to the result. The final value is stored in the original register D10.
 
 
Example 2: 
The absolute value of the negative value: 
1.  When the value of the 15
th
 bit in D0 is 1, M0 is ON. (The value in D0 is a negative value.) 
2.  When M0 is ON, the instruction NEG is used to obtain the two’s complement of the negative 
value in D0. (The corresponding positive value is obtained.)