Question: 2. Now that you learned how to implement subroutines, convert your Vector-Vector Multiplication code implemented for HW3 to use a subroutine. The same data and

2. Now that you learned how to implement subroutines, convert your Vector-Vector Multiplication code implemented for HW3 to use a subroutine. The same data and algorithm used for HW3 will be used. But this time, you will define a subroutine "vecMul" in a separate assembly file as described below Create a new project and add a new assembly file "vector mul main.s" to the project. . a. Define main function in myCode cODE AREA. b. The main function calls vecMul subroutine. To call vecMul that will be defined in another assembly file, you should use IMPORT directive (check the lecture slide) Pass the address of vector A as the first input parameter and the address of vector B as the second parameter to vecMul function. The first and second parameters should be passed via RO and R1, respectively c. d. The return value of vecMul should be stored in the variable C e. Define and initialize two 10-element integer arrays A and B, an integer variable C in DATA area just like you did for HW3 . Add another new assembly file "vector mul subroutine.s" to the project. a. Define a subroutine vecMul in mySubroutine CODE AREA. b. vecMul function runs the loop-based Vector-Vector Multiplication. To make this function visible by main function in another assembly file, you should use EXPORT directive (check the lecture slide) You can copy your HW3 code here. But, the two input parameters should be used as the base addresses of the two input vectors c. d. The multiplied result should be returned to main function via RO Use any general-purpose register if needed. Submit the vector mul main.s and vector mul subroutine.s to the Canvas . . 3. Write a recursive assembly subroutine that calculates the Fibonacci number. Fibonacci numbers are those that follow a special sequence like below: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, Nth Fibonacci number can be calculated with the following formula. 1 F (N1) F (N) - if N1 F (N-2) otherwise The pseudo code of Fibonacci number function is like below
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
