A Logisim circuit that can run Brainfuck programs
Created in two to three days during Sept 2024 as a science experiment
- Use the attached
bf_compiler.cppto translate your Brainfuck source code (source.bf) into hexadecimal format - Copy the program output into the ROM of the circuit (top left corner) in Logisim
- Enable clock ticks, set the tick frequency to the highest one available and start the Logisim simulation
- Enter inputs when the LED next to the screen is on
| Hexadecimal | Brainfuck command |
|---|---|
| 0 | (program halts) |
| 1 | >: loops back to address 0000 if overflow |
| 2 | <: loops back to address ffff if underflow |
| 3 | +: loops back to value 0x00 if overflow |
| 4 | -: loops back to value 0xff if underflow |
| 5 | .: treats bits 0~6 as ASCII character |
| 6 | ,: accepts one byte from keyboard each time |
| 7 | [ |
| 8 | ] |
| 9~f | (no operation; program continues) |
- Due to a design flaw of the circuit, a buffer half-byte must be added after each instruction, which costs clock cycles and ROM space
- There is no method (that I know of) to enter
\0into the keyboard buffer, so this may cause issues with programs that use\0as an input termination character - The circuit is unoptimized; it could use fewer components
