CS611
Spring 2002
Programming Assignment 3
Due Sunday March 10


Provide software emulation for the unimplemented sim611 floating-point instructions: add (ADDF), negate (NEGF), compare (CMPF), and clear (CLRF).

The floating-point data type contains 16 bits. Bit 15 is the sign bit. Bits 14 through 10 are the exponent. Bits 9 through 0 are the significand.

If the sign bit is set, the floating-point number is negative. If the sign bit is clear, the floating-point number is non-negative.

The exponent is a biased exponent. Subtract 15 from the stored exponent to get the actual exponent. A stored exponent of all zeros indicates that the floating-point number containing the exponent has the value zero.

Floating-point numbers are normalized to have one digit to the left of the radix point. Since this digit must always be one, it is not stored in the significand.

The ADDF (2C) opcode should be implemented with two extra bits on the right for better rounding results. This opcode takes two registers operands and is a 2-byte instruction: ADDF Ri,Rj : Ri <- Ri + Rj. When normalizing, fill with 0 bits from the right, if necessary. After normalizing, if the two extra bits are 10 or 11 then round up by adding 1 to the rightmost bit position of the result.

If the result of an ADDF instruction overflows or underflows, then the behavior is undefined. That is, it is the user's responsibility to avoid overflow and underflow. If they occur, then the emulation code can do whatever it wants. There are no particular requirements for how the emulation code should respond in these exceptional cases.

The NEGF (2D) opcode should simply flip the sign bit in the single register operand. It is a 2-byte instruction: NEGF Ri : Ri <- -Ri.

The CMPF (2E) opcode should set the C0 and C1 bits of the PSB in the same manner that the CMP instruction does for integer types. This opcode takes two registers operands and is a 2-byte instruction: CMPF Ri,Rj : C0 <- 1 if Ri == Rj; C0 <- 0 otherwise; C1 <- 1 if Ri < Rj, C1 <- 0 if Ri > Rj.

The CLRF (2F) opcode should clear all bits in the single register operand. It is a 2-byte instruction: CLRF Ri : Ri <- 0.0.

The CLRF opcode will be worth 60 points and should be done first. The NEGF opcode will be worth 10 points. The CMPF and ADDF opcodes will each be worth 15 points.

Your emulation code should be written in sim611 assembler. Place all your code in a single file called "fp.asm". Your code will be placed first before the user code in memory. (Use the -f flag to as611 to assemble your code with a user program: e.g. as611 -f fp.asm user.asm.) Upon program startup your code should set up a default stack and initialize R13 before jumping to the user code. You may assume the user code will not disturb R13 or fail to supply a valid stack.

The test files that will be used for grading are available in ~cs611/public/prog3. These will be the only test files I will use for grading for the assignment. However, I will not provide the correct answers for these files. We will work some of them in class, but the remainder you will need to work out by hand yourself.

You may lose points if your program is not properly structured or adequately documented.

Your assignment should be submitted for grading from a CIS Alpha machine (e.g. cisunix.unh.edu). To turn in this assignment, type:

~cs611/bin/submit prog3 fp.asm

Do not turn in any other files!

Submissions can be checked by typing:

~cs611/bin/scheck prog3

To receive full credit for the assignment, you must turn in your files prior to 8am on Monday March 11. Late submissions will be accepted at the penalty of 5 points per day up to one week late.

Your programs will be graded using a CIS Alpha machine (e.g. cisunix.unh.edu) so be sure to test in that environment.

Remember: as always you are expected to do your own work on this assignment.


Last modified on January 10, 2002.

Comments and questions should be directed to hatcher@unh.edu