CIS 351 |
Lab 7: Introduction to Assembly |
Fall 2020 |
For this lab, you are going to write some assembly code and test it using using the
MUnit
testing
framework.
MUnit
tests. Follow these steps:
munit.jar
into the directory for this repo
(or, copy it from /home/kurmasz/public/CIS351/AssemblyIntro
). 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!
.globl monkeyTrouble sleepIn posNeg
.text
.globl
.)
monkeyTrouble
,
sleepIn
, and posNeg
respectively.
a0
, a1
, and a2
.jr $ra
.1
for true
and 0
for false
.Each of these above rules is demonstrated in assemblyIntroSample.asm
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 you are confident your code and tests are complete and correct, commit everything with "[Grade Me]
" in the commit message.
There is no autograder for this lab. I will run my test locally.
!a0
, do the following:not $a0, $a0
andi $a0, $a0, 1
andi
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 Sunday, 25 October 2020, 5:57 PM