Homework 8 - Computer Organization Due: noon 4/12/04 (M)

The goal of this assignment is to provide you with experience in using the "Logical and Shift Instructions" (bit-wise operations: and, andi, or, etc. & shifting instructions: sra, srav, etc. ) and to help you understand Booth's multiplication algorithm. For this assignment, you are to implement Booth's multiplication algorithm on two 32-bit signed integers and get a 64-bit integer result. You will need to use the "MIPS Logical Instructions" (bit-wise operations, e.g., , etc.) to implement Booth's algorithm.

I want you to write a function called "Multiply" that is passed two signed integers (in $a0 and $a1) and returns their 64-bit product across registers $v0 and $v1. Register $v0 should return the most-significant 32-bits of the product and $v1 should contain the least-significant 32-bits of the product. Be sure that you DO NOT use any form of the multiply (e.g., mul, mult, multu, etc.) assembly language instruction, and be sure to follow the MIPS register convensions when implementing "Multiply."

Your "main" program should:

  1. interactively prompt for and read two integer values from the user by using the PCSpim system calls (pages 632 - 634 of text). Enter the value -30 for the multiplicand and 983 for the multiplier.
  2. call your Multiply function with these values
  3. use the PCSpim system call "print_int" to print the value of $v0 returned by Multiply
  4. use the PCSpim system call "print_int" to print the value of $v1 returned by Multiply

The resulting "Console" window showing the interaction of the complete program should look something like:

Enter the integer multiplicand: -30

Enter the integer multiplier: 983

The value returned in $v0 = -1

The value returned in $v1 = -29490

Notice that the PCSpim system call printed $v0's value as "-1" which is represented in two's-complement as all 1's. This is expected since the product (-29490) fits in the least-significant 32-bit value in $v1 with only the sign-extended 1's of a negative number carrying over into the most-significant 32-bits of $v0.

Turn in the following:

1) The MIPS assembly language programs (main and Multiply) for performing Booth's algorithm.

2) A snapshot of PCSpim containing the register values IMMEDIATELY after returning from your Multiply subprogram which was passed the integer value -30 for the multiplicand and 983 for the multiplier.

3) A snapshot of the Console window showing the complete interaction of your program using the value -30 for the multiplicand and 983 for the multiplier.