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

    1: /*
    2:   $Id: hppa.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 HPPA running HP-UX
    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: #ifdef DIRECT_THREADED
   30: 	/* PFA gives the parameter field address corresponding to a cfa */
   31: #	define PFA(cfa)	(((Cell *)cfa)+2)
   32: 	/* PFA1 is a special version for use just after a NEXT1 */
   33: 	/* the improvement here is that we may destroy cfa before using PFA1 */
   34: #	define PFA1(cfa)       /* PFA(cfa) */ \
   35: 	                        ({register volatile Cell *pfa asm("%31"); \
   36: 	                          ((int)pfa & (-4)); })
   37: 	/* HPPA uses register 2 for branch and link */
   38: 
   39: 	/* CODE_ADDRESS is the address of the code jumped to through the code field */
   40: #	define CODE_ADDRESS(cfa)	((Label)((*(unsigned *)(cfa))/* <<2 */))
   41: 	/* MAKE_CF creates an appropriate code field at the cfa; ca is the code address */
   42: 	/* we use ble and a register, since 'bl' only has 21 bits displacement */
   43: #endif
   44: #define MAKE_CFA(cfa,ca)	({long *_cfa        = (long *)(cfa); \
   45: 			  unsigned _ca = (unsigned)(ca); \
   46: 				  _cfa[0] = 0xE4A02000 | ((_ca+4-symbols[0]) & 0x7FC)<<1 ; \
   47: 				  _cfa[1] = *(long *)(_ca); \
   48: 				  /* printf("%08x:%08x,%08x\n",_cfa,_cfa[0],_cfa[1]); */ \
   49: 			  })
   50: 
   51: #ifdef DIRECT_THREADED
   52: #	define MAKE_CF(cfa,ca)		MAKE_CFA(cfa,ca)
   53: 	/*
   54: 	#define MAKE_CF(cfa,ca)	({long *_cfa        = (long *)(cfa); \
   55: 			  unsigned _ca = (unsigned)(ca); \
   56: 			  if((_ca-(int)(_cfa+1)>=-0x40000)||(_ca-(int)(_cfa+1)<0x40000)) \
   57: 			  { \
   58: 				  _cfa[1] = *(long *)(_ca); \
   59: 				  _ca = _ca-(int)(_cfa+1); \
   60: 				  _cfa[0] = 0xEBE00000 | \
   61: 				            ((int)_ca<0) | \
   62: 				            (_ca & 0x00FFC)<<1 | \
   63: 				            (_ca & 0x01000)>>10 | \
   64: 				            (_ca & 0x3E000)<<3; \
   65: 			  } \
   66: 			  else \
   67: 			  { \
   68: 				  _cfa[0] = 0x20200000 | \
   69: 				            ((int)_ca<0) | \
   70: 				            (_ca & 0x00001800)<<1 | \
   71: 				            (_ca & 0x0003E000)<<3 | \
   72: 				            (_ca & 0x000C0000)>>4 | \
   73: 				            (_ca & 0x7FF00000)>>19  \
   74: 				  _cfa[1] = 0xE4202002 | (_ca & 0x7FC)<<1 ; \
   75: 			  }})
   76: 	*/
   77: 	/* HP wins the price for the most obfuscated binary opcode */
   78: 
   79: 	/* this is the point where the does code starts if label points to the
   80: 	 * jump dodoes */
   81: 
   82: #	define DOES_CODE(label)	(((Xt *)(label))+2)
   83: 
   84: 	/* this is a special version of DOES_CODE for use in dodoes */
   85: #	define DOES_CODE1(label)	({register volatile Xt *_does_code asm("%31"); \
   86: 					  (Xt *)((int)_does_code & (-4)); })
   87: 	/* HPPA uses register 2 for branch and link */
   88: 
   89: 	/* this stores a call dodoes at addr */
   90: #	define MAKE_DOESJUMP(addr)	MAKE_CFA((addr),symbols[3])
   91: #endif
   92: 
   93: /* OS dependences */
   94: 
   95: #define SEEK_SET 0
   96: #define rint(x)	floor((x)+0.5)
   97: 
   98: #ifdef DIRECT_THREADED
   99: #	define CPU_DEP  register Label branchto asm("%5")=symbols[0];
  100: #	define CPU_DEP2 &&deadcode
  101: #	define CPU_DEP3 deadcode: return((Label *)branchto);
  102: #endif

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