3 ms·
It's beautiful. Here are examples of compiling c4 and using it, following the README: $ gcc -o c4 c4.c 2>/dev/null $ ./c4 hello.c hello, world
by acqq 7y ago
It's beautiful. Here are examples of compiling c4 and using it, following the README:
$ gcc -o c4 c4.c 2>/dev/null
$ ./c4 hello.c
hello, world
exit(0) cycle = 9
$ ./c4 -s hello.c
1: #include <stdio.h>
2:
3: int main()
4: {
5: printf("hello, world\n");
ENT 0
IMM -274739184
PSH
PRTF
ADJ 1
6: return 0;
IMM 0
LEV
7: }
LEV
$ ./c4 c4.c hello.c
hello, world
exit(0) cycle = 9
exit(0) cycle = 26015
$ ./c4 c4.c c4.c hello.c
hello, world
exit(0) cycle = 9
exit(0) cycle = 26015
exit(0) cycle = 10060183
It works on Windows too, if you have gcc installed.
Also, see "Adding support for 64 bit targets" commit:
https://github.com/rswier/c4/commit/2feb8c0a142b2e513be69442c24af82dbaf41a25 https://github.com/rswier/c4/commit/2feb8c0a142b2e513be69442...
And yes, swieros has much more.
- candiodari 7y agoSo it's not actually a compiler, it's a bytecode compiler + interpreter (like python) where the names of the bytecodes match what an x86 assembler would use, but the encoding doesn't (and it doesn't know how to create or link .exe ELF or whatever macos uses)