add and adds
Hi,
some questions about assembler:
- I want to add a signed 8-bit in xx into an unsigned 16bit in cPC. (There will be no overflow of the unsigned 16.bit result)
At the moment I have:
signx xx,#7 add cPC,xx
Is this correct?
I don't understand the difference between add and adds? I always thought that 2s complement takes care of everything.
- Is there a faster way to set a register value depending from a flag?
testbn r3,a wz if_nz mov b,#1 if_z mov b,#0
and:
cmp r2,#1 wz mov xx,#0 if_z mov xx,#1
Thanks for any hints!
Christof
Comments
Instead of answering that directly - The Propeller's instruction architecture uses instruction groups that use the two flags in different ways. Ie: The meaning of the flags changes depending on which group of instructions you're executing. Whereas other CPUs might rely more on conditional branching via many more flags that are collectively affected by each instruction.
So, as a general Prop rule, mixing unsigned instructions with signed instructions would be considered buggy.
Thank you!
The version with add works. I now fond my bug at another location. I assume, that the difference between add and adds is only relevant, if you have wc and use the flag.
Correct. ADD and ADDS only differ in the meaning of the Carry flag. And since they don't take a carry as an input then there is only an impact if the carry is written then subsequently used after the ADD or ADDS.
As for the second question, I guess WRC and WRZ would be best bet. Surprisingly, I've just noticed this group of instructions myself.
There is also RCZL and RCZR. Useful for stacking just the flags.
Thank you!
Meanwhile I had stumbled over wrz, but not on RCZL.
Christof