NEG

Instruction: Get the negative of a number.

NEG NValue, < # > SValue


Result: –SValue is stored in NValue.

  • NValue (d-field) is the register in which to write the negative of SValue.
  • SValue (s-field) is a register or a 9-bit literal whose negative value will be written to NValue.

Opcode Table:

–INSTR–  ZCRI –CON–    –DEST–         –SRC–

Z Result

C Result

Result

Clocks

 101001    001i    1111    ddddddddd    sssssssss

Result = 0

S[31]

Written

4

Concise Truth Table:

In

Out

Destination

Source

Z

C

Effects

Destination

Z

C

$----_----; -

$FFFF_FFFF; -1

-

-

wz wc

$0000_0001; 1

0

1

$----_----; -

$0000_0000; 0

-

-

wz wc

$0000_0000; 0

1

0

$----_----; -

$0000_0001; 1

-

-

wz wc

$FFFF_FFFF; -1

0

0

$----_----; -

$7FFF_FFFF; 2,147,483,647

-

-

wz wc

$8000_0001; -2,147,483,647

0

0

$----_----; -

$8000_0000; -2,147,483,648

-

-

wz wc

$8000_0000; -2,147,483,6481

0

1

$----_----; -

$8000_0001; -2,147,483,647

-

-

wz wc

$7FFF_FFFF; 2,147,483,647

0

1

1 The smallest negative number (-2,147,483,648) has no corresponding positive value in 32-bit two's-complement math.

Explanation

NEG stores negative SValue into NValue.

If the WZ effect is specified, the Z flag is set (1) if SValue is zero. If the WC effect is specified, the C flag is set (1) if SValue is negative or cleared (0) if SValue is positive. The result is written to NValue unless the NR effect is specified.

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.