Last active
December 13, 2022 07:24
-
-
Save skiselev/bff33b85970619dfb4b97846d1e3c905 to your computer and use it in GitHub Desktop.
ASCII Art snowflake challenge - 2022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; SNWFLK.ASM - PRINT CHRISTMAS STAR ON THE CONSOLE | |
; WRITTEN BY SERGEY KISELEV <[email protected]> | |
; | |
; RUNS ON CP/M SYSTEMS WITH INTEL 8080, ZILOG Z80 | |
; AND COMPATIBLE PROCESSORS | |
; | |
; BUILDING AND RUNNIG STEPS: | |
; A>ASM SNWFLK | |
; A>LOAD SNWFLK | |
; A>SNWFLK | |
BDOS EQU 5 | |
WCHAR EQU 2 ; CP/M WRITE CHARACTER TO CONSOLE | |
ORG 0100H | |
LXI H,ZDAT ; POINTER TO THE COMPRESSED DATA | |
LOOP: MOV A,M ; GET THE NEXT BYTE | |
CALL DSPTCH | |
MOV A,M ; GET THE BYTE AGAIN | |
RLC ; ROTATE LEFT | |
RLC ; ROTATE LEFT | |
RLC ; ROTATE LEFT | |
RLC ; ROTATE LEFT | |
CALL DSPTCH | |
INX H | |
JMP LOOP | |
DSPTCH: ANI 0FH ; GET LOW NIBBLE | |
JZ EXIT ; EXIT IF CODE EQUALS TO ZERO | |
PUSH H ; PRESERVE H | |
DCR A | |
LXI H,INDEX | |
ADD L | |
MOV L,A | |
MOV A,M ; A = INDEX[NIBBLE] | |
RLC | |
RLC | |
RLC | |
RLC | |
ANI 0FH ; A = TOKEN LENGHT - 1 | |
INR A | |
MOV D,A ; D = TOKEN LENGHT | |
MOV A,M ; A = INDEX[NIBBLE] | |
ANI 0FH ; A = TOKEN INDEX IN TOKEN[] | |
LXI H,TOKENS | |
ADD L | |
MOV L,A ; HL = TOKEN OFFSET | |
PRINT: PUSH H | |
MVI C,WCHAR | |
MOV E,M | |
CALL BDOS ; OUTPUT TO THE CONSOLE | |
POP H | |
INX H | |
DCR D | |
JNZ PRINT | |
EXIT: POP H | |
RET | |
; COMPRESSED DATA TABLE WITH THE SNOWFLAKE ASCII ART | |
ZDAT DB 4 OR 2 SHL 4, 4 OR 14 SHL 4 ; * * | |
DB 3 OR 6 SHL 4, 2 OR 7 SHL 4, 14 OR 3 SHL 4 ; _\/ \/_ (+ ' ') | |
DB 1 OR 6 SHL 4, 7 OR 14 SHL 4 ; _\/\/_ | |
DB 1 OR 5 SHL 4, 5 OR 6 SHL 4, 7 OR 8 SHL 4, 8 OR 14 SHL 4 ; _\_\_\/\/_/_/_ | |
DB 2 OR 12 SHL 4, 1 OR 12 SHL 4, 10 OR 11 SHL 4 ; / /_/\/\_ | |
DB 13 OR 1 SHL 4, 13 OR 14 SHL 4 ;\ \ | |
DB 3 OR 1 SHL 4, 10 OR 11 SHL 4, 14 OR 3 SHL 4 ; _/\/\_ (+ ' ') | |
DB 1 OR 12 SHL 4, 13 OR 2 SHL 4, 12 OR 13 SHL 4 ; /\ / | |
DB 14 OR 4 SHL 4 ;\ (+ ' *') | |
DB 2 OR 4 SHL 4 ; * * (- CRLF) | |
DB 14 OR 15 SHL 4, 14 OR 0 SHL 4 ;Merry Christmas | |
INDEX DB 0 OR (1-1) SHL 4 ; 1 - ' ' | |
DB 0 OR (2-1) SHL 4 ; 2 - ' ' | |
DB 0 OR (4-1) SHL 4 ; 3 - ' ' | |
DB 0 OR (5-1) SHL 4 ; 4 - ' *' | |
DB 5 OR (2-1) SHL 4 ; 5 - '_\' | |
DB 5 OR (3-1) SHL 4 ; 6 - '_\/' | |
DB 6 OR (3-1) SHL 4 ; 7 - '\/_' | |
DB 7 OR (2-1) SHL 4 ; 8 - '/_' | |
DB 8 OR (2-1) SHL 4 ; 9 - '_/' | |
DB 8 OR (3-1) SHL 4 ; 10 - '_/\' | |
DB 9 OR (3-1) SHL 4 ; 11 - '/\_' | |
DB 9 OR (1-1) SHL 4 ; 12 - '/' | |
DB 10 OR (1-1) SHL 4 ; 13 - '\' | |
DB 12 OR (2-1) SHL 4 ; 14 - CR-LF | |
DB 14 OR (16-1) SHL 4 ; 15 - 'Merry Christmas' | |
TOKENS DB ' *' | |
DB '_\/_/\_' | |
DB 0Dh, 0Ah | |
DB 'Merry Christmas!' | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment