From fda853b99f0f25d9454e24559e43752aa458d74e Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Mon, 10 Apr 2023 15:02:25 -0700 Subject: [PATCH] (stdlib) Starting testing suite --- cli/stdlib/build.sh | 26 +++++++++++++++ cli/stdlib/stdlib.tal | 75 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100755 cli/stdlib/build.sh create mode 100644 cli/stdlib/stdlib.tal diff --git a/cli/stdlib/build.sh b/cli/stdlib/build.sh new file mode 100755 index 0000000..5fb83cf --- /dev/null +++ b/cli/stdlib/build.sh @@ -0,0 +1,26 @@ +#!/bin/sh -e + +ASM="uxncli $HOME/roms/drifblim.rom" +EMU="uxncli" +LIN="uxncli $HOME/roms/uxnlin.rom" + +ID="stdlib" +SRC="${ID}.tal" +DST="${ID}.rom" +CPY="$HOME/roms" +ARG="" + +if [[ "$*" == *"--lint"* ]] +then + $LIN $SRC +fi + +$ASM $SRC $DST + +if [[ "$*" == *"--save"* ]] +then + cp $DST $CPY +fi + +$EMU $DST $ARG + diff --git a/cli/stdlib/stdlib.tal b/cli/stdlib/stdlib.tal new file mode 100644 index 0000000..86d5d66 --- /dev/null +++ b/cli/stdlib/stdlib.tal @@ -0,0 +1,75 @@ +|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 + +@tests + =test-dec1 + =test-dec2 + =test-hex1 + =test-hex2 + &end + +( +@|tests ) + +@test-dec1 ;dict/dec1 sdec #1234 EQU2 JMP2r +@test-dec2 ;dict/dec2 sdec #0123 EQU2 JMP2r +@test-hex1 ;dict/hex1 shex #12c0 EQU2 JMP2r +@test-hex2 ;dict/hex2 shex #034f EQU2 JMP2r + +( +@|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 ) + + LIT "0 SUB DUP #09 GTH JMP JMP2r + #27 SUB DUP #0f GTH JMP JMP2r + POP #ff + +JMP2r + +@dict + &dec1 "4660 $1 + &dec2 "291 $1 + &hex1 "12c0 $1 + &hex2 "34f $1 +