45 byte Christmas Present in Assembler
Author: Serato / Finnish Gold
Category: Christmas Challenge
System: C64
Language: C64 "64tass" Assembler
Len source code: 1613
Len exe file: 47
Len code only: 45
Instructions:
Load PRG and SYS713
Description:
This routine works by interpreting a script that contains either literal
characters to print, or instructions to loop back to a different section N
times. The counters for each loop are maintained separately. In this way a
recursive run-length encoding scheme is implemented.
For example, the sides of the box contain a ! followed by 8 hyphens, twice over,
with a final !. The script could represent this as "! ", loop to space 7 times,
then loop to ! 2 more times, then a new-line, then loop to ! again 7 times.
Thus that section of 160 bytes of output can be encoded in 6 bytes of script.
The entire 392 byte output is encoded in a 19 byte script. The interpreter takes
up the other 26 bytes.