uxn-utils/cli/stdlib/stdlib.tal

83 lines
1.1 KiB
Tal
Raw Normal View History

2023-04-10 18:02:25 -04:00
|0100
;tests/end ;tests
&l
LDA2k JSR2 test
INC2 INC2 GTH2k ?&l
POP2 POP2
#800f DEO
BRK
@test ( f -- )
#30 ADD #18 DEO #0a18 DEO
JMP2r
2023-04-10 18:09:17 -04:00
@tests [
=test-dec1 =test-dec2 =test-dec3 =test-dec4
=test-hex1 =test-hex2 =test-hex3 =test-hex4
] &end
2023-04-10 18:02:25 -04:00
(
@|tests )
2023-04-10 18:09:17 -04:00
@test-dec1 ;dict/dec1 sdec #1234 EQU2 JMP2r
@test-dec2 ;dict/dec2 sdec #0123 EQU2 JMP2r
@test-dec3 ;dict/dec3 sdec #0000 EQU2 JMP2r
@test-dec4 ;dict/dec4 sdec #0000 EQU2 JMP2r
@test-hex1 ;dict/hex1 shex #12c0 EQU2 JMP2r
@test-hex2 ;dict/hex2 shex #034f EQU2 JMP2r
@test-hex3 ;dict/dec3 sdec #0000 EQU2 JMP2r
@test-hex4 ;dict/dec4 sdec #0000 EQU2 JMP2r
2023-04-10 18:02:25 -04:00
(
@|stdlib )
@sdec ( str* -- val* )
LIT2r 0000
&w
LIT2r 000a MUL2r
LITr 00
LDAk #30 SUB STH ADD2r
INC2 LDAk ?&w
POP2
STH2r
JMP2r
@shex ( str* -- val* )
LIT2r 0000
&w
LITr 40 SFT2r
LITr 00
LDAk chex STH ADD2r
INC2 LDAk ?&w
POP2
STH2r
JMP2r
@chex ( c -- val|ff )
2023-04-10 18:09:17 -04:00
LIT "0 SUB DUP #09 GTH [ JMP JMP2r ]
#27 SUB DUP #0f GTH [ JMP JMP2r ]
2023-04-10 18:02:25 -04:00
POP #ff
JMP2r
2023-04-10 18:09:17 -04:00
@dict [
2023-04-10 18:02:25 -04:00
&dec1 "4660 $1
&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