home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
new
/
dev
/
c
/
hce
/
docs
/
a68k.doc
next >
Wrap
Text File
|
1992-09-02
|
29KB
|
691 lines
A68k - a freely distributable assembler for the Amiga
by Charlie Gibbs
with special thanks to
Brian R. Anderson and Jeff Lydiatt
(Version 2.61 - January 11, 1990)
Note: This program is Freely Distributable, as opposed to Public
Domain. Permission is given to freely distribute this program provided no
fee is charged, and this documentation file is included with the program.
This assembler is based on Brian R. Anderson's 68000 cross-
assembler published in Dr. Dobb's Journal, April through June 1986.
I have converted it to produce AmigaDOS-format object modules, and
have made many enhancements, such as macros and INCLUDE files.
My first step was to convert the original Modula-2 code into C.
I did this for two reasons. First, I had access to a C compiler, but
not a Modula-2 compiler. Second, I like C better anyway.
The executable code generator code (GetObjectCode and MergeModes)
is essentially the same as in the original article, aside from its
translation into C. I have almost completely rewritten the remainder
of the code, however, in order to remove restrictions, add enhancements,
and adapt it to the AmigaDOS environment. Since the only reference book
available to me was the AmigaDOS Developer's Manual (Bantam, February
1986), this document describes the assembler in terms of that book.
RESTRICTIONS
Let's get these out of the way first:
o The verification file (-v) option is not supported. Diagnostic
messages always appear on the console. They also appear in the
listing file, however (see extensions below). You can produce
an error file by redirecting console output to a file - the
line number counter and final summary are displayed on stderr
so you can still see what's happening.
o The file names in the INCLUDE directory list (-i) must be
separated by commas. The list may not be enclosed in quotes.
o Labels assigned by EQUR and REG directives are case-sensitive.
o Strange things will happen if your source code (including
INCLUDE files and macro expansions) exceeds 32,766 lines.
Tough darts. Break up your source file. Can you actually
read that monster? :-)
o The following directives are not supported, and will be flagged
as invalid op-codes:
OFFSET
NOPAGE
LLEN
PLEN
NOOBJ
FAIL
FORMAT
NOFORMAT
MASK2
I feel that NOPAGE, LLEN, and PLEN should not be defined within
a source module. It doesn't make sense to me to have to change
your program just because you want to print your listings on
different paper. The command-line switch "-p" (see below) can
be used as a replacement for PLEN; setting it to a high value
(like 32767) is a good substitute for NOPAGE. The effect of
LLEN can be obtained by running the listing file through an
appropriate filter.
EXTENSIONS
Now for the good stuff:
o Labels can be any length that will fit onto one source line
(currently 127 characters maximum). Since labels are stored
on the heap, the number of labels that can be processed is
limited only by available memory.
o The first character of a label can be '@' if the next character
is not numeric (this avoids confusion with octal constants).
This provides compatibility with the Lattice C compiler.
o Since section data and user macro definitions are stored in
the symbol table (see above), they too are limited only by
available memory. (Actually, there is a hard-coded limit of
32,767 sections, but I doubt anyone will run into that one.)
o The only values a label cannot take are the register names -
A68k can distinguish between the same name used as a label,
instruction name or directive, macro name, or section name.
o Section and user macro names appear in the symbol table dump,
and will also be cross-referenced. Their names can be the same
as any label (see above); they will be listed separately.
o INCLUDEs and macro calls can be nested indefinitely, limited
only by available memory. The message "Secondary heap
overflow - assembly terminated" will be displayed if memory
is exhausted. You can increase the size of this heap using
the -w switch (see below). Recursive macros are supported;
recursive INCLUDEs will, of course, result in a loop that
will be broken only when the heap overflows.
o The EVEN directive forces alignment on a word (2-byte)
boundary. It does the same thing as CNOP 0,2.
(This one is left over from the original code.)
o Backward references to labels within the current CODE section
will be converted to PC-relative addressing with displacement
if this mode is legal for the instruction. This feature is
disabled by the -n switch.
o If a MOVEM instruction only specifies one register, it is
converted to the corresponding MOVE instruction. Instructions
such as MOVEM D0-D0,label will not be converted, however.
This feature is disabled by the -n switch.
o ADD, SUB, and MOVE instructions will be converted to ADDQ,
SUBQ, and MOVEQ respectively if possible. Instructions coded
explicitly (e.g. ADDA or ADDI) will not be converted. This
feature is disabled by the -n switch.
o ADD, CMP, SUB, and MOVE to an address register are converted to
ADDA, CMPA, SUBA, and MOVEA respectively, unless (for ADD, SUB,
or MOVE) they have already been converted to quick form.
o ADD, AND, CMP, EOR, OR, and SUB of an immediate value are
converted to ADDI, ANDI, CMPI, EORI, ORI, and SUBI respectively
(unless the address register or quick conversion above has
already been done).
o If both operands of a CMP instruction are postincrement mode,
the instruction is converted to CMPM.
o Operands of the form 0(An) will be treated as (An) except for
the MOVEP instruction, which always requires a displacement.
This feature is disabled by the -n switch.
o The SECTION directive allows a third parameter. This can be
specified as either CHIP or FAST (upper or lower case). If
this parameter is present, the hunk will be written with the
MEMF_CHIP or MEMF_FAST bit set. This allows you to produce
"pre-ATOMized" object modules.
o The synonyms DATA and BSS are accepted for SECTION directives
starting data or BSS hunks. The CHIP and FAST options (see
above) can also be used, e.g. BSS name,CHIP.
o The following synonyms have been implemented for compatibility
with the Aztec assembler:
CSEG is treated the same as CODE or SECTION name,CODE
DSEG is treated the same as DATA or SECTION name,DATA
PUBLIC is treated as either XDEF or XREF, depending on
whether or not the symbol in question has been
defined in the current source module.
A single PUBLIC directive can name a mixture
internally- and externally-defined symbols.
o The ability to produce Motorola S-records is retained from the
original code. The -s switch causes the assembler to produce
S-format instead of AmigaDOS format. Relocatable code cannot
be produced in this format.
o Error messages consist of three parts.
The position of the offending line is given as a line
number within the current module. If the line is within a
macro expansion or INCLUDE file, the position of the macro
call or INCLUDE statement in the outer module is given as
well. This process is repeated until the outermost source
module is reached.
Next, the offending source line itself is listed.
Finally, the errors for that line are displayed. A flag
(^) is placed under the column where the error was detected.
o Named local labels are supported. These work the same as the
local labels supported by the Metacomco assembler (nnn$) but
are formed in the same manner as normal labels, except that
they must be preceded by a backslash (\).
o The following synonyms have been implemented for compatibility
with the Assempro assembler:
ENDIF is treated the same as ENDC
= is treated the same as EQU
| is treated the same as ! (logical OR)
o Quotation marks (") can be used as string delimiters
as well as apostrophes ('). Any given string must begin
and end with the