Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Design a job advertisement.

Answered: 1 week ago