qas takes one or more assembler source files and assembles them, producing QObject version 2 files.
qas is called with a set of options, plus a list of source files, which by convention are stored in a subdirectory named 's'. If there are no arguments, qas prints a message summarizing its options on the standard error.
If more than one source file is specified, qas places the resulting QObject files in a directory 'Q', with names of the files the same as the source filenames.
If only one source file is specified, the default naming scheme is used, however the output filename may be overriden using the -o name option.
Options for qas are as follows:-
-limit n Set the error limit to n.
-o filename Name the output file if only one source file is specified.
-throwback Use throwback to report errors instead of stderr.
-v Verbose.
-w Suppress all warnings.
-p Pedantic - allow extra informationals and warnings.
The `parent object file' name is set to be the filename as given on the command line, without modification.
ASSEMBLER SOURCE FORMAT
Comments begin with a ';' and run to the end of the line.
Labels are placed at the beginning of the line; local labels begin with '.'. Labels may end with : and may be quoted with '|'.
eg
label
|label|
label:
|label|:
.label
|.label|
.label:
|.label|:
Mnemonics are indented by at least one whitespace character; standard ARM, CP and FP mnemonics apply; use either upper- or lowercase. See later for accepted mnemonics.
Note that where a register is required, a register must be used, rather than simply a number; define registers using RN:, FN: or CN: (see below).
If an instruction cannot be assembled due to a large constant, qas will try to expand it into several instructions. Use the TEMP: switch (see below) to control expansion of some instructions; other instructions can be expanded without a temporary register.
Expressions are as per C; thus hex numbers are prefixed by `0x' not `&', since & is the bitwise AND operator. Strings are enclosed within double quotes; escape characters may be used such as \n, although \xnn and \0nn are not supported (although \0 is). Character constants may be used in place of integers, use single quotes.
Floating point constants are 0.0, 0.5, 1.0, 2.0, 3.0, 4.0, 5.0, 10.0. Values 0, 1, 2 etc are not acceptable.
Switches are also indented, and are terminated with a ':'. Switches take zero or more parameters.
Available switches are:-
CREATOR: "string"
PLATFORM: "string"
GET: "file"
SEGMENT: CODE|BSS|DATA|LIT
EXPORT: symbolname
WITHIN: symbolname
RN: string integer(0..15)
FN: string integer(0..7)
CN: string integer(0..15)
SET: string value
LINE: integer
BLOCK: integer
MSG: "string"
TEMP: register|STACK|NONE
ERROR: "string"
Notes:
1) Symbols have their segment set as the last SEGMENT: switch. SEGMENT: will end a symbol.
2) EXPORT: makes a symbol visible to all files rather than static.
3) LINE: will rarely be used by programmers; it is intended to allow use of a macro pre-processor.
4) CREATOR: and PLATFORM: set strings within the object file produced; see a description of the QObject file format.
5) GET: includes a file in a similar way to #include "file" by cpp.
6) The segments defined by SEGMENT: are:-
CODE executable code; read only
BSS uninitialized variables; read/write
DATA initialized variables; read/write
LIT constants ; read only
see a description of the QObject file format for more details.
7) WITHIN: defines a symbol within a symbol; in other words it exports a local label. For example:-
SEGMENT: CODE
EXPORT: exportSymbol
EXPORT: exportSymbol2
aSymbol
<some mnemonics>
WITHIN: exportSymbol
<some mnemonics>
WITHIN: exportSymbol2
<some mnemonics>
This code produces three symbols within the object file; aSymbol which is STATIC and thus cannot be accessed outside the file, and two GLOBAL symbols exportSymbol and exportSymbol2, which can be accessed outside the file. Linking to either or both of these symbols automatically links aSymbol.
An example of the use of this facility is implementing the SharedCLibrary; when a CLib function such as printf is used, it must also link the whole jump table.
8) RN:, FN: and CN: define registers, fp registers and co-processor registers.
9) SET: defines a value which can be used in expressions.
10) MSG: displays the string as an informational. ERROR: displays the string as an error.
11) BLOCK: defines an zero-initialized block of particular size. It ends a symbol, and must not be used in conjunction with code. It is usually used in the BSS or DATA segment. (Occasionally LIT). BSS BLOCK: symbols are initialised by __aif.
12) TEMP: describes how certain instructions may be synthesized. If the argument is a register, this register will be used; note that its value cannot be relied upon to be kept constant (r14 often is suitable). If STACK is used, qas places a register on the stack to use as a temp register. NONE (default) means no temp register is available.
LIST OF ACCEPTED MNEMONICS
Mnemonic syntax as standard; see any ARM programming text. Additional notes given:-
= Same as DCB
& Same as DCD
% Same as DBB
ABS
ACS
ADC
ADD
ADF
ADR Always expands to 12-bytes (3 words)
ALIGN Aligns to word boundary and pads with zeros. Not necessary at end of symbols
AND
ASN
ATN
B
BIC
BIN Syntax: BIN "file" include binary file
BL
CDP
CMF
CMN Requires temp
CMP Requires temp
CNF
COS
DBB Declare block of bytes; syntax DBB <number>, [pattern]. Pattern is 0 if omitted
DBD Declare block of words; syntax DBD <number>, [pattern]
DBW Declare block of halfwords; syntax DBW <number>, [pattern]
DCB Declare byte; can also declare strings
DCD Declare constants or symbolname+offset or symbolname-offset
DCFD Declare double prec. fp constant
DCFE Declare extended prec. fp constant; but constant is only double prec.
DCFP Declare packed BCD fp constant
DCFS Declare single prec. fp constant
DCW Declare half-word
DFL Declare symbol length
DFN Same as DCD
DVF
DWD Declare weak word; if symbol cannot be found, insert 0
DWF Same as DWD
DWL Declare weak symbol length
EOR
EQUB Same as DCB
EQUD Same as DCD
EQUS Same as DCB
EQUW Same as DCW
ERROR Exception
EXP
F0D \
F0E | unusual fp instructions; no known function
F0F /
FDV
FIX
FLT
FML
FRD
FT6 \
FT7 |
FT8 |
FT9 |
FTA | unusual fp instructions; no known function
FTB |
FTC |
FTD |
FTE |
FTF /
LDC
LDF
LDM
LDR
LGN
LOG
MCR
MLA
MNF
MOV
MRC
MUF
MUL
MVF
MVN
NRM
ORR
POL
POW
RDF
RFC
RFS
RMF
RND
RPW
RSF
SBC
SET Syntax: SET Rd Rn,#value. Same as ADD or SUB, but doesn't warn when converting
SIN
SQT
STC
STF
STM
STR
SUF
SWI
SWP
TAN
TEQ
TST
URD
WFC
WPS
XOR Same as EOR
EXAMPLE SOURCE FILE
------------------------------------------
; Print "Hello, world" using UnixLibQ (or other)
GET: "Q:Registers.s"
TEMP: lr
SEGMENT: CODE
EXPORT: main
main mov ip, sp
stmfd sp!, {v6, fp, ip, lr, pc}
sub fp, ip, #4
cmp sp, sl
bllt x$stack_overflow
adr a1, .message
bl printf
mov a1, #0
ldmea fp, {v6, fp, sp, pc}^
.message
dcb "Hello, world\n"
------------------------------------------
LIMITATIONS
No macro facilities are available in this version.
Input/output must be from files; cannot be from stdin/stdout.