Hanas J.

asked • 05/31/23

Order of RISC-V Conventions

Suppose we have the following stack, where the red line is the indicator for sp:

q3.png  

Suppose we now want the stack to contain these additional data items in the following order:

word.png

We are given the following instructions:

(a) addi sp, sp, -8 

(b) addi sp, sp, 4

(c) add sp, sp, 8 

(d) sw t2, 0(sp) 

(e) sw t2, 4(sp) 

(f) sw t0, 0(sp) 

(g) sw t0, 4(sp)

(h) lw t0, 4(sp)

(i) lw t2, 0(sp)

Which of the following sequence of RISC-V instructions will generate the stack status we want? Assuming that all the contents in the registers are words (4 bytes) and that the growth of the stack is downwards in memory(as was discussed in lectures).

  

  None of the options

 

  (b) -> (a) -> (e) -> (f)

 

  (b) -> (a) -> (g) -> (d)

 

  (b) -> (b) -> (h) -> (i)

 

  (c) -> (d) -> (g) -> (h)

 


1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.