Add control flow operands
This commit is contained in:
33
design.md
33
design.md
@@ -23,6 +23,17 @@
|
||||
Divide register A by 5 and store the result in register A:
|
||||
`divi %A $5 %A;`
|
||||
|
||||
Increment B until it is 10:
|
||||
```
|
||||
# Set B to zero
|
||||
addi $0 $0 %B;
|
||||
|
||||
loop:
|
||||
addi $1 %B %B;
|
||||
lti %B $10;
|
||||
jmp loop;
|
||||
```
|
||||
|
||||
## Reserved symbols
|
||||
|
||||
The following whitespace characters are used to separate symbols:
|
||||
@@ -32,15 +43,17 @@ The following whitespace characters are used to separate symbols:
|
||||
- newline (`\n`)
|
||||
|
||||
The following characters are used as identifiers:
|
||||
- dollar (`$`)
|
||||
- percentage (`%`)
|
||||
- colon (`:`)
|
||||
- semicolon (`;`)
|
||||
- hash (`#`)
|
||||
- dollar (`$`) for immediate (literal) values
|
||||
- percentage (`%`) for register identifiers
|
||||
- colon (`:`) for jump labels
|
||||
- semicolon (`;`) for statement termination
|
||||
- hash (`#`) for comments
|
||||
|
||||
All operands are reserved keywords and can therefore NOT be used as labels.
|
||||
All symbols are reserved keywords and can therefore NOT be used as labels.
|
||||
|
||||
## Operands
|
||||
## Symbols
|
||||
|
||||
### Operands
|
||||
|
||||
- `addi` add the first to the second argument and store the result in the third argument
|
||||
- `subi` subtract the first from the second argument and store the result in the third argument
|
||||
@@ -48,4 +61,10 @@ All operands are reserved keywords and can therefore NOT be used as labels.
|
||||
- `muli` multiply the first by the second argument and store the result in the third argument
|
||||
- `shli` shift left the first argument by the number of positions given by the second argument and store the result in the third argument
|
||||
- `shri` shift right the first argument by the number of positions given by the second argument and store the result in the third argument
|
||||
|
||||
### Control Flow
|
||||
|
||||
- `jmp` jump to the label given by the first argument
|
||||
- `lti` execute next statement if argument 1 is less than argument 2 else skip the next statement
|
||||
- `gti` execute next statement if argument 1 is greater than argument 2 else skip the next statement
|
||||
- `eqi` execute the next statement if argument 1 is equal to argument 2 else skip the next statement
|
||||
|
||||
Reference in New Issue
Block a user