Question: A.3 RISCV Assembly Programming In this question, you will practice writing assembly programs using the RISCV assembly code. Since the RISCV assembly code is very

 A.3 RISCV Assembly Programming In this question, you will practice writingassembly programs using the RISCV assembly code. Since the RISCV assembly codeis very similar to the MIPS assembly code, you may find thereferences in COD helpful. In all cases, assume the C variables are

A.3 RISCV Assembly Programming In this question, you will practice writing assembly programs using the RISCV assembly code. Since the RISCV assembly code is very similar to the MIPS assembly code, you may find the references in COD helpful. In all cases, assume the C variables are stored in the following registers: C Declaration Variable Register ao al a2 unsigned x unsigned y unsigned z unsigned a [20] unsigned* p char c[20] x Neo a3 a4 a5 A.3.1 Arithmetic and logic operations Implement the following C code segment as RISCV assembly code. z = X - Y - Z y = x & OxF0 + z & Ox04 y = a[2] + 9 y = a[a[O] + y] ((unsigned) c[1]) + x x = y % 4 Z = A.3.2 Assembly to C Convert the following assembly code segment into C code: addi a2, al, 9 add all, a2, a2 addi lw to, a3, 4 al, 0(to) . lb lb and to, 4(25) t1, 7(a5) ao, to, t1 lw to, o(a3) lw to, 4(to) SW to, 4(a3) A.3.3 Branches and Jumps Implement the following C code segment as RISCV assembly code. if (x == y) { z = x+1; } else { z = a[2]; } if (x z) { a[x] = a[x] + 1; } else { a[x] = a[x] 1; } for (x = 0; x 0) { a[x] = y; y++; X--; } A.3 RISCV Assembly Programming In this question, you will practice writing assembly programs using the RISCV assembly code. Since the RISCV assembly code is very similar to the MIPS assembly code, you may find the references in COD helpful. In all cases, assume the C variables are stored in the following registers: C Declaration Variable Register ao al a2 unsigned x unsigned y unsigned z unsigned a [20] unsigned* p char c[20] x Neo a3 a4 a5 A.3.1 Arithmetic and logic operations Implement the following C code segment as RISCV assembly code. z = X - Y - Z y = x & OxF0 + z & Ox04 y = a[2] + 9 y = a[a[O] + y] ((unsigned) c[1]) + x x = y % 4 Z = A.3.2 Assembly to C Convert the following assembly code segment into C code: addi a2, al, 9 add all, a2, a2 addi lw to, a3, 4 al, 0(to) . lb lb and to, 4(25) t1, 7(a5) ao, to, t1 lw to, o(a3) lw to, 4(to) SW to, 4(a3) A.3.3 Branches and Jumps Implement the following C code segment as RISCV assembly code. if (x == y) { z = x+1; } else { z = a[2]; } if (x z) { a[x] = a[x] + 1; } else { a[x] = a[x] 1; } for (x = 0; x 0) { a[x] = y; y++; X--; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!