DUEMMEGI
MCP 4 – User's manual
Contatto
3.2.11- @RAM k and @WORD k
The functions
@RAM k
and
@WORD k
allow to access to pairs of RAM locations or single Words. The
specified value (k) is the starting RAM address or the Word number and
must be a constant value
in the
range 0 to 65535 in the first case and 0 to 32767 in the second one.
For instance, the day of the month is mapped in RAM memory at the address 0x0F08-0x0F09, corresponding
to Word 1924; to copy this value (therefore the content of the Word 1924), for instance, into register R2, the
following notations can be used:
R2
=
@RAM
0x0F08
or
R2
=
@WORD
1924
.
On the other hand, the Word content can be also written:
@RAM
0x0F08 =
R2
or
@WORD
1924 =
R2
These functions are useful when the Word to be accessed to (both for reading and writing) cannot be
identified in other ways (in other words when it cannot be identified by notations as Cx, Ry, etc.) and they are
an option to the pointer method described before.
3.2.12- SWAP(x)
The
SWAP(x)
function exchange the high byte with the low byte of the specified Word (x). The Word can be
specified in one of the following ways:
1. directly by its symbolic name (e.g. R34, C48, AI24:3, etc.)
2. directly by @WORD or @RAM
3. by pointer
Examples of the first way:
R0
=
SWAP
(
I18:2
)
R1
=
SWAP
(
R1
)
Examples of the second way:
R66
=
SWAP
(
@WORD
1924)
Examples of the third way:
ptr = 1924
R45
=
SWAP
([ptr])
3.2.13- RANDOM(0)
The
RANDOM(0)
function returns a random number. The number is generated according to a particular
algorithm (Lehmer Random Number Generator) which returns a pseudo random value uniformly distributed.
The parameter passed to the RANDOM function must be always zero.
The following script call the RANDOM(0) function every 60 seconds and the returned random value will be
copied to R0.
script
1
trigger
= 60
R0
= RANDOM(0)
Endscript
DUEMMEGI
s.r.l. - Via Longhena, 4 – 20139 MILANO
Tel. 02/57300377 - Fax 02/55213686 –
www.duemmegi.it
Rel.: 1.2 October 2018
Page 43 of 87