VERIFY AND STATE THE FLAGS CZNV FOR EACH OF THE CONDITIONAL
VERIFY AND STATE THE FLAGS (CZNV) FOR EACH OF THE CONDITIONAL CHECKS USED BY THE ARM PROCESSOR
Perform arithmetic by taking sample numbers and verify the conditional checks using ARM instructions with the help of ARMSim# simulator. For example: (sample code for verifying EQ condition) MOV r0, #0x02; can be any number MOV rl, #0 times 02; can be any number CMP r0, r1; note that CMP instructions always affect the condition flags; Look at the Condition flags after this instruction for its correctness BLEQ same SWI 0 times 11; to terminate the execution and return control back to user Same: SWI 0 times 11; Single step the code to see where the control goes In the above, example, since r0 and r1 are having the same contents, BLEQ will be true and the control branches to the label same.Solution
Starting from the execution of the First statement.
1) As the MOV instruction will simply move the number to register r0. Therefore is no comparison done no checks done to move the value. Moreover the value will not overflow or underflow.
2) Similarly even for the second MOV command, there will be no change in the CZNV flag.
3) CMP command will compare the result of both the registers r0 and r1.That means the value of register r1 will be subtracted from r0.This is same as SUBS instruction but the result are discarded.
Thus the changes in the flags are:-
Z Set to 1 when result is zero, 0 otherwise.
C Set to 1 when results in a carry, 0 otherwise.
N Set to 1 when result is negative, 0 otherwise.
4) BLEQ command will be true because the register are having the same value.Therefore
Z Set to 1 when result is zero, 0 otherwise.
The value of Z flag will be set.
5) SWI instruction do not affect the condition flags.
