blob: 34ba9d916a326827b4207d13c0a8f040fd7f1cf6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
___________________________
OREO'S BRAINFUCK COMPILER
Aryadev Chavali
___________________________
Here is a simple brainfuck compiler/interpreter written in C. Most of
the code was written in 2023, but the compiler code was written in 2024.
Build instructions
==================
A C compiler capable of compiling C11 is required. `clang' and `gcc'
have been tested. `yasm' and `ld' are required for `obc', but the
assembly transpile step should work.
+ To build release: `make all RELEASE=1'
+ To build debug: `make all RELEASE=0'
+ To run examples: `make examples'
Goals
=====
+ [X] Complete reference interpreter for brainfuck
+ [X] Native compiler
Notes
=====
I cheat heavily to make the native compiler here; I'm not writing my
own ELF executables by hand (using `elf.h'). Instead I write valid
assembly code in a string buffer, then compile that via `yasm' and
`ld'.
It shouldn't be all that difficult to make a JIT from this point; just
translating the assembly snippets into machine code and embedding that
into an executable page.
|