PASM question - using CMP or CMPS
Chris_D
Posts: 305
Hi PASM folks,
I am curious as to why we have both of these. CMPS can work for sign and unsigned comparisons. So why do we need to have CMP?
Chris
I am curious as to why we have both of these. CMPS can work for sign and unsigned comparisons. So why do we need to have CMP?
Chris
Comments
Yeah I get what they both do, I just don't understand why I can't use CMPS for comparisons of both positive and negative numbersall the time.
Chris
I think I got it now.
Chris
Graham
The difference between CMP and CMPS is in the way the Carry flag is set. See the Propeller manual.
With a bit of thought I think you can convince yourself why using CMP for unsigned and CMPS for signed values works.
Hint:
In unsigned arithmetic $FFFFFFFF is greater than zero. Of course $FFFFFFFF is the maximum value possible.
In signed arithmetic $FFFFFFFF represents minus one and is therefore less than zero.
Hmmm...something subtle I have overlooked. Must investigate....