Lab exercise Week 8: Wednesday October 21.

 

In this exercise you will examine a program written for the LC3 machine.

 

The program is what we covered in class – addition of numbers. Specifically,  the program is loaded at address x3000. The program adds the five numbers  stored starting at address x300B. The register R2 serves as the "counter" and it counts down from 5 to 0. The sum of the five numbers is to be stored in Register R3 -- i.e., at the end of the program execution the sum of the five numbers (in this case 1 thourgh 5) should be stored in R3.  The  "algorithm"  is:

R1 = x300B
R3=0
R2=5
WHILE R2 not equal to 0
  R4 = Mem[R1]
  R3 = R3 + R4
  R2 = R2 -1
  R1 = R1 + 1
ENDWHILE

Your task is to  examine the object code provided to you . You should load this into the LC3 simulator, then run it step by step, and figure out if the program is working correctly. Your task is to determine (a) if the program is correct and (b) if it is incorrect then to identify the problem and fix it – i.e., figure out the error/bug and fix it by specifying what instructions need to be corrected and how.