2-189

2 Instructions
CP1E CPU Unit Instructions Reference Manual(W483)
Conversion Instructions
2
NEG
NEG
Applicable Program Areas
Operands
Operand Specifications
Flags
Function
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.

Instruction Mnemonic Variations Function
code Function
2’S COMPLEMENT NEG @NEG 160 Calculates the 2’s complement of a word of hexa-
decimal data.
Symbol
NEG
Area Step program areas Subroutines Interrupt tasks
Usage OK OK OK
Operand Description Data type Size
S Source word WORD 1
R Result word UINT 1
Area Word addresses Indirect DM addresses Constants CF Pulse bits TR bits
CIO WR HR AR T C DM @DM *DM
SOK OK OK OK OK OK OK OK OK OK --- --- ---
R---
Name Label Operation
Error Flag P_ER OFF
Equals Flag P_EQ ON if the result is 0000/0000 0000.
OFF in all other cases.
Negative Flag P_N ON if bit 15 of the result is ON.
OFF in all other cases.

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.
S: Source word
R: Result word
NEG(160)
S
R
(S) (R)2’s complement (Complement + 1)