Programming Assignment P6 - Some Assembly Required

Due Sunday, Oct. 18nd at 10:00pm, late submission at 11:59pm.


This assignment has three objectives:
  1. To introduce you to the process of writing LC3 assembly code.
  2. To extend your familiarity with the LC3 instruction set.
  3. To help you learn the LC3 tools including the assembler and simulator.

The Assignment

This assignment requires you to write a number of functions in LC3 assembly code. As the LC3 has a limited instruction set, you will find that you must write code to perform operations that you take for granted in high level programming languages such as C. 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. For all operations, the Param1 and Param2 variables are the two operands and the answer is stored in the Result variable. All numbers are 16-bit integers stored in 2's complement representation, and all results are limited to 16-bits. You should have already completed the first three functions during the lab. No detection of overflow is necessary. Here is a description of the functions you must write: 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 lab. You can follow the same procedure when debugging your program, as shown below.

Getting Started

Perform the following steps:
  1. Create a P6 directory in your cs270 directory for this assignment.
  2. Copy the starter file P6.asm into the directory.
  3. Open the file P6.asm with your favorite editor and study it.
  4. Assemble the program with the command ~cs270/lc3tools/lc3as P6.asm.
  5. Implement at least one of the functions in the file (see testing below).
  6. Fix all assembler errors and make sure that P6.obj and P6.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 P6.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 P6, the preliminary testing will cover the functions listed below. No additional testing will be performed, so your grade on P6 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. The first colun is the test name, the second column is the number of points, and the third column shows the test values and expected result.
compileTest  %  5 % make clean >/dev/null; make
integerAdd0  %  2 % Option = 0, Param1 = x5678, Param2 = x1234, Result = x68AC
integerAdd1  %  2 % Option = 0, Param1 = x1234, Param2 = xFFEC, Result = x1220
integerAdd2  %  1 % Option = 0, Param1 = x0000, Param2 = x1234, Result = x1234
integerSub0  %  2 % Option = 1, Param1 = x5678, Param2 = x1234, Result = x4444
integerSub1  %  2 % Option = 1, Param1 = x1234, Param2 = xFFEC, Result = x1248
integerSub2  %  1 % Option = 1, Param1 = xAA55, Param2 = x3355, Result = x7700
integerMul0  %  4 % Option = 2, Param1 = x5678, Param2 = x0000, Result = x0000
integerMul1  %  3 % Option = 2, Param1 = x1234, Param2 = x0010, Result = x2340
integerMul2  %  3 % Option = 2, Param1 = x1234, Param2 = x0003, Result = x369C
binaryOr0    % 10 % Option = 3, Param1 = x5678, Param2 = x0000, Result = x5678
binaryOr1    % 10 % Option = 3, Param1 = x0AA0, Param2 = x0550, Result = x0FF0
binaryOr2    %  5 % Option = 3, Param1 = x1234, Param2 = x6789, Result = x77BD
lshift0      % 10 % Option = 4, Param1 = x1234, Param2 = x0004, Result = x2340
lshift1      % 10 % Option = 4, Param1 = xAAAA, Param2 = x0001, Result = x5554
lshift2      %  5 % Option = 4, Param1 = x8765, Param2 = x0008, Result = x6500
rShift0      % 10 % Option = 5, Param1 = x1234, Param2 = x0005, Result = x0091
rShift1      % 10 % Option = 5, Param1 = x4321, Param2 = x0008, Result = x0043
rShift2      %  5 % Option = 5, Param1 = xA5A5, Param2 = x0002, Result = x2969

Assignment Submission

Submit the single file P6.asm to the Checkin tab on the course website, as you were shown in the recitation, and check your preliminary results.
© 2015 CS270 Colorado State University. All Rights Reserved.