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?
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.