Skip to content

Instantly share code, notes, and snippets.

@Ismael-VC
Created March 9, 2024 03:13
Show Gist options
  • Save Ismael-VC/42ab00c9c347b5b28aae6305671eb624 to your computer and use it in GitHub Desktop.
Save Ismael-VC/42ab00c9c347b5b28aae6305671eb624 to your computer and use it in GitHub Desktop.
%d { #010e DEO }
|20 @SP |0a @CR |06 @morse-align
|100
;ascii-str print-ascii>morse
BRK
@print-ascii>morse
&while ( str* -- )
LDAk DUP is-digit ?{
print-morse-digit !&continue
} DUP is-space ?{
POP morse-space !&continue
} DUP is-newline ?{
POP cr !&continue
} DUP is-alpha ?{
print-morse-char
}
&continue
INC LDAk ?&while
POP2
JMP2r
@print-str ( str* -- )
&while
LDAk emit
INC LDAk ?&while
POP2
.SP emit
JMP2r
@print-morse-digit ( digit -- )
#30 SUB .morse-align MUL
#00 SWP ;morse ADD2
print-str
JMP2r
@print-morse-char ( char -- )
;is-alpha/lowercase? LDA ?{ #20 SUB }
#37 SUB .morse-align MUL
#00 SWP ;morse ADD2
print-str
JMP2r
@emit ( char -- ) #18 DEO JMP2r
@cr ( -- ) #0a emit JMP2r
@is-newline ( char -- !f ) #0a EQU #00 EQU JMP2r
@is-space ( char -- !f ) #20 EQU #00 EQU JMP2r
@morse-space ( -- ) #2020 #20 emit emit emit JMP2r
@is-digit ( char -- !f ) DUP #2f GTH SWP #3a LTH AND #00 EQU JMP2r
@is-uppercase ( char -- !f ) #40 GTH SWP #5b LTH AND #00 EQU JMP2r
@is-lowercase ( char -- !f ) #60 GTH SWP #7b LTH AND #00 EQU JMP2r
@is-alpha ( char -- !f )
DUPk DUP is-uppercase
ROT ROT is-lowercase
DUP ,&lowercase? STR
ORA #00 EQU
JMP2r
&lowercase? $1
@ascii-str
"Hello -SP "UXN -CR
"ASCII -SP "to -SP "Morse -SP "Code -CR $1
@morse
&0 "----- $1 &1 ".---- $1 &2 "..--- $1 &3 "...-- $1
&4 "....- $1 &5 "..... $1 &6 "-.... $1 &7 "--... $1
&8 "---.. $1 &9 "----. $1
&A ".- $4 &B "-... $2 &C "-.-. $2 &D "-.. $3
&E ". $5 &F "..-. $2 &G "--. $3 &H ".... $2
&I ".. $4 &J ".--- $2 &K "-.- $3 &L ".-.. $2
&M "-- $4 &N "-. $4 &O "--- $3 &P ".--. $2
&Q "--.- $2 &R ".-. $3 &S "... $3 &T "- $5
&U "..- $3 &V "...- $2 &W ".-- $3 &X "-..- $2
&Y "-.-- $2 &Z "--.. $2
@saw
0003 0609 0c0f 1215 181b 1e21 2427 2a2d
3033 3639 3b3e 4143 4649 4b4e 5052 5557
595b 5e60 6264 6667 696b 6c6e 7071 7274
7576 7778 797a 7b7b 7c7d 7d7e 7e7e 7e7e
7f7e 7e7e 7e7e 7d7d 7c7b 7b7a 7978 7776
7574 7271 706e 6c6b 6967 6664 6260 5e5b
5957 5552 504e 4b49 4643 413e 3b39 3633
302d 2a27 2421 1e1b 1815 120f 0c09 0603
00fd faf7 f4f1 eeeb e8e5 e2df dcd9 d6d3
d0cd cac7 c5c2 bfbd bab7 b5b2 b0ae aba9
a7a5 a2a0 9e9c 9a99 9795 9492 908f 8e8c
8b8a 8988 8786 8585 8483 8382 8282 8282
8182 8282 8282 8383 8485 8586 8788 898a
8b8c 8e8f 9092 9495 9799 9a9c 9ea0 a2a5
a7a9 abae b0b2 b5b7 babd bfc2 c5c7 cacd
d0d3 d6d9 dcdf e2e5 e8eb eef1 f4f7 fafd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment