Forms groups of 1-3
One person in the group should create a team using the Github Classroom link.
There are four rounds. You will not complete them all in class.
After class, you may continue to work as a team, or go your own ways.
If you want to work together, join the team created above.
If you don't, make a new team - but be sure to share the code you worked on together.
If you need to split a team, ask me and I can remove someone from the group.
Create a file named FizzBuzz.asm
You may only use the registers $a0, $sp, $zero, and $ra. You may use $v0 for syscalls only.
You will submit your final versions by uploading them to the github repository, i.e. using "Add file/Upload files"
As mentioned in class, there are four steps to a proper linkage between functions. For full credit (5%) you should follow these steps even if they are not required for these specific procedures.
The pre-call step happens in the calling procedure just before the call, which must spill registers that are both in use and are not preserved across a call (i.e. temporary, argument, or value registers).
The prolog (or post-call) step is at the top of the called procedure, which must spill any registers that will both be used and which are preserved across a call (i.e. $s0-$s7). Further, unless the procedure is a leaf procedure, the $ra should be spilled as well.
The epilogue (or pre-return) step is at the end of the called procedure, which must restore any registers that were spilled in the post-call step. The $sp register should also be restored to it's original value.
The post-return step is in the calling procedure just after the call, which must restore any registers that were spilled in the pre-call step. The $sp register should be restored to it's pre-pre-call value.
You have two sample assembly programs: Hello World and AddProc in the repository and on the sample code page.
You may also want to look at 2-16-example.asm on the sample code page, but note that we did not use proper linkages for that file.
For example, we saved the $ra register in the pre-call step, instead of the post-call linkage.
Create a procedure labeled fizz that prints the string “fizz!\n”
Call it twice in main
Your output should be:
fizz!
fizz!
Create a procedure labeled buzz that prints the string “\tbuzz!\n”
Call it twice in fizz
Your output should be:
fizz!
buzz!
buzz!
fizz!
buzz!
buzz!
Add a parameter to fizz
Use a loop to call buzz that many times
Call fizz(1) and fizz(3) in main
Your output should be:
fizz!
buzz!
fizz!
buzz!
buzz!
buzz!
Add a parameter to buzz
Use a loop to print “buzz!” that many times on one line
Have fizz call buzz with the current value of its parameter
Your output should be:
fizz!
buzz!
fizz!
buzz!buzz!buzz!
buzz!buzz!
buzz
Round 1 complete: 11 (D+)
Round 2 complete: 14 (C+)
Round 3 complete: 17 (B+)
Round 4 complete: 19 (A)
Using proper linkages: +1
Using registers other than $a0, $sp, $zero, $ra, and $v0 (for syscalls only): -3