File:  [gforth] / gforth / Attic / decstation.h
Revision 1.1: download - view: text, annotated - select for diffs
Fri Feb 11 16:30:46 1994 UTC (25 years, 5 months ago) by anton
Branches: MAIN
CVS tags: HEAD
Initial revision

    1: /*
    2:   $Id: decstation.h,v 1.1 1994/02/11 16:30:46 anton Exp $
    3:   Copyright 1992 by the ANSI figForth Development Group
    4: 
    5:   This is the machine-specific part for a Decstation running Ultrix
    6: */
    7: 
    8: 
    9: /* Cell and UCell must be the same size as a pointer */
   10: typedef long Cell;
   11: typedef unsigned long UCell;
   12: 
   13: /* DCell and UDCell must be twice as large as Cell */
   14: typedef long long DCell;
   15: typedef unsigned long long UDCell;
   16: 
   17: /* define this if IEEE singles and doubles are available as C data types */
   18: #define IEEE_FP
   19: 
   20: /* the IEEE types are used only for loading and storing */
   21: /* the IEEE double precision type */
   22: typedef double DFloat;
   23: /* the IEEE single precision type */
   24: typedef float SFloat;
   25: 
   26: /* define this if the least-significant byte is at the largets address */
   27: /* #define BIG_ENDIAN */
   28: 
   29: /* some definitions for composing opcodes */
   30: #define JUMP_MASK	0x03ffffff
   31: #define J_PATTERN	0x08000000
   32: #define JAL_PATTERN	0x0c000000
   33: /* this provides the first 4 bits of a jump address, i.e. it must be <16 */
   34: #define SEGMENT_NUM	1
   35: 
   36: #ifdef DIRECT_THREADED
   37: 	/* PFA gives the parameter field address corresponding to a cfa */
   38: #	define PFA(cfa)	(((Cell *)cfa)+2)
   39: 	/* PFA1 is a special version for use just after a NEXT1 */
   40: #	define PFA1(cfa)	PFA(cfa)
   41: 	/* CODE_ADDRESS is the address of the code jumped to through the code field */
   42: #	define CODE_ADDRESS(cfa)	((Label)(((*(unsigned *)(cfa))^J_PATTERN^(SEGMENT_NUM<<26))<<2))
   43: 	/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
   44: #	define MAKE_CF(cfa,ca)	({long * _cfa = (long *)(cfa); \
   45: 					  _cfa[0] = J_PATTERN|((((long)(ca))&JUMP_MASK)>>2); /* J ca */ \
   46: 					  _cfa[1] = 0; /* nop */})
   47: #	ifdef undefined
   48: 		/* the following version uses JAL to make PFA1 faster */
   49: #		define PFA1(label)	({register Cell *pfa asm("$31"); \
   50: 						pfa; })
   51: 		/* CODE_ADDRESS is the address of the code jumped to through the code field */
   52: #		define CODE_ADDRESS(cfa)	((Label)(((*(unsigned *)(cfa))^JAL_PATTERN^(SEGMENT_NUM<<26))<<2))
   53: #		define MAKE_CF(cfa,ca)	({long *_cfa = (long *)(cfa); \
   54: 					  long _ca = (long)(ca);
   55: 						  _cfa[0] = JAL_PATTERN|(((((long)_ca)>>2)+4)&JUMP_MASK), /* JAL ca+4 */ \
   56: 						  _cfa[1] = *(long *)_ca; /* delay slot */})
   57: #	endif /* undefined */
   58: 
   59: 	/* this is the point where the does code starts if label points to the
   60: 	 * jump dodoes */
   61: #	define DOES_CODE(cfa)	((Xt *)(((char *)CODE_ADDRESS(cfa))+8))
   62: 
   63: 	/* this is a special version of DOES_CODE for use in dodoes */
   64: #	define DOES_CODE1(cfa)	DOES_CODE(cfa)
   65: 
   66: #	define DOES_HANDLER_SIZE	8
   67: #	define MAKE_DOES_CF(cfa, does_code)	({char *does_handlerp=((char *)does_code)-DOES_HANDLER_SIZE;	\
   68: 						  MAKE_CF(cfa,does_handlerp);	\
   69: 						  MAKE_DOES_HANDLER(does_handlerp);})
   70: 	/* this stores a jump dodoes at addr */
   71: #	define MAKE_DOES_HANDLER(addr)	({long * _addr = (long *)addr; \
   72: 					  _addr[0] = J_PATTERN|((((long)DODOES)>>2)&JUMP_MASK); /* J dodoes */ \
   73: 					  _addr[1] = 0; /* nop */})
   74: #endif
   75: #ifdef undefined
   76: /* and here are some more efficient versions that can be tried later */
   77: 
   78: /* the first version saves one cycle by doing something useful in the
   79:    delay slot. !! check that the instruction in the delay slot is legal
   80: */
   81: 
   82: #define MAKE_DOESJUMP(addr)	({long * _addr = (long *)addr; \
   83: 				  _addr[0] = J_PATTERN|(((((long)symbols[3])>>2)+4)&JUMP_MASK), /* J dodoes+4 */ \
   84: 				  _addr[1] = *(long *)symbols[3]; /* delay */})
   85: 
   86: /* the following version uses JAL to make DOES_CODE1 faster */
   87: /* !! does the declaration clear the register ? */
   88: /* it's ok to use the same reg as in PFA1:
   89:    dodoes is the only potential problem and I have taken care of it */
   90: #define DOES_CODE1(cfa)	({register Code *_does_code asm("$31"); \
   91: 				    _does_code; })
   92: #define MAKE_DOESJUMP(addr)	({long * _addr = (long *)addr; \
   93: 				  _addr[0] = JAL_PATTERN|(((((long)symbols[3])>>2)+4)&JUMP_MASK), /* JAL dodoes+4 */ \
   94: 				  _addr[1] = *(long *)symbols[3]; /* delay */})
   95: 
   96: #endif

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