Hacker News new | past | comments | ask | show | jobs | submit login
ABC: A C compiler for printable x86 (tom7.org)
123 points by djoldman on Jan 13, 2023 | hide | past | favorite | 22 comments



This is my favorite part of the paper:

> Now, for good reasons that I will explain later, this paper must contain 8,224 repetitions of the string "~~Q(", another weird flower. Please proceed to Page 3 to continue reading this interesting paper.

> ~~Q(~~Q(~~Q(~~Q(~~Q(~~Q(~~Q(~~Q(~~Q(~~Q([etc.]

It comes early enough that the paper hasn't given enough context to figure out why it's there, so unless you already know, it's just surreal and gives you a faint suspicion that the author is crazy.


Everything tom7 has made is golden, my personal favorite is "Elo World": https://www.youtube.com/watch?v=DpXy041BIlA


I too can't recommend him enough; even if the video title doesn't interest you at all, you'll absolutely be entertained. I watched all of his videos back-to-back when I found him :)


In my opinion, this is the coolest thing tom7 has ever done. It just barely works, relying on unexpected wrapping behavior for the instruction pointer and a series of medium-sized jumps to ever jump backwards, and a truly heinous mechanism for sending an interrupt to exit the program.

The fact that the paper contains the compiler executable (compiled by itself) is just amazing.


>The fact that the paper contains the compiler executable (compiled by itself) is just amazing.

Agree that it's amazing, but the paper contains a demo program produced by the compiler, not the compiler itself.


Ah! I misremembered. Makes sense, as the compiler is written in SML.


One thing about his videos is that they just contain so many truths put into words. In this video it's, for example: "I know there are many people who know everything about bytes, and then there are people watching this that don't live and breathe this stuff, and both will probably be bored by the details."

Also the one that hurt me personally from another video: "All I ever do with computers anyway is other computer stuff."



Previously: https://news.ycombinator.com/item?id=16312317

My favorite line from the paper is "the popular and elegant X86 architecture". Very subtle humor, I suspect not many people get it.


Nice to see someone's going through the tom7 back catalogue!

the compile-to-IRS-tax-forms one was a gem, too.


Scrolling quickly through the .txt version of this paper on my phone feels like a visual expression of the internet dial up sound.


In the accompanying video[0] at 7:36 mark, he goes to great lengths to express (A or B) as (A and B) + (A xor B).

Can anybody explain why it can't simply be expressed as (A and B) xor (A xor B)? What am I missing here?

0. https://www.youtube.com/embed/LA_DrBwkiJA


Whether you add or xor will make no difference since there will never be two bits set in the same position. The key point is that printable ASCII limits what operations are available, so you have to synthesize some of them.


The difference is that xor is available to him (he mentions that in the video), while addition needs to be achieved by combining multiple instructions.


it can, as was discussed in comments on the video with replies from Tom. IIRC, the source code has been updated to use that instead.


I wonder if the BOUND instruction could have been used to call int 21h more than once.

That would have the same problem that after return the BOUND instruction would be re-executed, but perhaps there are useful DOS calls that after execution modify the registers such that the bounds check wouldn't fail afterwards.


You can put the bounds immediately below the current stack pointer. Since the code runs in real mode, there is no separate "kernel stack", and any interrupt will overwrite the values with flags+CS+IP, which you have some control over.


This is, to date, the hardest i have ever seen someone work for this particular meme joke.


This is Tom's MO (and to a lesser extent a number of other sigbovik contributors). Extremely detailed and hard work on absolutely fundamentally silly problems. A true legend.


That's a beautiful form of art, somehow. Far away from the only form of art, but it's the kind of art where a) it's very obvious that you have to be extremely proficient in what you are doing (and so the stupid modern art spectator comment "I could have done this" is quelled from its very spark), and b) it's so useless, especially for the amount of effort put in, that it really only exists for itself and to please both creator and spectator.

There is one video of his that takes it to an extreme: https://www.youtube.com/watch?v=5TFDG-y-EHs - That is not only impossibly bonkers on just about every level, it's also so incredibly useless that the result is not even observable.


Tom7 is an absolute legend and I've seen this video and most of his library many times.


sed -E 's/(.{160})/\1\n/g' paper.txt | less




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: