Question: The following RISC - V procedure is intended to reverse a string. We have deliberately omitted the code that saves and restores registers from the

The following RISC-V procedure is intended to reverse a string. We have deliberately omitted the code that saves and restores registers from the stack. Inspect the code and select which registers, if any, must be saved in the stack.
section .text
global strrev
strrevi
8 s *1= str
a *0= sz
# t*theta = sz /0.2
1=1
#Enter stack frame
#What registers should we push to the stack?
#Get the size of the string
mv $1, ao #this is the same as add si, ae, zero
jal strlen
srai to, ab,1 # Divide sz by 2
11 tl,0 #1=0
[ matrix L1&g& for *1oop matrix ]
bget 1, te ,L2 add t2,s1,t1|| str +1 subt 3, a*theta ,t1 forall sz-1 a dd1 t3,t3,-1 sz-1-1 add t3,t3,s1 forall str + sz -1-11bt *4, theta(t2)/str[1]]1b t5, theta(t3) forall str[sz -1-1]
sbt *4, theta(t3) ne swap
sbt *5, theta(t2)
addi t 1,t1,1
JL1
L2:
#Leave stack frame
#what registers should we pop from the stack?
jr rab
which ones from below is correct:
ra
t0
No register needs saving
t4
t5
t3
t1
t2
a0
s1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!