blob: add0379d8bd0c1cdcca15fc094d63910ce29ab3f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/bin/bash
# builds the zygote for arm64 linux and runs it under qemu.
# needs gcc, aarch64-linux-gnu-gcc and qemu-aarch64. on an arm64 mac or linux box,
# build natively instead and drop the qemu prefix.
cd "$(dirname "$0")"; T=$(mktemp -d); Q="timeout 60 qemu-aarch64"
chk(){ if [ "$1" = "$2" ]; then echo "ok $3"; else echo "FAIL $3: got [$1]"; fi; }
gcc -w mkgenome.c -o $T/mkg && cat gen.s aslib.s | $T/mkg >$T/g.h
cmp -s $T/g.h genome.h && echo "ok genome.h is up to date" || echo "FAIL genome.h is stale, regenerate it"
aarch64-linux-gnu-gcc -O2 -w -DJTYPE=int -static core.c io_linux.c -o $T/zy || exit 1
chk "$($Q $T/zy <examples/hello.s)" "hello, world!" "hello"
chk "$($Q $T/zy <examples/fact.s)" "1101110101111100000000" "recursive factorial"
chk "$( (cat examples/echo.s; printf '`abc\n') | $Q $T/zy)" "abc" "echo after the backtick"
chk "$($Q $T/zy <examples/sm.s | tr '\n' '/')" "B/ABA/" "self-patching"
cat examples/asmain.s aslib.s >$T/asm.s
(cat $T/asm.s; printf '`'; cat examples/hello.s) | $Q $T/zy >$T/a
chk "$(od -An -td4 $T/a | tr -s ' \n' ' ' | sed 's/^ //;s/ $//')" "29 1 6 2 1 6 27 16 24 3 26 3 14 0 104 101 108 108 111 44 32 119 111 114 108 100 33 10 0" "self-hosted assembler, running on the zygote, assembles hello"
chk "$( (cat repl.s; printf '`104 p 105 p 10 p r`121 p 111 p 10 p r') | $Q $T/zy | tr '\n' '/')" "hi/yo/" "repl with mutated assembler"
rm -rf $T
|