Question

1 slli x30, x5, 3 add x30, x10, x30 slli x31, x6, 3 add x31, x11,...

1
slli x30, x5, 3
add x30, x10, x30
slli x31, x6, 3
add x31, x11, x31
ld x5, 0(x30)
addi x12, x30, 8
ld x30, 0(x12)
add x30, x30, x5
sd x30, 0(x31)
// x30 = f*8
// x30 = &A[f]
// x31 = g*8
// x31 = &B[g]
// f = A[f]
For the RISC-V assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are assigned to registers x5, x6, x7, x28, and x29, respectively. Assume that the base address of the arrays A and B are in registers x10 and x11, respectively.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

7.3の= add x 3) , xil, x31 ニValue of(x30) addi Xi2 X 1 2 add x30, x30, xS メ30 = x30 +XS store value of x 30 + A


CODE :

main.c saved 1 #include <stdio.h> 3 int main(void) 4. int f,g; //Initialize elements of array A,B 6 7int A -5,7,11,20,40,15,1

#include

int main(void)

{

int f,g;

//Initialize elements of array A,B

int A[] = {5,7,11,20,40,15,100,300,-25,66};

int B[] = {0,1,2,3,4,5,6,7,-8,9};

//Initialize f and g

f = 3;

g = 6;

int i = f; //x30

f = A[f];q

i = A[i+1] + f;

B[g] = i;

//Testing

printf("f = %d\n",f);

printf("B[g] = %d",B[g]);


return 0;

}



OUTPUT :

gcc version 4.6.3

Add a comment
Know the answer?
Add Answer to:
1 slli x30, x5, 3 add x30, x10, x30 slli x31, x6, 3 add x31, x11,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT