2021-05-16 05:20:04 -04:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
cd "$(dirname "${0}")/.."
|
|
|
|
rm -rf asma-test
|
|
|
|
mkdir asma-test
|
|
|
|
|
2021-05-16 05:58:00 -04:00
|
|
|
expect_failure() {
|
2021-10-07 17:30:19 -04:00
|
|
|
cat > asma-test/in.tal
|
2021-10-13 17:58:17 -04:00
|
|
|
bin/uxncli asma-test/asma.rom asma-test/in.tal asma-test/out.rom 2> asma-test/asma.log
|
2021-10-07 17:30:19 -04:00
|
|
|
if ! grep -qF "${1}" asma-test/asma.log; then
|
2021-08-10 14:23:53 -04:00
|
|
|
echo "error: asma didn't report error ${1} in faulty code"
|
2021-10-07 17:30:19 -04:00
|
|
|
cat asma-test/asma.log
|
2021-08-10 14:23:53 -04:00
|
|
|
fi
|
2021-05-16 05:58:00 -04:00
|
|
|
}
|
|
|
|
|
2021-05-16 05:20:04 -04:00
|
|
|
echo 'Assembling asma with uxnasm'
|
2021-10-07 17:30:19 -04:00
|
|
|
bin/uxnasm projects/software/asma.tal asma-test/asma.rom > asma-test/uxnasm.log
|
|
|
|
for F in $(find projects -path projects/library -prune -false -or -type f -name '*.tal' | sort); do
|
2021-05-16 05:20:04 -04:00
|
|
|
echo "Comparing assembly of ${F}"
|
|
|
|
|
2021-10-07 17:30:19 -04:00
|
|
|
UASM_BASE="asma-test/uxnasm-$(basename "${F%.tal}")"
|
|
|
|
if ! bin/uxnasm "${F}" "${UASM_BASE}.rom" 2> "${UASM_BASE}.log"; then
|
2021-05-16 05:20:04 -04:00
|
|
|
echo "error: uxnasm failed to assemble ${F}"
|
2021-10-07 17:30:19 -04:00
|
|
|
cat "${UASM_BASE}.log"
|
2021-05-16 05:20:04 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-07 17:30:19 -04:00
|
|
|
xxd "${UASM_BASE}.rom" > "${UASM_BASE}.hex"
|
2021-05-16 05:20:04 -04:00
|
|
|
|
2021-10-07 17:30:19 -04:00
|
|
|
ASMA_BASE="asma-test/asma-$(basename "${F%.tal}")"
|
2021-10-13 17:58:17 -04:00
|
|
|
bin/uxncli asma-test/asma.rom "${F}" "${ASMA_BASE}.rom" 2> "${ASMA_BASE}.log"
|
2021-10-07 17:30:19 -04:00
|
|
|
if ! grep -qF 'bytes of heap used' "${ASMA_BASE}.log"; then
|
2021-05-16 05:20:04 -04:00
|
|
|
echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
|
2021-10-07 17:30:19 -04:00
|
|
|
cat "${ASMA_BASE}.log"
|
2021-05-16 05:20:04 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-07 17:30:19 -04:00
|
|
|
xxd "${ASMA_BASE}.rom" > "${ASMA_BASE}.hex"
|
2021-05-16 05:20:04 -04:00
|
|
|
|
2021-10-07 17:30:19 -04:00
|
|
|
diff -u "${UASM_BASE}.hex" "${ASMA_BASE}.hex"
|
2021-05-16 05:20:04 -04:00
|
|
|
done
|
2021-05-16 05:58:00 -04:00
|
|
|
expect_failure 'Invalid hexadecimal: $defg' <<'EOD'
|
|
|
|
|1000 $defg
|
|
|
|
EOD
|
|
|
|
expect_failure 'Invalid hexadecimal: #defg' <<'EOD'
|
|
|
|
|1000 #defg
|
|
|
|
EOD
|
2021-10-30 02:48:41 -04:00
|
|
|
expect_failure 'Invalid hexadecimal: #' <<'EOD'
|
|
|
|
|1000 #
|
|
|
|
EOD
|
2021-11-03 15:38:02 -04:00
|
|
|
expect_failure 'Invalid hexadecimal: #0' <<'EOD'
|
|
|
|
|1000 #0
|
|
|
|
EOD
|
|
|
|
expect_failure 'Invalid hexadecimal: #000' <<'EOD'
|
|
|
|
|1000 #000
|
|
|
|
EOD
|
|
|
|
expect_failure 'Unrecognised token: 0' <<'EOD'
|
|
|
|
|1000 0
|
|
|
|
EOD
|
|
|
|
expect_failure 'Unrecognised token: 000' <<'EOD'
|
|
|
|
|1000 000
|
|
|
|
EOD
|
2021-05-16 05:58:00 -04:00
|
|
|
expect_failure 'Address not in zero page: .hello' <<'EOD'
|
|
|
|
|1000 @hello
|
|
|
|
.hello
|
|
|
|
EOD
|
|
|
|
expect_failure 'Address outside range: ,hello' <<'EOD'
|
|
|
|
|1000 @hello
|
|
|
|
|2000 ,hello
|
|
|
|
EOD
|
2021-10-20 12:35:41 -04:00
|
|
|
expect_failure 'Unrecognised token: hello' <<'EOD'
|
2021-05-16 05:58:00 -04:00
|
|
|
hello
|
|
|
|
EOD
|
2021-10-07 18:27:19 -04:00
|
|
|
expect_failure 'Macro already exists: %me' <<'EOD'
|
|
|
|
%me { #00 }
|
|
|
|
%me { #01 }
|
2021-05-16 05:58:00 -04:00
|
|
|
EOD
|
|
|
|
expect_failure 'Memory overwrite: SUB' <<'EOD'
|
|
|
|
|2000 ADD
|
|
|
|
|1000 SUB
|
|
|
|
EOD
|
2021-10-07 18:26:39 -04:00
|
|
|
expect_failure 'Recursion level too deep:' <<'EOD'
|
|
|
|
%me { you }
|
|
|
|
%you { me }
|
|
|
|
|1000 me
|
|
|
|
EOD
|
2021-10-07 18:31:40 -04:00
|
|
|
expect_failure 'Recursion level too deep: include' <<'EOD'
|
|
|
|
include asma-test/in.tal
|
|
|
|
EOD
|
2021-10-28 18:12:49 -04:00
|
|
|
expect_failure 'Label not found: ;blah' <<'EOD'
|
|
|
|
|1000 ;blah
|
|
|
|
EOD
|
|
|
|
expect_failure 'Label not found: ,blah' <<'EOD'
|
|
|
|
|1000 ,blah
|
|
|
|
EOD
|
|
|
|
expect_failure 'Label not found: .blah' <<'EOD'
|
|
|
|
|1000 .blah
|
|
|
|
EOD
|
2021-05-16 05:20:04 -04:00
|
|
|
echo 'All OK'
|
|
|
|
|