Thursday, December 30, 2010

arm carry flag vs x86 carry flag

For add operation arm_cf and x86_cf are the same. For sub they differ. This is because in arm sub rd, rn, rm is equivalent to add rd, rn, -rm. Carry flag is set to 1 after add operation if the sum of operands is greater than 2^32. So on arm carry flag after sub is set if rn + (2^32 - rm) > 2^32 equivalently rn > rm. But on x86 carry would be set for sub if rn < rm which is exactly the opposite.

No comments:

Post a Comment