Tuesday, November 23, at 5pm
There are many different ways of interpreting bits in memory. We are already familiar with the idea of a single LC-3 memory location containing either an LC-3 instruction or a 16-bit 2's complement value. Consider a program that deals with small integer values in the range -128 to +127 (decimal). We would need only 8 bits to represent each number, so to conserve memory we could pack two such numbers into a single LC-3 location (hence the term "packed array").
You are to write a program in LC-3 machine code (not assembly language) that will 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. The sum of the elements will be stored in one word of memory as a 16-bit 2's complement number.
For each word in the packed array, bits [15:8] contain the first 8-bit value, and bits [7:0] contain the second value.
Using LC3edit, create a file named
You should find the code you wrote
for Part 1 useful for Part 2. Your program should begin at
location x3000. The size of the packed array, N, is stored in
location x3101. You may assume that N <= 100 (decimal). The
packed array itself is stored beginning at location x3102. Your
program should store the result SUM in location x3100.
Prior to executing the program, you should manually load test values into locations x3101, and x3102 through x3102 + (N/2 -1).
Example: If prior to program execution memory is loaded with these values:
location contents x3101 x0006 x3102 x7F03 x3103 xFE7A x3104 x1B40then upon completion of the program, location x3100 will contain x0155.
unpack.binbefore 5pm on Tuesday, November23. Make sure you include your name and section number at the top of your file.