Propeller Manual

Table Of Contents
3: Assembly Language Reference – SUBX
Propeller Manual v1.1 · Page 355
For example, an unsigned double-long (64-bit) subtraction may look like this:
sub XLow, YLow wc wz 'Subtract low longs; save C and Z
subx XHigh, YHigh 'Subtract high longs
After executing the above, the double-long (64-bit) result is in the long registers
XHigh:XLow. If XHigh:XLow started out as $0000_0001:0000_0000 (4,294,967,296) and
YHigh:YLow was $0000_0000:0000_0001 (1) the result in XHigh:XLow would be
$0000_0000:FFFF_FFFF (4,294,967,295). This is demonstrated below.
Hexadecimal Decimal
(high) (low)
(XHigh:XLow) $0000_0001:0000_0000 4,294,967,296
- (YHigh:YLow) - $0000_0000:0000_0001 - 1
---------------------- ---------------
= $0000_0000:FFFF_FFFF = 4,294,967,295
Of course, it may be necessary to specify the WC and WZ effects on the final instruction, SUBX,
in order to watch for a result of zero or an unsigned borrow condition.
For
SUBX, if the WZ effect is specified, the Z flag is set (1) if Z was previously set and
Value1 - (Value2 + C) equals zero (use
WC and WZ on preceding SUB and SUBX instructions). If
the
WC effect is specified, the C flag is set (1) if the subtraction resulted in an unsigned borrow
(32-bit overflow). The result is written to Value1 unless the
NR effect is specified.