Department of Electrical and Computer Engineering

The University of Texas at Austin

EE 306, Fall 2013
Programming Assignment 1
Due: October 3rd, 11:59 pm
Yale N. Patt, Instructor
TAs:Ben Lin, Mochamad Asri, Ameya Chaudhari, Nikhil Garg, Lauren Guckert,
        Jack Koenig, Saijel Mokashi, Sruti Nuthalapati, Sparsh Singhai, Jiajun Wang

You must do every programming assignment by yourself. You are permitted to get help ONLY from the TAs and the instructor. When you have completed the program, and tested it sufficiently so that you are comfortable that it works on any input (i.e., value initially stored in x3100), submit it for grading according to the submission instructions at the end of this handout.


Counting "01" patterns in a 16-bit Bit Vector

Your Job: The addressability of the LC-3 is 16 bits; i.e., each memory location contains 16 bits of data. In this assignment, you are asked to write a program in LC-3 machine language to count the number of occurrences of the pattern "01" in a 16-bit word, and store the result back in memory. Counting the number of occurrences of the "01" pattern means counting the number of times the pattern "01" shows up in the entire 16 bit word.

Some examples:

     1111111111111110 has 0 occurrences of "01"
     0101010101010101 has 8 occurrences of "01"
     0000000100000000 has 1 occurrence of "01"
     1110110001100001 has 3 occurrences of "01"

Your program should assume that the input word is stored in memory location x3100. Your program should store the output count in memory location x3101. Your program should start at memory location x3000, and should halt the machine after storing the output to memory location x3101. So for example, if the memory location x3100 contains the word 1110110001100001, then your program should store the value 0000000000000011(which is 3 in decimal) in memory location x3101, then halt.

Hint 1: What happens when you add a number to itself? For example 1111000011001100 + 1111000011001100 = 1110000110011000.

Hint 2: Familiarize yourself with the software and documentation, and the submission instructions well before the deadline so that you can get help from a TA if you cannot figure out the mechanics by yourself. It is unreasonable to expect Professor Patt or a TA to help you submit your program at 11:45pm on the day the program is due simply because you left this for the last minute, and have discovered that you do not know how to do it by yourself.

Simulator/Testing Hint: You can test your program by setting the value of memory location x3100 before you run your program on the LC-3 simulator. On Windows machines, you can click on "Simulate" on the menubar and select "Set Value". You can also just press F4 and the "Set Value" dialog box will pop up. Finally, double-clicking on the contents of a memory location will also cause the "Set Value" dialog box to pop up.

Make sure you set a breakpoint before you run your program so that your program will stop just before it executes the trap instruction. This will allow you to examine the contents of x3101 after your program has finished executing, but before control is turned over to the operating system to halt your program.

Follow the following steps: Note: We understand that to test your program, you must first create a .obj file. The .obj file is not to be submitted for grading. We will create a .obj file from your .bin file when we grade your program.