CS 270
Programming Assignment PA7
More Assembly Required


PA7 due Sunday, April 5th at 10:00pm, no late submissions.


This assignment completes the previous one, with the same three objectives:
  1. To learn how to write an LC3 assembly program of significant size,
  2. to extend your familiarity with the LC3 instruction set,
  3. and to further understand the manipulation of floating-point numbers.

The Assignment

This assignment requires you to complete all the functions in LC3 assembly code from the previous assignment. The remaining functions are flt16_add and flt16_sub to support floating point addition and subtraction on 16-bit (half precision) floating point values. You can find documentation on this format, which is also defined by the IEEE 754 specification here. A short description of the half precision format is as follows: The protocol for calling functions has already been presented in the recitation. You can follow the same procedure when debugging your program, as shown below.

Getting Started

Perform the following steps:
  1. Create a PA7 directory in your cs270 directory for this assignment.
  2. Copy the starter file PA7.asm into the directory.
  3. Merge the functions you have already written in PA6.asm.
  4. Assemble the program with the command ~cs270/lc3tools/lc3as PA7.asm.
  5. Implement the remaining functions in the file (see testing below).
  6. Fix all assembler errors and make sure that PA7.obj and PA7.sym are created.
  7. Start the simulator with the command ~cs270/lc3tools/lc3sim-tk.
  8. Use the button to browse for and load your object code, called PA7.obj.
  9. Setup the Option, Param1, and Param2 fields with the values you want to test.
  10. Run your program by clicking on the Continue button.
  11. When the program stops, examine the value stored at memory location Result.
  12. Press the Reset button and return to step 9) to start a new test.

Important Information

We have made two changes to the specification after PA6 to simplify the assignment. The first is that handling equalization of the operand exponents is optional. You can receive up to 20 extra points on the assignment for implementing this, or you can assume that the exponents of the operands will be equal, see the Grading Criteria below. Note that you still must do normalization of the result (on either direction). The second change is that when the exponents differ, the first operand will always have a larger exponent than the second, so you only need to handle this case.

Grading Criteria

For the preliminary testing will help you verify the additional functions listed below. Note, the tests will remain the same for final grading, but the values of the floating point numbers added and subtracted will vary! The order of testing is intended to push you in the direction of incremental development, which is highly desirable for this assignment, since the flt32_add method is very long. The current solution from the instructor has ~90 lines, without exponent equalization. Here are the preliminary tests for PA7: The preliminary test patterns and solutions are shown below. Final test patterns will be very similar, but with different numbers to disallow hard coding in PA7.asm.
# Test patterns and answer key to PA7 preliminary testing

// x = 2.75, sign = 0
getSignX     % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, signX = x0000

// y = -2.5, sign = 1
getSignY     % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, signY = x0001

// x =  2.75, exp = 16
getExpX      % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, expX = x0010

// y = -2.5, exp = 16
getExpY      % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, expY = x0010

// x =  2.75, val =  10.11
getValX      % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, valX = x0580

// y = -2.5, val = -10.10
getValY      % 2.5 % Option =  0, Param1 = x4180, Param2 = xC100, valY = xFB00

// x = 2.75, y = -2.5, sum = 0.25, sign = 0
getSignSum   %   5 % Option =  0, Param1 = x4180, Param2 = xC100, signSum = x0000

// x = 2.75, y = -2.5, sum = 0.25, exp = 13
getExpSum    %   5 % Option =  0, Param1 = x4180, Param2 = xC100, expSum = x000D

// x = 2.75, y = -2.5, sum = 0.25, val = 1.00
getValSum    %   5 % Option =  0, Param1 = x4180, Param2 = xC100, valSum = x0400

// 1.50 + 1.25 = 2.75
flt16_add0   %  10 % Option =  0, Param1 = x3E00, Param2 = x3D00, Result = x4180

// 5.50 + 4.50 = 10.0
flt16_add1   %  10 % Option =  0, Param1 = x4580, Param2 = x4480, Result = x4900

// 1.50 - 1.25 = 0.25
flt16_sub0   %   5 % Option =  1, Param1 = x3E00, Param2 = x3D00, Result = x3400

// 5.50 - 4.50 = 1.0
flt16_sub1   %  10 % Option =  1, Param1 = x4580, Param2 = x4480, Result = x3C00

// 19.25 +  3.50 = 22.75
normalize0   %  10 % Option =  0, Param1 = x4CD0, Param2 = x4300, Result = x4DB0

// 19.25 - 10.00 =  9.25
normalize1   %  10 % Option =  1, Param1 = x4CD0, Param2 = x4900, Result = x48A0

Assignment Submission

Submit the single file PA7.asm to the Checkin tab on the course website, and check your preliminary results.
© 2014 CS270 Colorado State University. All Rights Reserved.