Author: Jonathan Harston
Category: Christmas Challenge
System: PDP11 running RT11
Language: PDP11 machine code
Source length: 1450 bytes
File length: 612 bytes
Executable length: 100 bytes
Instructions:
Copy the file 'xmas2024d' to a RT11 system as 'xmas24.sav'. Run by typing
'run xmas24'. The example is show running on a Soviet UKNC Electronia home
computer via emulation.
Description:
The program is four nested loops, looping between each block of characters,
each line of characters, each line, and each block of lines.
The output counter is toggled between 0 and 7 to output either 1 or 8 copies
of each loop: either a character horizontally or a line vertically.
The two characters used on a line are both held in a single 16-bit register,
and SWAB is used to toggle between which one is output. At the end of each
set of lines the "+-" and "! " characters are toggled between.
It turns out that to toggle between "+-" and "! " you can XOR with &0D0A,
which just happens to be the CR/LF sequence used at the end of each line,
so this is used on the return from printing the end-of-line sequence to
swap between the two character pairs.
Code space is saved by inlining all the calls to TTYOUT instead of the one
word overhead of a subroutine. If you could depend on the output device
expanding TABs into spaces, the eight spaces in the "ribbon" string could
be replaced with a single 9 byte, saving 7 bytes in the program length.
However, it's nice that the code is an exact round 100 bytes long.
The code has the standard 512-byte boiler-plate header to run on a RT11.