next up previous contents

[ENGN3213 Home]

   
Hand Assembly and Running

We now enter a short piece of code into memory by hand, set up the machine for running the code, and run the code.

Open the memory viewer:

Window $\to$ Memory Viewer
see Figure 44.


  
Figure 44: BSVC memory viewer.
\begin{figure}
\begin{center}
\epsfig{file=images/bsvc-mem-view.eps}\end{center}\end{figure}

By default, the memory viewer shows memory locations begining at $0000. We will enter the following code, begining at memory location $2000:

00002000  303C 2468     move.w  #$2468,d0       
00002004  31C0 1FF0     move.w  d0,$1ff0
00002008  4848          BREAK
To do this:

Before running the code, set the program counter to $2000 by clicking on it and entering the value $2000

Run the code by clicking the RUN button. You will notice that register D0 now contains the data $2468. Check that this data appears in memory (use the up arrow button).

Set PC to $2000, and run the code again using the SINGLE STEP button. Notice the instructions appear in the trace window and are reverse assembled, i.e. the simulator interprets the machine code and tells you the assembly code.

Exercises:

1.
Write down the addresses and contents of the two memory locations containing the data.

2.
What addressing modes are being used in each instruction?

3.
Hand code the following program, enter it into memory (start at address $2000), and run it.
move.w  #$2468,d0       
addq.w  #1,d0
        BREAK


next up previous contents

[ENGN3213 Home]

ANU Engineering - ENGN3213