Question: 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

 In this question, you will practice writing assembly programs using theRISCV 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 variables are stored in the following registers:

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 variables are stored in the following registers: C Declaration Variable Register unsigned x ao unsigned y y a1 unsigned z a2 unsigned a [20] unsigned* P a4 char c [20] a5 poN a3 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[0] + y) z = ((unsigned) c[1]) + x x = y % 4 A.3.2 Assembly to C Convert the following assembly code segment into C code: addi a2, ai, 9 add a0, a2, a2 addi to, a3, 4 lw a0, 0(to) lb lb and to, 4(a5) ti, 7(a5) a0, to, t1 lw to, 0(a3) lw to, 4(10) to, 4(a3) SW 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++; } 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 variables are stored in the following registers: C Declaration Variable Register unsigned x ao unsigned y y a1 unsigned z a2 unsigned a [20] unsigned* P a4 char c [20] a5 poN a3 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[0] + y) z = ((unsigned) c[1]) + x x = y % 4 A.3.2 Assembly to C Convert the following assembly code segment into C code: addi a2, ai, 9 add a0, a2, a2 addi to, a3, 4 lw a0, 0(to) lb lb and to, 4(a5) ti, 7(a5) a0, to, t1 lw to, 0(a3) lw to, 4(10) to, 4(a3) SW 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++; }

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!