From b78d9e1446d80a56c94de02be07df98e629fd1a7 Mon Sep 17 00:00:00 2001 From: Andrew Alderwick Date: Thu, 7 Oct 2021 22:00:54 +0100 Subject: [PATCH] Reimplemented software/asma with reading input filename from Console. --- etc/asma-test.sh | 25 +++----------- projects/examples/demos/asma-piano.tal | 2 ++ projects/library/asma.tal | 1 - projects/software/asma.tal | 48 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 21 deletions(-) create mode 100644 projects/software/asma.tal diff --git a/etc/asma-test.sh b/etc/asma-test.sh index ac8b216..78619c7 100755 --- a/etc/asma-test.sh +++ b/etc/asma-test.sh @@ -5,24 +5,9 @@ rm -rf asma-test mkdir asma-test cd asma-test -build_asma() { - sed -ne '/^( devices )/,/^( vectors )/p' ../projects/software/asma.tal - cat < 'in.tal' - ( cd .. && bin/uxncli asma-test/asma.rom ) > asma.log 2>/dev/null + echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log if ! grep -qF "${1}" asma.log; then echo "error: asma didn't report error ${1} in faulty code" xxd asma.log @@ -30,8 +15,7 @@ expect_failure() { } echo 'Assembling asma with uxnasm' -build_asma > asma.tal -( cd .. && bin/uxnasm asma-test/asma.tal asma-test/asma.rom ) > uxnasm.log +( cd .. && bin/uxnasm projects/software/asma.tal asma-test/asma.rom ) > uxnasm.log for F in $(find ../projects -path ../projects/library -prune -false -or -type f -name '*.tal' -not -name 'blank.tal' | sort); do echo "Comparing assembly of ${F}" BN="$(basename "${F%.tal}")" @@ -45,8 +29,9 @@ for F in $(find ../projects -path ../projects/library -prune -false -or -type f cp "${F}" 'in.tal' rm -f 'out.rom' - ( cd .. && bin/uxncli asma-test/asma.rom ) > asma.log - if [ ! -f 'out.rom' ]; then + echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log + cat asma.log + if ! grep -qF 'bytes of heap used' asma.log; then echo "error: asma failed to assemble ${F}, while uxnasm succeeded" tail asma.log exit 1 diff --git a/projects/examples/demos/asma-piano.tal b/projects/examples/demos/asma-piano.tal index bea9d8f..1837751 100644 --- a/projects/examples/demos/asma-piano.tal +++ b/projects/examples/demos/asma-piano.tal @@ -16,6 +16,8 @@ ) #0d ;asma/log-level STA + ;asma-heap ;heap STA2 + ( Assemble the source code into an output ROM file. diff --git a/projects/library/asma.tal b/projects/library/asma.tal index 8b33bae..a53027b 100644 --- a/projects/library/asma.tal +++ b/projects/library/asma.tal @@ -187,7 +187,6 @@ ;asma/error STA2 ;asma-trees/labels STA2 ;asma-trees/macros STA2 - ;asma-heap ;heap STA2 ;asma-opcodes/_entry ;asma-trees/opcodes STA2 ( fall through ) diff --git a/projects/software/asma.tal b/projects/software/asma.tal new file mode 100644 index 0000000..e6095b0 --- /dev/null +++ b/projects/software/asma.tal @@ -0,0 +1,48 @@ +( devices ) + +|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 ] +|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] +|a0 @File [ &vector $2 &success $2 &offset-hs $2 &offset-ls $2 &name $2 &length $2 &load $2 &save $2 ] + +( vectors ) + +|0100 @reset + ( + Set the log level for helping to debug stuff. + Its value is the bitwise OR of all the following output types: + #01 prints the number of lines in the source code, + #04 dumps all defined labels at end, and + #08 prints the heap usage. + ) + #09 ;asma/log-level STA + + ;asma-heap ;heap STA2 + + ;on-input .Console/vector DEO2 + BRK + +@on-input ( -> ) + .Console/read DEI + DUP #0a EQU ,&newline JCN + ;append-heap-byte JSR2 + BRK + + &newline ( 0a ) + DUP EOR ( 00 ) + ;append-heap-byte JSR2 ( ) + + ;asma-heap #0000 ;asma-assemble-file JSR2 + #01 .System/halt DEO + BRK + +include projects/library/asma.tal + +@asma-heap +|e000 &end + +@asma-read-buffer +|f800 &end + +@asma-write-buffer +|ffff &end +