== Description of C64 Assembler Submission for VC3 2021 Christmas tree program ==

The widths of the Christmas tree are 1,3,5,7,3,7,11,15,5,11,17,23,3,3. While a nested loop can easily calculate the first 12 numbers, I found it shorter to store them in memory with an offset of -1. This makes the first number 0. Since C64 BASIC initializes A, X and Y values to 0 in addresses 780-782, we can assume A, X  and Y to be 0 after the first SYS call, which helps handling the first "0" case without a table entry. To achieve this, we start by jumping into the middle of the loop, saving the need to pull the 0 value. The loop consists of printing cursor right characters (with the help of a Kernal function) until we are at the right place to start with the asterisks for drawing the tree. We use a direct decrement of the stored width, hence destroying the values, but since we need each value only once, this is no problem and allows for a very compact implementation. Then we issue a carriage return, increase the x register and jump back to the beginning of the loop. Unless we read a negative value, we continue drawing the remaining parts of the Christmas tree. In the end, a value from the program code will be loaded, which is $BC, the opcode for LDY addr,X, (the first instruction in the program). At this point, the program knows that the tree is fully drawn and loops forever.

The program code, including all tables necessary to operate correctly, is 43 bytes; the PRG file adds another 2 bytes for the load address. When the BASIC stub with the SYS call is included, the file size is 57 bytes.

The 57 bytes of the executable file comprise:

2 bytes      | 12 bytes   | 13 bytes   | 30 bytes
load address | BASIC stub | table data | machine code

