OBFI

Brainfuck Interpreter
git clone http://git.omkov.net/OBFI
Log | Tree | Refs | README | LICENCE | Download

OBFI/README.md (41 lines, 1.3 KiB) -rw-r--r-- file download

799eb29 Jakob Wakeling 2020-07-01 00:12:34
0
# OBFI
799eb29 Jakob Wakeling 2020-07-01 00:12:34
1
78da73c Jakob Wakeling 2023-12-28 16:23:49
2
A minimal and performant Brainfuck interpreter.
799eb29 Jakob Wakeling 2020-07-01 00:12:34
3
799eb29 Jakob Wakeling 2020-07-01 00:12:34
4
## Implementation Details
799eb29 Jakob Wakeling 2020-07-01 00:12:34
5
e15818a Jakob Wakeling 2020-07-01 15:54:06
6
* OBFI uses single octet cells, and arithmetic wraps around.
6080736 Jakob Wakeling 2024-01-27 14:18:37
7
* OBFI provides 30000 cells (configurable via `-l`).
37f8432 Jakob Wakeling 2020-08-17 23:37:29
8
* OBFI does not perform array bound checking.
2df5007 Jakob Wakeling 2020-08-26 22:26:08
9
* OBFI will set the current cell to 0 when EOF is encountered.
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
10
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
11
## Optimisations
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
12
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
13
* Compress `>` and `<` instructions.
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
14
* Compress `+` and `-` instructions.
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
15
* Replace `[+]` and `[-]` with a 'set to zero' instruction.
44e07d6 Jakob Wakeling 2020-07-14 13:19:24
16
* Replace `[>]` and `[<]` with a 'go to zero' instruction.
37f8432 Jakob Wakeling 2020-08-17 23:37:29
17
* Replace `[+>+>]` and `[>+>+]` with a 'move to' instruction.
37f8432 Jakob Wakeling 2020-08-17 23:37:29
18
* Replace `[-<-<]` and `[<-<-]` with a 'move to' instruction.
799eb29 Jakob Wakeling 2020-07-01 00:12:34
19
5a79c59 Jakob Wakeling 2022-03-09 22:35:10
20
## Usage
799eb29 Jakob Wakeling 2020-07-01 00:12:34
21
78da73c Jakob Wakeling 2023-12-28 16:23:49
22
To build **OBFI**, from the project root, run `make build`.
6080736 Jakob Wakeling 2024-01-27 14:18:37
23
6080736 Jakob Wakeling 2024-01-27 14:18:37
24
See `./bin/obfi --help` for program options.
6080736 Jakob Wakeling 2024-01-27 14:18:37
25
6080736 Jakob Wakeling 2024-01-27 14:18:37
26
## Performance
6080736 Jakob Wakeling 2024-01-27 14:18:37
27
6080736 Jakob Wakeling 2024-01-27 14:18:37
28
On a machine with an Intel i7 12700K (20 cores @ 4.90 GHz) and 64 GB of
6080736 Jakob Wakeling 2024-01-27 14:18:37
29
DDR4-4800 RAM, the `./examples/mandel.b` example was able to be run in an
6080736 Jakob Wakeling 2024-01-27 14:18:37
30
average time of `1.945` seconds, compiled as specified above.
6080736 Jakob Wakeling 2024-01-27 14:18:37
31
6080736 Jakob Wakeling 2024-01-27 14:18:37
32
For comparison, the [SBFI](https://github.com/rinoldm/sbfi) interpreter, on the
6080736 Jakob Wakeling 2024-01-27 14:18:37
33
same machine, with the same example program, was able to run in an average time
6080736 Jakob Wakeling 2024-01-27 14:18:37
34
of `1.245` seconds, compiled with its recommended compilation command.
799eb29 Jakob Wakeling 2020-07-01 00:12:34
35
799eb29 Jakob Wakeling 2020-07-01 00:12:34
36
## Meta
799eb29 Jakob Wakeling 2020-07-01 00:12:34
37
799eb29 Jakob Wakeling 2020-07-01 00:12:34
38
Copyright (C) 2020, Jakob Wakeling  
5a79c59 Jakob Wakeling 2022-03-09 22:35:10
39
[MIT Licence](https://opensource.org/licenses/MIT)
40