BrainDuck is an abstract computer for emuStudio, which mimics brainfuck programming language. Originally, brainfuck was developed by Urban Miller and it is well-known fact that the language has a minimalistic compiler and it’s eight instructions don’t prevent it to be Turing complete. Also, there exist many extensions of the language and there are organized programming contests in brainfuck worldwide. But all of that can be read at Wikipedia or at other sources.
BrainDuck architecture is just a name for virtual computer in emuStudio, and consists of these plugins:
brainc-brainduck: Compiler of brainfuck language (original, without extensions)
brainduck-cpu: Brainfuck emulator acting like CPU with two registers
brainduck-mem: Virtual operating memory which holds both compiled brainfuck program and data
brainduck-terminal: Virtual terminal for displaying the output and requesting for input.
BrainDuck is implemented as [von Neumann] computer. It means that the program and data are shared in the same memory. This is not a common approach to implementing brainfuck interpreters, and it might be changed in the future.
As implementing a brainfuck interpreter, one must deal with several portability issues, which include:
- Memory cell size (solved in
- Memory size (number of memory cells) (solved in
- End-of-line code (solved in
- End-of-file behavior (solved in
The solution is spread across the plugins, as you can see in the parentheses. Chapters devoted to plugin’s description contain specific information.
In order to use BrainDuck, there must be drawn the abstract schema, saved in the configuration file. Abstract schemas are drawn in the schema editor in emuStudio (please see emuStudio application documentation for more details). The following image shows the schema of BrainDuck computer:
The “–>” arrows are in a direction of dependency. So for example
brainc-brainduck depends on
brainduck-mem, because compiled programs are directly loaded into memory.
brainduck-terminal exists bidirectional dependency, because input gained from a terminal is passed to the CPU, and output is pushed from CPU to the terminal.
brainduck-cpu also depends on
brainduck-mem, because memory is a place where program and data are stored.