Giving the following ARM assembly code, find the the output of the ALU flags [Negative, Carry out, Zero, oVerflow]
MOV R0 #00000100
MOV R1 #00000100
MOV R2 #0000010A
CMP R0, R1
SUBGES R0, R0, R2
ADDLTS R0, R1, R2
The correct answer should be N=1 ; C=V=Z=0 but I'm not sure about it. Also, I'm not even sure if #00000100
is binary, decimal or hexadecimal.
Anyways, considering all of them hexadecimal, I'm proceeding in this way:
CMP R0 R1
Gives as ALU flags Z=1 and C=V=N=0.
SUBGES R0, R0, R2
performs a subtracion if "Greater or equal" (checks if N==V). Since N=V,
R0-R2 = 256 - 266 = -10
Recall that "S" uodates flags, N=1, C=Z=V=0.
ADDLTS R0, R1, R2
performs an addition if "Less Than" (checks if N!=V). Since N!=V,
R1 + R2 = 256 + 266 = 522
It means that N=C=Z=V=0.
Where am I wrong?
Update for those who may be interested in this question:
My professor made a mistake, that's all. The correct answer is that I wrote.