Skip to content

Commit d136bae

Browse files
committed
Added More Documentation
1 parent 91d5e84 commit d136bae

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

docs/locationspecifiers.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
## This Page Is A Work In Progress
1+
Location specifiers are an optimisation tool available to the developer to hand tune the memory allocation of
2+
variables in your Mastermind code. Location specifiers will override the compilers memory allocation algorithm.
3+
4+
### Usage
5+
Location specifiers can be added in the form of a memory address given during variable definition or before inline Brainfuck statements.
6+
7+
8+
For 1D Brainfuck you simply provide the x-coordinate where memory should be allocated
9+
```
10+
cell var @3 = 4;
11+
// compiled: >>>++++
12+
13+
bf @4 {
14+
<><><>
15+
}
16+
// compiled: >>>><><><>
17+
```
18+
19+
20+
Alternatively if using the 2D enhancements you can use a comma seperated list with an x-coordinate and y-coordinate for a 2D location
21+
```
22+
23+
bf @4,3 {
24+
<><><>
25+
}
26+
// compiled: >>>>^^^<><><>
27+
```
28+
29+
### Conflicts
30+
For location specifiers the responsibility is on the programmer to ensure that any memory overlaps are avoided. This can be especially common
31+
when specifying the location of a static array that might use multiple locations. However,
32+
the compiler can pick up on these errors and will not compile if it notices conflicting memory an example of code that does this and an error is below:
33+
34+
```
35+
cell a @1 = 1;
36+
cell foo @1 = 2;
37+
cell b = 3;
38+
```
39+
```
40+
Location specifier @1,0 conflicts with another allocation
41+
```

docs/optimisations.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,32 @@
1-
## This Page Is A Work In Progress
1+
## This Page Is A Work In Progress
2+
3+
### Cell Clearing
4+
TBD
5+
6+
### Constants
7+
Constants will optimise constant values by finding the best combination of products and a constant. For example 18 could
8+
be expressed as 6 * 3 or 2 * 9 which could reduce the amount of increment or decrement instructions required. Additionally
9+
the overflowing property of our cells makes it more efficient to decrement 0 to wrap around to 255
10+
11+
### Empty Blocks
12+
The empty blocks optimisation will remove code that the compiler can see will either never be entered or is empty when executed
13+
14+
### Generated Code
15+
Generated code is an optimisation that runs after Brainfuck code has been compiled. It optimises the movement between
16+
memory locations in code blocks that are safe to optimise this will be any code between input/output, loops, functions and conditional statements.
17+
18+
This algorithm has 2 options a greedy approach which will find a solution that works and then an exhaustive approach to try all
19+
permutations of movement between memory cells. Since this may be slow for larger code blocks this is configurable
20+
21+
### Generated Code Permutations
22+
This setting swaps between the greedy and exhaustive algorithm for our Generated Code optimisation. If generated code is not enabled
23+
this config will have no impact.
24+
25+
### Memory Allocations
26+
TBD
27+
28+
### Unreachable Loops
29+
TBD
30+
31+
### Variable Usage
32+
TBD

0 commit comments

Comments
 (0)