{"by":"isitcontent","descendants":36,"id":46392736,"kids":[46398494,46395324,46394190,46396321,46394948,46394371,46400918,46395534],"score":154,"text":"Repo: <a href=\"https:&#x2F;&#x2F;github.com&#x2F;valdanylchuk&#x2F;xcc700\" rel=\"nofollow\">https:&#x2F;&#x2F;github.com&#x2F;valdanylchuk&#x2F;xcc700</a><p>Hi Everyone! I just wrote my first compiler!<p>- single pass, recursive descent, direct emission<p>- generates REL ELF binaries, runnable using ESP-IDF elf_loader<p>- very basic features only, just enough for self-hosting<p>- treats the Xtensa CPU as a stack machine for simplicity, no register allocation &#x2F; window usage<p>- compilable on Mac, probably also Linux, can cross-compile for esp32 there<p>- wrote for fun &#x2F; cyberdeck project<p>Sample output from esp32:<p><pre><code>    xcc700.elf xcc700.c -o &#x2F;d&#x2F;cc.elf\n    \n    [ xcc700 ] BUILD COMPLETED &gt; OK\n    &gt; IN  : 700 Lines &#x2F; 7977 Tokens\n    &gt; SYM : 69 Funcs &#x2F; 91 Globals\n    &gt; REL : 152 Literals &#x2F; 1027 Patches\n    &gt; MEM : 1041 B .rodata &#x2F; 17120 B .bss\n    &gt; OUT : 27735 B .text &#x2F; 33300 B ELF\n    [ 40 ms ] &gt;&gt; 17500 Lines&#x2F;sec &lt;&lt;\n</code></pre>\nMy best hope is that some fork might grow into a unique nice language tailored to the esp32 platform. I think it is underrated in userland hobby projects.","time":1766761621,"title":"Show HN: Xcc700: Self-hosting mini C compiler for ESP32 (Xtensa) in 700 lines","type":"story","url":"https://github.com/valdanylchuk/xcc700"}