This is last minute change of plans for the labs. We are going to do a few little array computations today to make sure you have everything ready for the upcoming homework assignment.
You should work by yourself today. Hopefully you will breeze through this one and will have time to shorten the wires on the breadboard you created in the Power Management lab.
Getting Started
Downloading a starter project
Download a
tar.gz file
containing a compressed MPLAB X
project called ArrayTester
.
You should be able to expand it from the browser.
Be sure to store it in your MPLABXProjects
directory.
It might also be useful to bring up the Arrays with the MIPS32 Assembly lab in another browser window to jog your memory about UART simulation and MIPS32 arrays.
Looking at the code
Take a look at the following files within the project.
- tester.c —
Contains the
main
function for the project. Does little more than calltestArrayFunctions
with the address of functions to be tested. - misc.c —
Contains the
testArraysFunctions
function which calls two functions, passed as parameters, and see if they perform the same results. - testFunctionsInC.c — Four C array functions which you will implement in MIPS32 assembly language.
- tester.h — An include file with prototypes for all the functions.
- The .s files — These are outlines for your assembly code.
Note the header for the testArrayFunctions
function
in misc.c . This is how you
declare function prototype. The physicists using C (and FORTRAN)
love to pass functions to functions.
void testArrayFunctions( int32_t (*f1)(int32_t *, int32_t), int32_t (*f2)(int32_t *, int32_t), int32_t size)
Even stranger is the prototype for
testArrayFunctions
in tester.h . It doesn’t contain
parameter names. No other programming language has a (*)
.
void testArrayFunctions( int32_t (*)(int32_t *, int32_t), int32_t (*)(int32_t *, int32_t), int32_t) ;
By the way, most programmers would include the names.
Your task for today
First, comment out the #define
for BORINGTEST
and
comment in the #define
for EXCINGTEST
.
This will cause your program to use the MIPS32 assembly routines rather than
their C equivalents.
// #define BORINGTEST 1 #define EXCITINGTEST 1
Debug your project. You should now have lots of errors for the Exciting tests.
One at a time, fix all of the four MIPS32 routines.