Department of Electrical and Computer Engineering The University of Texas at Austin EE 306 Fall 2002 Yale Patt, Instructor TAs: Asad Bawa, Linda Bigelow, Mustafa Erwa, Lester Guillory, Kevin Major, Moinuddin Qureshi, Paroma Sen, Tanay Shah, Santhosh Srinath, Matt Starolis, David Thompson, Vikrant Venkateshwar Programming Assignment 2 (Machine Code) Due October 27, 2002 at 11:59pm 1. Background There are many different ways of interpreting bits in memory. We are already familiar with the idea of a single LC-2 memory location containing either an LC-2 instruction or a 16-bit 2's complement value. Consider a program that deals with small values in the range -128 to +127. We would only need 8 bits to represent each number, so to conserve memory we could pack two such numbers in a single LC-2 location, hence the name "packed," as it is often called. 2. Assignment Write a program to calculate the sum of all the 8-bit 2's complement values in a packed array of N elements. With N elements in the packed array, we require N/2 memory locations. For this assignment, we will assume N is even. (You might on your own think of what modifications you would have to make if N were odd.) Your SUM will be stored in one word of memory as a 16-bit 2's complement number. For each element in the array, bits [15:8] contain the first 8-bit value, and bits [7:0] contain the second value. Your program should begin at x3000. The size of the packed array, N, is stored in location x3101. We will restrict the value of N to be less than or equal to 600 (decimal). The packed array itself is stored beginning at location x3102. Your program should store the result SUM in location x3100. 3. Initial Values Your program should assume that there are already values stored in memory at locations x3101 and x3102 through x3102 + (N/2 - 1). When using the LC-2 simulator to test your program, you should manually load test values into these memory locations before running your program. Example: Consider the following array, where x3101 contains N, the number of elements in the array: x3101 | x0006 x3102 | x7F03 x3103 | xFE7A x3104 | x1B40 Your program should result in x0155 stored in location x3100. 4. Format Your program must be a text file of binary characters (i.e., a .bin file). Each line contains a 16-character string of ones and zeros. You are encouraged to add comments when useful and appropriate. 5. Submission Instructions We will post entirely new submission instructions on the course homepage later this week.