version 1.20, 2000/07/27 10:40:42
|
version 1.24, 2000/11/10 10:04:21
|
Line 1
|
Line 1
|
/* 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. |
|
|
Line 16
|
Line 16
|
|
|
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" |
Line 39
|
Line 39
|
#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 |
Line 169 char *tilde_cstr(Char *from, UCell size,
|
Line 170 char *tilde_cstr(Char *from, UCell size,
|
} |
} |
#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 |
Line 259 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 273 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
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[]= { |
Line 313 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 327 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
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; |
Line 355 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 369 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
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 |
Line 371 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 385 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
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 |
Line 387 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 401 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
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 |
Line 411 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 425 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
#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; |
Line 445 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
Line 459 Label *engine(Xt *ip0, Cell *sp0, Cell *
|
*--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; |
|
|