snowflake Author: Sergey Kiselev Category: Christmas Challenge System: IBM PC or compatibles Language: Assembler (TASM/MASM) Len source code: 2218 bytes Len exe file: 90 bytes Len code only: 90 bytes Instructions: On a real hardware: Copy vccc2025.com file to a floppy drive, boot the system into DOS, insert floppy disk into the system, and type "vccc2025" (without quotes). In an emulator: Use supplied vccc2025.img image, which is an image of a MS-DOS 3.30 bootable diskette, with the vccc2025.com and vccc2025.asm copied to it. For example, in PCjr https://www.pcjs.org/machines/pcx86/ibm/5160/cga/, press "Browse..." button at the bottom of the emulated display, browse and find vccc2025.img. Next press "Mount" button to mount the image, and then "Reset" button to reboot the system and boot from the image. Finally, once MS-DOS boots up, type "vccc2025" to run the snowflake program. Description: The code uses -9 to 9 grid in both horizontal (X) and vertical (Y) dimensions It relies on the following observations: - Symmetry: 1/8 of the image can be mirrored, and then rotated 4 times to draw the entire image - There are solid horizontal and vertical lines at X = 0 and Y = 0 - There are solid diagonal lines at Y = |X| && |X| <= 7 The solid lines are printed using simple coordinates comparison The remaining 6 asterisks are printed by comparing their absolute coordinates Comments: I did a few attempts at reducing the code size. For example, in the submitted code, SCASW instruction is used to compare the coordinates, which reduced the code size versus simple CMP / JE combination. I also tried packing absolute coordinates in a single byte - a nibble for X and Y respectively, but that did not result in the code size reduction. Similarly, I tried using an algorithmic approach to calculate absolute values, but ultimately simple comparison and conditional jumps produced the smallest code.