Browse code

Added test suite for asma

Andrew Alderwick authored on 16/05/2021 09:20:04
Showing 3 changed files
... ...
@@ -5,4 +5,5 @@
5 5
 *bmp~
6 6
 /bin
7 7
 *io.bit
8
-*.bak
9 8
\ No newline at end of file
9
+*.bak
10
+/*-test
10 11
\ No newline at end of file
11 12
new file mode 100755
... ...
@@ -0,0 +1,48 @@
1
+#!/bin/sh
2
+set -e
3
+cd "$(dirname "${0}")/.."
4
+rm -rf asma-test
5
+mkdir asma-test
6
+cd asma-test
7
+
8
+build_asma() {
9
+    sed -ne '/^( devices )/,/^( vectors )/p' ../projects/software/asma.usm
10
+    cat <<EOD
11
+|0100 @reset
12
+	;&source-file ;&dest-file ;asma-assemble-file JSR2
13
+	;asma/error LDA2 #0000 NEQ2 JMP BRK
14
+	#0000 DIV
15
+
16
+	&source-file "in.usm 00
17
+	&dest-file "out.rom 00
18
+
19
+EOD
20
+	sed -ne '/%asma-IF-ERROR/,$p' ../projects/software/asma.usm
21
+}
22
+
23
+echo 'Assembling asma with uxnasm'
24
+build_asma > asma.usm
25
+../bin/uxnasm asma.usm asma.rom > uxnasm.log
26
+find ../projects -type f -name '*.usm' -not -name 'blank.usm' | sort | while read F; do
27
+	echo "Comparing assembly of ${F}"
28
+	BN="$(basename "${F%.usm}")"
29
+
30
+	if ! ../bin/uxnasm "${F}" "uxnasm-${BN}.rom" > uxnasm.log; then
31
+		echo "error: uxnasm failed to assemble ${F}"
32
+		tail uxnasm.log
33
+		exit 1
34
+	fi
35
+	xxd "uxnasm-${BN}.rom" > "uxnasm-${BN}.hex"
36
+
37
+	cp "${F}" 'in.usm'
38
+	if ! ../bin/debugger asma.rom > asma.log; then
39
+		echo "error: asma failed to assemble ${F}, while uxnasm succeeded"
40
+		tail asma.log
41
+		exit 1
42
+	fi
43
+	xxd 'out.rom' > "asma-${BN}.hex"
44
+
45
+	diff -u "uxnasm-${BN}.hex" "asma-${BN}.hex"
46
+done
47
+echo 'All OK'
48
+
... ...
@@ -126,7 +126,7 @@
126 126
 	;asma/line LDA2 .Console/short DEO2
127 127
 	#2e .Console/char DEO
128 128
 	#0a .Console/char DEO
129
-	BRK
129
+	JMP2r
130 130
 
131 131
 	&line 20 "on 20 "line 20 00
132 132