dgrdo / ASM
Quick Reference
The code that dgrdo / ASM
recognises and compiles is composed of two large parts:
Assembler directives
.EQU
Assigns an expression to a symbol. At the moment,
.EQU
is used to assign easy to remember names to constants. See for example the way thestatus_reg
is defined in this example.DB
Sets the default value of one or more
BYTE
size memory locations.A straightforward example of its use is available here. Since
.DB
is most commonly used with Labels, see further below for more examples.Labels
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
JUMP
instruction, as is done here between lines 30 and 39Combined with the
.DB
directive, labels can be used to create and access "variables" at the lowest level. For more examples see Assignments.Comments
Anything preceded by a
#
character is considered a comment.
Digirule Assembly
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.
Digirule 2A
Flow Control | Memory | Arithmetic | Logic | Other |
---|---|---|---|---|
HALT | COPYLR | ADDLA | ANDLA | NOP |
DECRJZ | COPYLA | ADDRA | ANDRA | SPEED |
INCRJZ | COPYAR | SUBLA | ORLA | INITSP |
BCRSC | COPYRA | SUBRA | ORRA | |
BCRSS | COPYRR | SHIFTRL | XORLA | |
JUMP | CBR | SHIFTRR | XORRA | |
CALL | SBR | DECR | ||
ADDRPC | INCR | |||
RETLA | RANDA | |||
RETURN |
Where:
L
stands for LiteralR
stands for AddressA
stands for Accumulator (The only "register" in the Digirule CPU)Z
stands for Zero
For example:
COPYLA 2
Will set the Accumulator to 2COPYLR 2 120
Will set memory address120
to 2.COPYRR 24 25
Will copy the value of memory address24
to that of25
COPYRA 120
Will set the Accumulator to whatever value is in address120
and so on.
For a full reference, please see here.
Digirule 2U
The 2U
version supports all 2A
instructions plus the following:
Flow Control | Memory | Arithmetic | Logic | Other |
---|---|---|---|---|
JUMPI | COPYLI | MUL | COMOUT | |
CALLI | COPYRI | DIV | COMIN | |
BTSTSC | COPYAI | COMRDY | ||
BTSTSS | COPYIR | |||
COPYII | PINOUT | |||
COPYRR | PININ | |||
SWAPRA | PINDIR | |||
SWAPRR | ||||
BCLR | ||||
BSET | ||||
BCHG |
Where:
BTSTSC, BTSTSS
are equivalent toBCRSC, BCRSS
.BCLR, BSET
are equivalent toCBR, SBR
.'I' stands for "Indirectly". In other words, where
COPYRR 24 25
copied the value of address24
to address25
,COPYII 24 25
performs a copy between the memory addresses that24,25
point at.For example:
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