How does a negated compare work?

  • Thread starter Thread starter Ian_Brooks
  • Start date Start date
  • Tags Tags
    Compare Work
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
2 replies · 4K views
Ian_Brooks
Messages
127
Reaction score
0

Homework Statement



I understand that in the ARM architecture
CMP a1, a2

will take the difference between a1 and a2 and make a decision based on its flags
NZCV - if the difference is positive a1 > a2, and vice versa

But how does a negated cmp work?

CMN a1, a2 ?

Is it the opposite?


Homework Equations





The Attempt at a Solution



see above. the internet gives me nothing
 
Physics news on Phys.org
CMP means Compare values
CMN means Compare Negated values

The ARM instruction sets are widely published, but here is a link to a help page

http://www.heyrick.co.uk/assembler/cmp.html#cmn
I am sure you will be able to figure it out from there.
 
Last edited:
thanks for the link -

If
cmp a1, a2 ; performs a subtraction
cmn a1, a2 ; performs a subtration with the second opperand being negative or
...;a1-(-a2) so its the same as an add, so what's the benefit of using cmn besides branching?
 
Last edited: