3 . Instruction

Set

API

 

Mnemonic

 

Operands

 

 

Function

 

 

 

Controllers

 

29

D

NEG

 

P

 

 

 

 

2’s Complement

 

 

ES2/EX2 SS2

SA2

SX2

 

 

 

 

 

(Negation)

 

 

 

 

SE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Type

Bit Devices

 

 

 

Word devices

 

 

 

 

Program Steps

 

OP

 

X

Y

M

S

K

H KnX KnY KnM KnS T

C

D

E

F NEG, NEGP: 3 steps

 

D

 

 

 

 

 

 

 

*

*

*

*

*

*

*

* DNEG, DNEGP: 5 steps

 

 

 

 

 

 

 

 

PULSE

 

 

 

16-bit

 

 

32-bit

 

 

 

 

 

 

 

ES2/EX2

SS2

SA2

SX2

ES2/EX2

SS2

SA2

SX2

ES2/EX2 SS2

SA2

SX2

 

 

 

 

 

 

SE

SE

SE

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Operands:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

D: Device to store the operation result of 2’s Compliment

Explanations:

1.This instruction conducts operation of 2’s complement and can be used for converting a negative BIN value into an absolute value.

2.This instruction is generally used in pulse execution mode (NEGP, DNEGP).

3.If operand D uses index F, only a 16-bit instruction is available.

Program Example 1:

When X0 goes from OFF to ON, the phase of each bit in D10 will be reversed (01, 10) and then 1 will be added to the Least Significant Bit (LSB) of the register. Operation result will then be stored in D10.

X0

NEGP D10

Program Example 2:

To obtain the absolute value of a negative value:

1.When MSB (b15) of D0 is “1”, M0 = ON. (D0 is a negative value).

2.When M0 = ON, the absolute value of D0 can be obtained by NEG instruction.

M1000

BON D0 M0 K15

M0

NEGP D0

Program Example 3:

Obtain the absolute value of the remainder of the subtraction. When X0 = ON,

a)If D0 > D2, M0 = ON.

b)If D0 = D2, M1 = ON.

c)If D0 < D2, M2 = ON.

d)D4 is then able to remain positive.

3 - 89

Page 205
Image 205
Delta DVP-ES2/EX2/SS2/SA2/SX2/SE manual Neg