Wednesday, September 30, 2009 9:29 PM,
A student writes: Dr. Patt I have been running some tests on my program and I have noticed that in order to re-run my program without reloading the program, I must reset the PC to x3000. I suppose since I am not reloading the program, the LC-3 does not know where to reset the PC so I must manually set the the PC myself, is this correct? Or is there sometimes a code that will reset the PC at the very end of a program to prepare the computer for another run? Thank you for your time, <<name withheld to protect the student who would prefer not to reload>> Good question. When you load the program, your first line specifies the location that will contain the first instruction in your program and also sets the PC accordingly. What if you want to run the program again and again, because you want to test your program on additional input data. In the case of your first assignment, different initial values in x3100. It would be boring to have to reload the program each time you run it. In fact, you don't have to do that. Since the program is still in memory, you simply change PC to the starting address (manually) and run the program again. NOTE: This is only guaranteed to work if the execution of your program the first time did not change any of the locations in your program. For example, suppose your program had to do something 50 times and you had a location in your program that was keeping track of how many times you did that task. Suppose the way your program worked was to start with the value 50 stored in one of the locations after the HALT and during execution of the program that location kept getting decremented until it got to zero. The second time you ran the program the value in that location is zero, since your first execution of the program decremented the value 50 times. The second time you run the program it will run incorrectly, since that location contains 0 instead of 50. As long as you do not modify the program, there should be no problem running the program again and again by loading PC with the starting address. Good luck finishing the program by Sunday night. Yale Patt