--- gforth/Attic/engine.c 1994/05/05 15:46:42 1.4 +++ gforth/Attic/engine.c 1994/07/13 19:21:02 1.11 @@ -1,5 +1,5 @@ /* - $Id: engine.c,v 1.4 1994/05/05 15:46:42 pazsan Exp $ + $Id: engine.c,v 1.11 1994/07/13 19:21:02 pazsan Exp $ Copyright 1992 by the ANSI figForth Development Group */ @@ -13,12 +13,10 @@ #include #include #include +#include #include "forth.h" #include "io.h" -extern unlink(char *); -extern ftruncate(int, int); - typedef union { struct { #ifdef BIG_ENDIAN @@ -72,10 +70,6 @@ typedef struct F83Name { #define FTOS (fp[0]) #endif -/* -#define CA_DODOES (symbols[DODOES]) -*/ - int emitcounter; #define NULLC '\0' @@ -86,22 +80,22 @@ int emitcounter; static char* fileattr[6]={"r","rb","r+","r+b","w+","w+b"}; -Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp) +static Address up0=NULL; + +Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp) /* executes code at ip, if ip!=NULL returns array of machine code labels (for use in a loader), if ip==NULL - This is very preliminary, as the bootstrap architecture is not yet decided */ { Xt cfa; - Address lp=NULL; - Address up=NULL; + Address up=up0; static Label symbols[]= { &&docol, &&docon, &&dovar, &&douser, &&dodoes, - &&docol, /* dummy for does handler address */ + &&dodoes, /* dummy for does handler address */ #include "prim_labels.i" }; IF_TOS(register Cell TOS;) @@ -112,7 +106,7 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp if (ip == NULL) return symbols; - + IF_TOS(TOS = sp[0]); IF_FTOS(FTOS = fp[0]); prep_terminal(); @@ -120,7 +114,7 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp docol: #ifdef DEBUG - printf("col: %x\n",(Cell)PFA1(cfa)); + printf("%08x: col: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); #endif #ifdef undefined /* this is the simple version */ @@ -144,7 +138,7 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp docon: #ifdef DEBUG - printf("con: %x\n",*(Cell*)PFA1(cfa)); + printf("%08x: con: %08x\n",(Cell)ip,*(Cell*)PFA1(cfa)); #endif #ifdef USE_TOS *sp-- = TOS; @@ -156,7 +150,7 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp dovar: #ifdef DEBUG - printf("var: %x\n",(Cell)PFA1(cfa)); + printf("%08x: var: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); #endif #ifdef USE_TOS *sp-- = TOS; @@ -170,13 +164,13 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp douser: #ifdef DEBUG - printf("user: %x\n",(Cell)PFA1(cfa)); + printf("%08x: user: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); #endif #ifdef USE_TOS *sp-- = TOS; - TOS = up+*(Cell*)PFA1(cfa); + TOS = (Cell)(up+*(Cell*)PFA1(cfa)); #else - *--sp = up+*(Cell*)PFA1(cfa); + *--sp = (Cell)(up+*(Cell*)PFA1(cfa)); #endif NEXT; @@ -199,7 +193,8 @@ Label *engine(Xt *ip, Cell *sp, Cell *rp */ #ifdef DEBUG - printf("does: %x\n",(Cell)PFA(cfa)); fflush(stdout); + printf("%08x/%08x: does: %08x\n",(Cell)ip,(Cell)cfa,*(Cell)PFA(cfa)); + fflush(stdout); #endif *--rp = (Cell)ip; /* PFA1 might collide with DOES_CODE1 here, so we use PFA */