The Development Library 6-11
A link label is identified by a ‘
„’ as the first character.
Note 1: In projects, using less global labels is better because a global label takes longer to compile and because it
gives a better program structure. A good habit is to use global labels to cut the program in subroutines, and to use
local labels inside these subroutines.
Note 2: The command line editor is able to find labels in a source. See the
>L:L selection in the command line
:LLE menu.
Note 3: labels in System RPL should only be used by people who know what they are doing. They are only used for
fixed address program (absolute mode) which is pretty advanced programming.
Note 4: Labels can not be given the same name as constants.
4.1.8 “extable”
“extable” is an external library that contains a list of constants. This list can be used by MASD as a basic list of
constants and is especially useful to the System RPL programmer as most entry points are defined there (like
TURNMENUOFF for example). In addition, it also contains a set of supported constants and ASM entry points for
the ASM programmer. Please read the extable section in this document to find more information about this library.
4.1.9 Constants
Constants are a way for the user to associate a value to an alphanumerical name. This is extremely useful as it makes
programs much easier to read and makes them more portable. One of the most popular ways to use constants is to
represent memory address for storage of variables.
For example, instead of typing
!43[R8388 every time it is needed, it is better to declare 4O!K)Znup!R8388 at
the beginning of the project and then to type
43[-Q/K)Znup when needed (it is more portable, more readable
and less likely to cause errors).
You can create a constant in ASM or ARM mode by doing:
4O!OZp=$o)!<?qj)ZZtkG;)? or
4<76=<!OZp=$o)!<?qj)ZZtkG;)? or
<U5!OZp=$o)!<?qj)ZZtkG;)?!
In RPL mode, the only valid way to define a constant is:
<U5!OZp=$o)!<?qj)ZZtkG;)?!
<?qj)ZZtkG;)? is either a hexadecimal number or an expression (starting with a char that can not be confused
with the start of a hex number (
8..X,B..7). An expression starting with a hexadecimal number can be typed with a
leading
…, an expression starting with a decimal number can be typed with a leading g character. For an expression
starting with a constant that starts with a
8..X or!B..7 character, you should put the constant in brackets.
Note 1: A constant cannot be given the same name as a label.
Note 2: The name of a constant follows the same rules as the name of a label.
Note 3: A constant value is stored in 16 nibbles.
Note 4: Having constants starting with something that can be interpreted as a hex number, or an ARM register is not
a good idea as the compiler might get confused. For example:
4O!D27LL!a!MLN!Ka!D27LL will generate an
error on
7LL as the compiler will interpret the mov as a mov from SP to R4.
MASD introduces a ‘constant pointer’ called CP which helps to define constants. CP is defined by:
O2[<?qj)ZZtkG;)?!
CP is defined on 5 nibbles, its default value is 80100 (an area of memory that can be used freely by programmers).
<U5O2!6G&j)o)Gp!OkGZp$Gp=$o)!
Declares a constant with the current CP value and then increase CP by Increment.
Note 1: in ASM and ARM mode,
4OO2!6G&j)o)Gp!OkGZp$Gp=$o) is also valid
Note 2: Increment is a hexadecimal value, to use a decimal value, put a leading
!g.
For example, if CP equals to $10
<U5O2!Q!7kk!
Defines a Foo constant with a value of $10 and then change the value of CP to $15.
Several constants can be defined at once using CP.