Skip to content

0l3d/brainsuck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brainsuck 🧠

A minimalist Brainfuck interpreter and compiler written in C

Features

  • All 8 Brainfuck commands supported
  • 30,000 memory cells
  • File input/output
  • Interactive input with , command
  • Proper bracket matching for loops
  • Compiles brainfuck code to FASM (x86_64 linux).

Brainfuck Commands

Command Description
+ Increment memory cell
- Decrement memory cell
> Move pointer right
< Move pointer left
. Output character
, Input character
[ Jump forward if cell is 0
] Jump backward if cell is non-zero

Installation

git clone https://git.sr.ht/~oled/brainsuck
cd brainsuck
gcc -Os brainsuck.c -o brainsuck

Usage

./brainsuck <brainfuck_file> # INTERPRETER
# or
./brainsuck <brainfuck_file> -c # INTERPRETER + COMPILER
# out file name: compiled.brainsuck.asm

Hello World (hello.bf)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Run Examples

./brainsuck examples/hello.bf
./brainsuck examples/life.bf
./brainsuck examples/calculator.bf

License

This project is licensed under the GPL-3.0 License.

Author

Created by oled.

About

A Brainfuck interpreter and compiler in C.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages