Question: SW (c) In this question, you will write (short) RISC-V assembly programs for two different tasks. Your programs may only use the registers x0, ao,


SW (c) In this question, you will write (short) RISC-V assembly programs for two different tasks. Your programs may only use the registers x0, ao, t1, t2, sp, and fp, and the following RISC-V assembly commands: lw register offset (register) load a word of data at offset from an address stored in register,, into register register offset (register) store the value of register into memory at offset from an address stored in register add register1 register2 register3 add the values stored in register and register, and store the result in register addi register register, constant add the signed 16-bit value constant to the value stored in register, and and store the result in register . address jump to the instruction at address. be register registeraddress if the contents of register, and register, are equal, jump to the instruction at address. register register address if the contents of register and register, are different, jump to the instruction at address. Each instruction is to be written on a separate line. Use the convention that the stack grows "downwards" (i.e., that the front of the stack is at a lower address than the rest of the stack) and that sp points at an unused word in memory below the front of the stack. b bne ii. Write a RISC-V assembly program to add a sequence of numbers which are stored on the stack. Assume the following: The last item on the stack to be added, is at the address which is pointed to by fp; and that the initial value stored by fp is an address in memory which is higher than that stored in sp. In particular: there is at least one item on the stack to be added. The resulting sum is to be stored at the front of the stack. The first instruction should have a symbolic address "start", and the last instruction should jump to a symbolic address done". [20 marks] SW (c) In this question, you will write (short) RISC-V assembly programs for two different tasks. Your programs may only use the registers x0, ao, t1, t2, sp, and fp, and the following RISC-V assembly commands: lw register offset (register) load a word of data at offset from an address stored in register,, into register register offset (register) store the value of register into memory at offset from an address stored in register add register1 register2 register3 add the values stored in register and register, and store the result in register addi register register, constant add the signed 16-bit value constant to the value stored in register, and and store the result in register . address jump to the instruction at address. be register registeraddress if the contents of register, and register, are equal, jump to the instruction at address. register register address if the contents of register and register, are different, jump to the instruction at address. Each instruction is to be written on a separate line. Use the convention that the stack grows "downwards" (i.e., that the front of the stack is at a lower address than the rest of the stack) and that sp points at an unused word in memory below the front of the stack. b bne ii. Write a RISC-V assembly program to add a sequence of numbers which are stored on the stack. Assume the following: The last item on the stack to be added, is at the address which is pointed to by fp; and that the initial value stored by fp is an address in memory which is higher than that stored in sp. In particular: there is at least one item on the stack to be added. The resulting sum is to be stored at the front of the stack. The first instruction should have a symbolic address "start", and the last instruction should jump to a symbolic address done". [20 marks]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
