Document Sample
68K_simInfo Powered By Docstoc
					Using the EASy68K 68K Cross Assembler and Simulator
The 68K cross-assembler and simulator allows you to write a 68K assembly language program, assemble it into
68K binary code on an IBM PC, and then execute this code as if you were running it on a real 68K
microprocessor. The simulator allows you to execute a single instruction at a time, and to observe the state of
simulated registers after the execution of each instruction.

To begin a session, run the program EDIT68K.exe. This is a text editor for 68K assembly language programs. If
your computer does not have this program you can install it from the website

When you run EDIT68K you see the following screen.

This code in this window provides a template for your own program. You can erase this code and start again or
you can use it. Note that the provided code gives you the beginning and end of a program.

This code puts your program in memory at 100016. The END assembler directive has the label 'START' which
point to the beginning of the program (i.e., at address $1000). You must not put data here (i.e., immediately after
the ORG statement! The first line after START must be a valid 68K instruction.

Consider entering a program to add five numbers in a list using indexed addressing.

         LEA       List,A0          ;A0 is set to point at the list
         MOVE.B    #5,D0            ;Use D0 as a loop counter – set it to 5
         CLR.B     D1               ;Clear the total in D1 before we start
Loop     ADD.B     (A0),D1          ;Add the number pointed at by A0 to D1
         ADD.L     #1,A0            ;Point to the next number in the list
         SUB.B     #1,D0            ;Decrement the counter
         BNE       Loop             ;If we haven’t reached zero, go round again

List     DC.B      1,4,3,6,7        ;here’s the data to add.
The following picture shows the effect of entering this code into the editor.

The next step is to assemble the code. Click on 'Project' then click on 'Assemble Source' in the pull-down menu.
This will invoke the assembler. The code will either assemble successfully with no errors, or unsuccessfully
with one or more errors. If you have an error, you have to re-edit your code and then assemble it again. You
repeat this step until you have no errors.

                                                                         Click on the Project tab to
                                                                         get the ‘Assemble Source’
                                                                         menu. Select this.
The following is a picture of the situation after we have successfully assembled the code and we are about to
click on 'Execute' to invoke the simulator.

                                                                                                  This is the screen
                                                                                                  with the ‘no errors’

                                                                                       You click on the 'Execute'
                                                                                       message to begin running
                                                                                       your program.

At this stage you can execute the code line-by-line (i.e., instruction-by-instruction) and observe the execution of
the program and see the contents of the registers. At this stage, what you will see is:

                                                                                      The simulated registers

                                                                                         The first line of the
This screen shows the result after we've executed several instructions and been round the loop a few times. Note
that the next instruction to be executed is at address 00001014 and this instruction is SUB.B #1,D0.

At this stage we can examine the contents of several registers. The total in D1 is 0E16 and the loop count in D0 is
down to 2.
                                                Clicking on this button executes a single
                                                instruction and shows the state of all
                                                registers after the execution of that

This demonstrates a simple run of the simulator. You can do very much more! For example, you can set
breakpoints. A breakpoint is a point in the code at which execution stops and registers are displayed. You can
run the code (execution taking place at high speed invisibly) until the program counter reaches the breakpoint at
which the simulation stops and the registers are displayed.

If you use the View function, you can select 'memory' observe data in the 68K's simulated memory.