Question: 1 myfunc: 2 # Prologue (code for save registers are hidden) 3 4 # assign registers to hold arguments to myfunc 5 addi to,



1 myfunc: 2 # Prologue (code for save registers are hidden) 3 4 # assign registers to hold arguments to myfunc 5 addi to, a0, 0 6 addi so, al, 0 7 addi a7, a2, 0 8 9 jal generate_random #code for saving/restoring regs are hidden 10 11 # store and process return value 12 addi tl, a0, 0 slli t5, t1, 2 13 14 15 # setup arguments for reverse 16 add a0, to, x0 add al, 50, x0 add a2, t5, x0 addi a3, t1, 0 20 add a7, t5, a7 21 22 jal reverse #code for saving/restoring regs are hidden 23 24 # additional 17 18 19 25 add to, s0, x0 add t1, tl, a7 26 27 add s9, 58, t1 28 add s3, x0, t5 29 30 exit: # Epilogue (code for restoring registers are hidden) 31 ret The lifetime of register t1 is between lines 12 27 Question 2 6 The lifetime of register so is between line line 17 and 0.2 pts and Question 3 What callee-saved registers must be saved on the stack in the prologue of myfunc? U U U U U U U U U U SO a7 s8 $9 t1 to a3 s3 t5 a1 a0 Oa2 0.3 pts Question 4 What caller-saved registers must be saved on the stack before calling reverse? J U L D U 1 U U J a3 a2 SO a0 8 t5 a1 s9 a7 t1 ra to 0.3 pts s3 1 myfunc: 2 # Prologue (code for save registers are hidden) 3 4 # assign registers to hold arguments to myfunc 5 addi to, a0, 0 6 addi se, al, 0 7 addi a7, a2, 0 8 9 jal generate_random #code for saving/restoring regs are hidden 10 11 # store and process return value 12 addi tl, a0, 0 slli t5, t1, 2 13 14 15 # setup arguments for reverse 16 add a0, to, x0 add al, 50, x0 add a2, t5, x0 addi a3, t1, 0 20 add a7, t5, a7 21 22 jal reverse #code for saving/restoring regs are hidden 23 24 # additional 17 18 19 25 add to, s0, x0 add t1, tl, a7 26 27 add s9, 58, t1 28 add s3, x0, t5 29 30 exit: # Epilogue (code for restoring registers are hidden) 31 ret The lifetime of register t1 is between lines 12 27 Question 2 6 The lifetime of register so is between line line 17 and 0.2 pts and Question 3 What callee-saved registers must be saved on the stack in the prologue of myfunc? U U U U U U U U U U SO a7 s8 $9 t1 to a3 s3 t5 a1 a0 Oa2 0.3 pts Question 4 What caller-saved registers must be saved on the stack before calling reverse? J U L D U 1 U U J a3 a2 SO a0 8 t5 a1 s9 a7 t1 ra to 0.3 pts s3
Step by Step Solution
There are 3 Steps involved in it
In analyzing the assembly codes usage of registers we can determine the lifetime of certain registers and which calleesaved and callersaved registers ... View full answer
Get step-by-step solutions from verified subject matter experts
