Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgabis/business-card-brainfuck
Tiny Brainfuck interpreter.
https://github.com/kgabis/business-card-brainfuck
brainfuck c interpreter
Last synced: 3 months ago
JSON representation
Tiny Brainfuck interpreter.
- Host: GitHub
- URL: https://github.com/kgabis/business-card-brainfuck
- Owner: kgabis
- License: mit
- Created: 2015-12-02T20:50:27.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-04-02T09:08:50.000Z (almost 8 years ago)
- Last Synced: 2024-08-03T18:15:03.685Z (6 months ago)
- Topics: brainfuck, c, interpreter
- Language: C
- Size: 3.91 KB
- Stars: 18
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeInterpreter - business-card-brainfuck
README
## About
Business Card Brainfuck is a tiny [Brainfuck](http://en.wikipedia.org/wiki/Brainfuck) interpreter which fits on business cards and is only 512 bytes of code. It's inspired by [Business Card Raytracer](http://www.cs.utah.edu/~aek/code/card.cpp) by Paul Heckbert ([more](http://fabiensanglard.net/rayTracing_back_of_business_card/)).
It exists mostly to demonstrate how easy it is to implement a Brainfuck interpreter and because I was bored one evening. Indented code is located in bf_indent.c.## Code
```c
#include // Krzysztof Gabis 2015
#include // Usage: ./bf program
int p[64*1024],d[1024*1024],r,c,t,e;int main(int c,char*v[]){
if(c<2)exit(1);FILE*f=fopen(v[1],"r");while(f&&(c=getc(f))!=
EOF)p[r++]=c;r=0;while((c=p[r])){e=0;if(c=='>')t++;if(c=='<')
t--;if(c=='+')d[t]++;if(c=='-')d[t]--;if(c=='.')putc(d[t],
stdout);if(c==',')d[t]=getc(stdin);while(c=='['&&!d[t]){if(
p[r]=='[')e++;if(p[r]==']'&&e--==1)break;r++;}while(c==']'&&
d[t]){if(p[r]==']')e++;if(p[r]=='['&&e--==1)break;r--;}r++;}}```
## QR
![QR Code](qr.png)## Usage
```
make
./bf filename
```## Examples
```
./bf hw.bf
```
```
curl -s "http://www.99-bottles-of-beer.net/download/1718" > bottles.bf
./bf bottles.bf
``````
curl -s "http://esoteric.sange.fi/brainfuck/utils/mandelbrot/mandelbrot.b" > mandelbrot.bf
./bf mandelbrot.bf
```## License
[The MIT License (MIT)](http://opensource.org/licenses/mit-license.php)