Question

2.4 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. silix30, x5, 3 // x30=f*8 add x30, x10, x30 // x30=&A [f] s111 x31, x6 , 3 // x31 = g.8 add x31, x11, x31 // x31=&B [g] ld x5, 0(x30) // f=A[f] addi x12, x30, 8 ld x30, 0 (x12) add x30, x30, x5 sd x30, 0 (x31)

0 0
Add a comment Improve this question Transcribed image text
✔ Recommended Answer
Answer #1

Consider the variables f, g, h, i, and j are assigned to registers x5, x6, x7, x28, and x29, respectively. The base address o

Add a comment
Know the answer?
Add Answer to:
2.4 For the RISC-V assembly instructions below, what is the corresponding C statement? Assume that the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Similar Homework Help Questions
  • Problem 2.4: For the RISC-V assembly instructions below, what is the corresponding C statement? Assume that...

    Problem 2.4: 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. х30, х5, 3 add x30, x10, х30 // x30 %3D &A[F] slli x31, х6, 3 add x31, x11, х31 // х31 %3D &B[g] x5, 0(х30) // x30...

  • 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...

  • 2.7 5<S$2.2, 2.3> Translate the following C code to RISC-V. Assume that the variables f, g, h, i, and j are assigned to registers x5, x6. x7. x28, and x29, y. Assume that the base address of th...

    2.7 5<S$2.2, 2.3> Translate the following C code to RISC-V. Assume that the variables f, g, h, i, and j are assigned to registers x5, x6. x7. x28, and x29, y. Assume that the base address of the arrays A and B are in registers x10 and x11, respectively. Assume that the elements of the arrays A and B are 8-byte words: 2.7 5 Translate the following C code to RISC-V. Assume that the variables f, g, h, i, and...

  • Convert the following C statement to the corresponding ARMv7 assembly code: Assume that the variables f,...

    Convert the following C statement to the corresponding ARMv7 assembly code: Assume that the variables f, g, h, i, and j are assigned to registers X0,X1,X2,X3, and X4, respectively. Assume that the base address of the arrays A and B are in registers X6 and X7, respectively. B[8] = A[i−j]; Convert the following LEGv8 assembly instructions to ARMv7 as well as find the corresponding C statement. Assume that the variables f, g, h, i, and j are assigned to registers...

  • Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){...

    Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){ rpt=rpt-1; goto loop } 2. Translate the following Risc-V code into C. variable 'i' in register x5, variable 'result' in x6 ,base address of integer 'memarray' in x10    addi x6,x0,0    addi x29,x0,100 LOOP: ld x7,0(x10)    add x5,x5,x7    addi x10,x10,8    addi x6,x6,1    blt x6,x29, LOOP

  • 2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the...

    2.4 For the MIPS assembly instructions below, what is the corresponding C statement? Assume that the variables f, g, h, i, and j are assigned to registers $s0, $s1, $s2, $s3, and $s4, respectively. Assume that the base address of the arrays A and B are in registers $s6 and $s7, respectively. sll $t0, $s0, 2               # $t0 = f * 4 add $t0, $s6, $t0         # $t0 = &A[f] sll $t1, $s1, 2               # $t1 =...

  • Problem 1 (15 points) Translate the C code below into RISC-V, knowing that the values of...

    Problem 1 (15 points) Translate the C code below into RISC-V, knowing that the values of i and j are in registers x28 and x29, respectively. The base address of array B is in register x30, and the base address of array C is in register x31.

  • 1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume...

    1. (15 pts) For the following C statement, what is the corresponding MIPS assembly code? Assume f, g, h correspond to $80, $s1, and $s2, respectively. f=g+(h-5) 2. (15 pts) For the following pseudo-MIPS assembly instructions, what is the corresponding C code? add f, g, h add f,i, f 3. (30 pts) Provide the instruction type, assembly language instruction, and binary representation of the instruction described by the following MIPS fields: a. op = 0, rs = 18, rt=9, rd...

  • Translate the following C code to LEGv8. Assume that the variables f, g, h, i, and...

    Translate the following C code to LEGv8. Assume that the variables f, g, h, i, and j are assigned to registers X0, X1, X2, X3, and X4, respectively. Assume that the base address of the arrays A and B are in registers X6 and X7, respectively. Assume that the elements of the arrays A and B are 8-byte words: B[8] = A[i] + A[j];

  • (ii) f = g - A[C[16) + B[321) (iii) A[i] 4B[8i-811 + 4C[32i+321 Problem 2. Consider...

    (ii) f = g - A[C[16) + B[321) (iii) A[i] 4B[8i-811 + 4C[32i+321 Problem 2. Consider the following code (again, assume a 64-bit machine) ld x6, 0 (x7) sd x6, 8(x7) Assume that the register x7 contains the address 0x1000000000000000 and the data at address is 0x112233445566778899 AABBCCDDEEFF. a. What value is stored in 0x100000000000000F on a bigendian machine? b. What value is stored in 0x100000000000000F on a littleendian machine? Problem 1. Write down the RISC V code for the...

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