The code that
dgrdo / ASM recognises and compiles is composed of two large parts:
- Assembler directives
- Digirule Assembly
Assigns an expression to a symbol. At the moment,
.EQUis used to assign easy to remember names to constants. See for example the way the
status_regis defined in this example
Sets the default value of one or more
BYTEsize memory locations.
A straightforward example of its use is available here. Since
.DBis most commonly used with Labels, see further below for more examples.
A label is composed of alphanumeric characters and
_. Labels cannot start with a number and are terminated by a colon (
The most common use of a label is controlling the flow of code execution with a
JUMPinstruction, as is done here between lines 30 and 39
Combined with the
.DBdirective, labels can be used to create and access "variables" at the lowest level. For more examples see Assignments.
Anything preceded by a
#character is considered a comment.
This is only a brief reference of the instruction sets each Digirule model understands.
An extensive list of fully documented examples you can try out on
dgrdo / ASM
is available here.
Lstands for Literal
Rstands for Address
Astands for Accumulator (The only "register" in the Digirule CPU)
Zstands for Zero
COPYLA 2Will set the Accumulator to 2
COPYLR 2 120Will set memory address
COPYRR 24 25Will copy the value of memory address
24to that of
COPYRA 120Will set the Accumulator to whatever value is in address
120and so on.
For a full reference, please see here.
2U version supports all
2A instructions plus the following:
BTSTSC, BTSTSSare equivalent to
BCLR, BSETare equivalent to
'I' stands for "Indirectly". In other words, where
COPYRR 24 25copied the value of address
COPYII 24 25performs a copy between the memory addresses that
COPYLR R0 R2 # Load R2 with the address of R0 COPYLR R1 R3 # Load R3 with the address of R1 COPYII R2 R3 # Copy indirectly from R2 to R3. In the end, R1 will receive the 5 HALT R0: .DB 5 R1: .DB 0 R2: .DB 0 R3: .DB 0
A more detailed version of this reference card is available here