2025-05-17 # Micro Programs
Hey! Retro_Dev here. Not too long ago, I got obsessed over producing obscenely compact binaries for certain tasks. Of course, I only bother producing x86_64-linux binaries. I get frustrated working with windows. Additionally, I really like using the Zig programming language - it gives me great tools for making these small programs. Here is a collection of my produced projects. All of the base64 text directly encodes the program binaries.
256 bytes - 8k PPM mandelbrot renderer
Simply run the program, piping it's output to a file. The result is a grayscale 7680 by 4800 pixel mandelbrot render. Pretty sweet for 256 bytes, right? One of the key optimizations here is avoiding all floating point logic! Does it sound complicated? Well fortunately for us, I was able to use the divisor in the "pixel offset" to "complex coordinate" conversion as the scale factor for the fixed point numbers. Additionally, zig's amazing comptime system let me bump this divisor to a power of two, so that LLVM could compile this as a single bitshift.
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABUAAAA
VAABAFQAAQCsAAAArQAAAAcAAAAAEAAAVYnlU1dWg+wMahFaue8AAQDodgAAALug9v//gftgCQAAdGe/
AO3//4ld7IH/AAsAAHRUtf+Jfeix/4DpAXIxif4Pr/fB7guJ2A+vw8HoC40UBoH6AEAAAHcWD6/fi33o
KccB9wHbwfsLA13siM3ryoht841N8zHSQugOAAAAi33oR4td7OukQ+uRDwtVieVTagRYMdtDzYBbXcNQ
NQo3NjgwIDQ4MDAKMjU1Cg==
428 bytes - command line sudoku solver
This project gave me the biggest headache. Many programmers have implemented their own sudoku solver. It
is an entirely different problem to modify current algorithms to compile to shorter and fewer
instructions. Interestingly enough, I managed to optimize the standard backtracking algorithm the most
after refactoring my code to be faster, rather than just smaller! Strange solutions turn up in strange
places. Here is an example usage of the program:
./sudoku 530070000600195000098000060800060003400803001700020006060000280000419005000080079
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABUAAAA
VAABAFQAAQBYAQAAWAEAAAcAAAAAEAAAieBQ6AAAAABVieVTV1aD7GyLRQiLUAgxwIoMAoTJdA2AwdCI
DAKITAWLQOvsiVXsihoxybcDhNsPhKEAAACJyDHSagle9/aNPMCJVeSLdewB8vfYiUXoifgpyIl94AH+
iXXcavdehfZ0JY08MIP/93QJi33cOlw3CXR6i33oAfeD//d0BDoadGyDwglG69eJyDHSahte9/aJwg+2
ReT29w+29GvCGwHIKfAx0itF4ANF7DH2g/oDdCGJVehq/V+F/3QOMdI6XDgDD5TCAdZH6+6LVehCg8AJ
69qD/gF1FotF7IA8CAB0J0GD+VF19Osqhcl0XUmAfA2LAHX0i0XsihwI/suIHAgPhSn////r4cYECAmz
Cekc////aq9ejU3zMdtDaglfhfZ0J4tF7IpEMFEEMIhF82oEWInazYBPdQ7GRfMKagRYidrNgGoJX0br
1THAQDHbzYA=
636 bytes - snake game
Finally we arrive to the original motivation behind this obsession. A fully contained, statically linked x86 linux snake game. I really enjoyed making this project. While the project has existed for a while, I keep finding new ways to improve the game. Originally I was struggling to make the game work with the most barebones of logic. It's amazing to see how small these x86 ELF binaries can become. Definitely a bigger challenge than my 512 byte bootloader snake game - that game had no PHDR or ELF header to take up space :)
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABUAAAA
VAABAFQAAQAoAgAAKwIAAAcAAAAAEAAAVYnlU1dWgexQHgAAajZejVWkifAx27kBVAAAzYDGQhcAgGIM
/YnwMdu5BFQAAM2AvoAHAABqBFgx20O5VAIBAGoUWs2AuKIAAAC7awIBADHJzYAxwLmABwAAjb2k4f//
86vGReQCx0XgmgIAAL80BQAAsAKJRehqBViJRexqA1gx241NpDHSQs2AhcB0GIpFpAS/i03oMME8A3fh
gOEDgPkBdNnrA4tF6CQDiEXwuADi//+LXeCFwHQWi1QFpDHJg+oBcgKJ0YlMBaSDwATr5onYMdJqUFn3
8Q+2RfCJReiD4AP/JIVAAgEAg/tQarDrKoP6T7gBAAAAD4Q2////6yGF0rj/////D4Qn////6xKNg9D4
//+D+FBqUFgPghP///8Bw4O8naTh//8AD4UD////i0XsiYSdpOH//zn7iV3gdSmLDXsCAQBpyc0NAQBB
icgx0vf2g7yVpOH//wB16YnXg0XsBYkNewIBAGoEWDHbQ7lQAgEAagNazYAx9oH+gAcAAHROsCs593QW
i4y1pOH//7BAO03sdAiFybAudAKwb4hFpGoEWDHbQ41NpInazYBGifAx0ma5UABm9/FmhdJ1u2oEWDHb
Q7lpAgEAidrNgOuquKIAAAC7cwIBADHJzYC+gAcAAOmR/v//PgEBAGQBAQBFAQEAVQEBABtbSAAbWzJK
G1sxMjszNkjOvC1TbmVrIQAKAAAAAACA+KkyAAAAAMBoeAQB