Machine Problem 4, due Nov 9

Part of the homework for 22C:60, Fall 2008
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

Submit the source file mp4.a for your solution using the submit command, documented at:
-- http://www.divms.uiowa.edu/help/msstart/submit.html

The Problem

The file mp4.h contains the header file for a long-integer (64-bit) class. Long integers are represented by 2 consecutive words in memory and the routines in this package accept pointers to long-integer parameters as arguments. The methods on this class include conversion both ways between integer and long, copying long integers, add, subtract, multiply, divide and mod.

The Assignment

Write the corresponding mp4.a file that implements the required methods applicable to long integers, so that the methods applmay be called.

Note, you need not test your code, but we will, and the maximum possible credit will be limited depending on how much of it works. We therefore recommend that you agressively test your code. That means, you will want to write a main program (as a separate source file) and, as you write implementations for the different methods of the long-integer class, you should extend your test code to test the corresponding methods.

We strongly recommend incremental development! Our estimate is that a well prepared student should take about 6 hours to finish this project. Students who are less well prepared will take longer. Budget your time accordingly!

Half credit will be given for cleanly formatted properly commented source code, regardless of whether it works correctly, so long as it covers all of the required routines. Half credit will be given for the correct operation of your code, regardless of looks.

Notes

The implementation of the mod operation is deliberately a bit odd: It forces you to use a COMMON block to store the remainder from each each division just in case someone needs it.

The add and subtract operations force you to use the add with carry and subtract with borrow instructions. For multiply and divide, you will need to do long shifts as well, and possibly long negation. Each of these is a small programming problem in its own right.