Department of Electrical and Computer Engineering
University of Texas at Austin
EE 306, Fall 2019
Programming Assignment 1
Yale N. Patt, Instructor
TAs: Sabee Grewal, Arjun Ramesh, Joseph Ryan, Chirag Sakhuja, Meiling Tang, Grace Zhuang

Due: October 9, 2019 11:59 pm

Instructions:

  1. You must do every programming assignment by yourself. You are permitted to get help ONLY from the TAs and the instructor.
  2. There are two parts to this assignment. In each part you will be asked to write a different program. You will therefore submit two programs, one for Part 1 and one for Part 2. Both programs should be written in LC-3 machine language. Read the instructions carefully and make sure you follow them.


Part 1 (40 pts) - A Program that shifts a bit pattern to the left by a certain amount (a number between 0 and 16, including 0 and 16)

Problem: In this part, you are asked to write a program in LC-3 machine language to shift a bit pattern some number of bits to the left and store the result in memory. The number of bits the bit pattern should be shifted is called the shift amount. Shift amount is a non-negative number between 0 and 16, inclusive (that is 0 and 16 are valid shift amounts). Your program should assume that the initial bit pattern to be shifted is in memory location x3100 and the shift amount is stored in memory location x3101. Using those values, your program should perform the left shift and store the result in memory location x3102. Your program should start at memory location x3000.

Example: If the memory location x3100 contains the bit pattern 1101000100001011 and memory location x3101 contains the value 0000000000000101 (decimal 5), then your program needs to shift 1101000100001011 by 5 bits to the left and store the bit pattern 0010000101100000 in memory location x3102. Note that when you shift a bit pattern n bits to the left, you fill the lowest n bits of the bit pattern with 0's.

Hint: What happens when you add a number to itself?

File name: Write your program in a file named left_shift.bin.


 

Part 2 (60 pts) - A Program that rotates a bit pattern to the left by a certain amount (a number between 0 and 16, including 0 and 16)

Problem: Now that you have done the left shift, we'll ask you to do something more exciting: rotating a bit pattern. Your task in this part is to write a program in LC-3 machine language to rotate a bit pattern some number of bits to the left and store the result in memory. The rotate amount (number of bits you rotate the bit pattern to the left) is a non-negative integer between 0 and 16, inclusive. Your program should assume that the initial bit pattern is in memory location x3100 and the rotate amount is stored in memory location x3101. Using those values, your program should perform the left rotation and store the result in memory location x3102. Your program should start at memory location x3000.

Example: If the memory location x3100 contains the bit pattern 1101000100001011 and memory location x3101 contains the value 0000000000000101 (decimal 5), then your program needs to rotate 1101000100001011 by 5 bits to the left and store the bit pattern 0010000101111010 in memory location x3102. Note that when you rotate a bit pattern n bits to the left, it is just like a left shift except that top n bits before the shift end up as the bottom n bits.

File name: Write your program in a file named left_rotate.bin.
 

Notes and Suggestions:

When and how to submit: Submit your two files (left_shift.bin and left_rotate.bin) on Canvas before the deadline.