Professional Documents
Culture Documents
Easy68k Beginners Guide
Easy68k Beginners Guide
Peter Csaszar
Department of Electrical and Computer Engineering
Lawrence Technological University
TABLE OF CONTENTS
1. INTRODUCTION ............................................................................................................................... 3
2. PROGRAMMING IN 68000 ASSEMBLY........................................................................................ 3
2.1. THE CLASSIC ASSEMBLY PROCEDURE ........................................................................................... 3
2.2. DEVELOPMENT OF 68000 CODE ON A PC....................................................................................... 4
2.3. ASSEMBLY PROCEDURE USING THE EASY68K ............................................................................. 4
2.4. ADVANCED TOPICS ........................................................................................................................ 5
3. INTRODUCTION TO THE EASY68K ASSEMBLY LANGUAGE TOOL ................................. 6
3.1. EDIT68K EDITOR/ASSEMBLER....................................................................................................... 6
3.1.1. Launching Edit68K .............................................................................................................. 6
3.1.2. Customizing Edit68K............................................................................................................ 6
3.1.3. Creating, loading and saving a source file .......................................................................... 7
3.1.4. Editing a source file ............................................................................................................. 7
3.1.5. Assembling and running a source file .................................................................................. 8
3.2. SIM68K SIMULATOR ...................................................................................................................... 8
3.2.1. Launching Sim68K ............................................................................................................... 9
3.2.2. Loading an S-record file ...................................................................................................... 9
3.2.3. Running and pausing the simulation .................................................................................... 9
3.2.4. Single step execution .......................................................................................................... 10
3.2.5. Breakpoints ........................................................................................................................ 10
3.2.6. Restarting execution........................................................................................................... 10
3.2.7. View windows..................................................................................................................... 11
3.2.8. Logging .............................................................................................................................. 12
3.2.9. Simulating exceptions......................................................................................................... 13
3.2.10. Using the TRAP #15 Simulator Function Calls.................................................................. 13
4. CONCLUSIONS ................................................................................................................................ 14
REFERENCES ........................................................................................................................................... 14
1. INTRODUCTION
This document is the first part of the two-part series introducing the development of assembly
language programs for the Motorola 68000 microprocessor with the excellent EASy68K
Assembly Language Tool. In the first part of this writing the generic procedure of assembly
language programming, and the specific process offered by the EASy68K assembler/simulator
platform, are introduced. This is followed by the detailed guide for the executables in the
development suite. This writing’s companion document [2] takes the discussion to the next step;
it introduces the fundamental knowledge necessary for writing assembly programs, thus creating
the link between the assembler utility (requiring specific details about the processor’s
environment) and the microprocessor’s assembly language (a collection of abstract instructions
specific to the processor itself, see [1]).
Source 1:
C compiler Object 1
C code
Source 2:
68000 assembler Object 2 Linker Executable
68000 code
Source 3:
Pascal compiler Object 3
Pascal code
With the advent of the Java language and the Microsoft .NET platform, the compilation scheme
has gotten even more complex. However, with the EASy68K tool, the actual 68000 assembly
procedure will be simpler than the one depicted above; the details will be shown in Section 2.3.
The PC-simulation of the non-native 68000 assembly code described in the previous section is
implemented by the Sim68K simulator (Sim68K.exe).
The EASy68K assembler generates two important files, the S-record file and the list file.
1. S-record file (.S68): This file serves as the equivalent of the 68000-executable binary
machine code, but in a “tame” ASCII format (encoded to contain only printable ASCII
characters, arranged in lines with limited length), as specified by Motorola. (This
encoding guarantees that the machine code can be handled by communication protocols,
such as RS-232, used by development boards for receiving machine code. EASy68K’s
simulator can also read the S-record file, and conduct the simulation of the “executable.”
Note: The EASy68K assembler can also produce the optional Binary file (.BIN), with
the actual 68000 machine code inside. This may be used with development boards,
emulators or other simulators requiring the machine code in this format; however, the
Sim68K simulator has no use for this file.
2. List file (.L68): This file contains the copy of the original source file, with one important
difference: each line of the source is preceded by the corresponding machine code, and its
absolute address, in hexadecimal format.
Tip: The historical purpose of the list file is to verify code correctness during the
debugging procedure. However, it bears a crucial importance in the EASy68K
environment; without the corresponding list file, the Simulator is not able to do source-
level debugging of the assembly program represented by the S-record file. (Source-level
debugging means the ability to execute instructions in single steps with the help of the
original source code.)
The following figure summarizes the software development cycle using the EASy68K suite.
The objects represented by dashed line are optional, and are not part of the usual procedure
discussed in the rest of this document.
assembly code and machine code, disassembly sessions can be quite successful. (Don’t expect
similar results restoring massive C++ sources…) However, disassembly will never be able to
restore the helpful hints contained in the source file, such as meaningful label names, and most
importantly, comments.
Cross-assembly – The original meaning of this overloaded term is the conversion of machine
code for a certain processor into machine code for another one. In most cases, this task is not only
useless, but also very complicated due to the vastly different features offered by microprocessors.
A somewhat sensible application is the upgrade of legacy code for a newer processor within the
same family; however, even this task is better achieved by recompiling the original [platform-
independent] source to the new processor.
sufficiently indented, in order to leave room for reasonably long labels. The following tabulator
column recommendation (counted from the beginning of the line) assumes fixed tabs with size 8:
o Label: 0 tabs [i.e., the beginning of the line]
o Statement: 2 tabs (max. label length: 15 characters)
o Arguments: 3 tabs
o Comments: 5 tabs (max. argument length: 15 characters)
Note: The EASy68K assembler allows white space after any comma (‘,’) character, e.g., between
two arguments, or within the value list of the DC assembler directive. This decision is really left
up to the programmer; it is not considered bad assembly programming style not to put spaces to
the aforementioned positions.
Tip: The caret (‘^’) character on the bottom of the editor window helps to identify where a line
should end. For the Courier New font, the caret enforces the following total line lengths:
• Size 8: 89 characters
• Size 10: 79 characters
This is more conservative than the printing limitations, therefore typing past the caret is not a big
disaster.
3.2.5. Breakpoints
If only a certain section of the program exhibits problems, it would be very tedious to reach the
desired point through single steps. The EASy68K makes it possible to “cut to the chase” through
breakpoints. If a program execution launched with the Run command encounters a breakpoint,
the Simulator is switched to Paused Mode, and the commands for single step execution become
available. Breakpoints can be toggled by clicking on the colored dot preceding each line of the
list file in the Simulator window. Red indicates the presence of a breakpoint; otherwise the color
of the dot is green.
Tip: Breakpoints can be “hard-wired” into the source code by placing the “*[sim68k]break”
string starting from position 1 into the line immediately preceding the line to be breakpointed.
(This feature is useful when a certain portion of the code is being tested for an extended period of
time; there is no need to place a breakpoint in the Simulator manually over and over again.)
Note: Advanced breakpoint conditions can be selected through the “View > Breakpoints” menu
item; however this feature is only recommended for advanced users!
memory position; recall that the “PUSH” stack operation is implemented with the
Address Register Indirect with Predecrement addressing mode), the Status Register
(loaded with $2000 – Trace Mode off, Supervisor Mode on, all interrupts enabled) and
the Program Counter (initialized to the address of the label in the loaded program’s END
directive). The program is ready to execute from the beginning; however, this command
has no effect on the memory contents whatsoever.
• Reload Program – “Run > Reload Program” menu item, Ctrl-F3 hotkey or <Reload
Program> toolbar button
Same as Reset Program, but the memory areas defined by a DC or DCB directive are also
reinitialized. This command must be used when a program contains any of these
directives to define memory contents that will be subsequently overwritten.
Note: The Reload Program command will close any execution logging or output logging (see
Section 3.2.8) in progress.
• Hardware View. A great addition to the views of Sim68K from version 3.0 is the
Hardware View window that implements the simulation of certain common hardware
features. These are:
o Input-output devices. Associated with a unique memory peripheral address
beginning at $E00000, these devices implement 8 pushbutton inputs, toggle
switch inputs, LED outputs (8 bits in a byte), plus an 8-digit 7-segment display
output (8 bytes, with bitmapped segment data in each byte).
o Interrupt buttons. These 7 pushbuttons can simulate an autovector hardware
interrupt event. It is also possible to associate one of these interrupt signals with
the Auto-Interrupt Timer, with a firing period defined as a multiple of 100
milliseconds. This latter feature provides a way to simulate timer-triggered
interrupts, a very common technique in microcontroller environments.
o Reset button. This button simulates a processor Hardware Reset event.
Note: This simulated hardware reset must not be confused with the Reset
Program simulator command. When a Hardware Reset event occurs, the SSP and
PC registers are loaded from the first two entries of the processor’s simulated
Exception Vector Table respectively, and the SR is loaded with the value $2700
(only the non-maskable interrupt is enabled); this is the exact procedure a real
68000 processor follows as a response to a hardware reset.
Warning! At the time of this writing, the Simulator (v3.4) responds to the
Interrupt and Reset buttons, even if the simulation of exceptions is not enabled
(see Section 3.2.9). Avoid tampering with these buttons if the corresponding
Exception Vector Table entries have not been set up properly.
More information about the Hardware View Window can be found in the EASy68K
Online Help [4], under the “Simulator Operation > Hardware Window” entry.
3.2.8. Logging
The Simulator provides two different logging facilities.
1. Execution logging. It is possible to save the status of the Simulator into a logfile during
execution, by selecting one of the Execution Log type options from the dialog accessed
through the “Options > Log Output…” menu item. This information includes the
executed instruction, the contents of all 68000 registers, and since version 2.2 – thank to
the suggestion from the author of this document – also the contents of a selected memory
area, after an instruction was stepped through with one of the single step execution
commands in Paused Mode (see Section 3.2.4).
Note: Remember that when memory logging is also requested as part of the Execution
Log, the starting address and number of logged bytes must be provided in hexadecimal.
Warning! As it has been mentioned previously, the running commands of Section 3.2.3
produce no Execution Log. Zooming through the entire program containing no
breakpoints with the Run command will write nothing in the Execution Logfile!
2. Output logging. By turning on the output logging feature of the Simulator from the
“Options > Log Output…” menu item’s dialog, all characters displayed in the output
window will be saved in the output logfile. This also includes the characters entered
through user input (unlike the “>” redirection operator in Unix and DOS), which makes
this facility perfect for recording the input/output events of a simulation session.
The default logfile names are derived from the name of the assembly source file, but can be
changed freely. The logging features are generally very intuitive. However, further information is
provided in the EASy68K Online Help [4], under the “Simulator Operation > Options” entry.
Tip: The most frequently used function calls belong to the group called “Text I/O”; the majority
of these use registers D1 and/or A1 for passing parameters, and only a few uses D2 as well.
Therefore it is recommended to reserve D0, D1 and A1, and refrain from using them for any other
purpose than the function calls (except maybe for very short-term temporary data storage), so that
no bad surprises or inexplicable bugs will occur during program development.
Warning: On a similar note: register A7 is the system stack pointer, therefore must be fully
reserved in all programs using subroutines and/or exceptions.
Note: Keep in mind that the numeric input/output function calls of the Text I/O group use the
entire 32 bits of the D1 register for data transfer, and regard its contents as a signed longword
(with range –2,147,483,648…+2,147,483,647). If the value to be input/output has a different data
type, conversion overflow testing or sign extension is required respectively.
The complete list and specification of the TRAP #15 function calls can be found in the EASy68K
Online Help [4], under the “Simulator I/O” entry. The Text I/O group’s function calls are listed
in the “Text/Time/Terminate” subentry.
4. CONCLUSIONS
This document introduced the EASy68K Assembly Language Tool, a premium environment for
developing and simulating 68000 assembly code on a PC running Microsoft Windows.
The author would like to express his appreciation to Professor Charles Kelly at Monroe County
Community College (Monroe, Michigan) for the development and maintenance of the EASy68K
suite, a truly remarkable software toolkit for the 68000 microprocessor.
REFERENCES
[1] Motorola, Inc.: M68000 8-/16-/32-bit Microprocessors Users Manual. (Reprinted by multiple
publishers, e.g. Prentice Hall, 1989; Barnes & Noble, 1991.)
[2] Peter Csaszar: 68000 Quick Start Guide. (Microprocessors Lab supplementary material.)
Lawrence Technological University, 2006.
[3] James L. Antonakos: The 68000 Microprocessor. Fifth Edition. Pearson Prentice Hall, 2004.
[4] Charles Kelly: EASy68K Assembly Language Tool Online Help. (Edit68K “Help > Help”
menu item or Sim68K “Help > Sim68K Help” menu item.)