1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-10-07 04:00:58 +11:00
collapseos/emul/8086/forth.c
2020-10-24 21:50:44 -04:00

42 lines
735 B
C

#include <stdint.h>
#include <stdio.h>
#include "cpu.h"
#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));
}
int main(int argc, char *argv[])
{
INTHOOKS[1] = int1;
reset86();
// 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);
}
fclose(bfp);
exec86(100);
return 0;
}