SectorC: 512바이트 C 컴파일러 (2023)
SectorC: A C Compiler in 512 bytes (2023)
요약
SectorC는 x86-16 어셈블리로 작성되었으며 512바이트 부트 섹터 안에 완벽하게 들어가는 놀라운 C 컴파일러입니다. 흥미로운 프로그램을 작성하기에 충분한 C의 부분 집합을 지원하여 역사상 가장 작은 C 컴파일러일 가능성이 높습니다. 개발 과정에서는 공간으로 구분된 "메가 토큰"과 `atoi()`를 나쁜 해시 함수로 사용하는 것과 같은 혁신적인 기술을 사용하여 극심한 크기 제약을 극복했으며, 궁극적으로 극도로 제한된 공간 내에서 기능적인 C 컴파일러를 구현했습니다.
댓글 (77)
Discussed at the time: https://news.ycombinator.com/item?id=36064971
SectorC: A C Compiler in 512 bytes - https://news.ycombinator.com/item?id=36064971 - May 2023 (80 comments)
PS. There left 21 bytes (21 * 0x00 - from 0x01e0 to 0x01fd). Maybe something can be packed there ;)
This is a great demonstration of how simple the bare bones of C are, which I think is one reason I and many others find it so appealing despite how Spartan it is. C really evolved from B which was a demake of Fortran, if Ken Thompson is to be trusted.
And PS, it's "chose your own adventure". :-) I love minimalism.
Examples:
was it supposed to be "<150"?
Oh no. Now more people are able to do what I do. I'm not special anymore.
Both interesting projects, but other than the words 'boot sector', 'C' and 'compiler', I don't see a similarity.
And anyway, isn't that kind of missing the point. 512 bytes isn't much. Your comment is nearly a 5th of that budget.
https://www.oocities.org/trentgamblin/sizehack/entries.html#...
Fun fact, Tiny C Compiler was derived from such a C compiler submitted to the the International Obfuscated C Code Contest.
https://xorvoid.com/otcc_deobfuscated.html https://github.com/xorvoid/otcc_deobfuscated
#!/bin/sh
echo "awk: bailing out" >&2If you're running on Linux, adjust the qemu call to use alsa rather than coreaudio.
I generated a pull request for this on Github. If the author is happy enough with my verbose shell scripting style :-) it might get included.
Maybe it's time to equip it with a C compiler...
I could have sworn I remembered atoi() being defined to return 0 for invalid input (i.e. text not representing an integer in base ten).
Not saying we should all write boot sector code, but reading through projects like this is genuinely humbling. Great educational resource too.
On other HN posts, they're stating something like "software development is dead", "LLM as a compiler", "Do you read compiled assembly?", and so on.
While some other posts like this contain huge mechanical sympathy and literally r/w the assembly directly.