From c912158744115abea84eab55cedc93728ad74067 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 24 Oct 2020 23:33:12 -0400 Subject: [PATCH] Run "all" tests under the 8086 emulator --- blk/458 | 2 +- emul/8086/forth.c | 20 ++++++++++++++++++-- emul/8086/xcomp.fs | 3 +++ tests/Makefile | 1 + tests/all/runtests.sh | 5 +++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/blk/458 b/blk/458 index 02c5871..52ab807 100644 --- a/blk/458 +++ b/blk/458 @@ -1,4 +1,4 @@ -CODE BYE BEGIN, JMPs, AGAIN, ;CODE +CODE BYE HLT, BEGIN, JMPs, AGAIN, ;CODE CODE S= 2 chkPS, SI POPx, DI POPx, CH CH XORrr, CL [SI] MOVr[], CL [DI] CMPr[], diff --git a/emul/8086/forth.c b/emul/8086/forth.c index 6c55bbb..049b942 100644 --- a/emul/8086/forth.c +++ b/emul/8086/forth.c @@ -28,6 +28,7 @@ INT 2: KEY. AL = char read INT 3: AT-XY. AL = x, BL = y INT 4: BLKREAD. AX = blkid, BX = dest addr INT 5: BLKWRITE. AX = blkid, BX = src addr +INT 6: RETCODE. AX = retcode. */ void int1() { @@ -45,7 +46,17 @@ void int1() { } void int2() { - regs.byteregs[regal] = getchar(); + int c; + if (fp != NULL) { + c = getc(fp); + } else { + // debug_panel(); + c = wgetch(w); + } + if (c == EOF) { + c = 4; // ASCII EOT + } + regs.byteregs[regal] = c; } void int3() { @@ -70,6 +81,10 @@ void int5() { } } +void int6() { + retcode = getreg16(regax); +} + int main(int argc, char *argv[]) { INTHOOKS[1] = int1; @@ -77,6 +92,7 @@ int main(int argc, char *argv[]) INTHOOKS[3] = int3; INTHOOKS[4] = int4; INTHOOKS[5] = int5; + INTHOOKS[6] = int6; reset86(); fprintf(stderr, "Using blkfs %s\n", BLKFS_PATH); blkfp = fopen(BLKFS_PATH, "r+"); @@ -131,5 +147,5 @@ int main(int argc, char *argv[]) //emul_printdebug(); } - return 0; + return retcode; } diff --git a/emul/8086/xcomp.fs b/emul/8086/xcomp.fs index acb444d..0f03559 100644 --- a/emul/8086/xcomp.fs +++ b/emul/8086/xcomp.fs @@ -13,6 +13,9 @@ CODE _ BX POPx, AX POPx, 4 INT, ;CODE : EFS@ BLK( _ ; CODE _ BX POPx, AX POPx, 5 INT, ;CODE : EFS! BLK( _ ; +( 8086 port doesn't define PC@ and PC!, but test harness uses + it. Our forth binary uses INT 6 for retcode. ) +CODE PC! AX POPx, ( discard ) AX POPx, 6 INT, ;CODE 380 LOAD ( xcomp core high ) (entry) _ ( Update LATEST ) PC ORG @ 8 + ! ," BLK$ " diff --git a/tests/Makefile b/tests/Makefile index 786924c..a91d000 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -2,5 +2,6 @@ run: $(MAKE) -C ../cvm all $(MAKE) -C ../emul/z80 all + $(MAKE) -C ../emul/8086 all cd all && ./runtests.sh cd z80 && ./runtests.sh diff --git a/tests/all/runtests.sh b/tests/all/runtests.sh index f329b95..ca0a9af 100755 --- a/tests/all/runtests.sh +++ b/tests/all/runtests.sh @@ -3,6 +3,7 @@ BASE=../.. CVM="${BASE}/cvm/forth" Z80="${BASE}/emul/z80/forth" +I8086="${BASE}/emul/8086/forth" TMP=$(mktemp) chk() { @@ -15,6 +16,10 @@ chk() { if ! ${Z80} ${TMP}; then exit 1 fi + echo "Running test $1 under 8086" + if ! ${I8086} ${TMP}; then + exit 1 + fi } if [ ! -z $1 ]; then