Shop OBEX P1 Docs P2 Docs Learn Events
PASM Question re: SUB — Parallax Forums

PASM Question re: SUB

mynet43mynet43 Posts: 644
edited 2010-01-12 23:18 in Propeller 1
I'm trying to subtract two unsigned numbers and end up with the absolute value of the difference.

I've never tried it before, so I thought it might be faster to just ask [noparse]:)[/noparse]

Here's an example:

mov t1,#1 ' put a 1 in t1
mov t2,#2 ' put a 2 in t2
sub t1,t2 ' subtract t2 from t1 (i.e. 1 - 2 = ?)

The description says if WC is specified, then the C flag is set if the subtraction results in an unsigned borrow. Not sure exactly how to interpret this without printing out some test cases. Not too easy from assembly code.

Would someone please show me how to correct this, so that it always ends up with the absolute value?

Thanks for the help.

Jim

Comments

Sign In or Register to comment.