emul/8086: and we have liftoff!

Getting a Collapse OS prompt.
This commit is contained in:
Virgil Dupras 2020-10-24 22:06:51 -04:00
parent 942a50a86d
commit d11ac3f006
6 changed files with 26 additions and 11 deletions

View File

@ -13,10 +13,8 @@ forth: forth.c forth.bin $(OBJS)
emul.o: emul.c $(BLKFS) emul.o: emul.c $(BLKFS)
$(CC) -DFBIN_PATH=\"`pwd`/forth.bin\" -DBLKFS_PATH=\"`pwd`/$(BLKFS)\" -c -o emul.o emul.c $(CC) -DFBIN_PATH=\"`pwd`/forth.bin\" -DBLKFS_PATH=\"`pwd`/$(BLKFS)\" -c -o emul.o emul.c
forth.bin: foo.asm forth.bin: xcomp.fs $(STAGE)
nasm -o $@ foo.asm $(CDIR)/stage < xcomp.fs > $@
#forth.bin: xcomp.fs $(STAGE) $(BLKFS)
# $(CDIR)/stage < xcomp.fs > $@
$(BLKFS): $(STAGE) $(BLKFS): $(STAGE)

View File

@ -1217,13 +1217,13 @@ void intcall86(uint8_t intnum) {
tf = 0;*/ tf = 0;*/
} }
void exec86(int execloops) { int exec86(int execloops) {
int loopcount; int loopcount;
uint8_t docontinue; uint8_t docontinue;
static uint16_t firstip; static uint16_t firstip;
for (loopcount = 0; loopcount < execloops; loopcount++) { for (loopcount = 0; loopcount < execloops; loopcount++) {
if (hltstate) return; if (hltstate) return 0;
reptype = 0; reptype = 0;
segoverride = 0; segoverride = 0;
@ -3393,6 +3393,7 @@ void exec86(int execloops) {
break; break;
} }
} }
return 1;
} }
void reset86() { void reset86() {

View File

@ -53,5 +53,5 @@ void write86 (uint32_t addr32, uint8_t value);
void writew86 (uint32_t addr32, uint16_t value); void writew86 (uint32_t addr32, uint16_t value);
uint8_t read86 (uint32_t addr32); uint8_t read86 (uint32_t addr32);
uint16_t readw86 (uint32_t addr32); uint16_t readw86 (uint32_t addr32);
void exec86(int execloops); int exec86(int execloops); // returns 0 if halted
void reset86(); void reset86();

View File

@ -1,3 +0,0 @@
mov al, 'X'
int 1
hlt

View File

@ -19,9 +19,14 @@ void int1() {
putchar(getreg8(regal)); putchar(getreg8(regal));
} }
void int2() {
putreg8(regal, getchar());
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
INTHOOKS[1] = int1; INTHOOKS[1] = int1;
INTHOOKS[2] = int2;
reset86(); reset86();
// initialize memory // initialize memory
FILE *bfp = fopen(FBIN_PATH, "r"); FILE *bfp = fopen(FBIN_PATH, "r");
@ -36,6 +41,6 @@ int main(int argc, char *argv[])
c = getc(bfp); c = getc(bfp);
} }
fclose(bfp); fclose(bfp);
exec86(100); while (exec86(100));
return 0; return 0;
} }

14
emul/8086/xcomp.fs Normal file
View File

@ -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!