You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
0 commit comments