z80-forth (770 bytes)
1 #!/bin/sh 2 # z80-forth -- boot the Z80 Forth kernel in z80pack cpmsim and attach its serial console. 3 # PORT picks the TCP port of the emulated serial console (default 4455). Quit with ctrl-c. 4 set -e 5 SRC=$(cd "$(dirname "$0")" && pwd) 6 PORT=${PORT:-4455} 7 IMG=$SRC/kernel.mos 8 [ -x "${Z80PACK:-$HOME/src/z80pack}/cpmsim/cpmsim" ] || "$SRC/build-emu.sh" >&2 9 [ "$IMG" -nt "$SRC/kernel.lisp" ] && [ "$IMG" -nt "$SRC/asm.lisp" ] || "${SBCL:-sbcl}" --script "$SRC/kernel.lisp" "$IMG" >/dev/null 10 EPID=$(PORT=$PORT "$SRC/emu.sh" "$IMG") 11 trap 'kill $EPID 2>/dev/null; ${STTY:-stty} sane 2>/dev/null' EXIT HUP INT TERM 12 sleep 0.5 # let cpmsim open its listening socket 13 ${STTY:-stty} -echo -icanon 2>/dev/null || true # the kernel echoes; no tty when piped 14 ${NC:-nc} 127.0.0.1 $PORT