8cc.js
C code
// You can run a larger C program (FizzBuzz) by changing this condition. // Note you may not want to do this for slower backends (e.g., Brainfuck). #if 1 int putchar(int c); int main() { const char* p = "Hello, world!\n"; for (; *p; p++) putchar(*p); return 0; } #else #include
int main() { for (int i = 1; i <= 100; i++) { if (i % 5) { if (i % 3) { printf("%d\n", i); } else { printf("Fizz\n"); } } else { printf("FizzBuzz\n" + i * i % 3 * 4); } } return 0; } #endif
ELVM IR
Assembled code
Output
JavaScript
JavaScript (asm.js)
Ruby
Python
Java
Emacs Lisp
C
x86
Piet
C-INTERCAL
Whitespace
Befunge
Brainfuck
Unlambda
"Compile" runs 8cc.js on JavaScript to generate ELVM IR.
"Assemble" runs ELVM's assembler (elc.js) for specified language. Language selection makes sense only when you assemble EIR.
"Run EIR" runs ELVM IR on JavaScript (eli.js).
"Run JS" runs "Assembled code" as JavaScript.
You'll see blue and red boxes when you hover your mouse over a button. Blue box is source and red box is destination.