A good answer might be:

Yes. You might try this as an exercise.

Running the Program

You can run the program by initializing the PC (to 0x00400000) and repeatedly hitting single step (F10). But when the array has many entries this is tedious. On the version of SPIM for windows you can do the following to start the program and run it to completion:

  1. Initialize the PC (as usual).
  2. Hit F10 once (or more, if you want).
  3. Click on "Continue" in the "Simulator" menu.
  4. The program will execute until the PC goes beyond the end of the program.
  5. The simulator halts.

This procedure is not very elegant. Set a breakpoint at the last instruction if you want. Or set a breakpoint at the top of the loop so that the loop body executes once per "Continue".

If you click "Go" in the menu, the simulator tries to start with some code that is not there and halts. "Bare Machine" is set in the options menu, so the extra code is not there. Keep things this way for now, unless you want to experiment.

QUESTION 16:

Is a single run of the program enough to be certain that it is correct?