0
0
ARM Architectureknowledge~20 mins

Compare and branch patterns in ARM Architecture - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ARM Compare and Branch Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding ARM Compare and Branch Instructions

In ARM assembly, compare and branch instructions are used to control program flow based on conditions. Which of the following best describes the purpose of the CBZ instruction?

AIt compares a register to zero and branches if the register is zero.
BIt compares two registers and branches if they are equal.
CIt compares a register to zero and branches if the register is not zero.
DIt unconditionally branches to a label.
Attempts:
2 left
💡 Hint

Think about what the abbreviation CBZ stands for.

📋 Factual
intermediate
2:00remaining
ARM Branch Instruction Condition Codes

Which ARM condition code suffix causes a branch if the previous comparison found the values to be not equal?

ANE
BEQ
CGT
DLT
Attempts:
2 left
💡 Hint

Recall that NE stands for 'Not Equal'.

🚀 Application
advanced
2:00remaining
Predicting Branch Outcome from ARM Code

Given the following ARM assembly snippet, what will be the value of register R2 after execution if R1 contains 0?

    CMP R1, #0
    BNE skip
    MOV R2, #1
skip:
    MOV R2, #2
A0
B1
CUndefined
D2
Attempts:
2 left
💡 Hint

Consider what the BNE instruction does when R1 is zero.

🔍 Analysis
advanced
2:00remaining
Identifying Error in ARM Compare and Branch Sequence

Examine the following ARM code snippet. What error will occur when this code runs?

    CMP R0, R1
    BEQ label
    MOV R2, #5
label:
    MOV R2, #10
ALogical error: MOV R2, #5 is always skipped.
BNo error; R2 will be 10 regardless of comparison.
CRuntime error because label is undefined.
DSyntax error due to missing colon after label.
Attempts:
2 left
💡 Hint

Check the label syntax and branching logic carefully.

Reasoning
expert
2:00remaining
Choosing the Correct Branch Instruction for a Condition

You want to branch to done only if the value in R3 is less than the value in R4. Which ARM instruction should you use immediately after CMP R3, R4?

ABLE done
BBGT done
CBLT done
DBNE done
Attempts:
2 left
💡 Hint

Remember that BLT means 'Branch if Less Than'.