RISCOS.com

www.riscos.com Technical Support:
Acorn Assembler

 


Symbolic capabilities


The assembler also has a range of symbolic capabilities, with which you can set up symbols as constants or as variables. These are described below.

Setting constants

The EQU and * directives are used to give a symbolic name to a fixed or program-relative value. The syntax is:

label EQU expression
label
* expression

RN defines register names. Registers can only be referred to by name. The names R0-R15, r0-r15, PC, pc, LR, lr, SP and sp are predefined. Names may also be defined for the registers used by the ARM Procedure Call Standard; see Controlling syntax.

FN defines the names of floating point registers. The names F0-F7 and f0-f7 are built in. The syntax is:

label RN numeric-expression
label
FN numeric-expression

CP gives a name to a coprocessor number, which must be within the range 0 to 15. The names p0-p15 are pre-defined.

CN names a coprocessor register number; c0-c15 are pre-defined. The syntax is:

label CP numeric-expression
label
CN numeric-expression

Local and global variables - GBL, LCL and SET

While most symbols have fixed values determined during assembly, variables have values which may change as assembly proceeds. The assembler supports both global and local variables. The scope of global variables extends across the entire source file while that of local variables is restricted to a particular instantiation of a macro (see the chapter entitled Macros). Variables must be declared before use with one of these directives.

GBLA Declares a global arithmetic variable. Values of arithmetic variables are 32-bit unsigned integers.
GBLL Declares a global logical variable
GBLS Declares a global string variable
LCLA Declares and initialises a local arithmetic variable (initial state zero)
LCLL Declares and initialises a local logical variable (initial state false)
LCLS Declares and initialises a local string variable (initial state null string)

The syntax of these directives is:

directive variable-name

The value of a variable can be altered using the relevant one of the following three directives:

SETA Sets the value of an arithmetic variable
SETL Sets the value of a logical variable
SETS Sets the value of a string variable

The syntax of these directives is:

variable-name directive expression

where expression evaluates to the value being assigned to the variable named.

(You can also declare and set the value of global variables at assembly time; see Predefining a variable.)

Variable substitution - $

Once a variable has been declared its name cannot be used for any other purpose, and any attempt to do so will result in an error. However, if the $ character is prefixed to the name, the variable's value will be substituted before the assembler checks the line's syntax. Logical and arithmetic variables are replaced by the result of performing a :STR: operation on them (see Unary operators); string variables are replaced by their value.

Built-in variables

There are seven built-in variables. They are:

{PC} or .Current value of the program location counter.
{VAR} or @Current value of the storage-area location counter.
{TRUE}Logical constant true.
{FALSE}Logical constant false.
{OPT}Value of the currently set listing option. The OPT directive can be used to save the current listing option, force a change in it or restore its original value.
{CONFIG}Has the value 32 if the assembler is in 32-bit program counter mode, and the value 26 if it is in 26-bit mode.
{ENDIAN}Has the value "big" if the assembler is in big-endian mode, and the value "little" if it is in little-endian mode.

This edition Copyright © 3QD Developments Ltd 2015
Last Edit: Tue,03 Nov 2015