Reimplemented software/asma with reading input filename from Console.
This commit is contained in:
parent
d34ec6584c
commit
b78d9e1446
|
@ -5,24 +5,9 @@ rm -rf asma-test
|
||||||
mkdir asma-test
|
mkdir asma-test
|
||||||
cd 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() {
|
expect_failure() {
|
||||||
cat > 'in.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
|
if ! grep -qF "${1}" asma.log; then
|
||||||
echo "error: asma didn't report error ${1} in faulty code"
|
echo "error: asma didn't report error ${1} in faulty code"
|
||||||
xxd asma.log
|
xxd asma.log
|
||||||
|
@ -30,8 +15,7 @@ expect_failure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
echo 'Assembling asma with uxnasm'
|
echo 'Assembling asma with uxnasm'
|
||||||
build_asma > asma.tal
|
( cd .. && bin/uxnasm projects/software/asma.tal asma-test/asma.rom ) > uxnasm.log
|
||||||
( cd .. && bin/uxnasm asma-test/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
|
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}"
|
echo "Comparing assembly of ${F}"
|
||||||
BN="$(basename "${F%.tal}")"
|
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'
|
cp "${F}" 'in.tal'
|
||||||
rm -f 'out.rom'
|
rm -f 'out.rom'
|
||||||
( cd .. && bin/uxncli asma-test/asma.rom ) > asma.log
|
echo asma-test/in.tal | ( cd .. && bin/uxncli asma-test/asma.rom ) > out.rom 2> asma.log
|
||||||
if [ ! -f 'out.rom' ]; then
|
cat asma.log
|
||||||
|
if ! grep -qF 'bytes of heap used' asma.log; then
|
||||||
echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
|
echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
|
||||||
tail asma.log
|
tail asma.log
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
)
|
)
|
||||||
#0d ;asma/log-level STA
|
#0d ;asma/log-level STA
|
||||||
|
|
||||||
|
;asma-heap ;heap STA2
|
||||||
|
|
||||||
(
|
(
|
||||||
Assemble the source code into an output ROM file.
|
Assemble the source code into an output ROM file.
|
||||||
|
|
||||||
|
|
|
@ -187,7 +187,6 @@
|
||||||
;asma/error STA2
|
;asma/error STA2
|
||||||
;asma-trees/labels STA2
|
;asma-trees/labels STA2
|
||||||
;asma-trees/macros STA2
|
;asma-trees/macros STA2
|
||||||
;asma-heap ;heap STA2
|
|
||||||
;asma-opcodes/_entry ;asma-trees/opcodes STA2
|
;asma-opcodes/_entry ;asma-trees/opcodes STA2
|
||||||
( fall through )
|
( fall through )
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue