From ecc350ca5c2eb50be8309c5f14f8bf0d87db9a02 Mon Sep 17 00:00:00 2001 From: Moon Flower Date: Mon, 12 Oct 2026 08:46:23 +0330 Subject: a --- docs/history/07-zygote/code/test.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 docs/history/07-zygote/code/test.sh (limited to 'docs/history/07-zygote/code/test.sh') diff --git a/docs/history/07-zygote/code/test.sh b/docs/history/07-zygote/code/test.sh new file mode 100755 index 0000000..add0379 --- /dev/null +++ b/docs/history/07-zygote/code/test.sh @@ -0,0 +1,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 $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 -- cgit v1.2.3