diff --git a/emul/8086/Makefile b/emul/8086/Makefile index 7768963..7024d87 100644 --- a/emul/8086/Makefile +++ b/emul/8086/Makefile @@ -13,10 +13,8 @@ forth: forth.c forth.bin $(OBJS) emul.o: emul.c $(BLKFS) $(CC) -DFBIN_PATH=\"`pwd`/forth.bin\" -DBLKFS_PATH=\"`pwd`/$(BLKFS)\" -c -o emul.o emul.c -forth.bin: foo.asm - nasm -o $@ foo.asm -#forth.bin: xcomp.fs $(STAGE) $(BLKFS) -# $(CDIR)/stage < xcomp.fs > $@ +forth.bin: xcomp.fs $(STAGE) + $(CDIR)/stage < xcomp.fs > $@ $(BLKFS): $(STAGE) diff --git a/emul/8086/cpu.c b/emul/8086/cpu.c index 41d6543..671a5c5 100755 --- a/emul/8086/cpu.c +++ b/emul/8086/cpu.c @@ -1217,13 +1217,13 @@ void intcall86(uint8_t intnum) { tf = 0;*/ } -void exec86(int execloops) { +int exec86(int execloops) { int loopcount; uint8_t docontinue; static uint16_t firstip; for (loopcount = 0; loopcount < execloops; loopcount++) { - if (hltstate) return; + if (hltstate) return 0; reptype = 0; segoverride = 0; @@ -3393,6 +3393,7 @@ void exec86(int execloops) { break; } } + return 1; } void reset86() { diff --git a/emul/8086/cpu.h b/emul/8086/cpu.h index dc10759..7414b10 100755 --- a/emul/8086/cpu.h +++ b/emul/8086/cpu.h @@ -53,5 +53,5 @@ void write86 (uint32_t addr32, uint8_t value); void writew86 (uint32_t addr32, uint16_t value); uint8_t read86 (uint32_t addr32); uint16_t readw86 (uint32_t addr32); -void exec86(int execloops); +int exec86(int execloops); // returns 0 if halted void reset86(); diff --git a/emul/8086/foo.asm b/emul/8086/foo.asm deleted file mode 100644 index 8d672c4..0000000 --- a/emul/8086/foo.asm +++ /dev/null @@ -1,3 +0,0 @@ -mov al, 'X' -int 1 -hlt diff --git a/emul/8086/forth.c b/emul/8086/forth.c index 10a9536..8c16ee9 100644 --- a/emul/8086/forth.c +++ b/emul/8086/forth.c @@ -19,9 +19,14 @@ void int1() { putchar(getreg8(regal)); } +void int2() { + putreg8(regal, getchar()); +} + int main(int argc, char *argv[]) { INTHOOKS[1] = int1; + INTHOOKS[2] = int2; reset86(); // initialize memory FILE *bfp = fopen(FBIN_PATH, "r"); @@ -36,6 +41,6 @@ int main(int argc, char *argv[]) c = getc(bfp); } fclose(bfp); - exec86(100); + while (exec86(100)); return 0; } diff --git a/emul/8086/xcomp.fs b/emul/8086/xcomp.fs new file mode 100644 index 0000000..647576a --- /dev/null +++ b/emul/8086/xcomp.fs @@ -0,0 +1,14 @@ +0xff00 CONSTANT RS_ADDR +0xfffa CONSTANT PS_ADDR +RS_ADDR 0x80 - CONSTANT SYSVARS +30 LOAD ( 8086 asm ) +262 LOAD ( xcomp ) 270 LOAD ( xcomp overrides ) +445 461 LOADR ( 8086 boot code ) +353 LOAD ( xcomp core low ) +CODE (emit) AX POPx, 1 INT, ;CODE +CODE (key) 2 INT, AH 0 MOVri, AX PUSHx, ;CODE +380 LOAD ( xcomp core high ) +(entry) _ ( Update LATEST ) PC ORG @ 8 + ! +EOT, +ORG @ 256 /MOD 2 PC! 2 PC! +H@ 256 /MOD 2 PC! 2 PC!