0
0
ARM Architectureknowledge~20 mins

Preserving callee-saved registers in ARM Architecture - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
ARM Callee-Saved Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why preserve callee-saved registers?

In ARM architecture, why must a function preserve callee-saved registers?

ABecause the caller expects these registers to remain unchanged after the function call.
BBecause callee-saved registers are used only for temporary calculations within the function.
CBecause the operating system requires all registers to be saved by the callee.
DBecause callee-saved registers are automatically saved and restored by hardware.
Attempts:
2 left
💡 Hint

Think about who is responsible for keeping the values intact across function calls.

📋 Factual
intermediate
2:00remaining
Which ARM registers are typically callee-saved?

Identify the registers that are usually preserved by the callee in ARM calling conventions.

Ar4 to r11 and the stack pointer (sp)
Br0 to r3 and the link register (lr)
CProgram counter (pc) and r0 to r3
DOnly r0 and r1
Attempts:
2 left
💡 Hint

Consider which registers are used for passing arguments and which are preserved.

🔍 Analysis
advanced
2:00remaining
Effect of not preserving callee-saved registers

What is the likely outcome if a function modifies callee-saved registers but does not restore them before returning?

AThe function will cause a hardware exception immediately.
BThe caller may experience incorrect data or behavior due to unexpected register changes.
CThe program will automatically fix the registers after the function returns.
DThere will be no effect because callee-saved registers are not used by the caller.
Attempts:
2 left
💡 Hint

Think about the caller's expectations about register values after a function call.

🚀 Application
advanced
2:00remaining
Preserving callee-saved registers in assembly

Given this ARM assembly snippet, which option correctly preserves callee-saved registers?

ARM Architecture
push {r4, r5, lr}
// function body
pop {r4, r5, pc}
ANo push or pop instructions are needed for callee-saved registers.
BPush r0, r1 at start; pop r0, r1 at end.
CPush only lr at start; pop only lr at end.
DPush r4, r5, and lr at start; pop r4, r5, and pc at end to restore registers and return.
Attempts:
2 left
💡 Hint

Remember which registers must be saved and how to return from a function.

Reasoning
expert
3:00remaining
Stack frame and callee-saved registers interaction

In ARM, when a function uses callee-saved registers and creates a stack frame, what is the correct order of operations to preserve these registers and set up the frame?

A1, 3, 2, 4
B2, 1, 3, 4
C1, 2, 3, 4
D2, 3, 1, 4
Attempts:
2 left
💡 Hint

Think about saving registers before using stack space and restoring in reverse order.