COSC 201: Computer Organization

Lab 7: Floating-Point Arithmetic

Purpose
Learn how floting-point numbers are represented and how to carry out floating-point aritmetic operations.
Method
Write assembly code to implement a function for floating-point multiplication using the supplied outline.
Preparation
Read Chapter 4 in the text. Review Appendix A, Section 10.
Files to Use
main.s, float.s
What to Hand In
Completed float.s and floatopt.s

The file float.s contains an outline of assembly code for a function that multiplies two numbers in IEEE 754 single precision floating point format. The file main.s contains a program for testing the multiplication function.

Your first task is to complete the assembly code for this funtion, one instruction per commented line. Ignore the possibility of overflow and underflow, and do not round the result. If you need an immediate value that is larger than 16 bits, such as for a mask, use the li pseudo-instruction to first load the value into a register. After restoring the implicit most-significant bit of the significand, it is a 24-bit number with 23 bits to the right of the binary point. When multiplying two such significands, the result is a 48-bit number with 46 bits to the right of the binary point. There may be 1 or 2 bits to the left of the binary point, so check the 48th bit of the result to determine whether or not it is necessary to normalize.

Test your function using the SPIM simulator by loading main.s and float.s. Test your multiplication function with operands such as 0.0, 1.0, -1.0, 2.0, 0.5, etc.

Your second task is to optimize the function to reduce the number of instructions executed. Include comments in your optimized code that indicate what changes you made and how they improve the code. Save your optimized assembly code as floatopt.s. Test using SPIM.

Hand in your files float.s and floatopt.s by placing copies in your ~/courses/201/assignments directory, and sending e-mail to your instructor. Be sure that your name appears in the comments at the top of each file that you hand in.