Simulation (Stage 2) -- Methods for the controlled simulation of Task 1

Avoiding the run-away code problem -- attempt 1

Although there are things to be fixed, it is still possible to run the "e1v3.out" code in a more controlled, non-crashing way.

Reset the Source window to mycode and the PC to 0x1000. This resetting of the windows and PC can also be made much easier with a few SDS tricks discussed on the next page.

Double-click in the space to the left side of memory location 0x1012. A BREAKPOINT, marked by the small red flag, has been set. If you now hit GO, you will find that the simulation no longer "runs-way" but stops at the BREAKPOINT. You can clear a BREAKPOINT by clicking on its flag.


Running our code in a very controlled way -- attempt 2

Reset the PC to 0x1000 and use the STEP option from the Toolbar or the Run option. Activate the STEP option to move through the code executing one instruction at a time.

As you STEP through the program, examine the value in the D0 register shown in the Register window. You should see

  1. D0 = 0x27F (639), and PC = 0x1006 after the first instruction has executed and brought in the contents of memory location A (0x2000 contains 0x27F (639))
  2. D0 = 0x1A8 (424) and PC = 0x100C after the second instruction has brought in the contents of memory location B (0x2002 contains 0xFF29 (-215)) and added it into register D0
  3. PC = 0x1012 after the third instruction has stored the value in D0 into memory location 0x7200 (C). If you bring up a Memory window ( you can examine and clear memory location 0x7200 as follows

    You can now watch this memory location change as the instructions execute after resetting the simulation. Note that you can't use the label C in the Memory window to specify memory location 0x7200 for two reasons

NOTE:- The PC (green arrow) always points to the instruction about to be executed. All the values in the registers and memory locations correspond to what happened after the previous instruction was executed. Make sure that you don't interpret the simulation information the wrong way.


Generating a final version of our code

We can now go back and fix up our final code file with the lessons we have learnt

You might like to try and fix these problems before moving on and finding my suggested solutions to these problems on the next WEB page.



Last modified: July 02, 1996 07:13 PM by M. Smith.
Copyright -- M. R. Smith