version 1.4, 1994/05/05 15:46:42
|
version 1.7, 1994/06/01 10:05:15
|
Line 13
|
Line 13
|
#include <assert.h> |
#include <assert.h> |
#include <stdlib.h> |
#include <stdlib.h> |
#include <time.h> |
#include <time.h> |
|
#include <sys/time.h> |
|
#include <sys/unistd.h> |
#include "forth.h" |
#include "forth.h" |
#include "io.h" |
#include "io.h" |
|
|
extern unlink(char *); |
|
extern ftruncate(int, int); |
|
|
|
typedef union { |
typedef union { |
struct { |
struct { |
#ifdef BIG_ENDIAN |
#ifdef BIG_ENDIAN |
Line 72 typedef struct F83Name {
|
Line 71 typedef struct F83Name {
|
#define FTOS (fp[0]) |
#define FTOS (fp[0]) |
#endif |
#endif |
|
|
/* |
|
#define CA_DODOES (symbols[DODOES]) |
|
*/ |
|
|
|
int emitcounter; |
int emitcounter; |
#define NULLC '\0' |
#define NULLC '\0' |
|
|
Line 86 int emitcounter;
|
Line 81 int emitcounter;
|
|
|
static char* fileattr[6]={"r","rb","r+","r+b","w+","w+b"}; |
static char* fileattr[6]={"r","rb","r+","r+b","w+","w+b"}; |
|
|
Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp) |
Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp) |
/* executes code at ip, if ip!=NULL |
/* executes code at ip, if ip!=NULL |
returns array of machine code labels (for use in a loader), 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; |
Xt cfa; |
Address lp=NULL; |
|
Address up=NULL; |
Address up=NULL; |
static Label symbols[]= { |
static Label symbols[]= { |
&&docol, |
&&docol, |
Line 101 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 94 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
&&dovar, |
&&dovar, |
&&douser, |
&&douser, |
&&dodoes, |
&&dodoes, |
&&docol, /* dummy for does handler address */ |
&&dodoes, /* dummy for does handler address */ |
#include "prim_labels.i" |
#include "prim_labels.i" |
}; |
}; |
IF_TOS(register Cell TOS;) |
IF_TOS(register Cell TOS;) |
Line 120 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 113 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
|
|
docol: |
docol: |
#ifdef DEBUG |
#ifdef DEBUG |
printf("col: %x\n",(Cell)PFA1(cfa)); |
printf("%08x: col: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); |
#endif |
#endif |
#ifdef undefined |
#ifdef undefined |
/* this is the simple version */ |
/* this is the simple version */ |
Line 144 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 137 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
|
|
docon: |
docon: |
#ifdef DEBUG |
#ifdef DEBUG |
printf("con: %x\n",*(Cell*)PFA1(cfa)); |
printf("%08x: con: %08x\n",(Cell)ip,*(Cell*)PFA1(cfa)); |
#endif |
#endif |
#ifdef USE_TOS |
#ifdef USE_TOS |
*sp-- = TOS; |
*sp-- = TOS; |
Line 156 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 149 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
|
|
dovar: |
dovar: |
#ifdef DEBUG |
#ifdef DEBUG |
printf("var: %x\n",(Cell)PFA1(cfa)); |
printf("%08x: var: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); |
#endif |
#endif |
#ifdef USE_TOS |
#ifdef USE_TOS |
*sp-- = TOS; |
*sp-- = TOS; |
Line 170 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 163 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
|
|
douser: |
douser: |
#ifdef DEBUG |
#ifdef DEBUG |
printf("user: %x\n",(Cell)PFA1(cfa)); |
printf("%08x: user: %08x\n",(Cell)ip,(Cell)PFA1(cfa)); |
#endif |
#endif |
#ifdef USE_TOS |
#ifdef USE_TOS |
*sp-- = TOS; |
*sp-- = TOS; |
TOS = up+*(Cell*)PFA1(cfa); |
TOS = (Cell)(up+*(Cell*)PFA1(cfa)); |
#else |
#else |
*--sp = up+*(Cell*)PFA1(cfa); |
*--sp = (Cell)(up+*(Cell*)PFA1(cfa)); |
#endif |
#endif |
NEXT; |
NEXT; |
|
|
Line 199 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
Line 192 Label *engine(Xt *ip, Cell *sp, Cell *rp
|
|
|
*/ |
*/ |
#ifdef DEBUG |
#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 |
#endif |
*--rp = (Cell)ip; |
*--rp = (Cell)ip; |
/* PFA1 might collide with DOES_CODE1 here, so we use PFA */ |
/* PFA1 might collide with DOES_CODE1 here, so we use PFA */ |