From 25b9639a36112df074d894517dda118fc35cd1b8 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sat, 1 Jul 2023 10:47:51 -0700 Subject: [PATCH] Added symbols parser --- cli/symbols/build.sh | 25 +++++++++++ cli/symbols/sym.tal | 94 +++++++++++++++++++++++++++++++++++++++ cli/symbols/test.symbols | Bin 0 -> 122 bytes 3 files changed, 119 insertions(+) create mode 100755 cli/symbols/build.sh create mode 100644 cli/symbols/sym.tal create mode 100644 cli/symbols/test.symbols diff --git a/cli/symbols/build.sh b/cli/symbols/build.sh new file mode 100755 index 0000000..54f0e1b --- /dev/null +++ b/cli/symbols/build.sh @@ -0,0 +1,25 @@ +#!/bin/sh -e + +ID="sym" +ASM="uxncli $HOME/roms/drifblim.rom" +EMU="uxncli" +LIN="uxncli $HOME/roms/uxnlin.rom" +SRC="${ID}.tal" +DST="${ID}.rom" +CPY="$HOME/roms" +ARG="test.symbols" + +if [[ "$*" == *"--lint"* ]] +then + $LIN $SRC +fi + +$ASM $SRC $DST + +if [[ "$*" == *"--save"* ]] +then + cp $DST $CPY +fi + +$EMU $DST $ARG + diff --git a/cli/symbols/sym.tal b/cli/symbols/sym.tal new file mode 100644 index 0000000..c0d4c8d --- /dev/null +++ b/cli/symbols/sym.tal @@ -0,0 +1,94 @@ +( uxncli sym.rom file.bin.sym ) + +|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1 +|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 + +|0000 + + @src $40 + +|0100 + +@on-reset ( -> ) + .Console/type DEI ?&>has-arg + ;Dict/usage + #010f DEO + BRK &>has-arg + ;await-src .Console/vector DEO2 + BRK + +@await-src ( -> ) + .Console/read DEI .src skey ?on-ready + BRK + +@on-ready ( -> ) + ;src .File/name DEO2 + #8000 .File/length DEO2 + ;sym .File/read DEO2 + ;sym + &w + LDA2k #2018 DEO + INC2 INC2 DUP2 #0a18 DEO + scap INC2 LDAk ?&w + POP2 + #800f DEO + BRK + +@ ( id -- ) + DUP #0f AND ?&>no-lb + POP #0a18 DEO + JMP2r &>no-lb + #01 AND ?&>end + #2018 DEO &>end + JMP2r + +( +@|stdlib ) + +@skey ( key buf -- proc ) + OVR #21 LTH ?&eval + #00 SWP sput #00 JMP2r + &eval ( -- ) + POP2 #01 JMP2r + +@scap ( str* -- end* ) + !&a + &w ( -- ) + INC2 &a LDAk ?&w + JMP2r + +@sput ( chr str* -- ) + scap INC2k #00 ROT ROT STA + STA + JMP2r + +@ ( short* -- ) + SWP /b + &b ( -- ) + DUP #04 SFT /c + &c ( -- ) + #0f AND DUP #09 GTH #27 MUL ADD LIT "0 ADD #18 DEO + JMP2r + +@ ( err* -- ) + !&a + &w ( -- ) + LDAk #19 DEO + INC2 &a LDAk ?&w + POP2 JMP2r + +@ ( err* -- ) + !&a + &w ( -- ) + LDAk #19 DEO + INC2 &a LDAk ?&w + POP2 JMP2r + +( +@|res ) + +@Dict &usage "usage: 20 "sym.rom 20 "input.bin.sym 0a $1 + +@sym + + diff --git a/cli/symbols/test.symbols b/cli/symbols/test.symbols new file mode 100644 index 0000000000000000000000000000000000000000..f8e3fa2923d1785d6150866ab927cd39b566c9f1 GIT binary patch literal 122 zcmXwwu?m1N3@;f^K(@cQ9Qw2!nx~sB&Wg)9s~( wBnKG#(R%q1^)&nrX7n6mCb=~LhjieqrNbt5LE2ukI@1S@)A?fWFy>qoAEi$m?f?J) literal 0 HcmV?d00001