Question: RISC-V Assembly Language. Consider the C++ program fragment: for( j=0; j
RISC-V Assembly Language.
Consider the C++ program fragment:
for( j=0; j which performs a computation on two floating-point arrays of size 'n'. Rewrite this fragment in RISC-V assembly language. Take n = 64. The address of 'a[0]' is 2048. The address of 'b[0]' is 3072. Set 'r1' to the address of 'a[0]'. Set 'r2' to the address of 'b[n-1]'. Set 'r3' to the byte address immediately following the end of array 'a'. Use only the following instructions. Note: only the _syntax_ is shown; choose your own registers. set r1,m // set 'r1' to integer 'm' fld f6,n(r2) // load into 'f6' the eight bytes starting at Mem[r2+n] fst f8,o(r3) // store starting at Mem[r3+o] the eight bytes in 'f8' fmul f4,f0,f2 // put the product 'f0 * f2' into 'f4' addi r1,r1,j // add integer 'j' to 'r1' subi r1,r1,k // subtract integer 'k' from 'r1' bne r1,r2,loop // if 'r1 /= r2' then goto 'loop'
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
