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.

Step 1: Learn how to test your code

Before writing any code, you first need to learn how to write and run MUnit tests. Follow these steps:
  1. Follow this GitHubClassroom link and clone the resulting repository.
  2. Download 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.
  3. Download Mars. This file is also listed in .gitignore so that it is not stored by GitHub.
  4. Launch Mars, open assemblyIntroSample.asm and see if you can spot the bug.
  5. From the command line, run javac -cp munit.jar AssemblyIntroSampleTest.java. (If you are doing this on your own machine, make sure the javac executable is in your path.)
  6. Now, run 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: 2
These 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.
Do not continue until you have (1) figured out how to run my test code, and (2) have found and fixed the bug in triple!

Step 2: Write some Java

Go to CodingBat and solve these three problems:

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!

Step 3: Write and test some MIPS assembly

Now solve each problem using MIPS assembly. In order for your solution to work with my testing software, you must follow these rules:

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.

Submission and grading

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.

Hints:


Updated Sunday, 25 October 2020, 5:57 PM

W3c Validation