News for hackers. Stuff that matters.
Re:4043 byte PC emulator (2013) by pjc50 on Friday October 12, 2018 @04:43AM (#18200117)
Possibly there were some assisting tools, but most likely nothing more complicated than search-and-replace. Handcrafting these things is the whole art of the IOCCC.

Many years ago I wrote some obfuscated Perl, assisted by the fact that the language is pretty obfuscated to start with. https://flatline.org.uk/snowflake.pl.txt - I think I may have had a tool to help it fit the template, but since you can't have a space in the middle of an operator restructuring the program to make the operators fit the snowflake was a major part of the effort.

While there's an "unobfuscated" version of the emulator program in this thread, it's clearly not the same program - there's no "switch/case" in the obfuscated version.

Re:4043 byte PC emulator (2013) by szc on Friday October 12, 2018 @05:22AM (#18200262)
You can turn a switch statement into a series of ? :

switch(a) { case x: do1(); break; case y: do2(); break; default do3(); break; }

becomes

   a == x ? do1() : a == y ? do2() : do3();
These structures can be seen in the minimized version (and a few other IOCCC winners :-).

This code likely doesn't optimize quite as well. Several cute things you can do with switch statements cannot be translated so easily.

Re:4043 byte PC emulator (2013) by pjc50 on Friday October 12, 2018 @05:48AM (#18200334)
Aha, found a partially-deobfuscated version: https://gist.github.com/slacka/8306176

The instruction decode mechanism is a chain of "e--||(expression), e--|| ..." expressions. At the point where e-- is zero the expression will be evaluated.

The program makes heavy use of the equivalence between "index[pointer]" and "pointer[index]", presumably to save brackets.

Re:4043 byte PC emulator (2013) by szc on Friday October 12, 2018 @06:16AM (#18200411)
Very true || !false. The 3rd, 4th and 5th ways to encode a switch can be done using <disconnected>