From afb2761a2b9ad7882f90e97138a18693bbc87c0a Mon Sep 17 00:00:00 2001 From: zxq5 Date: Fri, 27 Jun 2025 13:58:21 +0100 Subject: [PATCH] . --- src/SUMMARY.md | 1 + src/dsc.md | 19 +++++++++++++++++++ src/dsc/functions.md | 1 + src/misc_languages/brainf.md | 25 ++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/dsc/functions.md diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 897054b..4f4067d 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -27,5 +27,6 @@ - [Display](emulator/features/display.md) - [Instruction History](emulator/features/instruction_history.md) - [DSC - Damn Simple Code](dsc.md) + - [Functions](dsc/functions.md) - [Other Language Support](misc_languages.md) - [Brainf*](misc_languages/brainf.md) \ No newline at end of file diff --git a/src/dsc.md b/src/dsc.md index 66ab689..376dc89 100644 --- a/src/dsc.md +++ b/src/dsc.md @@ -1 +1,20 @@ # 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) + - \ No newline at end of file diff --git a/src/dsc/functions.md b/src/dsc/functions.md new file mode 100644 index 0000000..0c5faf5 --- /dev/null +++ b/src/dsc/functions.md @@ -0,0 +1 @@ +# Functions diff --git a/src/misc_languages/brainf.md b/src/misc_languages/brainf.md index c4f972c..9ba6764 100644 --- a/src/misc_languages/brainf.md +++ b/src/misc_languages/brainf.md @@ -1,5 +1,20 @@ # 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 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 - 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. -- 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. \ No newline at end of file +- 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 + -brainf +```