First page Back Continue Last page Overview Graphics
CMPA MEM ;A-MEM->Sets Flags
CMPB MEM ;B-MEM->Sets Flags
These instructions perform a subtraction and modify flags according to the results of the subtraction but they do not modify a destination register.
The instructions are identical to SUBA and SUBB with the exception that the destination register is unchanged.
Since the original register is unchanged (as it would be in the case of a subtraction) multiple compare instructions can be executed without reloading the source register.
The compare instructions are extremely useful when comparing the magnitudes of two numbers. The compare instruction performs a subtraction but does not modify the destination register. The carry flag will be set whenever the subtrahend is larger than the minuend. The numbers are compared as unsigned numbers when modifying the borrow (carry) flag. That is $ff (would be -1 if considered signed and smaller than +1) is considered larger than $01 (would still be 1 if considered signed).