Project 9: Programming in pseudo-assembly

This project will give you practice in writing in an assembly-like language.

1. Introduction and setup

In class we have seen some examples of programs written for our virtual machine. In this project you will try your hand at writing a program yourself.

Copy the code for the virtual machine and disassembler (and related tools and examples) from the course directory.

cp -r /homes/tvandrun/Public/cs245/proj9/* .

2. Your task

Write a program gcd.asm that computes the greatest common divisor of 180 and the integers from 18 to 24, using the Euclidean algorithm. In particular, implement a program from the following pseudo-code:

for (i = 18; i <= 24; i++)
   print gcd(180, i);


int gcd(int a, int b) {
  if (b == 0) return a;
  else return gcd(b, a mod b);
}

The virtual machine, however, doesn't use asm files. It needs a vml file---that is, your assembly program must be assembled into a program in the machine language. I have provided an assembler tool, the program assembler.py. It's written in Python, so you're not expected to know how it works (although if you're curious about Python, you're welcome to look at it). You can use it this way:

./assembler.py gcd.asm

It will produce a file gcd.vml which you can then run using the provided virtualmachine.c. (I have also provided disassembler.c in case you find it useful to reverse the process that assembler.py does.)

3. To turn in

Please turn in your gcd.asm to the turn-in directory:

cp gcd.asm /cslab.all/ubuntu/cs245/turnin/(your user id)/proj9

DUE: Friday, Dec 11, 5:00 pm. You may not use late days for this assignment.

5. Grading

Grading for this project will follow this approximate point breakdown (the right to make minor adjustments in point distribution is reserved):


Thomas VanDrunen
Last modified: Tue Aug 4 11:36:50 CDT 2015