Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

b ) ( 0 . 5 Point ) Please explain the functionality of the program ( i . e . , what it does )

b)(0.5 Point) Please explain the functionality of the program (i.e., what it does), and give the updated data in the memory after the program execution in Table 4.
Solution:
It's like a sort function(like insertion sort), sorting from small to large.
Table 4: Updated Memory Content After Program Execution
\table[[Address,Momory Content],[dots,dots,dots,dots,cdots,dots,dots,dots,dots],[0\times 10010000,0\times 0000000=,0\times 0000000b,0\times 0000000e,0\times 0000000E,0\times 0000001b,0\times 0000001e,0\times 00000020,0\times 00000021],[0\times 10010020,0\times 00000011,0\times 00000022,0\times 00000033,0\times 00000044,0\times 00000055,0\times 00000066,0\times 00000077,0\times 00000088],[dots,dots,dots,dots,cdots,dots,dots,dots,...]]
c)(0.5 Point) Are there any problem with this program? (Hint: related to issues of register usage convention).
Solution:
Yes. We may affect the register values outside the function.
So we need to use local registers and stack space to ensure our uses do not affect the register values outside the function. (2 Points) Table 2 gives the RISC-V binary code and data (both in hexadecimal representation) for a program. Suppose PC=000400000 before program execution.
Table 2: Memory Content Before Program Execution
\table[[Address,,,,Momory,Content,,,],[cdots,cdots,cdots,cdots,cdots,...,cdots,cdots,-],[0x00400000,0\times 0Ee10517,0\times 00050513,0\times 00800593,0x00B000eE,0x00008067,0x00450293,0x00259313,0x00650363],[0x00400020,0x0272d863,0x0002=303,0xinfe2Be13,0x00=4e63,0x000in2e83,0x01435863,0x01de2223,0xinfe=0=13],[0x00400040,0xlarr=0006e3,0\times 006-:2223,0\times 00428293,0xine000=3,0\times 00000B67,...,dots,...],[cdots,cdots,cdots,cdots,...,...,cdots,cdots,cdots],[0\times 10010000,0\times 0000001e,0\times 00000021,0\times 0000000e,0\times 0000000b,0\times 0000000E,0x00000020,0\times 0000001b,0\times 0000000=],[0\times 10010020,0\times 00000011,0\times 00000022,0\times 00000033,0\times 00000044,0\times 00000055,0x00000066,0\times 00000077,0\times 00000088],[cdots,cdots,cdots,cdots,cdots,cdots,cdots,cdots,cdots]]
a)(1 Point) Please translate the RISC-V binary code back into RISC-V assembly code in Table 3. The semantics of the first instruction AUIPC is: x10=PC+(Imm2012), and here Imm20=00fc10.
Table 3: Assembly Code of the Program
\table[[Label,Instruction],[L1: ,,AUIPC \times 10,0\times 0fc10],[L2:,ADDI x10,x10,0],[L3:,ADDI X11, X0,8],[L4:,JAL x1, L6],[L5:,JALR x0,x1,0],[L6:,ADDI x5, X10,4],[L7:,SLLI x6,x11,2],[L8:,ADD x7,x10,x6],[L9:,BGE x5,x7, L21],[L10:,LWx6,0(x5)],[L11:,ADDI x28,x5,-4],[L.12:,BLT x28,x10, L18],[L13:,LW x29,0(x28)],[L14:,BGE x6,x29, L18],[L15:,SW x29,4(x28)],[L16:,ADDI x28,x28,-4],[L17:,BEQ\times 0,x0,L12],[L18:,SW \times 6,4(\times 28)],[L19:,ADDI x5,x5,4],[L.20:,BEQ\times 0,x0,L9],[L21:,JALR x16,x0,0]]
image text in transcribed

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

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Show the impact emotional labor has on employees.

Answered: 1 week ago

Question

=+Does it showcase the firm's benefits?

Answered: 1 week ago

Question

=+ Does it list exciting places to go and famous sites to see?

Answered: 1 week ago