CIS 351 |
Assembly Loops |
Winter 2022 |
For this lab, you are going to write and test some assembly code using loops. As with previous assignments, in order for your solution to work with my testing software, you must follow these rules:
.globl
.a0
, a1
, and a2
.
a0
will contain the first parameter, a1
the second, etc.
jr $ra
.1
for true
and 0
for false
.You must also write a reasonably complete set of unit tests.
int indexOf(int value, int[] array)
array
that is equal to value
, or return -1
if
value
doesn't appear in array
. For this
problem, a negative value will mark the end of
array
.
int max(int[] array, int length)
array
.
void reverse(char[] string)
string
in place. string
will be null-terminated. Hint: Set up two
pointers, one to the first character, one to the last. Then "walk" the pointers toward the middle swapping as
you go.
void evenOdd(int[] array, int length)
array
in place such that all the even numbers come before all the odd numbers.
The numbers may be in any order, so long as the evens come before the odds. This problem is based on
the evenOdd CodingBat problem; however, unlike the CodingBat
problem, you are not allowed to write data outside of the array.
You may use this class as a
starting point for your MUnit
tests.
Use this GitHub Classroom repository. Place your code in loops1.asm
.
Do not rename the methods. The repo also has a file you can use as the
starting point for your MUnit
tests.
Be sure to document and comment your code!
When your code passes all tests, commit your code with [Grade Me]
in the message.
Updated Tuesday, 8 February 2022, 3:11 PM