Homework 2

Due Friday, October 17

Note: In this and all other homework assignments, you are required to meet all specifications in the problem statement. This is both for pedagogical reasons and to make it easier for the Reader to grade. To receive credit, you must comply with all details specified in the problem statement.

In this problem you will extend the Mac-1 instruction set, by adding a MULL instruction, which does multiplication. Use the DePaul University MicMac simulator, described on my Mic-1/Mac-1 simulator Web page.

You will add a MULL ("multiply local") instruction to the Mac-1 instruction set, having the format 11111111zzzzzzzz. Its action will be ac:=ac*m[sp+z]. In other words, the contents of the ac will be multiplied by the contents of the z-th element in the runtime stack.

The multiplier and multiplicand are to be interpreted as 2s-complement signed integers, while z is to be interpreted as a nonnegative number. Don't worry about overflow; just assume (for simplicity, not for practicality) that the users will never input numbers whose product is wider than 16 bits.

It is completely up to you how you implement MULL, other than the technical restrictions set here.

Your design must allow the correct execution of any existing MAC-1 machine-language (not just assembly-langauge) program.

Submit your homework in the following form: You will send files named mul_mac.def and mul_mac.mal for the extended Mac-1 machine, and only one more file, named README. The latter will list the members of your group; do NOT include any other information in this file Your e-mail packaging operations must include tar, gzip and uuencode. In applying the latter, you must arrange things so that when the Reader applies uudecode to your e-mail message, the result is a file named hwk_1_I.tar.gz.

The Reader will have written a shell or Perl script which automatically runs ma, assem and sim on your files. The Reader will use his own (secret) .asm file, which will include a loop containing a MUL instruction. The loop will have three iterations, in which MUL will be tested on three different pairs of numbers. In this manner, the Reader's .asm file will:

The reason for the last item is that EXTRA CREDIT will be given for whichever two homework teams submit the fastest implementations of MULL, as measured above.

By the way, this "contest" is in keeping with microcoding in general. In high-level programming, we usually don't care about small increases in speed; usually the clarity of the code is more important. But microcode directly affects the overall speed of the machine itself, so optimal code is of great value.

In writing your Mic-1 code, I recommend that you start with the simpler case, in which both operands are positive. Once you have that running well, modify your code to allow for the general case.