Diff for /gforth/Attic/engine.c between versions 1.14 and 1.20

version 1.14, 1994/09/08 17:20:05 version 1.20, 1994/12/12 17:10:35
Line 1 Line 1
 /*  /*
   $Id$  
   Copyright 1992 by the ANSI figForth Development Group    Copyright 1992 by the ANSI figForth Development Group
 */  */
   
Line 17 Line 16
 #include "forth.h"  #include "forth.h"
 #include "io.h"  #include "io.h"
   
   #ifndef SEEK_SET
   /* should be defined in stdio.h, but some systems don't have it */
   #define SEEK_SET 0
   #endif
   
 typedef union {  typedef union {
   struct {    struct {
 #ifdef BIG_ENDIAN  #ifdef WORDS_BIGENDIAN
     Cell high;      Cell high;
     Cell low;      Cell low;
 #else  #else
Line 123  static char* fileattr[6]={"r","rb","r+", Line 127  static char* fileattr[6]={"r","rb","r+",
   
 static Address up0=NULL;  static Address up0=NULL;
   
 #if defined(i386) && defined(FORCE_REG)  /* if machine.h has not defined explicit registers, define them as implicit */
 #  define REG(reg) __asm__(reg)  #ifndef IPREG
   #define IPREG
 Label *engine(Xt *ip0, Cell *sp0, Cell *rp, Float *fp, Address lp)  #endif
 {  #ifndef SPREG
    register Xt *ip REG("%esi")=ip0;  #define SPREG
    register Cell *sp REG("%edi")=sp0;  #endif
   #ifndef RPREG
 #else  #define RPREG
 #  define REG(reg)  #endif
   #ifndef FPREG
 Label *engine(Xt *ip, Cell *sp, Cell *rp, Float *fp, Address lp)  #define FPREG
 {  #endif
   #ifndef LPREG
   #define LPREG
   #endif
   #ifndef CFAREG
   #define CFAREG
   #endif
   #ifndef UPREG
   #define UPREG
 #endif  #endif
   #ifndef TOSREG
   #define TOSREG
   #endif
   #ifndef FTOSREG
   #define FTOSREG
   #endif
   
   Label *engine(Xt *ip0, Cell *sp0, Cell *rp0, Float *fp0, Address lp0)
 /* 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
 */  */
   register Xt cfa  {
 #ifdef i386    register Xt *ip IPREG = ip0;
 #  ifdef USE_TOS    register Cell *sp SPREG = sp0;
    REG("%ecx")    register Cell *rp RPREG = rp0;
 #  else    register Float *fp FPREG = fp0;
    REG("%edx")    register Address lp LPREG = lp0;
 #  endif    register Xt cfa CFAREG;
 #endif    register Address up UPREG = up0;
    ;    IF_TOS(register Cell TOS TOSREG;)
   Address up=up0;    IF_FTOS(register Float FTOS FTOSREG;)
   static Label symbols[]= {    static Label symbols[]= {
     &&docol,      &&docol,
     &&docon,      &&docon,
Line 160  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 180  Label *engine(Xt *ip, Cell *sp, Cell *rp
     &&dodoes,  /* 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_FTOS(Float FTOS;)  
 #ifdef CPU_DEP  #ifdef CPU_DEP
   CPU_DEP;    CPU_DEP;
 #endif  #endif
   
   #ifdef DEBUG
     fprintf(stderr,"ip=%x, sp=%x, rp=%x, fp=%x, lp=%x, up=%x\n",
             (unsigned)ip,(unsigned)sp,(unsigned)rp,
             (unsigned)fp,(unsigned)lp,(unsigned)up);
   #endif
   
   if (ip == NULL)    if (ip == NULL)
     return symbols;      return symbols;
   
Line 176  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 200  Label *engine(Xt *ip, Cell *sp, Cell *rp
       
  docol:   docol:
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x: col: %08x\n",(Cell)ip,(Cell)PFA1(cfa));    fprintf(stderr,"%08x: col: %08x\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
 #ifdef i386  #ifdef CISC_NEXT
   /* this is the simple version */    /* this is the simple version */
   *--rp = (Cell)ip;    *--rp = (Cell)ip;
   ip = (Xt *)PFA1(cfa);    ip = (Xt *)PFA1(cfa);
   NEXT;    NEXT;
 #endif  #else
   /* this one is important, so we help the compiler optimizing    /* this one is important, so we help the compiler optimizing
      The following version may be better (for scheduling), but probably has       The following version may be better (for scheduling), but probably has
      problems with code fields employing calls and delay slots       problems with code fields employing calls and delay slots
Line 197  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 221  Label *engine(Xt *ip, Cell *sp, Cell *rp
     ip = current_ip+1;      ip = current_ip+1;
     NEXT1_P2;      NEXT1_P2;
   }    }
   #endif
       
  docon:   docon:
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x: con: %08x\n",(Cell)ip,*(Cell*)PFA1(cfa));    fprintf(stderr,"%08x: con: %08x\n",(Cell)ip,*(Cell*)PFA1(cfa));
 #endif  #endif
 #ifdef USE_TOS  #ifdef USE_TOS
   *sp-- = TOS;    *sp-- = TOS;
Line 212  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 237  Label *engine(Xt *ip, Cell *sp, Cell *rp
       
  dovar:   dovar:
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x: var: %08x\n",(Cell)ip,(Cell)PFA1(cfa));    fprintf(stderr,"%08x: var: %08x\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
 #ifdef USE_TOS  #ifdef USE_TOS
   *sp-- = TOS;    *sp-- = TOS;
Line 226  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 251  Label *engine(Xt *ip, Cell *sp, Cell *rp
       
  douser:   douser:
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x: user: %08x\n",(Cell)ip,(Cell)PFA1(cfa));    fprintf(stderr,"%08x: user: %08x\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
 #ifdef USE_TOS  #ifdef USE_TOS
   *sp-- = TOS;    *sp-- = TOS;
Line 238  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 263  Label *engine(Xt *ip, Cell *sp, Cell *rp
       
  dodefer:   dodefer:
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x: defer: %08x\n",(Cell)ip,(Cell)PFA1(cfa));    fprintf(stderr,"%08x: defer: %08x\n",(Cell)ip,(Cell)PFA1(cfa));
 #endif  #endif
   cfa = *(Xt *)PFA1(cfa);    cfa = *(Xt *)PFA1(cfa);
   NEXT1;    NEXT1;
Line 262  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 287  Label *engine(Xt *ip, Cell *sp, Cell *rp
             
      */       */
 #ifdef DEBUG  #ifdef DEBUG
   printf("%08x/%08x: does: %08x\n",(Cell)ip,(Cell)cfa,*(Cell)PFA(cfa));    fprintf(stderr,"%08x/%08x: does: %08x\n",(Cell)ip,(Cell)PFA(cfa),(Cell)DOES_CODE1(cfa));
   fflush(stdout);    fflush(stderr);
 #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 */
Line 275  Label *engine(Xt *ip, Cell *sp, Cell *rp Line 300  Label *engine(Xt *ip, Cell *sp, Cell *rp
   *--sp = (Cell)PFA(cfa);    *--sp = (Cell)PFA(cfa);
 #endif  #endif
   NEXT;    NEXT;
     
 #include "primitives.i"  #include "primitives.i"
 }  }

Removed from v.1.14  
changed lines
  Added in v.1.20


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>