Instruction counter (IC): contains the index of the current instruction being executed. Normally, after an instruction is executed, the value of IC is increased by 1. Jump instructions such as goto
can alter the content of this register and hence change the logical flow of the program.
Supported registers: D-Risc assembly allows the use of 64 registers, zero-indexed. To access a register, use R + the number of the register, as in R1
. Symbolic register names, like Rbase
, are not supported yet.
Spacing and parameter rules: only one instruction is allowed per line. Parameters must be separated by a comma. The last parameter must not be followed by any comma or other text, except for comments (see below). Valid example: load r1, r2, r3
.
Labels: a label is a short alpha-numerical string followed by a colon, which identifies a line of code. It can be used for jumps, or to describe what a section of the program does (much like a function name). A valid label is, for example, label:
. You can only put labels at the beginning of a line. Valid example: loop: clear r1
.
Comments: you can comment your code by adding a semi-colon at the end of an instruction, or on a line of its own, followed by your comment. For example:
add r1, r2, r3 ;this adds r1 to r2 and puts the result in r3
.
Below you can find the full list of supported instructions, alongside their syntax and semantics.
Instruction | Parameter 1 | Parameter 2 | Parameter 3 | Semantics |
---|---|---|---|---|
add | r1 | r2 | r3 | reg[3] = reg[1] + reg[2] |
addi | r1 | const | r2 | reg[2] = reg[1] + const |
sub | r1 | r2 | r3 | reg[3] = reg[1] - reg[2] |
subi | r1 | const | r2 | reg[2] = reg[1] - const |
mul | r1 | r2 | r3 | reg[3] = reg[1] * reg[2] |
muli | r1 | const | r2 | reg[2] = reg[1] * const |
div | r1 | r2 | r3 | reg[3] = reg[1] / reg[2] |
divi | r1 | const | r2 | reg[2] = reg[1] / const |
inc | r1 | reg[1]++ |
||
dec | r1 | reg[1]-- |
||
clear | r1 | reg[1] = 0 |
||
mov | r1 | r2 | reg[2] = reg[1] |
|
movi | const | r1 | reg[1] = const |
|
load | r1 | r2 | r3 | reg[3] = mem[r[1] + r[2]] |
loadi | r1 | const | r3 | reg[3] = mem[r[1] + const] |
store | r1 | r2 | r3 | mem[r[1] + r[2]] = reg[3] |
storei | r1 | r2 | r3 | mem[r[1] + const] = reg[3] |
goto | label | ic = label |
||
ifcondition Supported: if<, if<=, if>, if>=, if=, if!= |
r1 | r2 | label | if(reg[1] condition reg[2]) then ic = label |
ifcondition0 Supported: if<0, if<=0, if>0, if>=0, if=0, if!=0 |
r1 | label | if(reg[1] condition 0) then ic = label |
The program found on this page is still in beta mode. This means that you might encounter bugs during its use. If you do, please contact me to report them.
Note: this program has compatibility issues with most mobile phone browsers, and hence will not work properly on a phone. Please only use this tool on a computer browser.
SHR
and SHL
shift instructionsload rbase, rindex, rtemp
SETMEM
instruction that allows to directly manipulate the content of a memory locationDelay in-between instructions: ms
IC:
Registers
Used memory locations
Previously unused memory locations are initialized to a random value if loaded into a register.
Compiler messages