DevpacST V2 PDF
DevpacST V2 PDF
DevpacST V2 PDF
Assembler/Editor/Debugger
System Requirements:
Atari ST Computer with a mouse an d a disk drive
Printing History:
1st Edition August 1986 (ISBN 0 948517 04 2)
Reprinted April 1987 & October 1987
2nd Edition April 1988 (ISBN 0 948517 11 5)
Set using an Apple Macintosh™ with Microsoft Word™ & Aldus Pagemaker™
ISBN 0 948517 11 5
Introduction 9
The Editor 9
A Few Words about Dialog Boxes 11
Entering text and Moving the cursor 11
Cursor keys 12
Tab key 13
Backspace key 14
Delete key 14
Goto a particular line 14
Go to top of file 14
Go to end of file 14
Quitting GenST 15
Deleting text 15
Delete line 15
Delete to end of line 15
UnDelete Line 15
Delete all the text 15
Page Table of Contents HiSoft DevpacST
CHAPTER 3 - Macro Assembler 31
Introduction 31
Invoking the Assembler 31
From the Editor 31
Stand-Alone Assembler 32
Command Une Format 33
Output Filename 34
Assembly Process 34
Assembly to Memory 34
Binary file types 35
Types of code 36
Assembler Statement Format 37
Label field 37
Mnemonic Field 38
Operand Field 38
Comment Field 38
Examples of valid lines 39
Expressions 39
Operators 39
Numbers 40
Character Constants 40
Allowed Type Combinations 41
Addressing Modes 42
Special Addressing Modes 42
Local Labels 43
Symbols and Periods 43
Instruction Set 44
Word Alignment 44
Instruction Set Extensions 44
Assembler Directives 46
Assembly Control 46
END 46
INCLUDE 46
INCBIN 47
OPT 47
EVEN 50
CNOP 51
DC 51
DS 51
DCB 52
FAIL 52
OUTPUT 52
_G2 52
Repeat Loops 52
REPT 53
ENDR 53
Page iv Table of Contents HiSoft DevpacST
Imports & Exports 69
XDEF 70
XREF 70
Using Imports in Expressions 71
COMMENT 72
ORG 72
OFFSET 73
LK 73
DRI Debug Option 73
Writing GST Libraries 73
Simple File Format Examples 74
Directive Summary 76
Symbolic Debugging 84
MonST Dialog and Alert Boxes 84
Initial Display 85
Front Panel Display 85
Simple Window Handling 87
Command Input 87
MonST Overview 88
MonST Reference 90
Numeric Expressions 90
Window Types 91
Register Window Display 91
Disassembly Window Display 92
Memory Window Display 93
Source-code Window Display 93
Window Commands 93
Cursor Keys 96
Screen Switching 96
Breaking into Programs 98
Page vi Table of Contents HiSoft DevpacST
CHAPTER 5 - Linker 119
Introduction 119
Invoking the Linker 119
Command Une 120
Example Command Lines 121
LinkST Running 121
Control Files 122
INPUT 122
OUTPUT 122
LIBRARY 122
SECTION 123
DEBUG 123
XDEBUG 123
DATA 123
BSS 123
Automatic Double-Clicking 124
Errors 129
Warnings 133
Page viii Table of Contents HiSoft DevpacST
Appendix E
Converting from other Assemblers 173
Atari MADMAC 173
GST-ASM 174
MCC Assembler 174
K-Seka 174
Fast ASM 174
Upgrades 180
Suggestions 180
DevpacST Developer Version 180
Before hiding away your master disk make a note in the box below
of the serial number written on it. You will need to quote this if you
require technical support.
Serial No:
Registration Card
Enclosed with this manual is a registration card which you should
fill in and return to us after reading the licence statement. Without
it you will not be entitled to technical support or upgrades. Be sure
to fill in all the details especially the serial number and version
number. Also supplied is a 68000 Pocket Guide which details the
entire 68000 instruction set.
Of course the faster the cycle, the faster you can get your
programs up and running and DevpacST was designed to be as
fast and powerful as possible. The Link stage is optional, as is the
Compile stage.
Text Files
Binary Files
Folders
Beginners
If you are a newcomer to assembly language then we recommend
that you read one of the books in the Bibliography alongside this
manual.
To start with load GENST2.PRG from your backup copy (you have
made a backup, haven't you?) which must also contain the files
MONST2 . PRG and DEMO . S, at minimum, by double-clicking on its
icon. After a short delay the screen will show an empty window; to
load the file you should move the mouse over the File menu and
click on Load. The standard GEM file selector will then appear and
the file we want is called DEMO. s. You may either double-click on the
name or type it in and press Return to load the file.
When the file has loaded the window will show the top lines of the
file. If you want to have a quick look at the program you may click
on the scroll bar or use the cursor keys.
A dialog box will appear, which should be left alone except the
button near the bottom, labelled None, should be clicked on. Click
on the Assemble button or press Return and the assembly will
begin.
The assembler will report an error, instruction not recognised,
and pressing any key will return you to the editor. The cursor will
be placed on the incorrect line and the error message displayed in
the status line.
The assembly worked this time, so click on Run from the Program
menu, and what happens? Not a lot it would seem, except that a
couple of bombs appeared briefly on the screen - oh, there's a bug.
The tool for finding bugs is a debugger, so click on Debug from the
Program menu. The debugger is described more fully later on, but
for now we just want to run the program from the debugger to
'catch' the bombs and find out what causes them, so press Ctrl-R.
After a brief delay the message Bus Error will appear in the bottom
window, with the disassembly window showing the current
instruction
MOVE.W 1,-(A7)
move.w
then press Return to start the search. The first occurrence has a
hash sign, so press Alt-N to find the next, which is the line
move.w c conin,-(a7)
Ahah! - this is the one, so add a hash to change it to
move.w #c conin,-(a7)
then assemble it again. If you click on Run from the Program menu
you should see the message, and pressing any key will return you
to the editor.
However, did you notice how messy the screen was - the desktop
pattern looked very untidy and you possibly got mouse
'droppings' left on the screen. This was because DEMO is a TOS
program running with a GEM screen - to change this, click on Run
with GEM from the Program menu - the check mark next to it
should disappear. If you select Run again you can see the display is
a lot neater, isn't it? If you run a GEM program you must ensure
the check mark is there beforehand, otherwise nasty things can
happen.
Although the program now works we shall use MonST, the
debugger, to trace through the program, step by step. To do this
click on Debug from the Program menu, and the debugger will
appear with the message Breakpoint, showing your program.
There are various windows, the top one displaying the machine
registers. the second a disassembly of the program, the third
some other memory, and the bottom window displaying various
messages.
If you look at window 2. the disassembly window, you will see the
current instruction, which in our case is
MOVE.L #string,-(A7)
As the debug option was specified in the source code any symbols
will appear in the debugger.
To execute this call press Ctrl-Z, which will have printed the
string. To prove it press v again, then any key to return to MonST.
Press Ctrl -z twice more until you reach the next Trap. This one
waits for a key press so hit Ct r l - z and the program display will
automatically appear, waiting for a key. When you're ready, press
the q key. You will return to MonST and if you look at the register
window the low 8 bits of register DO should be $71, the ASCII code
for q, and next to that it will be shown as q (unless in low-
resolution).
The final Trap quits the program, so to let it run its course press
Ctrl-R, you will then return to the editor as the program has
finished.
Note the way we have used the courier font to indicate text or
values that appear on screen or input to be typed from the
keyboard. Also, Ctrl -x means hold the ct rl key down on the
keyboard and press x, while Return indicates that you should
press the Return key on the keyboard. These conventions will be
used throughout the manual.
CHAPTER 2
Screen Editor
Introduction
To enter and assemble your programs you need an editor of some
sort and an assembler. GenST combines both of these functions
together in one integrated program, giving a GEM-driven full-
screen editor and a fast, full-specification assembler. It also allows
you to run your assembled programs directly from memory
without having to quit the program or do a disk access and to
access the debugger at the press of a key. The fact that all these
features are combined in one program means that correcting
errors and making changes is as fast as possible without the need
for slow disk accesses and other programs.
This chapter details the use of the editor and how to assemble
programs - it does not detail the assembler or the debugger
themselves, they are covered in the following chapters.
To run GenST, double click on the GENST2 . PRG icon from the
Desktop. When it has loaded a menu bar will appear and an empty
window will open, ready for you to enter and assemble your
programs.
The Editor
A text editor is a program which allows you to enter and alter lines
of text, store them on disk, and load them back again. There are
two types of text editors: line editors, which treat each line
separately and can be very tricky to use, and screen editors, which
display your text a screen at a time. The latter tend to be much
easier to use.
The editor section of GenST is a screen editor which allows you to
enter and edit text and save and load from disk, as you would
expect. It also lets you print some or all of your text, search and
replace text patterns and use any of the Srs desk-accessories. It is
GEM-based, which means it uses all the user-friendly features of
GEM programs that you have become familiar with on your
computer such as windows, menus and mice. However, if you're a
die-hard, used to the hostile world of computers before the advent
of WIMPs, you'll be pleased to know you can do practically
everything you'll want to do from the keyboard without having to
touch a mouse.
The editor is 'RAM-based', which means that the file you are
editing stays in memory for the whole time, so you don't have to
wait while your disk grinds away loading different sections of the
file as you edit. As the ST range has so much memory, the size
limitations often found in older computer editors don't exist with
GenST; if you have enough memory you can edit files of over 300k
(though make sure your disk is large enough to cope with saving it
if you do!). As all editing operations, including things like
searching, are RAM-based they act blindingly quickly.
When you have typed in your program it is not much use if you are
unable to save it to disk, so the editor has a comprehensive range of
save and load options, allowing you to save all or part of the text
and to load other files into the middle of the current one, for
example.
If at any time you get stuck, pressing the Help key will bring up a
comprehensive display of the keys required for functions not
visible in any menus.
Buttons may be clicked on with the mouse an d cause the dialog box
to go away. Usually there is a default button, shown by having a
wider border than the others. Pressing Return on the keyboard is
equivalent to clicking on the default bu tton.
Editable text is shown with a dotted line, and a vertical bar marks
th e cursor position. Characters may be typed in and corrected
using th e Backspace, Delete and cursor keys. You can clear th e
whole edit fi eld by pressing th e Esc key. If there is more than one
editable text field in a dialog box, you can move between them using
th e 1 and t keys or by clicking near them with th e mouse.
To enter text, you type on the keyboard. As you press a key it will
be shown on the screen an d the cursor will be advanced along the
line. If you are a very good typist you may be able to type faster
than the editor can re-display the line; if so, don't worry, as the
program will not lose the keystrokes and will catch up when you
pause. At the end of each line you press the Return key (or the
Enter key on the numeric pad) to start the next line. You can
correct your mistakes by pressing the Backspace key, which
deletes the character to the left of the cursor, or the Delete key.
which removes the character the cursor is over.
Cursor keys
To move the cursor around the text to correct errors or enter new
characters, you use the cursor keys, labelled .- -^ t an d 1. If you
move the cursor past the right-hand end of the line this won't add
anything to your text, but if you try to type some text at that point
the editor will automatically add the text to the real end of th e line.
If you type in long lines the window display will scroll sideways if
necessary.
To move immediately to the start of the current line, press ctrl (-,
and to move to the end of the current line press ctrl -^ .
To move the cursor a word to the left, press shift i- and to move a
word to the right press Shift -. You cannot move past the end of a
line with Shift -). A word is defined as anything surrounded by a
space, a tab or a start or end of line. The keys trl-A and Ctrl-F
also move the cursor left and right on a word basis.
To move the cursor a page up, you can click on the upper grey part
of the vertical scroll bar, or press Ctrl-R or Shift t To move the
cursor a page down, you can click on the lower grey part of the
scroll bar, or press ctrl-C or Shift 1.
Tab key
The Tab key inserts a special character (ASCII code 9) into your
text, which on the screen looks like a number of spaces, but is
rather different. Pressing Tab aligns the cursor onto the next
'multiple of 8' column, so if you press it at the start of a line
(column 1) the cursor moves to the next multiple of 8, +1, which is
column 9. Tabs are very useful indeed for making items line up
vertically and its main use in GenST is for making instructions line
up. When you delete a tab the line closes up as if a number of spaces
had been removed. The advantage of tabs is that they take up only
1 byte of memory, but can show on screen as many more, allowing
you to tabulate your program neatly. You can change the tab size
before or after loading GenST using the Preferences command
described shortly.
Backspace key
The Backspace key removes th e character to the left of th e cursor.
If you backspace at th e very beginning of a line it will remove the
'invisible' carriage return and Join th e line to th e end of the previous
line. Backspacing when the cursor is past th e end of th e line will
delete the last character on the line, unless th e line is empty in
which case it will re-position the cursor on the left of th e screen.
Delete key
The Delete key removes the character under the cursor and has
no effect if the cursor is past th e end of the current line.
Go to top of file
To move to th e top of th e text, click on Goto Top from th e Options
menu, or press Alt-T. The screen will be re-drawn if required
starting from line 1.
Go to end of file
To move the cursor to th e start of the very last line of th e text, click
on Goto Bottom, or press Alt-B.
Quitting GenST
To leave GenST, click on Quit from the File menu, or press Alt-Q. If
changes have been made to the text which have not been saved to
disk, an alert box will appear asking for confirmation. Clicking on
Cancel will return you to the editor, while clicking on OK will
discard the changes an d return you to the Desktop.
Deleting text
Delete line
The current line can be deleted from the text by pressing Ctrl-Y.
UnDelete Line
When a line is deleted using either of the above commands it is
preserved in an internal buffer, an d can be re-inserted into the text
by pressing trl-u, or the Undo key. This can be done as many
times as required, particularly useful for repeating similar lines or
swapping over individual lines.
To clear out the current text, click on Clear from the File menu, or
press Alt-c. If you have made any ch an ges to the text that have
not been saved onto disk, a confirmation is required an d the
requisite alert box will appear. Clicking on OK will delete the text, or
Cancel will abort the operation.
Disk Operations
It is no use being able to type in text if you are unable to save it
anywhere permanently, or load it back subsequently, so the editor
has a comprehensive set of features to read from and write to disk.
Figure 2.1 shows an example of the file selector box. At the top the
current drive, directory and type selection is shown. To the right is
a space for the actual filename, with OK and Cancel buttons below
it and a window taking up most of the remainder of the selector.
This window displays all of the filenames that correspond to the
drive and directory above.
If the file you want is not in the sub-directory shown, you can go
down a directory level by clicking on the directory name in the
window, or you can go up a directory by clicking on the close box of
the filename window. By default, GenST displays all files ending in
.S, as this is the usual extension for assembly language programs.
If you want to change this, you have to edit the Directory string
and replace the .S with the extension of you choice, such as .ASM. If
you want to be shown all the files, regardless of extension, replace
the . s with . *. If you do edit the Directory string you need to click
in the filename area of the window to tell GEM to re-display the
filenames. If you want to change the disk drive specifier, you
should click on the Directory string with the mouse (or press t ),
edit it to suit and click in the filename area of the window.
Note
In all pre-blitter versions of the ST ROMs there is a bug
which means that if you press _ (underline) when the cursor is in
the Directory string the machine will crash!
Saving Text
To save the text you are currently editing, click on Save As from
the File menu, or press Alt-S. The standard GEM File Selector will
appear, allowing you to select a suitable disk and filename. Clicking
OK or pressing Return will then save the file onto the disk. If an
error occurs a dialog will appear showing a TOS error number, the
exact meaning of which can be found in Appendix A.
If you click on Cancel the text will not be saved. Normally if a file
exists with the same name it will be deleted and replaced with the
new version. but if Backups are selected from the Preferences
options then any existing file will be renamed with the extension
.BAK (deleting any existing . BAK file) before the new version is
saved.
Save
Loading Text
To load in a new text file, click on Load from the File menu, or press
Alt-L. If you have made any changes that have not been saved, a
confirmation will be required. The GEM file selector will appear,
allowing you to specify the disk and filename. Assuming you do not
Cancel, the editor will attempt to load the file. If it will fit, the file is
loaded into memory and the window is re-drawn. If it will not fit an
alert box will appear warning you, and you should use Preferences
to make the edit buffer size larger, then try to load it again.
Inserting Text
If you want to read a file from disk and insert it at the current
position in your text click on Insert File from the File menu, or press
Alt-I. The standard GEM file selector will appear and assuming
that you do not cancel, the file will be read from the disk and
inserted, memory permitting.
To find the next occurrence of the string click on Find Next from the
Search menu, or press Alt-N. The search starts at the position
just past the cursor.
Block Commands
A block is a marked section of text which may be copied to another
section, deleted, printed or saved onto disk. The function keys are
used to control blocks.
Marking a block
The start of a block is marked by moving the cursor to the required
place and pressing key F1. The end of a block is marked by moving
the cursor and pressing key F2. The start and end of a block do not
have to be marked in a specific order - if it is more convenient you
may mark the end of the block first.
A marked block is highlighted by showing the text in reverse. While
you are editing a line that is within a block this highlighting will
not be shown but will be re-displayed when you leave that line or
choose a command.
Copying a block
A marked block may be copied, memory permitting, to another
part of the text by moving the cursor to where you want the block
copied and pressing key F4. If you try to copy a block into a part of
itself, the message Invalid block will appear and the copy will be
aborted.
Deleting a block
A marked block may be deleted from the text by pressing Shift-F5.
The shift key is deliberately required to prevent it being used
accidentally. A deleted block is remembered, memory permitting,
in the block buffer, for later use.
Note
This is on a different key to that used in GenST in
versions before 2.0.
Copy block to block buffer
The current marked block may be copied to the block buffer,
memory permitting, by pressing Shift-F9. This can be very useful
for moving blocks of text between different files by loading the first,
marking a block, copying it to the block buffer then loading the
other file and pasting the block buffer into it.
Pasting a block
A block in the block buffer may be pasted at the current cursor
position by pressing F5.
Note
The block buffer will be lost if the edit buffer size is
changed or an assembly occurs.
Printing a block
A marked block may be sent to the printer by clicking on Print Block
from the File menu, or by pressing Alt-W. An alert box will appear
confirming the operation and clicking on OK will print the block.
The printer port used will depend on the port chosen with the
Install Printer desk accessory, or will default to the parallel port.
Tab characters are sent to the printer as a suitable number of
spaces, so the net result will normally look better than if you print
the file from the Desktop.
If you try to Print when no block is marked at all then the whole file
will be printed.
Help Screen
The key equivalents for the commands not found in menus can be
seen by pressing the Help key, or Alt-H. A dialog box will appear
showing the WordStar and function keys, as well as the free
memory left for the system.
Preferences
Selecting Preferences... from the Options menu will produce a
dialog box allowing you to change several editor settings:
Tabs
By default the text buffer size is 60000 bytes, but this can be
changed from 4000 to 999000 bytes. This determines the largest
file size that can be loaded and edited. Care should be taken to leave
sufficient room in memory for assembly or running MonST -
pressing the Help key displays free system memory, and for
assembly or debugging this should always be at least 100k bytes.
Changing the editor workspace size will cause any text you are
currently editing to be lost, so a confirmation is required if it has
not been saved.
The Numeric Pad option allows the use of the numeric keypad in
an IBM-PC-like way allowing single key presses for cursor
functions, and defaults to Cursor pad mode. The keypad works as
shown in Figure 2.2 below.
( *
) /
9 Page Up -
7Start of line
8 T
4 <— 6 —> +
1Endoflie
D Page Down Enter
. 0
Backups
Auto Indenting
Cursor
If you click on the Cancel button any changes you make will be
ignored. If you click on the OK button the changes specified will
remain in force until you quit the editor. If you would like the
configuration made permanent then click on the Save button,
which will create the file GENST2. INF on your disk. Next time you
run GenST the configuration will be read from that file.
Assembly
To assemble the program you are currently editing click on
Assemble from the Program menu, or press Alt-A. The meaning of
the various options, together with the assembly process itself is
detailed in the next chapter. The only option covered here is the
Output to option.
Running Programs
If you click on Run from the Program menu or press Alt-X (eXecute)
you can then run a program previously assembled into memory.
When your program finishes it will return you to the editor. If the
assembly didn't complete normally for any reason then it is not
possible to run the program.
If your program crashes badly you may never return to the editor,
so if in doubt save your source code before using this, or the
following command.
Note
If only non-fatal errors occurred during assembly (e.g.
undefined symbols) you will still be permitted to run your
program, at your own risk.
When issuing a Run command from the editor the machine may
seem to 'hang up' and not run the program. This occurs if the
mouse is in the menu bar area of the screen and can be corrected
by moving the mouse. Similarly when a program has finished
running, the machine may not return to the editor. Again, moving
the mouse will cure the problem. This is due to a feature of GEM
beyond our control.
Debug
If you wish to debug a program previously assembled to memory
click on Debug from the Program menu, or press Alt-D. This will
invoke MonST to debug your program, included any debugging
information specified. Pressing Ctrl-C from MonST will terminate
both your program and the debugger. The screen type selected is
determined by the Run with GEM option, described below.
Note
If the Load MonST option is disabled this option is not
available and the menu item is disabled.
MonST
Note
If the Load MonST option is disabled this option is not
available and the menu item is disabled.
Normally when the commands Run, Debug or MonST are used the
screen is initialised to the normal GEM type, with a blank menu
bar and patterned desktop. However if running a TOS program this
can be changed to a blank screen with flashing cursor, by clicking
on Run with GEM, or by pressing Alt-K. A check-mark next to the
menu item means GEM mode, no check mark means TOS mode.
The current setting of this option is remembered if you Save
Preferences.
Note
Running a TOS program in GEM mode will look messy
but work, but running a GEM program in TOS mode can crash the
machine.
Jump to Error
Run Other...
This option lets you run other programs from within the editor,
then return to it when they finish. Its main use is to allow you to
run programs you have assembled to disk, or to run the linker,
without having to quit to the Desktop and double-click them. You
can run both TOS and GEM programs using this command,
subject to available memory. When you click on Run Other... from
the Program menu you will first be warned if you have not saved
your source code, then the GEM File Selector will appear, from
which you should select the program you wish to run. If it is a . TOS
or . TTP program you will be prompted for a command line, then
the screen initialised suitably.
The window used by the editor works like all other GEM windows,
so you can move it around by using the move bar on the top of it,
you can change its size by dragging on the size box, and make it full
size (and back again) by clicking on the full box. Clicking on the
close box is equivalent to choosing Quit from the File menu.
Desk Accessories
If your ST system has any desk accessories, you will find them in
the Desk menu. If they use their own window, as Control Panel
does, you will find that you can control which window is at the
front by clicking on the one you require. For example, if you have
selected the Control Panel it will appear in the middle of the screen,
on top of the editor window. You can then move it around and if you
wish it to lie 'behind' the editor window, you can do it by clicking on
the editor window, which brings it to the front, then re-sizing it so
you can see some part of the control panel's window behind it.
When you want to bring that to the front Just click on it and the
editor window will go behind. The editor's cursor only flashes and
the menus only work when the editor's window is at the front.
Having done this, you will return to the Desktop. To test the
installation, double-click on a file with the chosen extension which
must be on the same disk and in the same folder as GenST and the
Desktop will load GenST, which will in turn load in the file of your
choice ready for editing or assembly.
Note
To make the configuration permanent, you have to
use the Save Desktop option.
If you use the PATH feature of the Saved! by HiSoft desk accessory
then the restriction of having your data files in the same folder and
drive as your assembler described above is not relevant. The editor
looks for the GENST2 . INF configuration file firstly in the current
directory (which is the folder where you double-clicked on the data
file), then using the system path. Saving the editor preferences will
put the . INF file in the same place it was loaded from, or if it was
not found then it will be put in the current directory.
You may invoke Saved! from within the editor at any time by
pressing Sh i ft-dr. This will only work if the desk accessory is
called SAVED! . ACC or SAVED . ACC on your boot disk.
CHAPTER 3
Macro Assembler
Introduction
GenST is a powerful, fast, full specification assembler, available
instantly from within the editor or as a stand-alone program. It
converts the text typed or loaded into the editor, optionally
together with files read from disk, into a binary file suitable for
immediate execution or linking, or into a memory image for
immediate execution from the editor.
Symbols case This lets you select whether labels are case
dependent or not. If case Dependent is selected then Test and
test would be different labels, if case Independent is selected then
they would be the same.
Debug Info If you wish to debug your program using your original
symbols you can select Normal or Extended debug modes. The
advantage of extended debug is that up to 22 characters of each
symbol are included in the debug information, whereas normal
mode restricts symbols to eight characters.
List selecting Printer will divert the assembly listing to the current
printer port, or selecting Disk will send the listing to a file based on
the source filename, but with the extension . LST
The first two options may also be specified in the source file using
the OPT directive.
Stand-Alone Assembler
1f the . TTP version of the assembler is invoked the without a
command line the programmer will be asked for one, conforming
to the rules below, or press Return to abort. At the end of assembly
there will be a pause, pressing any key will exit the program. If a
command line has been supplied the assembler will not wait for a
key as it assumes it has been run from a CLI or batch file.
Command Line Format
test -b
assembles t est . s with no binary output file
test -om:test.prg -p
assembles test . s into a binary file m: test .prg and a listing file to
test.lst
test -12dpprn:
assembles test .s into DRI linkable code with debug and a listing to
the parallel port. (A listing to the serial port can be obtained by
specifying AUX: as the listing name).
Output Filename
Assembly Process
Assembly to Memory
clr.w -(a7)
trap#1
The first three are double-clickable, can be run from the Desktop
and are known as executable. They differ in the initialisation
performed before the execution. With . PRG files the screen is
cleared to the Desktop's pattern, while with the other two the
screen clears to white, the flashing cursor appears and the mouse
is disabled. When you double-click a . TTP file the Desktop will
prompt you for a command line to pass to it.
. ACC files are executable files but cannot be double-clicked on from
the Desktop. They will only run successfully when executed by the
AES during the boot sequence of the machine.
. BIN and .o files cannot be run immediately, but have to be read
into a linker, usually with other sections, and are known as
Iinkable object modules. There are two different linker formats on
the ST. . BIN files are GST format, . o files are DRI format. The
differences between these are discussed later in this chapter.
The above extensions are not absolute rules; for example, if you
have a TOS type program you may give it a . PRG extension and use
the Install Application function from the Desktop, but it's usually
much easier to use the normal extensions. One exception is for
programs which are designed to be placed in the AUTO folder so
they execute during the boot sequence. They have to be TOS type
programs, but need the extension . PRG for the boot sequence to
find them.
Note
Certain versions of the French ST ROMs do not
recognise .TTP files from the Desktop so they have to be renamed
. TOS then installed as TOS Takes Parameters.
Types of code
Unlike most 8-bit operating systems, but like most 16-bit
systems, an executable program under GEMDOS will not be loaded
at a particular address but, instead, be loaded at an address
depending on the exact free memory configuration at that time.
move.l #string,a0
Note
For certain programs, normally games or for cross-
machine development an absolute start address may be required.
for this reason the ORG directive is supported.
Exceptions to this are comment lines, which are lines starting with
an asterisk or semi-colon, and blank lines, which are ignored. Each
field has to be separated from the others by white space - any
number or mixture of space and tab characters.
Label field
The label should normally start at column 1, but if a label is
required to start at another position then it should be followed
immediately by a colon (:). Labels are allowed on all instructions,
but are prohibited on some assembler directives, and absolutely
required on others. A label may start with the characters A-Z, a-z,
or underline (_), and may continue with a similar set together with
the addition of the digits o-9 and the period (J.
Labels starting with a period are local labels, described later. Macro
names and register equate symbols may not have periods in them,
though macro names may start with a period. By default the first
127 characters of labels are significant, though this can be reduced
if required. Labels should not be the same as register names, or the
reserved words SR. CCR or USP.
Mnemonic Field
The mnemonic field comes after the label field and can consist of
68000 assembler instructions, assembler directives or macro calls.
Some instructions and directives allow a size specifier, separated
from the mnemonic by a period. Allowed sizes are . B for byte, .w for
word, . L for long and .S for short. Which size specifiers are allowed
in each particular case depends on the particular instruction or
directive. GenST is case-insensitive to mnemonic and directive
names, so Move is the same as move and the same as move, for
example.
Operand Field
For those instructions or directives which require operands, this
field contains one or more parameters. separated by commas.
GenST is case-insensitive regarding register names so they may
be in either or mixed case.
Comment Field
Any white space not within quotation marks found after the
expected operand(s) is treated as a delimiter before the start of the
comment, which will be ignored by the assembler.
Examples of valid lines
move.l d0, (a0)+ co mment is here
loop TST.W dO
lonely. label
rt s
* this is a complete line of co mm ent
; and so is this
indented: link A6,#-10 make room
a_string: dc.b 'spaces allowed in quotes' a string
Expressions
GenST allows complex expressions an d support s full operator
precedence, parenthesis and logical operators.
Operators
Numbers
Character Constants
"Q" Q $00000051
'hi' hi $00006869
"Test" test $54657374
"it's" it's $6974277C
'it " s' it's $6974277C
Strings used in DC. B statements follow slightly different
justification rules, detailed with the directive later.
The use of an asterisk (*) denotes the value of the program counter
at the start of the instruction or directive an d is always a relative
quantity.
The table in Figure 3.2 summarises for each operator the results of
the various type combinations of parameter and which
combinations are not allowed. An R denotes a Relative result, an A
denotes absolute and a * denotes that the combination is not
allowed an d will produce an error message if attempted.
AopA AopR R op A R op R
Shift operators A * * *
Bitwise operators A * * *
Multiply A • * *
Divide A * a a
Add A R R *
Subtract A * R A
Comparisons A * * A
move.l (a3,d2.l)0
will assemble to th e same as
move.l 0(a3,d2.l),d0
Special Addressing Modes
The data and address registers can also be denoted by use of the
reserved symbols RO through R15. RO to R7 are equivalent to DO to
D7, R8 to R15 are equivalent to AO to A7. This is included for
compatibility with other assemblers.
Local Labels
GenST supports local labels, that is labels which are local to a
particular area of the source code. These are denoted by starting
with a period and are attached to the last non-local label, for
example:
The local labels . w and . L are not allowed to avoid confusion with
the absolute addressing syntax.
move.l vector.w,d0
where vector is an absolute value, such as a system variable. This
would generate an undefined label error, as the label would be
scanned as vector .w. To get around this, the expression, in this
case a symbol, may be enclosed in brackets, e.g.
move.l (vector).w,d0
though the period may still be used after numeric expressions, e.g.
move.l $402.w,d0
Note
GenST version 1 also supported the use of \ instead of
a period to denote short word addressing and this is still
supported in this version, but this is not recommended due to the
potential for \w and \L to be mistaken for macro parameters.
Instruction Set
Word Alignment
All instructions with the exception of DC.B and DS.B are always
assembled on a word boundary. Should you require a DC. B
explicitly on a word boundary, the EVEN directive should be used
before it. Although all instructions that require it are word-aligned,
labels with nothing following them are not word-aligned and can
have odd values. This is best illustrated by an example:
The above code would not produce the required result as start
would have an odd value. To help in finding such instructions the
assembler will produce an error if it finds an odd destination in a
BSR or BRA operand. Note that such checks are not made on any
other instructions, so it is recommended that you precede such
labels with EVEN directives if you require them to be word-aligned. A
common error is deliberately not to do this, as you know the
preceding string is an even number of bytes long. All will be well
until the day you change the string...
Branch instructions
BTST Instruction
CLR Instruction
CLR An is not allowed, use SUB.L An,An instead (though note that
the flags are not effected).
CMP Instruction
DBcc Instruction
ILLEGAL Instruction
LINK Instruction
MOVES Instruction
Assembler Directives
Certain pseudo-mnemonics are recognised by GenST. These
assembler directives, as they are called, are not (normally) decoded
into opcodes, but instead direct th e assembler to take certain
actions at assembly time. These actions have the effect of changing
the object code produced or th e format of the listing. Directives are
scanned exactly like executable instructions and some may be
preceded by a label (for some it is obligatory) and may be followed
by a comment. If you put a label on a directive for which it not
relevant, th e result will be undefined but will usually result in the
label being ignored.
Each directive will now be described in turn. Please note that the
case of a directive name is not important, though they generally
are shown in upper case. The use of angled brackets (< >) in
descriptions denote optional items, ellipses (...) denote repeated
items.
Assembly Control
END
This directive signals that no more text is to be examined on the
current pass of the assembler. It is not obligatory.
INCLUDE filename
This directive will cause source code to be taken from a file on disk
and assembled exactly as though it were present in th e text. The
directive must be followed by a filename in normal GEMDOS
format.
If the filename has a space in it the name should be enclosed in
single or double quotes. A drive specifier, directory and extension
may be included as required, e.g.
include b:constants/header.s
Note
The more memory the better, GenST will read the
whole of the file in one go if it can and not bother to re-read the file
during pass 2.
INCBIN filename
This takes a given binary file and includes it, verbatim, into the
output file. Suggested uses include screen data, sprite data and
ASCII files.
Option O - Optimising
With this option enabled with P+ GenST will check that all code
generated is position-independent, generating errors on any lines
which require relocation. It can be disabled with P- and defaults to
off.
If you wish to disable the warnings that GenST can produce, you
can do so with w-. To re-enable them, use w+. This directive can be
used as often as required.
Option Summary
opt m+,s+,w-
will turn macro expansions on, enable the symbol table list and
turn warnings off.
<label> EVEN
This directive will force the program counter to be even, Le. word-
aligned. As GenST automatically word-aligns all instructions
(except DC.Bs and DS.Bs) it should not be required very often, but
can be useful for ensuring buffers and strings are word-aligned
when required.
CNOP offset,alignment
This directive will align the program counter using the given offset
and alignment. An alignment of 2 means word-aligned, an
alignment of 4 means long-word-aligned and so on. The alignment
is relative to the start of the current section. For example,
cnop l,4
dc.b l,2,3 ,9
ds.b 8
ds.w 4
ds.l 2
FAIL
This directive will produce the error user error. It can be used for
such things as warning the programmer if an incorrect number of
parameters have been passed to a macro.
OUTPUT filename
This directive sets the normal output filename though can be
overridden by specifying a filename at the start of assembly. If
filename starts with a period then it is used as an extension and
the output name is built up as described previously.
Repeat Loops
It is often useful to be able to repeat one or more instructions a
particular number of times and the repeat loop construct allows
this.
<label> REPT expression
ENDR
Lines to be repeated should be enclosed within REPT and ENDR
directives and will be repeated the number of times specified in the
expression. If the expression is zero or negative then no code will be
generated. It is not possible to nest repeat loops. For example
Note
Program labels should not be defined within repeat
loops to prevent label defined twice errors.
Listing Control
LIST
This will turn the assembly listing on during pass 2, to whatever
device was selected at the start of th e assembly (or to the screen if
None was initially chosen). All subsequent lines will be listed until
an END directive is reached, the end of the text is reached, or a
NOLIST directive is encountered.
NOLIST
This will turn off any listing during pass 2.
When a listing is requested onto a printer or to disk, the output is
formatted into pages, with a header at the top of every page. The
header itself consists a line containing the program title, date, time
and page number, then a line showing the program title, then a
line showing the sub-title, then a blank line. The date format will be
printed in the form DD/MM/YY, unless the assembler is running on
a US Atari ST, in which case the order is automatically changed to
MM/DD/YY. Between pages a form-feed character (ASCII FF, value
12) is issued.
PLEN expression
This will set the page length of the assembly listing and defaults to
60. The expression must be between 12 and 255.
LLEN expression
This will set the line width of the assembly listing and defaults to
132. The value of the expression must be between 38 and 255.
TTL string
This will set the title printed at the top of each page to the given
string, which may be enclosed in single quotes. The first TTL
directive will set the title of the first printed page. If no title is
specified the current include file name will be used.
SUBTIL string
Sets the sub-title printed at the top of each page to the given string,
which may be enclosed in single quotes. The first such directive will
set the sub-title of the first printed page.
SPC expression
This will output the number of blank lines given in the expression
in the assembly listing, if active.
PAGE
Causes a new page in the listing to be started.
LISTCHAR expression<,expression> ...
This will send the characters specified to the listing device (except
the screen) an d is intended for doing things such as setting
condensed mode on printers. For example, on Epsons and
compatibles the line
listchar 15
Label Directives
label = expression
Alternate form of EQU statement.
rsreset
d next rs.l 1
dflag rs.b 1
d_ where rs.l 1
move.l d_next(a0),l
move.l d__where(a0),a2
tst.b d_flag(a0)
onstate rs.b 1
start rs.l 1
end rs.l 1
move.b onstate(a6),d1
move.1 start(a6),d0
cmp.l end(a6),d0
Each such directive uses its own internal counter, which is reset to
0 at the beginning of each pass. Every time the assembler comes
across the directive it sets the label according to the current value
(with word alignment if it is .W or .L) then increments it according
to the size and magnitude of the directive. If the above definitions
were the first RS directives, onstate would be 0, start would be 2
and end would be 6.
RS R ES ET
This directive will reset the internal counter as used by the RS
directive.
RSSET expression
This allows the RS counter to be set to a particular value.
_ R S
_ (reserved symbol)
This is a reserved symbol having the current value of the RS
counter.
Conditional Assembly
FEQ expression
FNE expression
FGT expression
FGE expression
FLT expression
FLE expression
These directives will evaluate th e expression, compare it with zero
and then turn conditional assembly on or off depending on the
result. The conditions correspond exactly to the 68000 condition
codes. For example, if the label DeBUG had th e value 1, then with the
following code,
IFeQ DeBUG
logon dc.b 'enter a command:',0
eNDC
IFNe DeBUG
opt d+ labels please
logon dc.b 'Yeah, gimme man:',0
eNDC
th e first conditional would turn assembly off as 1 is not EQ to 0,
while the second conditional would turn it on as 1 is NE to 0.
Note
IFNE corresponds to IF in assemblers with only one
conditional directive.
ELSEIF
This directive toggles conditional assembly from on to off, or vice
versa.
ENDC
This directive will terminate the current level of conditional
assembly. If there are more IFs than ENDCs an error will be
reported at th e end of the assembly.
label MACRO
This starts a macro definition and causes GenST to copy all
following lines to a macro buffer until an ENDM directive is
encountered. Macro definitions may not be nested.
ENDM
This terminates the storing of a macro definition, after a MACRO
directive.
MEXIT
This stops prematurely the current macro exp an sion and is best
illustrated by the INC example given later.
Once a macro has been defined with the MACRO directive it can be
invoked by using its name as a directive, followed by up to 36
parameters. In the macro itself the parameters may be referred to
by using the backslash character (\) followed by an alpha-numeric
(l-9, A-Z or a-z) which will be replaced with the relevant parameter
when expanded or with nothing if no parameter was given. There is
also the special macro parameter \0 which is the size appended to
the macro call and defaults to w if none is given. If a macro
parameter is to include spaces or commas then the parameter
should be enclosed in between < and > symbols; in this case a >
symbol may be included within the parameter by specifying ».
A macro call may be spread over more than one line, particularly
useful for macros with large numbers of parameters. This can be
done by ending a macro call with a comma then starting the next
line with an & followed by tabs or spaces then the continuation of
the parameters.
In the assembly listing the default is to show just the macro call
and not the code produced by it. However, macro expansion
listings can be switched on and off using the OPT M directive
described previously.
call_gemdos MACRo
move.w #\l,-(a7) function
trap #l
lea \2(a7),a7 correct stack
eNDM
The directives are in capitals only to make them stand out: they
don't have to be. If you wanted to call this macro to use GEMDOS
function 2 (print a character) the code would be
move.w #'X',-(a7)
call_gemdos 2,4
move.w #2,-(a7)
trap #1
lea 4(a7),a7
•
Example 2 - an INC instruction
The 68000 does not have the INC instruction of other processors,
but the same effect can be achieved using an ADDQ #1 instruction.
A macro may be used to do this, like so:
inc MACRO
IFC ' ' ,'\l'
fail missing parameter!
MEXIT
ENDC
addq.\0 #l,\1
ENDM
An example call would be
inc.l a0
addq.l #1,a0
function factor(n:integer):integer;
begin
if n>0 then
factor:=n*factor(n-l)
else
factor:=l
end;
The macro definition for this uses the SET directive to do the
multiplication n*(n-1)*(n-2) etc. in this way:
rtseq MACRO
bne.s \@
its
\@
eNDM
showname MACRO
dc.b \l,'\<version>',0
eNDM
version equ 42
showname <'Real Ale Search Program v'>
table_entry macro
dc.b .end\@-* length byte
dc.b \l always
IFNC .\2',,,
dc.w \2,\3 2nd and 3rd together
eNDC
dc. l \4, \5, \6, \7
IFNC ,\8,,,,
dc.b '\8' text
ENDC
dc.b \9
.end\@ dc.b 0
eNDM
* sample call
table_entry $42,,,tl,t2,t3,t4,
& <enter name:>,%0110
This is a non-trivial example of how macros can make a
programmer's life so much easier when dealing with complex data
structures. In this case the table consists of a length byte,
calculated in the macro using \@, two optional words, four longs,
an optional string, a byte, then a zero byte. The code produced in
this example would be
dc.b .end_001
dc.b $42
dc.l t1,t2,t3,t4
dc.b 'Enter name:'
dc.b %0100
.end_001 dc.b 0