| /* Gforth virtual machine (aka inner interpreter) |
/* Gforth virtual machine (aka inner interpreter) |
| |
|
| Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. |
Copyright (C) 1995,1996,1997,1998,2000 Free Software Foundation, Inc. |
| |
|
| This file is part of Gforth. |
This file is part of Gforth. |
| |
|
| |
|
| You should have received a copy of the GNU General Public License |
You should have received a copy of the GNU General Public License |
| along with this program; if not, write to the Free Software |
along with this program; if not, write to the Free Software |
| Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. |
| */ |
*/ |
| |
|
| #include "config.h" |
#include "config.h" |
| #include <unistd.h> |
#include <unistd.h> |
| #include <pwd.h> |
#include <pwd.h> |
| #include <dirent.h> |
#include <dirent.h> |
| |
#include <sys/resource.h> |
| #ifdef HAVE_FNMATCH_H |
#ifdef HAVE_FNMATCH_H |
| #include <fnmatch.h> |
#include <fnmatch.h> |
| #else |
#else |
| } |
} |
| #endif |
#endif |
| |
|
| |
DCell timeval2us(struct timeval *tvp) |
| |
{ |
| |
#ifndef BUGGY_LONG_LONG |
| |
return (tvp->tv_sec*(DCell)1000000)+tvp->tv_usec; |
| |
#else |
| |
DCell d2; |
| |
DCell d1=mmul(tvp->tv_sec,1000000); |
| |
d2.lo = d1.lo+tvp->tv_usec; |
| |
d2.hi = d1.hi + (d2.lo<d1.lo); |
| |
return d2; |
| |
#endif |
| |
} |
| |
|
| #define NEWLINE '\n' |
#define NEWLINE '\n' |
| |
|
| #ifndef HAVE_RINT |
#ifndef HAVE_RINT |
| MORE_VARS |
MORE_VARS |
| #endif |
#endif |
| register Address up UPREG = UP; |
register Address up UPREG = UP; |
| IF_TOS(register Cell TOS TOSREG;) |
IF_spTOS(register Cell spTOS TOSREG;) |
| IF_FTOS(register Float FTOS FTOSREG;) |
IF_fpTOS(register Float fpTOS FTOSREG;) |
| #if defined(DOUBLY_INDIRECT) |
#if defined(DOUBLY_INDIRECT) |
| static Label *symbols; |
static Label *symbols; |
| static void *routines[]= { |
static void *routines[]= { |
| return symbols; |
return symbols; |
| } |
} |
| |
|
| IF_TOS(TOS = sp[0]); |
IF_spTOS(spTOS = sp[0]); |
| IF_FTOS(FTOS = fp[0]); |
IF_fpTOS(fpTOS = fp[0]); |
| /* prep_terminal(); */ |
/* prep_terminal(); */ |
| SET_IP(ip); |
SET_IP(ip); |
| NEXT; |
NEXT; |
| fprintf(stderr,"%08lx: con: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa)); |
fprintf(stderr,"%08lx: con: %08lx\n",(Cell)ip,*(Cell*)PFA1(cfa)); |
| #endif |
#endif |
| #ifdef USE_TOS |
#ifdef USE_TOS |
| *sp-- = TOS; |
*sp-- = spTOS; |
| TOS = *(Cell *)PFA1(cfa); |
spTOS = *(Cell *)PFA1(cfa); |
| #else |
#else |
| *--sp = *(Cell *)PFA1(cfa); |
*--sp = *(Cell *)PFA1(cfa); |
| #endif |
#endif |
| fprintf(stderr,"%08lx: var: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
fprintf(stderr,"%08lx: var: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
| #endif |
#endif |
| #ifdef USE_TOS |
#ifdef USE_TOS |
| *sp-- = TOS; |
*sp-- = spTOS; |
| TOS = (Cell)PFA1(cfa); |
spTOS = (Cell)PFA1(cfa); |
| #else |
#else |
| *--sp = (Cell)PFA1(cfa); |
*--sp = (Cell)PFA1(cfa); |
| #endif |
#endif |
| fprintf(stderr,"%08lx: user: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
fprintf(stderr,"%08lx: user: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
| #endif |
#endif |
| #ifdef USE_TOS |
#ifdef USE_TOS |
| *sp-- = TOS; |
*sp-- = spTOS; |
| TOS = (Cell)(up+*(Cell*)PFA1(cfa)); |
spTOS = (Cell)(up+*(Cell*)PFA1(cfa)); |
| #else |
#else |
| *--sp = (Cell)(up+*(Cell*)PFA1(cfa)); |
*--sp = (Cell)(up+*(Cell*)PFA1(cfa)); |
| #endif |
#endif |
| #ifdef DEBUG |
#ifdef DEBUG |
| fprintf(stderr,"%08lx: field: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
fprintf(stderr,"%08lx: field: %08lx\n",(Cell)ip,(Cell)PFA1(cfa)); |
| #endif |
#endif |
| TOS += *(Cell*)PFA1(cfa); |
spTOS += *(Cell*)PFA1(cfa); |
| } |
} |
| NEXT_P0; |
NEXT_P0; |
| NEXT; |
NEXT; |
| *--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 */ |
| #ifdef USE_TOS |
#ifdef USE_TOS |
| *sp-- = TOS; |
*sp-- = spTOS; |
| TOS = (Cell)PFA(cfa); |
spTOS = (Cell)PFA(cfa); |
| #else |
#else |
| *--sp = (Cell)PFA(cfa); |
*--sp = (Cell)PFA(cfa); |
| #endif |
#endif |
| SET_IP(DOES_CODE1(cfa)); |
SET_IP(DOES_CODE1(cfa)); |
| /* fprintf(stderr,"TOS = %08lx, IP=%08lx\n", TOS, IP);*/ |
/* fprintf(stderr,"TOS = %08lx, IP=%08lx\n", spTOS, IP);*/ |
| } |
} |
| NEXT; |
NEXT; |
| |
|