The "10 print" maze generator in 15 bytes of x86 assembler.
Fifteen bytes
thread:
mov dl,'/'
in al,41h
aaa
jp print
mov dl,'\'
print:
mov ah,02h
int 21h
jmp thread
It ain't much yet this reproduces the famous 10 print
program from the Commodore 64 Basic manual featured in a brilliant book 10 print by Nick Montfort et al.
The original
10 PRINT CHR$(205.5+RND(1)); : GOTO 10
The original Commodore 64 BASIC program consists in an infinite loop that randomly prints out the character 205 or 206, i.e. the slash or back-slash characters, which as they fill the screen form some intricate pattern akin to a maze or a weaving thread.
How does it work
There is not much science in this piece of code.
The register dl
is first set to output the character /
, then we check the system clock, do a little BCD ( binary coded decimal ) dance around the current tick count, and either jump to output the character stored in dl
, or switch dl
to the character \
and output it, and finaly we repeat the procedure until the user breaks the program by pressing Ctrl+C
.
Kicking the ball
My x86 fu was rusty, so my only hope with this production was to get the ball rolling and see other takes on this seemingly simple problem.
About one hour after I published Thread JS on Pouet, a comment in Thread over, the 12 bytes record on C64 linked to 10 and 11 bytes versions of 10 PRINT
program for DOS turning the memory into a woven maze!
Ten bytes
init:
scasb
salc
and al,'\'-'/'
add al,'/'
int 29h
jmp init
Mission accomplished
The feedback to Thread on Pouet.net was positive. This took off some of the dust out of my x86 assembler fu, got some cool tricks and pointers from the best size optimizers and shed some light on even smaller renditions of the 10 PRINT
program.
Other recent experiments
There are many experiments and projects like THREAD to discover other here.
- FRONTFEST MOSCOW It was an honour to be invited to Fronfest Moscow 2017 with the little family to give my first workshop; implementing a Twin-stick shooter using ES6 and Canvas, and to continue my CODE🎙ART series of talks + live coding aiming to inspire new web developer artists. on November 18th, 2017
- VOLTRA VOLTRA: Grinding the Universe, a gritty JavaScript demo, winner of the 1024 bytes demo competition at the Assembly 2017. on August 6th, 2017
- BREATHING EARTH Another take on Nadieh Bremer mesmerizing Breathing Earth visualisation, running at 60fps on a 2D Canvas without libraries or frameworks. on June 26th, 2017
- DRAGON PUNCH An itsy bitsy Dragon curve renderer in 121 bytes. on February 26th, 2014
- THREAD JS Breaking the 64 bytes fronteer with the famous "10 print" maze generator. on December 16th, 2013
- JS1K SPEECH SYNTHESIZER Sorry but I didn't have the time nor felt like doing heavy 3D, FPS game, particle systems, flying hearts and flowers for JS1K#4. This time, Audio was ON and several entries featured a melody and other simple sound effects, so I had to make a Speech Synthesizer in 1K of JavaScript. on March 14th, 2012
- TILT SHIFT A very fast & simple tilt-shift effect in Canvas. on January 10th, 2009
- ASAHIKAWA Flyby the city of Asahikawa in 64 bytes. on January 21st, 2007
Let's talk
Don't be shy; get in touch by mail, twitter, github, linkedin or pouet if you have any questions, feedback, speaking, workshop or performance opportunity.