CS 270, Spring 2014
Programming Assignment PA6
More Assembly Required
PA6 due Thursday, Mar. 27 at 11:59pm, no late submissions.
This assignment completes the previous one, with the same three objectives:
- To learn how to write an LC3 assembly program of significant size,
- to extend your familiarity with the LC3 instruction set,
- 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 include right_shift,
flt16_get_exp, 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:
- Bit 15, the most significant bit represents the sign, 0 for positive, 1 for negative.
- Bits 10..14 contain the exponent biased by 15.
- For example, a binary 10000 in the exponent field is 16 - 15 = 1.
- Bits 0..9 contain the fractional part of the number, i.e. the part right of the decimal point.
- As with single precision, there is an implicit 1 added to left of the decimal point.
- For example, 0x4340 is positive with an exponent of 1, and mantissa of binary 1.1101.
- This means binary 1.1101 * 2 = binary 11.101 = 3.5.
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:
- Create a PA6 directory in your cs270 directory for this assignment.
- Copy the starter file PA6.asm into the directory.
- Merge the functions you have already written in
PA5.asm
.
- Assemble the program with the command
~cs270/lc3tools/lc3as PA6.asm
.
- Implement the remaining functions in the file (see testing below).
- Fix all assembler errors and make sure that PA6.obj and PA6.sym are created.
- Start the simulator with the command
~cs270/lc3tools/lc3sim-tk
.
- Use the button to browse for and load your object code, called PA6.obj.
- Setup the
Option
, Param1
, and Param2
fields with the values you want to test.
- Run your program by clicking on the
Continue
button.
- When the program stops, examine the value stored at memory location Result.
- Hit the
Reset
button and return to step 9) to start a new test.
Important Information
We have made two changes to the specification after PA5 to simplify the assignment.
The first is that handling normalization of the operands is optional. You can receive
up to 20 extras 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 ~75 lines, without operand normalization. Here are the preliminary tests for PA6:
- Correct implementation of the flt16_get_exp function. (10 points)
- Correct implementation of the right_shift function. (15 points)
- Correct extraction of the sign from flt16 numbers. (5 points)
- Correct extraction of the exponent from flt16 numbers. (5 points)
- Correct extraction of the mantissa from flt16 numbers. (5 points)
- Correct computation of the sign of the result. (5 points)
- Correct computation of the exponent of the result. (5 points)
- Correct computation of the mantissa of the result. (5 points)
- Correct implementation of the flt16_add function. (20 points)
- Correct implementation of the flt16_sub function. (25 points)
- Correct implementation of operand normalization. (20 points)
Assignment Submission
Submit the single file PA6.asm
to the Checkin tab on the course
website, and check your preliminary results.
© 2014 CS270 Colorado State University. All Rights Reserved.