Basic arithmetic and jump labels

This commit is contained in:
2019-11-17 21:02:35 +01:00
commit b84557b3e1
34 changed files with 1350 additions and 0 deletions

40
design.md Normal file
View File

@@ -0,0 +1,40 @@
# Design
## Parsing
- First we tokenize the input (syntax check)
- Then we interpret the input (semantics check)
- Then we execute the input
## Notation
- `[operation][number type]`, e.g. `divi` for divide (div) integer
- `%[register]` for addressing registers
- `$[value]` for using literals/immediate values
- `;` for end of statement (mandatory)
- `[label]:` for labels
- Elements must be separated by whitespace character
- Good: `add $2 $5 %A;`
- Bad: `add $2$5%A;`
## Examples
Divide register A by 5 and store the result in register A:
`divi %A $5 %A;`
## Reserved symbols
The following whitespace characters are used to separate symbols:
- space (' ')
- tab ('\t')
- return carriage ('\r')
- newline ('\n')
The following characters are used as identifiers:
- dollar ('$')
- percentage ('%')
- colon (':')
- semicolon (';')
- hash ('#')
All operands are reserved keywords and can therefore NOT be used as labels.