The Student Room Group

Assembly Question

I don't understand the answer to this question : https://gyazo.com/22171f59cd73ddc9b08424fcdea1c325

The answer : https://gyazo.com/dca42a4a7ef6e02c237ea9d3c379cf86

Why does it have two end ifs... why does it have end ifs at all if this is assembly?
Original post by brbrbrh
I don't understand the answer to this question : https://gyazo.com/22171f59cd73ddc9b08424fcdea1c325

The answer : https://gyazo.com/dca42a4a7ef6e02c237ea9d3c379cf86

Why does it have two end ifs... why does it have end ifs at all if this is assembly?


The end ifs are just what they write instead of for example HALT, which tells the program to stop. Instead of using the two if statements you could label each statement in the order it should be carried out in. This might be easier.

1. CMP R1, #5
2. BNE 4
3. MOV R2, #10
4. HALT

this is what I would have done, so if the number 2 is true then the program will locate number 4 and stop the procedure

Quick Reply