Question: 1. [12 points] This problem uses the RISC-V program fragment below. L1: addi x12, x0, 5 add x11, x0, // x11 = 0 //
![1. [12 points] This problem uses the RISC-V program fragment below. L1:](https://dsd5zvtm8ll6.cloudfront.net/questions/2024/03/65f26eebdfc1d_1710390440906.jpg)
1. [12 points] This problem uses the RISC-V program fragment below. L1: addi x12, x0, 5 add x11, x0, // x11 = 0 // x19 = 0 add x19, x0, addi x20, x0, 150 bge x11, x12, Exit slli x13, x11, 3 add x14, x16, x13 ld x15, 0(x14) blt x15, x20, L2 sd x0, 0(x14) add x19, x15, x19 beq x0, x0, L3 // i8 //x16 address of array[0] L2: addi x15, x15, 1 sd x15, 0(x14) L3: addi x11, x11, 1 jal x0, L1 // i++ Exit: (a) Write code (C or Java) that performs the same function as this code. (b) Assume that array [] = {100, 150, 200, 250, 300}. What is the value of x19 at the end? (c) Assume that array[] = {100, 150, 200, 250, 300}. What is the average CPI of the code frag- ment, assuming the cycle latencies shown in the table below? format R-type CPI 1 I-type 2 S-type SB-type U-type UJ-type 4 3 1 2 (d) Rewrite the assembly code above to use pointers instead of array indexes. Your code should modify x16 to do this, and you should have no need for x14.
Step by Step Solution
3.43 Rating (159 Votes )
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
