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.
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABU
AAAAVAABAFQAAQCsAAAArQAAAAcAAAAAEAAAVYnlU1dWg+wMahFaue8AAQDodgAAALug9v//gftg
CQAAdGe/AO3//4ld7IH/AAsAAHRUtf+Jfeix/4DpAXIxif4Pr/fB7guJ2A+vw8HoC40UBoH6AEAA
AHcWD6/fi33oKccB9wHbwfsLA13siM3ryoht841N8zHSQugOAAAAi33oR4td7OukQ+uRDwtVieVT
agRYMdtDzYBbXcNQNQo3NjgwIDQ4MDAKMjU1Cg==
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
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABU
AAAAVAABAFQAAQBYAQAAWAEAAAcAAAAAEAAAieBQ6AAAAABVieVTV1aD7GyLRQiLUAgxwIoMAoTJ
dA2AwdCIDAKITAWLQOvsiVXsihoxybcDhNsPhKEAAACJyDHSagle9/aNPMCJVeSLdewB8vfYiUXo
ifgpyIl94AH+iXXcavdehfZ0JY08MIP/93QJi33cOlw3CXR6i33oAfeD//d0BDoadGyDwglG69eJ
yDHSahte9/aJwg+2ReT29w+29GvCGwHIKfAx0itF4ANF7DH2g/oDdCGJVehq/V+F/3QOMdI6XDgD
D5TCAdZH6+6LVehCg8AJ69qD/gF1FotF7IA8CAB0J0GD+VF19Osqhcl0XUmAfA2LAHX0i0XsihwI
/suIHAgPhSn////r4cYECAmzCekc////aq9ejU3zMdtDaglfhfZ0J4tF7IpEMFEEMIhF82oEWIna
zYBPdQ7GRfMKagRYidrNgGoJX0br1THAQDHbzYA=
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 :)
f0VMRgEBAQAAAAAAAAAAAAIAAwABAAAAVAABADQAAAAAAAAAAAAAADQAIAABACgAAAAAAAEAAABU
AAAAVAABAFQAAQAoAgAAKwIAAAcAAAAAEAAAVYnlU1dWgexQHgAAajZejVWkifAx27kBVAAAzYDG
QhcAgGIM/YnwMdu5BFQAAM2AvoAHAABqBFgx20O5VAIBAGoUWs2AuKIAAAC7awIBADHJzYAxwLmA
BwAAjb2k4f//86vGReQCx0XgmgIAAL80BQAAsAKJRehqBViJRexqA1gx241NpDHSQs2AhcB0GIpF
pAS/i03oMME8A3fhgOEDgPkBdNnrA4tF6CQDiEXwuADi//+LXeCFwHQWi1QFpDHJg+oBcgKJ0YlM
BaSDwATr5onYMdJqUFn38Q+2RfCJReiD4AP/JIVAAgEAg/tQarDrKoP6T7gBAAAAD4Q2////6yGF
0rj/////D4Qn////6xKNg9D4//+D+FBqUFgPghP///8Bw4O8naTh//8AD4UD////i0XsiYSdpOH/
/zn7iV3gdSmLDXsCAQBpyc0NAQBBicgx0vf2g7yVpOH//wB16YnXg0XsBYkNewIBAGoEWDHbQ7lQ
AgEAagNazYAx9oH+gAcAAHROsCs593QWi4y1pOH//7BAO03sdAiFybAudAKwb4hFpGoEWDHbQ41N
pInazYBGifAx0ma5UABm9/FmhdJ1u2oEWDHbQ7lpAgEAidrNgOuquKIAAAC7cwIBADHJzYC+gAcA
AOmR/v//PgEBAGQBAQBFAQEAVQEBABtbSAAbWzJKG1sxMjszNkjOvC1TbmVrIQAKAAAAAACA+Kky
AAAAAMBoeAQB