Programming Assignment PA6 - Some Assembly Required

Due Sunday, March 22nd at 10:00pm, no late submission.


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 at the IEEE 754 specification. A short description of the half precision format: 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 PA6 directory in your cs270 directory for this assignment.
  2. Copy the starter file PA6.asm into the directory.
  3. Open the file PA6.asm with your favorite editor and study it.
  4. Assemble the program with the command ~cs270/lc3tools/lc3as PA6.asm.
  5. Implement at least one of the functions in the file (see testing below).
  6. Fix all assembler errors and make sure that PA6.obj and PA6.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 PA6.obj.
  9. Click in the Address field and enter the label of the memory location, for example Option, Param1, Param2.
  10. After entering a value you must press Enter on the keyboard.
  11. Click in the Value field and enter the value you want to store there and press Enter on the keyboard.
  12. Repeat steps 9) and 10) for each value you need to set
  13. Run your program by clicking on the Continue button.
  14. When the program stops, examine the value stored at memory location Result.
  15. Hit the Reset button and return to step 8) to start a new test.

Grading Criteria

For PA6, the preliminary testing will cover the functions listed below. You do not need to implement flt16_add or flt16_sub for PA6. No additional testing will be performed, so your grade on PA6 will be determined by the result of preliminary testing. Here is an answer key that may help you to figure out the algorithms for each function:
compileTest  %  5 % make clean >/dev/null; make
signZero     %  3 % Option =  2, Param1 = x0000, Result = x0000
signPos      %  3 % Option =  2, Param1 = x5380, Result = x0000
signNeg      %  4 % Option =  2, Param1 = xD380, Result = x0001
valZero      %  3 % Option =  4, Param1 = x0000, Result = x0000
valCase0     %  3 % Option =  4, Param1 = x4010, Result = x0410
valCase1     %  4 % Option =  4, Param1 = x4380, Result = x0780
absZero      %  3 % Option =  5, Param1 = x0000, Result = x0000
absPos       %  3 % Option =  5, Param1 = x5120, Result = x5120
absNeg       %  4 % Option =  5, Param1 = xD120, Result = x5120
negZero      %  3 % Option =  6, Param1 = x0000, Result = x0000
negPos       %  3 % Option =  6, Param1 = x3FC0, Result = xBFC0
negNeg       %  4 % Option =  6, Param1 = xBFC0, Result = x3FC0
lm1Zero      %  1 % Option =  7, Param1 = x0000, Result = xFFFF
lm1Left      %  3 % Option =  7, Param1 = x8000, Result = x000F
lm1Middle    %  3 % Option =  7, Param1 = x0ABC, Result = x000B
lm1Right     %  3 % Option =  7, Param1 = x0001, Result = x0000
lshiftZero   %  3 % Option =  8, Param1 = x1234, Param2 = x0000, Result = x1234
lshiftPos    %  3 % Option =  8, Param1 = x1234, Param2 = x0008, Result = x3400
lshiftNeg    %  4 % Option =  8, Param1 = x1234, Param2 = xFFF8, Result = x1234
binaryOrZero %  3 % Option = 10, Param1 = x5678, Param2 = x0000, Result = x5678
binaryOr1    %  3 % Option = 10, Param1 = x0AA0, Param2 = x0550, Result = x0FF0
binaryOr2    %  4 % Option = 10, Param1 = x1234, Param2 = x6789, Result = x77BD
rightShift0  %  5 % Option = 9, Param1 = x1234, Param2 = x0005, Result = x0091
rightShift1  %  5 % Option = 9, Param1 = x4321, Param2 = x0008, Result = x0043
rightShift2  %  5 % Option = 9, Param1 = xA5A5, Param2 = x0002, Result = x2969
getExp0      %  5 % Option = 3, Param1 = x4F80, Result = x0013
getExp1      %  5 % Option = 3, Param1 = x3D00, Result = x000F
Looking ahead to PA7, 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 PA7:

Assignment Submission

Submit the single file PA6.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.