home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
asm2
/
ASMTxt
< prev
next >
Wrap
Text File
|
1996-12-27
|
32KB
|
812 lines
INTRODUCTION
~~~~~~~~~~~~
ASM is a (mostly) full function assembler for the Archimedes and A3000 machines,
producing an AOF (Acorn Object Format) file suitable for use with the linker.
To install ASM, simply move the file "ASM" into your Library directory.
To assemble a file, use the command:
ASM [options] <sourcefile>
where <sourcefile> is the name of the file to be assembled. If no directory is specified,
ASM will look for the source file in sub-directory A. For compatibility with C, the filename
"SOURCE.A" is taken to refer to "A.SOURCE". The output will have the same leaf name as the
sourcefile, and be stored in sub-directory O.
Options are used to modify the standard behaviour of the assembler, and are introduced by
a hyphen, the option name, and any allowed parameters. So long as enough letters of the option
name are given to preclude ambiguity, any number of letters may be given; all options are case-
insensitive. In the list of options below, the upper case part of the name indicates the minimum
that can be specified to preclude ambiguity.
Option Effect
-Output <filename> The assembled code is written to <filename> rather than the
default. If no directory is given, subdirectory O is assumed.
-List [<filename>] An assembler listing is produced. If no filename is given, the
file is given the same name as the sourcefile. By default, the
file is produced in subdirectory L.
-Hex Include the generated hex code in the -List file. If -List is
not explicitly specified, this option implies it.
-Include <pathlist> Specifies a search path for use in the 'INCLUDE' directive (qv).
<pathlist> is a comma-separated list of directories (or RISCOS
symbols) to be searched for the file.
This is a slight deviation from the method use by the C compiler,
which allows the -I option (which serves the same purpose) to be
specified several times, each of which extended the search list.
ASM only allows a single use of -Include, where all the paths are
specified at once.
-VErbose Output informational messages describing the current phase of assembly.
-VAlidate The List file produced contains a disassembly of the generated code
rather than the source code. It is not anticipated that users will
make much use of this. As for -Hex, -VAlidate implies -List.
-Flags <flaglist> Defines a number of flags to be set before beginning the assembly, for
use in the IFDEF/IFNDEF directives. <flaglist> is a comma-separated
list of flag names. Note that these flags are NOT assembler symbols,
and cannot be used as such - they are only recognized by IFDEF and
IFNDEF.
-Nocase Forces ASM to use case-insensitive name matching for user-defined
symbols.
-Throwback Enables the Acorn desktop throwback error-reporting mechanism.
-Processor <CPU> Specifies the target processor. This constrains which of the extended
instruction set operations are available. Legal values for <CPU> are:
ARM2, ARM3, ARM6 and ARM7.
(StrongARM will be coming when I discover what additional opcodes, if
any, are available).
-Help Produce brief help text for the ASM syntax and options.
Examples
ASM tharg
will assemble the code in A.tharg and produce an object file O.tharg
ASM -hex -flags debug,check -include <C$UserLibRoot>,<ASM$MylibRoot> eric
will assemble the file A.eric and produce an object file O.eric; a listing file called
L.eric will be produced containing the hex code generated. Any 'INCLUDE' statements will
look in directories <C$UserLibRoot> and <ASM$MylibRoot> for the include files. Finally,
the conditional assembly flags debug and check will be treated as set.
SOURCE FORMAT
~~~~~~~~~~~~~
It is assumed that the user is fully familiar with ARM assembly language (what are you
doing with ASM if you aren't?) and therefore this note contains no tutorial-type introduction;
only the differences between the ASM format and that in use in the BASIC assembler are detailed.
It is recommended that users of ASM be familiar with the "RISCOS Programmer's Reference
Manual" (especially those sections on the linker and Acorn Procedure Calling Standard) and Peter
Cockerell's "ARM Assembly Language Programming".
Throughout, mnemonics and their options follow the de facto standard, that in Cockerell's
book. For certain FP coprocessor instructions this differs slightly from that used by the
disassembler (SWI "Debugger_Disassemble"), which seems to contain a bug anyway.
The general format of a line is:
[<label-part>] [<mnemonic-part>] [<comment-part>]
Any or all of these parts are optional. Unlike the BASIC assembler, there is no facility
to put multiple mnemonics on a single line by separating them with a colon.
<label-part> A label is any legal ASM Symbol (see below), terminated by a colon.
<mnemonic-part> This part is any ARM instruction mnemonic (eg ADDS, STMFD), generic coprocessor
mnemonic (eg MCR, CDPEQ), or any Floating Point coprocessor mnemonic (eg MUFD,
FIXS), plus any associated parameters.
Alternatively, this could be the ADR pseudo-operation, or any ASM directive
(eg IFDEF, MACRO).
<comment-part> A comment is introduced by a semi-colon. Any text following a semi-colon on a
line is ignored.
In addition to the above format, ASM will also accept constant definitions of the form:
<label> = <constant-expression>
and <label> = <register-expression>
where <label> is a legal ASM identifier (without the colon this time), <constant-expression>
evaluates to an integer, and <register-expression> is one of the built-in register symbols
(see “Symbols in ASM” below).
The following code fragment demonstrates both possible formats (it actually performs a 64-bit
integer addition):
result = 0
lhs = result + 1
rhs = lhs + 2
EXPORT Long_Add ; Make the function external
Long_Add: STMFD sp!,{lhs ,lhs+1,link}
ADDS lhs,lhs,rhs
ADCS lhs+1,lhs+1,rhs+1
BVS overflow
STMIA result,{lhs ,lhs+1}
LDMFD sp!,{lhs ,lhs+1,pc}^
overflow: ADR R0,oflerr
SWI "OS_GenerateError"
oflerr: DCD &901
DCS "Arithmetic overflow"
DCB 0
ALIGN
etc
Symbols in ASM
~~~~~~~~~~~~~~
Symbols (Identifier names) in ASM may contain the following characters: A-Z, a-z, 0-9,
underscore (_) and dollar ($). These may be in any order, with the exception that an identifier
cannot begin with a digit.
There are several classes of identifiers in ASM :
Constants Constants are defined by the use of the <constant> = <expression> format. The
expression must evaluate to an integer, and may contain other constants. For
example, the symbol "result" in the example above is a constant.
Local Symbols A local symbol is a label. The symbols "overflow" and "oflerr" in the example
above are local symbols. Local symbols may be either "Close" or "Far": see below.
Global Symbols A global symbol is similar to a local symbol, but one that has been made
externally visible at the link stage by the use of the EXPORT directive. Global
Symbols may be "Close" or "Far".
Externals An external sy