aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Chambers <[email protected]>2021-10-07 16:57:41 +1300
committerAndrew Chambers <[email protected]>2021-10-07 16:57:41 +1300
commit2a302793114003a4440f43f4beb9a3d752171408 (patch)
tree32f327e5fd8952bd3f57fe8d2a5a169c45491708 /test
parentf4a9a52d001a54ca1142110b70142a8ef8df53bc (diff)
WIP refactor.
Diffstat (limited to 'test')
-rw-r--r--test/test.sh106
1 files changed, 58 insertions, 48 deletions
diff --git a/test/test.sh b/test/test.sh
index 0d92e4a..9622963 100644
--- a/test/test.sh
+++ b/test/test.sh
@@ -12,7 +12,11 @@ t () {
clang -Wno-everything -c -s "$tmps" -o "$tmpo"
objcopy -j ".text" -O binary "$tmpo" "$tmpb"
want="$(xxd -ps "$tmpb" | head -n 1 | cut -d ' ' -f 2-)"
- ./minias < "$tmps" > "$tmpo"
+ if ! ./minias < "$tmps" > "$tmpo"
+ then
+ echo "failed to assemble: $1"
+ exit 1
+ fi
objcopy -j ".text" -O binary "$tmpo" "$tmpb"
got="$(xxd -ps "$tmpb" | head -n 1 | cut -d ' ' -f 2-)"
if test "$got" != "$want"
@@ -27,10 +31,21 @@ t () {
# TODO Tidy and be more systematic, we could just loop
-t "xchg %rax, %rax"
-t "xchg %eax, %eax"
-t "xchg %ax, %ax"
t "xchg %al, %al"
+t "xchg %ax, %ax"
+t "xchg %ax, %r9w"
+t "xchg %r9w, %ax"
+t "xchg %ax, %bx"
+t "xchg %bx, %ax"
+#t "xchg %eax, %eax" # XXX We encode this as nop, but clang does not.
+t "xchg %eax, %r9d"
+t "xchg %r9d, %eax"
+t "xchg %eax, %ebx"
+t "xchg %ebx, %eax"
+t "xchg %rax, %r9"
+t "xchg %r9, %rax"
+t "xchg %rax, %rbx"
+t "xchg %rbx, %rax"
t "xchg %rax, (%rax)"
t "xchg %eax, (%rax)"
t "xchg %ax, (%rax)"
@@ -40,32 +55,55 @@ t "xchg (%rax), %eax"
t "xchg (%rax), %ax"
t "xchg (%rax), %al"
-exit 0
-
t "addb %al, %al"
-t "addb (%rax), %al"
t "addb %al, (%rax)"
-
+t "addb (%rax), %al"
+t "addl %eax, %eax"
+t "addl %eax, %ebx"
+t "addl %eax, (%r9)"
+t "addl %eax, (%rax)"
+t "addl %ebx, (%r9)"
+t "addq %rax, %rax"
+t "addq %rax, %rbx"
+t "addq %rax, (%rax)"
+t "addq %rax, (%rbx)"
+t "addq (%rax), %rax"
+t "andb %al, %al"
+t "andb %al, (%rax)"
+t "andb (%rax), %al"
+t "andl %eax, %eax"
+t "andq %rax, %rax"
+t "andq %rax, (%rax)"
+t "andq (%rax), %rax"
+t "leave"
+t "nop"
+t "orb %al, %al"
+t "orb %al, (%rax)"
+t "orb (%rax), %al"
+t "orl %eax, %eax"
+t "orq (%rax), %rax"
+t "orq %rax, %rax"
+t "orq %rax, (%rax)"
+t "ret"
t "subb %al, %al"
-t "subb (%rax), %al"
t "subb %al, (%rax)"
-
+t "subb (%rax), %al"
+t "subl %eax, %eax"
+t "subq %rax, %rax"
+t "subq (%rax), %rax"
t "xorb %al, %al"
-t "xorb (%rax), %al"
t "xorb %al, (%rax)"
+t "xorb (%rax), %al"
+t "xorl %eax, %eax"
+t "xorq %rax, %rax"
+t "xorq %rax, (%rax)"
+t "xorq (%rax), %rax"
-t "orb %al, %al"
-t "orb (%rax), %al"
-t "orb %al, (%rax)"
-
-t "andb %al, %al"
-t "andb (%rax), %al"
-t "andb %al, (%rax)"
+exit 0
t "movb %al, %al"
t "movb (%rax), %al"
t "movb %al, (%rax)"
-
t "movw %ax, %r9w"
t "movw %ax, %ax"
t "addw %ax, %ax"
@@ -77,32 +115,4 @@ t "movl (%rax), %eax"
t "movl %eax, (%rax)"
t "leaw (%rax), %ax"
t "leaq (%rax), %rax"
-t "leal (%rax), %eax"
-t "addq (%rax), %rax"
-t "andq (%rax), %rax"
-t "orq (%rax), %rax"
-t "subq (%rax), %rax"
-t "xorq (%rax), %rax"
-t "nop"
-t "ret"
-t "leave"
-t "addq %rax, %rax"
-t "addl %eax, %eax"
-t "subq %rax, %rax"
-t "subl %eax, %eax"
-t "addq %rax, %rbx"
-t "addl %eax, %ebx"
-t "addq %rax, (%rax)"
-t "addq %rax, (%rbx)"
-t "addl %eax, (%rax)"
-t "addl %eax, (%r9)"
-t "addl %ebx, (%r9)"
-t "orq %rax, %rax"
-t "orq %rax, (%rax)"
-t "orl %eax, %eax"
-t "xorq %rax, %rax"
-t "xorq %rax, (%rax)"
-t "xorl %eax, %eax"
-t "andq %rax, %rax"
-t "andq %rax, (%rax)"
-t "andl %eax, %eax"
+t "leal (%rax), %eax" \ No newline at end of file