10 PRINT Marches on

The news service of my school at MIT, the School of Humanities, Arts, and Social Sciences, has an article about 10 PRINT CHR$(205.5+RND(1)); : GOTO 10.

Also, there has been some furious and pretty amazing program creation and compaction going on in DOS/x86 land. It all seems to have started when demoscener Trixter (a.k.a. Jim Leonard) decided to port 10 PRINT to x86 assembly. His first, straightforward version was 42 bytes long, but he was quickly able to chop it down by replacing the random number generator with a single instruction: 25 bytes. Getting ready of some of the nice and tidy but strictly unnecessary startup and shutdown code brought the program down to 15 bytes. Then, thanks to the clever use of an opcode that I’d never heard of before which is meant for string comparison and is called SCAS, he was able to trim the code to 13 bytes — the shortest he thought it could ever be.

Of course, someone (Peter Ferrie) found a way to get rid of another byte, so the program sat at 12 bytes long.

herm1t came along to provide an optimization that assumed DOS was loaded, reducing the program to 11 bytes.

And, most recently, Peter Ferrie returned to lop off another byte, showing that the program (on Intel CPUs, at least) need only be 10 bytes long.

Trixter provides the full story (so far!) on his blog, Oldskooler Ramblings.

My joke about this is that the shortest possible 10-PRINT-like program will be a single jmp instruction to a run of 8 or 9 bytes that happen to already be in memory. However, this is probably only a joke: the number of possible 8-byte combinations of bits are 256^8 = 18446744073709551616, so it really isn’t very likely, even for an extremely short program of this sort, that it will just happen to be lying around somewhere in memory initially.

Speaking of the demoscene, I mentioned in my last post that viznut has checked out the book. He’s also written a very nice VIC-20 version of the program that uses two of the tiles from the Black Path Game instead of the original diagonal lines:

0 FORI=7168TO7183:READA:POKEI,A:NEXT:POKE36869,255
1 PRINTCHR$(64.5+RND(.));:GOTO1
2 DATA16,16,32,192,3,4,8,8,8,8,4,3,192,32,16,16

The result:

VIC-20 Black Path Game version of 10 PRINT

Finally, we had a great time exhibiting the 10 PRINT program and the 10 PRINT book at the 2013 MLA’s electronic literature exhibit and presenting the program and modifications of it at the MLA offsite electronic literature reading. Thanks to Dene Grigar and Kathi Inman Berens for curating the exhibit and the reading. And, thanks to Patsy Baudoin, Mark C. Marino, and Mark Sample for joining me for that presentation and for offering commentary (play-by-play and color) as I coded on the Commodore 64.

One Reply to “10 PRINT Marches on”

  1. Hello,

    I did have a Commodore 116/16 in the 80’s as a boy, but I haven’t known the 10 PRINT program until recently. I used to draw the pattern on a graph paper, though, when I was bored at school. Later, I implemented a program in Perl that tries to change the maze to eliminate its unreachable parts by connecting them to the existing path. You can view the code at PerlMonks [http://www.perlmonks.org/?node_id=843144] and watch a screencast at Youtube [https://www.youtube.com/watch?v=HqyeksHSoRo].

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

This site uses Akismet to reduce spam. Learn how your comment data is processed.