.
This commit is contained in:
@@ -27,5 +27,6 @@
|
|||||||
- [Display](emulator/features/display.md)
|
- [Display](emulator/features/display.md)
|
||||||
- [Instruction History](emulator/features/instruction_history.md)
|
- [Instruction History](emulator/features/instruction_history.md)
|
||||||
- [DSC - Damn Simple Code](dsc.md)
|
- [DSC - Damn Simple Code](dsc.md)
|
||||||
|
- [Functions](dsc/functions.md)
|
||||||
- [Other Language Support](misc_languages.md)
|
- [Other Language Support](misc_languages.md)
|
||||||
- [Brainf*](misc_languages/brainf.md)
|
- [Brainf*](misc_languages/brainf.md)
|
||||||
+19
@@ -1 +1,20 @@
|
|||||||
# DSC - Damn Simple Code
|
# DSC - Damn Simple Code
|
||||||
|
|
||||||
|
# This document is a work in progress!
|
||||||
|
# Nothing is final!
|
||||||
|
|
||||||
|
|
||||||
|
## Syntax
|
||||||
|
- we aim to make the syntax simple and easy to understand, this has the following benefits
|
||||||
|
- easy to write
|
||||||
|
- easy to parse
|
||||||
|
- little variation in syntax means we have to handle less cases in semantic analysis, meaning we will be able to create a working compiler quicker.
|
||||||
|
|
||||||
|
## Types
|
||||||
|
- we should support the following types
|
||||||
|
- unsigned integer types (U8, U16, U32)
|
||||||
|
- signed integer types (I8, I16, I32)
|
||||||
|
- boolean type (Bool)
|
||||||
|
- struct types (Struct)
|
||||||
|
- dynamic types *(Dyn)
|
||||||
|
-
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
# Functions
|
||||||
@@ -1,5 +1,20 @@
|
|||||||
# Brainf*
|
# Brainf*
|
||||||
|
|
||||||
|
## Language overview
|
||||||
|
|
||||||
|
- Brainf* instructions are as follows:
|
||||||
|
|
||||||
|
| Instruction | Description |
|
||||||
|
| --- | --- |
|
||||||
|
| `+` | Increment the current memory cell |
|
||||||
|
| `-` | Decrement the current memory cell |
|
||||||
|
| `<` | Move the data pointer to the left |
|
||||||
|
| `>` | Move the data pointer to the right |
|
||||||
|
| `.` | Output the value of the current memory cell as a character |
|
||||||
|
| `,` | Input a character and store its value in the current memory cell |
|
||||||
|
| `[` | Jump to the instruction after the matching `]` if the value in the current memory cell is zero |
|
||||||
|
| `]` | Jump to the instruction after the matching `[` if the value in the current memory cell is non-zero |
|
||||||
|
|
||||||
## Implementations
|
## Implementations
|
||||||
we currently have two implementations of the brainf* esoteric programming language:
|
we currently have two implementations of the brainf* esoteric programming language:
|
||||||
|
|
||||||
@@ -10,4 +25,12 @@ we currently have two implementations of the brainf* esoteric programming langua
|
|||||||
### Interpreter
|
### Interpreter
|
||||||
- this method is much slower, with even jumping to the start of a loop having an O(n) time complexity, which depending on the complexity of the program can up to double the running time.
|
- this method is much slower, with even jumping to the start of a loop having an O(n) time complexity, which depending on the complexity of the program can up to double the running time.
|
||||||
- additionally, interpreting the language means much more logic is required at runtime relative to compiling.
|
- additionally, interpreting the language means much more logic is required at runtime relative to compiling.
|
||||||
- from our testing on a few example programs such as a fibonacci sequence generator, the interpreter is several orders of magnitude slower, with the fibonacci generator beingabout 10 times slower than it's compiled equivalent.
|
- from our testing on a few example programs such as a fibonacci sequence generator, the interpreter is several orders of magnitude slower, with the fibonacci generator beingabout 10 times slower than it's compiled equivalent, at around 3.8 million instructions to generate and pretty-print the first 16 fibonacci numbers, compared to around 350,000 for the compiled version, which we estimate is about as efficient as brainf* can be on our architecture without writing an optimiser.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
### Compiling
|
||||||
|
- currently [The DSA Assembler](../dsa/tooling/assembler.md) supports compiling brainf* programs, with the following command:
|
||||||
|
```bash
|
||||||
|
<assembler binary name> -brainf
|
||||||
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user