For example, assume your student ID (SID) is 87654315 and x=5, then use your SID to define the initial values of A as follows:
Then the array A should be modified to:
Sample Output:
Original A=[[6,7,6,5,4,3,1,5]]
Modified A=[[245,320,125,180,45,80,5,125]]
Main program or function must conform to this convention strictly and use the stack to save and restore the necessary register values.
2. Program specifications:
Given an array A with 8 integers in words, i.e. A=[ag aas], write an MIPS assembly program to perform the following tasks:
a. Swap each pair of the array elements, A[2i] and A[2i+1] if A[2i]>A[2i+1] for all i=0..3 and
b. Square each element and then the result is multiplied by an immediate constant, (hard-coded in the program where x is the 8th digit of your SID if it is 0, set x=9).
The task (a) and (b) should be implemented by two functions which are called "swap" and "squaremul". The function, "swap" should accept two input arguments, swap them if necessary, pass the swapped results to the function "squaremul" and return the final results back to the caller while the function "squaremul" should accept one input argument and return the square and multiplication of the argument back to the caller.
Assume ag>a>a>a>a>a>as>a6>a, the array A should be modified as below: A=[axaxaxaxaxaxaxax].
Finally, print the modified array A as shown in the sample output.
The program execution flow is shown below:
start: -...--.-
jal swap
swap...
jal squaremul
squaremul:
jal squaremul
For example, assume your student ID (SID) is 87654315 and x=5, then use your SID to define the initial values of A as follows:
Then the array A should be modified to:
Sample Output:
Original A=[S754315]