It's possible to create an unlimited number of aliases with the EQU keyword. These aliases cannot be modified once they are defined, unlike variables. Classic assemblers tend to mix the notions of labels, variables and alias. RASM wont change the value of an alias during assembly, even using compressed sections.

my_alias EQU #4000
ld hl,my_alias

Dynamic variables

It's possible to create an unlimited number of variables with the = operator. These variables must be initialized before use (we are not coding Basic!). It's possible to declare them at the same time as a REPEAT loop (see the REPEAT directive). The variables are in double floating point format internally. As for all RASM expressions, a correct rounding is done at the end of calculations, when you want to convert it to an 8-bit or 16-bit value.

Example of a typical sine table creation:

repeat 256
defb 127*sin(ang)

Literal values

RASM interprets numeric values in the following formats:
- In decimal if the value starts with a digit and contains only digits
- In binary if the value starts with %, 0b or ends with b
- In octal if the value starts with @
- In hexadecimal if the value starts with #, $, 0x or ends with h
- In ASCII value if a single char is between quotes (value possibly translated by an active CHARSET directive)
- In value associated with an alias, a variable or a label, if the literal starts with a letter, a dot or an @ for proximity/local labels
- The $ symbol used alone indicates the start address of the current instruction*.

*When defining DEFB, DEFW, DEFI, DEFR or DEFS, the current address is the address of the current element. All these directives will produce the same data whether they are used with several arguments or several directives in a row, unlike several assemblers such as Pasm, AS80 and UZ80 to name a few.

DAMS users: Beware, the & symbol is reserved for the AND operation. If you need to keep this notation, think about the command line option -amper

Allowed characters

Between quotes, all characters are allowed (with the command line option -fq), at your own risk concerning the ASCII conversion to the Amstrad. Apart from quotes, you can use all letters, all numbers, the dos, the arobas, the parentheses, the dollar, the common operators, the hash, paragraphs and chevrons, both types of quotes as well as the escaped characters \t \n \r \f \v \b \0.

By using -utf8 option on the command line, the following characters will be replaced by their respective values in the Amstrad Basic french or spanish ASCII tables

à = 64 or @
ç = 92 or
é = 123 or {
ù = 124 or |
è = 125 or }
Ñ = 161
ñ = 171
¿ = 174
¡ = 175

Computational operators

RASM uses a multiple priority expression engine (like C), it supports the classical operations of multiplication, addition, subtraction, division, as well as the following operators

^ or XOR for exclusive OR
% or MOD for modulo
& or AND for logical operator AND
&& for boolean operator AND
| ou OR for logical operator OR
|| for boolean operator OR
<< shift left
>> shift right
hi(n) high byte of 16 bit value
lo(n) low byte 16 bit value
sin(n) returns the sine of an angle in degrees
cos(n) returns the cosine of an angle in degrees
asin(n) arc-sine
acos(n) arc-cosine
atan(n) arc-tan
int(n) convert to integer
frac(n) returns fractionnal part of a floating point value
floor(n) round floating point value to lower integer
ceil(n) round floating point value to higher integer
abs(n) absolute value
rnd(n) random value between 0 and n-1
ln(n) log
log10(n) log10
exp(n) exponential
pow2 compute 2 power N
sqrt(n) sqare root
== equality (= in MAXAM mode)
!= ou <> different from
<= lower or equal
>= higher or equal
< lower
> higher
getnop('assembly code') returns execution time in NOP of the assembly code in parameter (Amstrad)
gettick('assembly code') returns execution time in Ticks of the assembly code in parameter (Spectrum)
duration('assembly code') returns execution time in NOP or Tick according to RASM current machine mode
get_r(n) get red component of an Amstrad Plus ink
get_v(n) get green component of an Amstrad Plus ink
get_b(n) get blue component of an Amstrad Plus ink
set_r(n) convert red level (0 à 15) to his Amstrad Plus ink position
set_v(n) convert green level (0 à 15) to his Amstrad Plus ink position
set_b(n) convert blue level (0 à 15) to his Amstrad Plus ink position
; SET_<component> functions can be paired with an OR to combine the three components into one Amstrad Plus color
soft2hard_ink(n) convert Basic ink color to hardware Gate Array color
hard2soft_ink(n) convert hardware Gate Array color to Basic ink color
filesize('filename') returns the size of filename
getsize('assembly code') returns the size in byte of one or more instructions
is_register('string') returns 0 or 1 nvoie 0 ou 1 depending on whether the given string is a Z80 register

RASM does all its internal calculations in double precision floating point numbers. Correct rounding is performed at the end of the calculation chain for integer requirements. If the evaluation of an expression results in a calculation error, the result of the evaluation will be forced to zero.

Operator priorities

Operator RASM Prevalence Maxam Prevalence
() 0 0
! 1 464
* / % 2 464
+ - 3 464
« » 4 464
< <= == => > != 5 464
& AND 6 464
| OR 7 464
^ XOR 8 464
&& 9 6128
| | 10 6128
Sauf mention contraire, le contenu de cette page est protégé par la licence Creative Commons Attribution-ShareAlike 3.0 License