Propeller Manual

Table Of Contents
3: Assembly Language Reference – ABS
ABS
Instruction: Get the absolute value of a number.
ABS AValue, # SValue
Result: Absolute SValue is stored in AValue.
AValue (d-field) is the register in which to write the absolute of SValue.
SValue (s-field) is a register or a 9-bit literal whose absolute value will be written to
AValue.
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– Z Result C Result Result Clocks
101010 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
$0000_0001; 1 0 0
$----_----; -
$0000_0000; 0 -
-
wz wc
$0000_0000; 0 1 0
$----_----; -
$FFFF_FFFF; -1 -
-
wz wc
$0000_0001; 1 0 1
$----_----; -
$7FFF_FFFF; 2,147,483,647
-
-
wz wc
$7FFF_FFFF; 2,147,483,647 0 0
$----_----; -
$8000_0000; -2,147,483,648
-
-
wz wc
$8000_0000; -2,147,483,648
1
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
ABS takes the absolute value of SValue and writes the result into AValue.
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 AValue unless the
NR effect is specified.
Literal SValues are zero-extended, so
ABS is really best used with register SValues.
Propeller Manual v1.1 · Page 257