Reputation: 139
so I'm trying to study for this test and one of the things on the study guide gives us some ARM Code and tells us to fill in a branch prediction table based on how the code runs.
I can understand how I'm supposed to do it, but with branch prediction the actual outcome comes into play, too, and I can't figure out the outcome (per cycle) from the code. The code is:
MOV r0, #4
B1 MOV r2, #5; Branch 1
SUB r2, r2, r0
B2 SUBS r2, r2, #1; Branch 2
BNE B2
SUBS r0, r0, #1
BNE B1
What's confusing me is the BNE statements. Usually when I see one of those conditional statements there has been a CMP statement earlier in the code, and that way I can know whether to take the branch or not. But I see no compare statement anywhere in this code, so I don't know how to determine if I should take a branch or not.
Upvotes: 0
Views: 300
Reputation: 3811
The SUBS
performs a subtraction and a comparison with zero of the result in one instruction. The BNE
conditional branches use the condition flags that were set by these SUBS
instructions
Upvotes: 0