commit b78d9e1446d80a56c94de02be07df98e629fd1a7
parent d34ec6584c85d9a3f7fa9613c124e50fb91ca4c5
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date: Thu, 7 Oct 2021 22:00:54 +0100
Reimplemented software/asma with reading input filename from Console.
Diffstat:
4 files changed, 55 insertions(+), 21 deletions(-)
diff --git 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 <<EOD
-|0100 @reset
- ;&source-file ;&dest-file ;asma-assemble-file JSR2
- #01 .System/halt DEO
- BRK
-
- &source-file "asma-test/in.tal 00
- &dest-file "asma-test/out.rom 00
-
-EOD
- sed -ne '/%asma-IF-ERROR/,$p' ../projects/software/asma.tal
-}
-
expect_failure() {
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
@@ -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
@@ -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
@@ -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
+