3: Assembly Language Reference – ADDSX In a signed multi-long operation, the first instruction is unsigned (ex: ADD), any middle instructions are unsigned, extended (ex: ADDX), and the last instruction is signed, extended (ex: ADDSX). Make sure to use the WC, and optionally WZ, effect on the leading ADD and ADDX instructions. For example, a signed double-long (64-bit) addition may look like this:
add addsx
XLow, YLow XHigh, YHigh
wc wz
'Add low longs together; save C and Z 'Add high longs together
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 $FFFF_FFFF:FFFF_FFFF (-1) the result in XHigh:XLow would be $0000_0000:FFFF_FFFF (4,294,967,295). This is demonstrated below.
(XHigh:XLow) + (YHigh:YLow)
Hexadecimal (high) (low) $0000_0001:0000_0000 + $FFFF_FFFF:FFFF_FFFF ---------------------= $0000_0000:FFFF_FFFF
Decimal 4,294,967,296 + -1 --------------= 4,294,967,295
A signed triple-long (96-bit) addition would look similar but with an ADDX instruction inserted between the ADD and ADDSX instructions:
add addx addsx
XLow, YLow XMid, YMid XHigh, YHigh
wc wz wc wz
'Add low longs; save C and Z 'Add middle longs; save C and Z 'Add high longs
Of course, it may be necessary to specify the WC and WZ effects on the final instruction, ADDSX, in order to watch for a result of zero or signed overflow condition. Note that during this multi-step operation the Z flag always indicates if the result is turning out to be zero, but the C flag indicates unsigned carries until the final instruction, ADDSX, in which it indicates signed overflow. For ADDSX, if the WZ effect is specified, the Z flag is set (1) if Z was previously set and SValue1 + SValue2 + C equals zero (use WC and WZ on preceding ADD and ADDX instructions). If the WC effect is specified, the C flag is set (1) if the summation resulted in a signed overflow. The result is written to SValue1 unless the NR effect is specified.
Propeller Manual v1.1 ¡ Page 263