CHRISTMAS PRESENT
Author: Prevtenet
Category: Christmas Challenge
System: CP/M-80 2.2
Language: Assembler (WinApe)
Len source code: 583
Len exe file: 66
Len code only: 66
Instructions:
Load the .COM file onto a machine or emulator running CP/M-80 2.2 and execute
from the command prompt by typing PRESENT. The official platform this is
claimed to run correctly on is the very quirky combination of CPvM running on
SymbOS 4 running on an Amstrad CPC (three layers of 8-bit! See symbos.org for
instructions on getting any or all of this set up.) It should also run on
most other CP/M machines, but the exact output may vary slightly depending on
the exact CP/M implementation and terminal emulation.
Description:
This is essentially a tiny decompression algorithm that takes advantage of how
the present shape can be considered a group of recursively repeating subunits.
It reads bytes from itself, with three cases:
0 = return - return to the byte after the last call
<128 = call - continue reading from location 0x1xx
>128 = print - print specified character (clearing bit 7)
Comments:
Bonus puzzle - can you work out why, on many CP/M 2.2 systems, this will exit
cleanly despite lacking an actual exit condition? Hint - the answer has to do
with how the CP/M 2.2 BIOS is laid out in memory.