/bf.c
Created
September 25, 2010 09:36
-
Star
(135)
You must be signed in to star a gist -
Fork
(9)
You must be signed in to fork a gist
-
-
Save lifthrasiir/596667 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The world's smallest Brainfuck interpreter in C, by Kang Seonghoon | |
* http://j.mearie.org/post/1181041789/brainfuck-interpreter-in-2-lines-of-c */ | |
s[99],*r=s,*d,c;main(a,b){char*v=1[d=b];for(;c=*v++%93;)for(b=c&2,b=c%7?a&&(c&17 | |
?c&1?(*r+=b-1):(r+=b-1):syscall(4-!b,b,r,1),0):v;b&&c|a**r;v=d)main(!c,&a);d=v;} |
Wow. wow.
To any newcomers:
Compile using gcc with the flag "-m32"
You may need to install the gcc-multilib package in order to target an x86 binary
After you have the right libraries installed, you should be able to compile like this:
gcc -m32 -o bf bf.c
Cheers!
Og code using an online C beautifier: https://codebeautify.org/c-formatter-beautifier/y255f5fa5
s[99], * r = s, * d, c;
main(a, b) {
char * v = 1[d = b];
for (; c = * v++ % 93;)
for (b = c & 2, b = c % 7 ? a && (c & 17 ?
c & 1 ? ( * r += b - 1) : (r += b - 1) : syscall(4 - !b, b, r, 1), 0) : v; b && c | a ** r; v = d) main(!c, & a);
d = v;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
After a few back and forth with GPT-4o, I got this: