1. (25 points) Write the RISC-V assembly code for the following C code. Take a screenshot of your completed assembly code. Skeleton is provided (hw2_1_skeleton.s). Assume that the register x10 holds the base address of array A. The length of array A is stored in the register x11. Registers x5, x6, and x7 hold the values of i, j, and temp, respectively. 2
= = = O O OCTA co N A 1 for (i = 0; i < LENGTH; i++) { 0 2 for (j = i + 1; j < LENGTH; j++) { 3 if (A > A[j]) { 4 temp = A; 5 A A [j]; 6 A [j] = temp; 7 } 8 } 9} =
.data A: .word 27,20,2,24,7,19,2, 10, 10,22 .text la x10, A addi x11, x0, 10 addi x5, 0 addi x6, xe, 0 addi x7, x0 0 х0, # put the base address of array A in x10 # put the length of array A in x11 # the temperary variable i # the temperary variable j # the temperary variable temp # insert your code here exit: nop
1. (25 points) Write the RISC-V assembly code for the following C code. Take a screenshot of your completed assembly cod
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
1. (25 points) Write the RISC-V assembly code for the following C code. Take a screenshot of your completed assembly cod
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!