2023-04-10 18:02:25 -04:00
|
|
|
|0100
|
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@on-reset ( -> )
|
2023-04-10 18:02:25 -04:00
|
|
|
;tests/end ;tests
|
2023-10-28 12:02:44 -04:00
|
|
|
&l ( -- )
|
|
|
|
LDA2k JSR2 test INC2 INC2 GTH2k ?&l
|
2023-04-10 18:02:25 -04:00
|
|
|
POP2 POP2
|
2024-01-08 23:08:24 -05:00
|
|
|
( lb ) #0a18 DEO
|
2023-10-28 12:02:44 -04:00
|
|
|
( debugger ) #010e DEO
|
|
|
|
( exit ) #800f DEO
|
|
|
|
BRK
|
2023-04-10 18:02:25 -04:00
|
|
|
|
|
|
|
@test ( f -- )
|
2023-10-28 12:02:44 -04:00
|
|
|
#30 ADD #18 DEO
|
|
|
|
JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
(
|
|
|
|
@|tests )
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-04-10 18:09:17 -04:00
|
|
|
@tests [
|
|
|
|
=test-dec1 =test-dec2 =test-dec3 =test-dec4
|
2024-01-08 23:08:24 -05:00
|
|
|
=test-hex1 =test-hex2 =test-hex3 =test-hex4
|
2024-01-09 23:27:57 -05:00
|
|
|
=test-scmp1 =test-scmp2 =test-scmp3 =test-scmp4
|
|
|
|
=test-scpy1 ] &end
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-dec1
|
2024-01-08 23:08:24 -05:00
|
|
|
#0a18 DEO
|
2023-10-28 12:02:44 -04:00
|
|
|
;dict/dec1 sdec #1234 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-dec2
|
|
|
|
;dict/dec2 sdec #0123 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-dec3
|
|
|
|
;dict/dec3 sdec #0000 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-dec4
|
|
|
|
;dict/dec4 sdec #0000 EQU2 JMP2r
|
2023-04-10 22:59:42 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-hex1
|
2024-01-08 23:08:24 -05:00
|
|
|
#0a18 DEO
|
2023-10-28 12:02:44 -04:00
|
|
|
;dict/hex1 shex #12c0 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-hex2
|
|
|
|
;dict/hex2 shex #034f EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-hex3
|
|
|
|
;dict/dec3 sdec #0000 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@test-hex4
|
|
|
|
;dict/dec4 sdec #0000 EQU2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2024-01-08 23:08:24 -05:00
|
|
|
@test-scmp1
|
|
|
|
#0a18 DEO
|
|
|
|
{ "text 00 }
|
|
|
|
STH2r { "text 00 }
|
|
|
|
STH2r scmp #01 EQU JMP2r
|
|
|
|
|
|
|
|
@test-scmp2
|
|
|
|
{ "text 00 }
|
|
|
|
STH2r { "te 00 }
|
|
|
|
STH2r scmp #00 EQU JMP2r
|
|
|
|
|
|
|
|
@test-scmp3
|
|
|
|
{ "textext 00 }
|
|
|
|
STH2r { "text 00 }
|
|
|
|
STH2r scmp #00 EQU JMP2r
|
|
|
|
|
|
|
|
@test-scmp4
|
|
|
|
{ 00 "ext 00 }
|
|
|
|
STH2r { "text 00 }
|
|
|
|
STH2r scmp #00 EQU JMP2r
|
|
|
|
|
2024-01-09 23:27:57 -05:00
|
|
|
@test-scpy1
|
|
|
|
#0a18 DEO
|
|
|
|
{ "hello 00 }
|
|
|
|
STH2kr ;&buf <scpy>
|
|
|
|
STH2r ;&buf scmp #01 EQU JMP2r
|
|
|
|
&buf $10
|
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
2024-01-09 23:21:14 -05:00
|
|
|
@scap ( str* -: end* )
|
|
|
|
INC2 & LDAk ?scap
|
2023-10-28 12:02:44 -04:00
|
|
|
JMP2r
|
|
|
|
|
2024-01-09 23:21:14 -05:00
|
|
|
@slen ( str* -: len* )
|
|
|
|
DUP2 scap/ SWP2 SUB2 JMP2r
|
2023-10-28 12:02:44 -04:00
|
|
|
|
2024-01-09 23:21:14 -05:00
|
|
|
@<scpy> ( src* dst* -: )
|
|
|
|
STH2
|
|
|
|
&w ( src* `dst* -- )
|
|
|
|
LDAk #00 STH2kr STA2
|
2023-10-28 12:02:44 -04:00
|
|
|
INC2r INC2 LDAk ?&w
|
2024-01-09 23:21:14 -05:00
|
|
|
POP2 POP2r JMP2r
|
|
|
|
|
|
|
|
@<sput> ( chr str* -: )
|
|
|
|
STH2
|
|
|
|
#00 STH2r scap/ STA2
|
2023-10-28 12:02:44 -04:00
|
|
|
JMP2r
|
|
|
|
|
2024-01-09 23:21:14 -05:00
|
|
|
@<sclr> ( str* -: )
|
|
|
|
STH2
|
|
|
|
#00 STH2r
|
2023-10-28 12:02:44 -04:00
|
|
|
&w ( -- )
|
2024-01-09 23:21:14 -05:00
|
|
|
STAk INC2 LDAk ?&w
|
|
|
|
STA
|
|
|
|
JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@scmp ( a* b* -- f )
|
2024-01-09 11:22:32 -05:00
|
|
|
STH2
|
|
|
|
&l ( -- )
|
|
|
|
LDAk ?{
|
|
|
|
&d LDA LDAr STHr EQU JMP2r }
|
|
|
|
LDAk LDAkr STHr NEQ ?&d
|
|
|
|
INC2 INC2r !&l
|
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@sdec ( str* -- val* )
|
|
|
|
[ LIT2r 0000 ]
|
|
|
|
&w ( -- )
|
|
|
|
( validate ) LDAk [ LIT "0 ] SUB #09 GTH ?&end
|
|
|
|
( accumulate ) [ LIT2r 000a ] MUL2r
|
2024-01-08 23:08:24 -05:00
|
|
|
( combine ) LDAk [ LIT "0 ] SUB [ LITr 00 ] STH
|
|
|
|
ADD2r
|
2023-10-28 12:02:44 -04:00
|
|
|
( continue ) INC2 LDAk ?&w
|
|
|
|
&end POP2 STH2r JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@shex ( str* -- val* )
|
|
|
|
[ LIT2r 0000 ]
|
|
|
|
&w ( -- )
|
|
|
|
( validate ) LDAk chex INC #00 EQU ?&end
|
|
|
|
( accumulate ) [ LITr 40 ] SFT2r
|
2024-01-08 23:08:24 -05:00
|
|
|
( combine ) LDAk chex [ LITr 00 ] STH
|
|
|
|
ADD2r
|
2023-10-28 12:02:44 -04:00
|
|
|
( continue ) INC2 LDAk ?&w
|
|
|
|
&end POP2 STH2r JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@chex ( c -- val|ff )
|
|
|
|
( dec ) [ LIT "0 ] SUB DUP #09 GTH ?{ JMP2r }
|
|
|
|
( hex ) #27 SUB DUP #0f GTH ?{ JMP2r }
|
|
|
|
( err ) POP #ff JMP2r
|
|
|
|
|
|
|
|
(
|
|
|
|
@|print )
|
|
|
|
|
|
|
|
@<pstr> ( str* -- )
|
|
|
|
&w ( -- )
|
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 & LDAk ?&w
|
|
|
|
POP2 JMP2r
|
|
|
|
|
|
|
|
@<phex> ( short* -- )
|
|
|
|
SWP <phex>/b
|
|
|
|
&b ( -- )
|
|
|
|
DUP #04 SFT <phex>/c
|
|
|
|
&c ( -- )
|
|
|
|
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@<pdec> ( short* -- )
|
|
|
|
#2710 [ LIT2r 00fb ]
|
|
|
|
&w ( -- )
|
|
|
|
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
|
|
|
|
DUP [ LIT "0 ] ADD #19 DEO
|
|
|
|
INCr }
|
|
|
|
POP2 #000a DIV2 SWPr INCr STHkr ?&w
|
|
|
|
POP2r POP2 POP2 JMP2r
|
|
|
|
|
|
|
|
@<pmem> ( addr* -- )
|
|
|
|
#0000
|
|
|
|
&l ( -- )
|
|
|
|
ADD2k LDA <phex>/b
|
|
|
|
DUP #0f AND #0f NEQ #16 MUL #0a ADD #18 DEO
|
|
|
|
INC NEQk ?&l
|
|
|
|
POP2 POP2 JMP2r
|
2023-04-10 18:02:25 -04:00
|
|
|
|
2023-04-10 22:59:42 -04:00
|
|
|
(
|
|
|
|
@|assets )
|
|
|
|
|
2023-10-28 12:02:44 -04:00
|
|
|
@dict &dec1 "4660 $1
|
2023-04-10 18:02:25 -04:00
|
|
|
&dec2 "291 $1
|
2023-04-10 18:09:17 -04:00
|
|
|
&dec3 "0 $1
|
|
|
|
&dec4 "q2x*63? $1
|
2023-04-10 18:02:25 -04:00
|
|
|
&hex1 "12c0 $1
|
|
|
|
&hex2 "34f $1
|
2023-04-10 18:09:17 -04:00
|
|
|
&hex3 "0 $1
|
|
|
|
&hex4 "q2x*63? $1
|
2023-04-10 18:02:25 -04:00
|
|
|
|