CIS 351 |
Lab 5: Introduction to Assembly |
Fall 2021 |
For this lab, you are going to write some assembly code and test it using using the
MUnit testing
framework. Begin by watching this video .
MUnit tests. Follow these steps:
munit.jar into the directory for this repo
(or, copy it from /home/kurmasz/public/CIS351/AssemblyIntro). The file mars.jar
is in the repository's .gitignore
so that GitHub doesn't have to store hundreds of copies of this file. This is why you have to download it separately,
and why you won't see it on the GitHub page.
.gitignore so that it is not stored by GitHub.Mars, open
assemblyIntroSample.asm and see if you can spot the bug.
javac -cp munit.jar
AssemblyIntroSampleTest.java. (If you are doing this on
your own machine, make sure the javac executable is in
your path.)
java -jar munit.jar assemblyIntroSample.asm
AssemblyIntroSampleTest.class. (Notice that you are
specifying the name of the class file, not the name of
the class.)
At this point, you should see the following output:
MIPSUnit::MUnit version 1.1 built Sun Apr 08 14:26:21 EDT 2018. Built with MARS version 4.4 Failure: triples_positive_number(AssemblyIntroSampleTest): expected:<6> but was:<4> Failure: triples_negative_numbers(AssemblyIntroSampleTest): expected:<-18> but was:<-12> Tests run: 6, Failures: 2These tests fail because there is a bug in
triple. Edit
assemblyIntroSample.asm and fix the bug. When you have
fixed the bug, you will see
MIPSUnit::MUnit version 1.1 built Sun Apr 08 14:26:21 EDT 2018. Built with MARS version 4.4 All tests (6) passed.
triple!
Do not continue until CodingBat has indicated that you have solved all three problems correctly. If you don't know how to code these problems in Java or Python, you certainly won't be able to do it in assembly!
assemblyIntro.asm as your starting point.
In order for your solution to work with my testing software, you must follow these rules:
.globl monkeyTrouble sleepIn posNeg
.text.globl.)
monkeyTrouble,
sleepIn, and posNeg respectively.
a0, a1, and a2.jr $ra.1 for true and 0 for false.To test your code, edit AssemblyIntroTest.java then compile and run using the instructions from
step 1. These tests are not complete; you will need to add some of your own.
When your code and tests are complete and correct (i.e., passes the automated tests), commit everything with "[Grade Me]" in the commit message.
You must have a complete set of test cases for each problem. That means four tests for monkeyTrouble and sleepIn, and
eight tests for posNeg.
!a0, do the following:not $a0, $a0andi $a0, $a0, 1andi instruction makes sure that only the least-significant bit has a value other than 0.)
beq and bne),
but you don't need them to complete this assignment. Anything you think you need a branch for can be
done using slt and slti.
Updated Monday, 11 October 2021, 1:44 PM