Starting validation
This commit is contained in:
parent
5b3007e21c
commit
f41eb2a86f
|
@ -3,6 +3,7 @@
|
||||||
ASM="uxncli $HOME/roms/drifblim.rom"
|
ASM="uxncli $HOME/roms/drifblim.rom"
|
||||||
EMU="uxncli"
|
EMU="uxncli"
|
||||||
LIN="uxncli $HOME/roms/uxnlin.rom"
|
LIN="uxncli $HOME/roms/uxnlin.rom"
|
||||||
|
BAL="uxncli $HOME/roms/uxnbal.rom"
|
||||||
|
|
||||||
ID="stdlib"
|
ID="stdlib"
|
||||||
SRC="${ID}.tal"
|
SRC="${ID}.tal"
|
||||||
|
@ -10,6 +11,11 @@ DST="${ID}.rom"
|
||||||
CPY="$HOME/roms"
|
CPY="$HOME/roms"
|
||||||
ARG=""
|
ARG=""
|
||||||
|
|
||||||
|
if [[ "$*" == *"--bal"* ]]
|
||||||
|
then
|
||||||
|
$BAL $SRC
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$*" == *"--lint"* ]]
|
if [[ "$*" == *"--lint"* ]]
|
||||||
then
|
then
|
||||||
$LIN $SRC
|
$LIN $SRC
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
|0100
|
|0100 @on-reset ( -> )
|
||||||
|
|
||||||
@on-reset ( -> )
|
|
||||||
;tests/end ;tests
|
;tests/end ;tests
|
||||||
&l ( -- )
|
&l ( -- )
|
||||||
LDA2k JSR2 test INC2 INC2 GTH2k ?&l
|
LDA2k JSR2 test INC2 INC2 GTH2k ?&l
|
||||||
|
@ -21,62 +19,56 @@
|
||||||
=test-dec1 =test-dec2 =test-dec3 =test-dec4
|
=test-dec1 =test-dec2 =test-dec3 =test-dec4
|
||||||
=test-hex1 =test-hex2 =test-hex3 =test-hex4
|
=test-hex1 =test-hex2 =test-hex3 =test-hex4
|
||||||
=test-scmp1 =test-scmp2 =test-scmp3 =test-scmp4
|
=test-scmp1 =test-scmp2 =test-scmp3 =test-scmp4
|
||||||
=test-scpy1 ] &end
|
=test-scpy1 =test-spal1 =test-spal2 ]
|
||||||
|
&end
|
||||||
|
|
||||||
@test-dec1
|
@test-dec1 #0a18 DEO
|
||||||
#0a18 DEO
|
|
||||||
;dict/dec1 sdec #1234 EQU2 JMP2r
|
;dict/dec1 sdec #1234 EQU2 JMP2r
|
||||||
|
|
||||||
@test-dec2
|
@test-dec2 ;dict/dec2 sdec #0123 EQU2 JMP2r
|
||||||
;dict/dec2 sdec #0123 EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-dec3
|
@test-dec3 ;dict/dec3 sdec #0000 EQU2 JMP2r
|
||||||
;dict/dec3 sdec #0000 EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-dec4
|
@test-dec4 ;dict/dec4 sdec #0000 EQU2 JMP2r
|
||||||
;dict/dec4 sdec #0000 EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-hex1
|
@test-hex1 #0a18 DEO
|
||||||
#0a18 DEO
|
|
||||||
;dict/hex1 shex #12c0 EQU2 JMP2r
|
;dict/hex1 shex #12c0 EQU2 JMP2r
|
||||||
|
|
||||||
@test-hex2
|
@test-hex2 ;dict/hex2 shex #034f EQU2 JMP2r
|
||||||
;dict/hex2 shex #034f EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-hex3
|
@test-hex3 ;dict/dec3 sdec #0000 EQU2 JMP2r
|
||||||
;dict/dec3 sdec #0000 EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-hex4
|
@test-hex4 ;dict/dec4 sdec #0000 EQU2 JMP2r
|
||||||
;dict/dec4 sdec #0000 EQU2 JMP2r
|
|
||||||
|
|
||||||
@test-scmp1
|
@test-scmp1 #0a18 DEO
|
||||||
#0a18 DEO
|
|
||||||
{ "text 00 }
|
{ "text 00 }
|
||||||
STH2r { "text 00 }
|
STH2r { "text 00 }
|
||||||
STH2r scmp #01 EQU JMP2r
|
STH2r scmp #01 EQU JMP2r
|
||||||
|
|
||||||
@test-scmp2
|
@test-scmp2 { "text 00 }
|
||||||
{ "text 00 }
|
|
||||||
STH2r { "te 00 }
|
STH2r { "te 00 }
|
||||||
STH2r scmp #00 EQU JMP2r
|
STH2r scmp #00 EQU JMP2r
|
||||||
|
|
||||||
@test-scmp3
|
@test-scmp3 { "textext 00 }
|
||||||
{ "textext 00 }
|
|
||||||
STH2r { "text 00 }
|
STH2r { "text 00 }
|
||||||
STH2r scmp #00 EQU JMP2r
|
STH2r scmp #00 EQU JMP2r
|
||||||
|
|
||||||
@test-scmp4
|
@test-scmp4 { 00 "ext 00 }
|
||||||
{ 00 "ext 00 }
|
|
||||||
STH2r { "text 00 }
|
STH2r { "text 00 }
|
||||||
STH2r scmp #00 EQU JMP2r
|
STH2r scmp #00 EQU JMP2r
|
||||||
|
|
||||||
@test-scpy1
|
@test-scpy1 #0a18 DEO
|
||||||
#0a18 DEO
|
|
||||||
{ "hello 00 }
|
{ "hello 00 }
|
||||||
STH2kr ;&buf <scpy>
|
STH2kr ;&buf <scpy>
|
||||||
STH2r ;&buf scmp #01 EQU JMP2r
|
STH2r ;&buf scmp #01 EQU JMP2r
|
||||||
&buf $10
|
&buf $10
|
||||||
|
|
||||||
|
@test-pal1 { "racecar 00 }
|
||||||
|
STH2r spal #01 EQU JMP2r
|
||||||
|
|
||||||
|
@test-pal2 { "racecat 00 }
|
||||||
|
STH2r spal #00 EQU JMP2r
|
||||||
|
|
||||||
(
|
(
|
||||||
@|stdlib )
|
@|stdlib )
|
||||||
|
|
||||||
|
@ -84,6 +76,10 @@
|
||||||
INC2 & LDAk ?scap
|
INC2 & LDAk ?scap
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
|
@palindrome? ( str* -- f )
|
||||||
|
scap/
|
||||||
|
( TODO ) JMP2r
|
||||||
|
|
||||||
@slen ( str* -: len* )
|
@slen ( str* -: len* )
|
||||||
DUP2 scap/ SWP2 SUB2 JMP2r
|
DUP2 scap/ SWP2 SUB2 JMP2r
|
||||||
|
|
||||||
|
@ -99,7 +95,7 @@
|
||||||
#00 STH2r scap/ STA2
|
#00 STH2r scap/ STA2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@<sclr> ( str* -: )
|
@<sclr> ( str* -- )
|
||||||
STH2
|
STH2
|
||||||
#00 STH2r
|
#00 STH2r
|
||||||
&w ( -- )
|
&w ( -- )
|
||||||
|
@ -125,45 +121,44 @@
|
||||||
( continue ) INC2 LDAk ?&w
|
( continue ) INC2 LDAk ?&w
|
||||||
&end POP2 STH2r JMP2r
|
&end POP2 STH2r JMP2r
|
||||||
|
|
||||||
@shex ( str* -- val* )
|
@shex ( str* -: val* )
|
||||||
[ LIT2r 0000 ]
|
[ LIT2r 0000 ]
|
||||||
&w ( -- )
|
&w ( str* `acc* -: val* )
|
||||||
( validate ) LDAk chex INC #00 EQU ?&end
|
LDAk chex INC #00 EQU ?{
|
||||||
( accumulate ) [ LITr 40 ] SFT2r
|
[ LITr 40 ] SFT2r LDAk chex [ LITr 00 ] STH
|
||||||
( combine ) LDAk chex [ LITr 00 ] STH
|
ADD2r INC2 LDAk ?&w }
|
||||||
ADD2r
|
POP2 STH2r JMP2r
|
||||||
( continue ) INC2 LDAk ?&w
|
|
||||||
&end POP2 STH2r JMP2r
|
|
||||||
|
|
||||||
@chex ( c -- val|ff )
|
@chex ( c -: val! )
|
||||||
( dec ) [ LIT "0 ] SUB DUP #09 GTH ?{ JMP2r }
|
( dec ) [ LIT "0 ] SUB DUP #09 GTH ?{ JMP2r }
|
||||||
( hex ) #27 SUB DUP #0f GTH ?{ JMP2r }
|
( hex ) #27 SUB DUP #0f GTH ?{ JMP2r }
|
||||||
( err ) POP #ff JMP2r
|
( err ) POP #ff JMP2r
|
||||||
|
( return 1 if string is palindrome, otherwise 0 )
|
||||||
|
|
||||||
(
|
(
|
||||||
@|print )
|
@|print )
|
||||||
|
|
||||||
@<pstr> ( str* -- )
|
@<pstr> ( str* -: )
|
||||||
&w ( -- )
|
|
||||||
LDAk #18 DEO
|
LDAk #18 DEO
|
||||||
INC2 & LDAk ?&w
|
INC2 & LDAk ?<pstr>
|
||||||
POP2 JMP2r
|
POP2 JMP2r
|
||||||
|
|
||||||
@<phex> ( short* -- )
|
@<phex> ( short* -: )
|
||||||
SWP <phex>/b
|
SWP /b
|
||||||
&b ( -- )
|
&b ( byte -: )
|
||||||
DUP #04 SFT <phex>/c
|
DUP #04 SFT /c
|
||||||
&c ( -- )
|
&c ( byte -: )
|
||||||
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
|
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@<pdec> ( short* -- )
|
@<pdec> ( short* -: )
|
||||||
#2710 [ LIT2r 00fb ]
|
#2710 [ LIT2r 00fb ]
|
||||||
&w ( -- )
|
&>w ( short* size* `acc* -: )
|
||||||
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
|
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?&e
|
||||||
DUP [ LIT "0 ] ADD #19 DEO
|
DUP [ LIT "0 ] ADD #19 DEO
|
||||||
INCr }
|
INCr
|
||||||
POP2 #000a DIV2 SWPr INCr STHkr ?&w
|
&e ( short* size* `acc* -: )
|
||||||
|
POP2 #000a DIV2 SWPr INCr STHkr ?&>w
|
||||||
POP2r POP2 POP2 JMP2r
|
POP2r POP2 POP2 JMP2r
|
||||||
|
|
||||||
@<pmem> ( addr* -- )
|
@<pmem> ( addr* -- )
|
||||||
|
|
Loading…
Reference in New Issue