wake up! 16b
wake up! 16b
Released at the Outline Demoparty in May 2026, Ommen, NL
An exploration of algorithmic density in 16 bytes of x86 assembly.
Watch Video
Demozoo Entry
In the demoscene, exploring what can be achieved within extreme constraints is a rewarding technical challenge. The following 16 bytes of x86 real-mode DOS assembly code represent a careful exercise in algorithmic density. When executed, it utilizes the computer's video memory as a calculation space to draw an infinite Sierpinski fractal, while simultaneously interpreting that geometry as audio data.
int 10h ; 2 bytes<br>mov bh, 0xb8 ; 2 bytes<br>mov ds, bx ; 2 bytes<br>L:<br>lodsb ; 1 byte<br>sub si, byte 57 ; 3 bytes<br>xor [si], al ; 2 bytes<br>out 61h, al ; 2 bytes<br>jmp short L ; 2 bytes
1. The Canvas: A Primed Void
The code begins with a standard BIOS interrupt: int 10h. This initializes Video Mode 0, establishing a 40x25 text mode grid. The subsequent instructions point the Data Segment (DS) to 0xB800, the physical memory address of the VGA/CGA text buffer.
When the BIOS clears the screen during this interrupt, it does not fill the memory with absolute zeroes. In text mode, every character space consists of two bytes: the ASCII character and the color attribute. The BIOS initializes all 2,000 character slots uniformly: the ASCII byte is set to 0x20 (the Space character), and the color byte is set to 0x07 (Light Gray text on a Black background). While the screen appears completely empty, it is actually a canvas primed with a uniform pattern of data.
The Importance of Uniformity: The mathematical progression we are about to explore relies on a predictable environment. If the memory contained random artifact data, the algorithmic calculations would ingest those discrepancies. In a cellular automaton, an unexpected bit can disrupt the pattern. A reasonably uniform memory space provides a foundation for the fractal to emerge clearly.
2. The Engine: Additive Prefix Sums
To understand the pure mathematics of the fractal, let us temporarily isolate our variables. We will model a perfectly zeroed state instead of the base 0x20 initialization. Additionally, we will substitute add instead of xor, and step forward by 16 bytes at a time across this memory, assuming the accumulator AL is loaded with the value 2 .
A real-mode DOS segment spans exactly 65,536 bytes. By moving forward 16 bytes per iteration, it takes exactly 4,096 steps to traverse the segment (\( 65536 / 16 = 4096 \)). When the SI register advances past 0xFFFF, it wraps cleanly back to 0x0000.
As the loop progresses, it adds the current value of the accumulator to the memory cell, reading the updated value back into the accumulator. This effectively creates a running prefix sum. Because 4,096 is a multiple of 256 (the capacity of our 8-bit register), the mathematical carryover aligns when the segment wraps, cleanly resetting AL to 2 at the end of each full sweep.
The value of the \( k \)-th modified cell during pass \( p \) across the segment follows a binomial coefficient sequence, scaled by our initial value of 2:
$$A^{(p)}[k] \equiv 2 \binom{k+p}{p-1} \pmod{256}$$
The following table illustrates the first 16 steps of calculation across 16 memory cells, demonstrating how the values accumulate row by row:
Pass \ Cell
3. Crystallization: XOR and the Sierpinski Shift
A deeper pattern is present within those decimal values. When performing binary addition, the bit-planes carry over into adjacent positions. However, if we discard the arithmetic carry and perform addition strictly modulo 2, we are left with the Exclusive OR (XOR) operation.
By using xor instead of add, the algorithm isolates the bit-planes. Because our modeled starting value is 2 (binary 00000010), only Bit 1 is ever affected by this specific calculation. The cascading decimal numbers become a pure toggle between 0x00 and 0x02. This progression maps perfectly to Rule 60 in Stephen Wolfram's elementary cellular automata:
$$Cell^{(p)}[k] = Cell^{(p-1)}[k] \oplus Cell^{(p)}[k-1]$$
According to Lucas's Theorem, this XOR relationship is mathematically guaranteed to match the state of Bit 1 from the additive table. We can validate this by visualizing the binary propagation (where '2' denotes Bit 1 being set):
Pass \ Cell
4. The Voice of the Machine: Translating Data to Audio
A remarkably elegant detail lies in the instruction: out 61h, al
Port 61h interfaces with the internal PC speaker. Bit 1 of this port directly controls the speaker cone by pushing it outward when set to 1, and returning it when set to 0. Our routine computes the fractal via XOR, updates the memory, and immediately sends that byte to the speaker port.
Because the algorithm specifically isolates and toggles Bit 1, the geometry of the Sierpinski triangle serves as a direct set of instructions for the speaker cone. The execution speed of the CPU establishes the functional sample rate.
The patterns of 1s and 0s generated by the fractal yield...