Question

So I have this line of code:

LOOP CMP Y, #0
BEQ DONE - When it is equal go to DONE.
ADD X, #1 - add decimal constant 1 to x.
SUB Y, #1 - subtract decimal constant 1 from y
B LOOP - branch loop (start the loop again)
DONE ...

I just read that CMP means subtracting the operand from Rn (Y minus 0) And that CMN means adding the operand to the Rn (0 + Y for example)

The first line (LOOP CMP Y, #0): I thought this just compares Y with the number 0. Is this true?

Was it helpful?

Solution

Yes -- cmp (at least in most assembly languages) does a subtraction. It sets the flags based on the result of that subtraction, but then throws away the result itself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top