Macro Assembler Syntax

Character Set

The Macro Assembler recognizes the standard ASCII character set, consisting of upper and lowercase letters (A-Z, a-z), digits (0-9), and a group of special characters listed in the table below. The Macro Assembler also recognizes the ASCII control characters signifying carriage return, new line, form feed, vertical tab, and horizontal tab.
Character Name Character Name
'
single quote
"
double quote
(
left parenthesis
)
right parenthesis

blank
%
percent
-
minus sign
+
plus sign
:
colon
!
exclamation mark
,
comma
\
backslash
.
decimal point
*
asterisk
&
ampersand
_
underscore
~
tilde
|
vertical bar
=
equals sign
^
carat
<
less than
>
greater than
/
slash
$
dollar sign
@
at sign
#
number sign
;
semicolon


Identifiers

Identifiers, or symbols, are composed of letters, digits, and the special characters: decimal point or underscore.The first character of an identifier must be alphabetic or one of these two special characters. Upper and lowercase letters are distinct; the identifier abc is not the same as the identifier ABC. Characters in reserved symbols, such as directives, machine instructions, and registers, are also case sensitive.

Examples:

The following table shows some valid and invalid identifiers:
Identifier Validity
*star
Invalid (may not start with *)
123test
Invalid (may not start with digit)
f-ptr
Invalid (hyphen not allowed)
_hello
Valid
LABEL
Valid
test4
Valid

Reserved Symbols

The following identifiers are part of the fundamental assembly language. These symbols and their meanings are shown in the table below. Identifiers in both upper and lower cases are reserved.
Identifier Meaning
r0 - r15
integer registers
cr0 - cr31
control registers
psr
status register
gbr
global base register
sp
stack pointer (r15)
vbr
vector base register
epsr, fpsr, epc, fpc
exception shadow registers
sso0-ss4
supervisor storage registers
gcr
global control register
gsr
global status register
pc
program counter

Constants

Macro Assembler constants may be numeric, character, or string constants.

Numeric Constants

A sequence of digits defines a numeric constant. By default, constants are in decimal or floating point format, although this can be changed by a directive in a source file. However, constants can be specified in hexadecimal, octal, binary by preceding the number with one of the special prefixes on the following page:
Type Prefix Example
hexadecimal
0x
0xb0b
octal
0
0747
binary
0b
0b110011

All integer constants are assigned 32-bit two's complement values.

String Constants

Some directives take a string constant as one or more of their arguments. A string constant consists of a sequence of characters enclosed in double quotes ("). A string constant can contain any ASCII character including ASCII null, except newline. The null character is not appended to strings by the Macro Assembler, as it is in C or C++.

Character Constants

A character constant can be used in any location where an integer constant is needed. A character constant consists of the following items in this order: either a single ASCII character or a single quote character (`), a backslash character (\), one of the value escape characters, and a single quote character (`). A character constant is considered equivalent to the ASCII value of the character or escape sequence. For example, the character constant a is equivalent to the decimal integer 97, and the character constant \r is equivalent to the decimal integer 13 (see table on the following page).

Character Escape Sequences

Character and string constants consists of ASCII characters. The ASCII backslash (\) is used within character and string constants to escape the quotation marks and to specify certain control characters symbolically. A backslash followed by any non-escape character is equivalent to that character (e.g. \a is equivalent to a since \a is not an escape sequence).
Escape Character ASCII Value
\0
null
0 (0x0)
\b
backspace
8 (0x8)
\t
horizontal tab
9 (0x9)
\n
newline
10 (0xA)
\v
vertical tab
11 (0xB)
\f
formfeed
12 (0xC)
\r
return
13 (0xD)
\nnn
octal value nnn

\'
single quote
39 (0x27)
\"
double quote
34 (0x22)
\\
backslash in a constant or string
92 (0x5c)

Source Statements

A Macro Assembler source statement consists of a series of fields, delimited by spaces and/or horizontal tab. The general format of a statement is:

[label:] operator arguments[comments]

Label Field

The label field is optional. When specified, it starts in column one and is terminated by the first white space character or line terminator detected. The last character of the label field must be a colon. More than one label may be associated with a given statement line, but a line may consist of no more than one label field.

The label is used to associate a memory location or constant value with the symbolic label name. Labels may have the same names as instructions and directives.

Operator Field

The operator field starts with the first non-white space character after the optional label field and is terminated by the first white space character or line terminator encountered after the operator. An operator is any symbolic opcode, directive, or macro call.

Argument Field

The argument field starts with the first non-white space character following the operator field, and ends with a line terminator or the beginning of a comment field. Arguments are entered to the opcode or directive or are macro call specified.

Comment Field

The comment field is optional and begins with a double slash (//) or a pound sign (#). Ignore all characters to the right of the comment character until the end of the line.

Continuation Lines

The Macro Assembler does not support continuation lines.

White Space

White space consists of spaces, form feeds, and horizontal tabs.

Line Terminators

Assembly input lines are terminated by a semicolon, line feed, form feed, or a carriage return.


Previous

Next



Copyright © 1999, Green Hills Software. All rights reserved.