Department of Electrical and Computer Engineering
University of Texas at Austin
EE 379K
Fall 2000
Y. N. Patt, Instructor
TAs: Kathy Buchheit, Laura Funderburg, Chandresh Jain, Onur Mutlu,
Danny Nold, Kameswar Subramanian, Francis Tseng, Brian Ward
Programming Assignment 2
Due: October 22, 2000 11.59 PM
Reversing a bit pattern in memory
Problem Statement
You are asked to write a program in LC-2 machine language that takes
a word stored at memory location x3100 and reverse all the bits.
You will store your result in memory location x3300. Example: If
the bit pattern 1010100101001011 is stored at memory location x3100,
your program should write the bit pattern 1101001010010101 into memory
location x3300.
Hint: As you know from programming assignment 1, ADDing a bit pattern
to itself effectively shifts the bit pattern to the left by one bit position.
If I have a number X and I AND it with the bit pattern 0000000000000001,
what do I get? What do I get when I AND the same number with 0000000000000010?
Notes and Suggestions
-
The first line of your programs must specify the memory address of the
first instruction of your program. LC-2 simulator will place your program
starting at that address. For this assignment, you should place your program
starting at x3000 (the first line of your program should contain
the bit pattern 0011000000000000).
-
A good strategy is to spend time thinking about your program before sitting
at the computer. You'll minimize the time spent programming and probably
save yourself frustration when it comes time to debug your program. Our
experience tells us that programs rarely work on the first shot. Be prepared
to debug your program!
-
Before running your program, you should deposit a value into memory location
x3100
using the "Set Register or Memory" or "Set Values" menu in the simulator.
If your program functions correctly, the number at the location x3300 will
be the reverse of the bit pattern stored at location x3100. You
should verify that your program works correctly by testing it with several
different values.
-
If you are working on a Windows machine, use the LC2Edit program to type
in your programs. On Sun and Linux workstations, pico, emacs, and vi are
several of the text editors you can use. Your program file needs to be
in plain text format. Please ask any TA if you have any questions.
What to Turn In
You will submit your program electronically. You can find instruction
on how to submit your program in a document titled "How to submit your
programs" that is linked from the course homepage.
-
If you are working from Windows, submit your program by clicking on the
Submit-ITC program. This will bring up a window where you fill in your
ECE login name, the unique number of the discussion section in which you
would like your programs returned to you, the name of the file you are
submitting, and the program number. To enter the file name, you should
click on the find button and locate your file. The program number for this
assignment is 2.
-
If you are working from Unix, submit your program using the submit-itc
script. The program number for this assignment is 2.
submit-itc myprog2.bin 2
If you wrote your program in hex, you may submit your .hex file in a similar
manner. You will receive a response by email to your ECE account.
Make
sure to check the email response to see if it was received on time.
The email you will receive contains a lot of information about your program,
including a copy of your program. Please read the entire email and make
sure that you can see your program in the email. If you cannot see your
program in the email, we will not be able to see it either.
Note: You must submit your program by following the steps above. You
may NOT email your program to your TA.