Question: Assignment You will be using C++ ABI for MIPS to create two functions that solve different problems. The structures used in this program are: struct

Assignment

You will be using C++ ABI for MIPS to create two functions that solve different problems.

The structures used in this program are:

struct Values { char operation; short left; short right; int result; }; struct Matrix3 { int mat[9]; }; struct Vector3 { int vec[3]; };

The gofunc Function

The gofunc function has the following C++ prototype:

int gofunc(Values values[], int num_values);

This function will take an array of Values structures and perform the operation given in the field "operation" to every Value structure's left right and store the result in the result field. You will be doing this for num_values number of elements.

This is why the structure is NOT constant. It will be modified in place.

Finally, when this function is done, it will return the number of valid operations that were successfully performed.

The following operations must be supported:

'&' result = left & right
'|' result = left | right
'^' result = left ^ right
'~'

result = ~left

The MatMul Function

The matmul function has the following prototype:

void matmul(Vector3 &result, const Matrix3 &mat, const Vector3 &vec);

This function will perform matrix multiplication on mat x vec and store the resulting vector into result. If you don't remember, matrix multiplication is performed as follows.

[m11 m12 m13 m21 m22 m23 m31 m32 m33 ] [v1 v2 v3]=[m11v1+m12v2+m13v3m21v1+m22v2+m23v3m31v1+m32v2+m33v3]

To receive credit for this function, you must use loops. Take a look at the formula above and notice the parallelism there, such as v1 being present for all first column values (m11, m21, and m31).

The matrix in the structure is formatted in row-major, meaning that m[0] = m11, m[1] = m12, and m[2] = m13 and so forth.

Testing

As always, I recommend you write your logic in C++, then translate. If you ask for help with the TAs (or me), we may ask you to show us your logic. Do not change the prototypes and do not change the structures. Notice that there is no "int main". You can create one to test your code, but we will only be testing your product function.

Notice that these are pure functions, so you will only need the .text section.

Restrictions and Hints

  1. You must use the proper registers for your functions' parameters and return types.
  2. Do not prompt the user for anything inside of these functions. All of the data will be passed into your function from main.
  3. You are permitted to use the stack for local variables or to preserve saved registers, and global variables are not permitted.
  4. You may use pseudo-instructions for this lab as long as you know how it operates.
  5. Do not use instructions we have not covered in class, such as mflo and so forth. We require you to understand all instructions that you choose to use.
  6. You can create a main to test your functions, however do not submit it or anything to support it. We only want gofunc and matmul in one assembly source file.

NEEDS TO BE WRITTEN IN MIPS!!!!!!!!!!!!!!!!!!!!!!

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!