Due date

Due Tuesday, February 5, by midnight

Lab Objective

Assembly language programming is both useful and great fun! Refer to Figure 1 for a picture of a good-looking assembly language programmer.

Richard Friendman, 1964
Figure 1: A good-looking assembly language programmer named Richard Friedman, 1964. Click the photo to read about his 40 years with computers.

Warm-up: The LC-3 Simulator

For the next three lab assignments, you will use LC3Edit as your assembler and Simulate as your simulator. In this warm-up, you will launch both and become acquainted with assembler directives, symbolic labels, and some assembly instructions.

What's assumed

For this lab, we assume that you've read chapters 5 and 7 in the textbook and attended lectures. That is, you should know about the LC-3 architecture and instruction set architecture. You should be familiar with LC-3 instructions. You should have a basic understanding of the assembler directives .orig, .fill, and .stringz. You should know what a symbolic label is and how to use it.

If you didn't bring your textbook to class, you can read about LC-3 in Appendix A online. This appendix includes the instruction set architecture (all the commands you can use).

What's required

Familiarize yourself with the editor and simulator which you'll be using for the next three weeks.


  1. Start the LC-3 editor, LC3Edit.exe. You can find it on the PCServer in Class Folders\Computer Engineering\CE 12L\LC3.
  2. Copy the sample code into the LC3Edit program. sample code
  3. Compile the code by selecting Translate>Assemble or clicking on the "asm" button. Save the file in your home directory.
  4. Check for errors. If there were problems assembling, correct the errors now.
  5. Start the LC-3 simulator, Simulate.exe. You can find it on the PCServer in Class Folders\Computer Engineering\CE 12L\LC3.
  6. In the simulator, open your assembled file which has a .obj extension.
  7. Now, you are ready to run the program. Although you can run it all at once without stopping, this won't be useful because the program produces no output. So you won't have a good idea of what's going on. Instead, click the Step into button for each instruction, and pay attention to the register contents at the top of the screen. The ones you're interested in at this point are R0 through R7.
  8. Make sure the program is doing what you think it's doing. You can double-check your estimates with the register contents.
  9. Make changes to the assembly code, re-assemble it, re-load it into the simulator, and run it again until it works as expected.
  10. If you want to run the program again without re-loading it, scroll back to where the program begins (in this case, x3000 was defined as the execution beginning). Then right-click and choose Set PC to Selected Location to set the program counter to execute this line next. Now you can step through the instructions one at a time again.

Lab tutors: Go over these topics

Your lab tutor will cover the following topics in the first 40 minutes of lab.

Lab 3: rot-13

You are sitting in class when you remember that there is a big Team Fortress 2 video game tournament this evening, and you need to send a message your friend on the other side of the classroom to remind her to attend. But you don't want anyone who may intercept it -- especially the professor -- to know what the message says.

You decide to encrypt your message using rot-13.

Rot-13 is a simple cypher which rotates each character by 13 places. That is, A becomes N, B becomes O, and so on. You can read more about it on Wikipedia's ROT13 page. See Figure 2 for a graphical representation of rot-13.

Figure 2: The graphical representation of rot-13

Another way to look at the algorithm is this.

                  (Input letter + 13) mod 26, 
Output letter = {              if input letter is alphabetic
                  Input letter,                    otherwise

But that's really the same as this.

                   Input letter + 13, if input letter is a-m
Output letter =  { Input letter - 13, if input letter is n-z
                   Input letter,                   otherwise
For our purposes, rot-13 affects only alphabetic characters (that is, letters A-Z and a-z). It does not affect special characters (punctuation) nor numbers (0-9). Newline ('\n') is the exit character; when the user hits enter, the program terminates.

You can verify that your program works by translating the coded sentence on the whiteboard. See Figure 3.

Figure 3: What does the coded text say, and does it make sense? Click image for larger version.

What's required

A checkoff, a lab write-up, and lab3.asm


Your program should behave as follows:

  1. Display a greeting. Hello, assembly language rules.
  2. Display a prompt. How are you? Please enter something.
  3. User is expected to enter a letter.
  4. Check if the letter is a newline, the exit character. If it is, go to 8.
  5. Verify the letter should be rot-13'd.
  6. Show the rot-13 of the letter.
  7. Go to 2.
  8. Exit.


  1. You can start with this skeleton file, or with a blank file. The skeleton contains labels with placeholder instructions. The labels represent things your program should accomplish in that space.
  2. Remember to initialize registers you will use to 0. My favorite way of initializing a register is AND R0, R0, x0. What's yours?
  3. You may display more information than is required here. For example, you may display a -> n instead of just n by itself.
  4. Modify the comments in the code to include your name, e-mail address, lab number, and date at the top of the file. Additionally, include your register assignments (which register is being used for what), your basic algorithm in a list or pseudocode, and anything else that may help us to read your assembly file. See Section 1.2.1 in the Lab Manual for commenting style.

Example output

Welcome to LC-3.  I am a rot-13 converter.
: T -> G
: F -> S
: 2 -> 2
:   ->  
: m -> z
: a -> n
: t -> g
: c -> p
: h -> u
:   ->  
: t -> g
: o -> b
: n -> a
: i -> v
: g -> t
: h -> u
: t -> g
: \n
----- Halting the processor -----

Grading template

This is a suggested grading rubrik. Your tutor may or may not use this rubric to grade by, but it is a good general guideline before submitting your code to check off these points.

Coding requirements

Comments requirements

Lab report requirements

Let's face it. Your assembly language (.asm) file will be ugly. So ugly, in fact, that we want you to tell us about it.

The lab write-up should contain information about you and your program, including but not limited to

In the lab report, we will be looking for the following things. The lab report is worth 10 points. We do not break down the point values; instead, we will assess the lab report as a whole while looking for the following content in the report.