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
1. We are storing 0 to x10 register for comparison to rpt variable. And x19 register is used to store rpt variable.
add x10, x0, x0 # x10=0
Loop:
bge x10, x19, Exit #if rpt <=0 then exit
addi x19, x19, -1 #rpt= rpt-1
j Loop #iterate
Exit
2. Confusion in this part of answer.
Result=0; i=0; j=0;
If(result<100)
{ i=i+a[j];
j=j+8;
result=result+1;
}
Please do the following problems 1. translate into RISC-V Assembly variable rpt in x19 register. if(rpt>0){...
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]...
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...
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, 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...
Consider the following RISC-V loop: (i) LOOP: beq x6, XO, DONE (ii) addi x6, x6, -1 addi x5, x5, 2 (iv) slli x7, x5, 1 (iv) bge x5, XO, DONE (vi) jal x0, LOOP (vii) DONE: some-other-instruction Assume that the register x6 is initialized to the value 5, and x5 and x7 to the value 0. Find... a) Final value of x5 at the end of execution b)Final value of x7 at the end of execution c)Total number of instructions...
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.
Translate these loops into C. Assume that the C level integer i is held in register $t1,$s2 holds the c level integer called result, and $s0 holds the base address of the integer MemArray. addi $t1, $s0, 400 loop: lw $s1, 0($s0) add $s2, $s2, $s1 lw $s1, 4($s0) add $s2, $s2, $s1 addi $s0, $s0, 8 bne $t1, $s0, Loop
(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...
Computer Architecture Please help me explain the answer 3 For the following statement, translate the statement to ARM assembly code. Assume that variable fand g are each in register rO, r1. Base address of array A is in r3 and base address of array B is in r4. Temporary register is r5. f= g + A[B[3]] Ans) sol) LDR r5, 14, #12] ADD rs. r3. r5, LSL #2 LDR r5, [r3. #01 ADD rO, rl, r5 3 For the following...
please code using risc-v language and make it as simple as possible Problem 1: (20 marks) Part 1: (15 points) Compile the RISC-V assembly code for the following C code. Assume that n and k are passed in x3 and x4 respectively. Values n and k are initialized to 14 and 14. Assume that result returned in register fl and that double precision numbers are used. After you are done store the result in address: 12(x3). Are you allowed to?...