CS 270, Spring 2014
Programming Assignment PA5
Some Assembly Required

PA5 due Thursday, Mar. 13 at 11:59pm, late submissions until Mar. 15 at 11:59pm (-20 points).


This assignment and the one that follows have 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 write a number of functions in LC3 assembly code. It is the first installment of an LC3 assembly program that manipulates floating point numbers. In the second assignment you will complete all the functions, including floating point addition and subtraction. In a previous assignment, you implemented 32-bit (single precision) floating point addition and subtraction in the C programming language using only integer operations. In this assignment you will do the same things in LC3 assembly language 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: As the LC3 has a limited instruction set, you will find that you must write code to perform operations that you took for granted in the previous assignment. For example, the left and right shift operators (<< and >>) do not exist in LC3, nor is there a bitwise OR operator (|). Therefore, you must write functions to perform these operations. Unlike your previous assignment, you do not have code for the getField() and setField() functions so you will need to implement these in LC3 assembly by shifting and masking. To avoid making you write extensive I/O code for LC3, we will let you manually test code by:
  1. Loading your program into the LC3 simulator.
  2. Storing the operands into memory at one or more specified labels.
  3. Running (or initially stepping and debugging) your program.
  4. Examining one or more memory locations at specified labels for your results.
The protocol for this assignment 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 PA5 directory in your cs270 directory for this assignment.
  2. Copy the starter file PA5.asm into the directory.
  3. Open the file PA5.asm with your favorite editor and study it.
  4. Assemble the program with the command ~cs270/lc3tools/lc3as PA5.asm.
  5. Implement at least one of the functions in the file (see testing below).
  6. Fix all assembler errors and make sure that PA5.obj and PA5.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 PA5.obj.
  9. Click in the Address field and enter the label of the memory location, for example Option or Param1, and press Enter on the keyboard.
  10. Click in the Value field and enter the value you want to store there and press Enter on the keyboard.
  11. Repeat steps 9) and 10) for each value you need to set
  12. Run your program by clicking on the Continue button.
  13. When the program stops, examine the value stored at memory location Result.
  14. Hit the Reset button and return to step 8) to start a new test.

Grading Criteria

For PA5, the preliminary testing will cover the functions listed below. You do not need to implement flt16_add, flt16_sub, flt16_get_exp, or right_shift for PA5. No additional testing will be performed, so your grade on PA5 will be determined by the result of preliminary testing. Looking ahead to PA6, 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! Here are the preliminary tests for PA6:

Assignment Submission

Submit the single file PA5.asm to the Checkin tab on the course website, as you were shown in the recitation, and check your preliminary results.

© 2014 CS270 Colorado State University. All Rights Reserved.