Question: 1. (40 points) Write a MIPS assembly program that reads n elements from an array A, and writes those N elements to another array B
1. (40 points) Write a MIPS assembly program that reads n elements from an array A, and writes those N elements to another array B in reverse order. For example, if A contains {10,20,30,40,50,60,70,80} and n equals to 5; then at the end of the program execution, the array B must contain (50,40,30,20,10). The main function of the program is given in the following. You only need to write code that defines the "reverse" function. Write a single-line comment for each instruction of your code, explaining the purpose of that instruction. .data A: .word 10, 15, 20, 4, 89, 34, 55, 66, 22, 19, 56, 78 #A is the source array B: .word 0:20 #destination array to store data in reversed order n: .word 10 #the number of elements .text .globl main main: la $a0, A la Sal, B la $t2, n lw $a2, 0(t2) #load the base address of A to $a0 #load the base address of A to Sal jal reverse #procedure/function call from main li $v0,10 #system call syscall reverse: # your function definition goes after here (Hint: Consider using a stack)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
