5.61 · exercise

Predict: Subroutine State and Linkage

Act as the CPU. Trace the register states and stack allocations that a subroutine call sets up.

0 of 4 correct

Mental Trace

// the bl below sits at address 0x400040
bl swap
add w0, w0, 1

Mental Trace

// C, where sum takes ten int arguments
sum(10, 20, 30, 40, 50, 60, 70, 80, 90, 100);

Mental Trace

cube:
    mul w9, w0, w0
    mul w0, w9, w0
    ret

Mental Trace

// C, where struct mystruct is 64 bytes of int members
struct mystruct lvar;
return lvar;