ABSNEG

Instruction: Get the negative of a number's absolute value.

ABSNEG NValue, < # > SValue


Result: Absolute negative of SValue is stored in NValue.

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

Opcode Table:

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

Z Result

C Result

Result

Clocks

 101011    001i    1111    ddddddddd    sssssssss

Result = 0

S[31]

Written

4

Concise Truth Table:

In

Out

Destination

Source

Z

C

Effects

Destination

Z

C

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

$0000_0001; 1

-

-

wz wc

$FFFF_FFFF; -1

0

0

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

$0000_0000; 0

-

-

wz wc

$0000_0000; 0

1

0

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

$FFFF_FFFF; -1

-

-

wz wc

$FFFF_FFFF; -1

0

1

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

$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,648

0

1

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

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

-

-

wz wc

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

0

1

Explanation

ABSNEG negates the absolute value of SValue and writes the result 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.

Literal SValues are zero-extended, so ABS is really best used with register SValues.

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