collapseos/emul/8086/forth.c

42 lines
735 B
C
Raw Normal View History

2020-10-24 20:41:51 -04:00
#include <stdint.h>
#include <stdio.h>
#include "cpu.h"
2020-10-24 21:50:44 -04:00
#ifndef FBIN_PATH
#error FBIN_PATH needed
#endif
extern uint8_t byteregtable[8];
extern union _bytewordregs_ regs;
extern INTHOOK INTHOOKS[0x100];
/* we have a fake INT API:
INT 1: EMIT. AL = char to spit
INT 2: KEY. AL = char read
*/
void int1() {
putchar(getreg8(regal));
}
2020-10-24 20:41:51 -04:00
int main(int argc, char *argv[])
{
2020-10-24 21:50:44 -04:00
INTHOOKS[1] = int1;
2020-10-24 20:41:51 -04:00
reset86();
2020-10-24 21:50:44 -04:00
// initialize memory
FILE *bfp = fopen(FBIN_PATH, "r");
if (!bfp) {
fprintf(stderr, "Can't open forth.bin\n");
return 1;
}
int i = 0;
int c = getc(bfp);
while (c != EOF) {
write86(i++, c);
c = getc(bfp);
2020-10-24 20:41:51 -04:00
}
2020-10-24 21:50:44 -04:00
fclose(bfp);
exec86(100);
2020-10-24 20:41:51 -04:00
return 0;
}