home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / EFFO / pd3.lzh / SBPROLOG2.2 / SIM / sim.h < prev    next >
Text File  |  1991-08-10  |  5KB  |  132 lines

  1. /************************************************************************
  2. *                                    *
  3. *    The SB-Prolog System                        *
  4. *    Copyright SUNY at Stony Brook, 1986                *
  5. *                                    *
  6. ************************************************************************/
  7.  
  8. /*-----------------------------------------------------------------
  9. SB-Prolog is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY.  No author or distributor
  11. accepts responsibility to anyone for the consequences of using it
  12. or for whether it serves any particular purpose or works at all,
  13. unless he says so in writing.  Refer to the SB-Prolog General Public
  14. License for full details.
  15.  
  16. Everyone is granted permission to copy, modify and redistribute
  17. SB-Prolog, but only under the conditions described in the
  18. SB-Prolog General Public License.   A copy of this license is
  19. supposed to have been given to you along with SB-Prolog so you
  20. can know your rights and responsibilities.  It should be in a
  21. file named COPYING.  Among other things, the copyright notice
  22. and this notice must be preserved on all copies. 
  23. ------------------------------------------------------------------ */
  24.  
  25. /* sim.h */
  26.  
  27. #include <stdio.h>
  28. #include <math.h>
  29.  
  30. #define maxregs       257
  31. #define maxtraps      2
  32. #define WRITEFLAG     1
  33. #define READFLAG      0
  34. #define max_len       1280
  35. #define bucket_chain  53
  36. #define null          0
  37. #define true          1
  38. #define false         0
  39. #define PERM           1
  40. #define TEMP          0
  41. #define CAR           1
  42. #define CDR          0
  43.  
  44. #define T_ORDI  0    /* constant-type: no ep definition */
  45. #define T_DYNA    1    /* constant-type: dynamic, code in buffer */
  46. #define T_PRED  2    /* constant-type: ep points to compiled code */
  47. #define T_BUFF  3    /* constant-type: no ep field at all */
  48. #define T_TEMP_PRED 15    /* psc entry for predicate containing offset
  49.                 entry point */
  50.  
  51. /* ------------ Type Specifiers --------------------------------------- */
  52.  
  53. typedef unsigned char byte;
  54. typedef unsigned long word;
  55. typedef byte *pb;
  56. typedef word *pw;
  57.  
  58. struct psc_rec {
  59.     byte entry_type;
  60.     byte arity;
  61.     unsigned short length;
  62.     char  *nameptr;
  63.     byte  *ep;      /* entry point, various meaning */
  64. };
  65.  
  66.  
  67. /* --------- External variable declarations -------------------------------- */
  68.  
  69. extern int maxmem, maxpspace, maxtrail;
  70.  
  71. extern word     *memory;   /* heap, local stack   */
  72. extern word     *pspace; /* psc records, instructions, p-names */
  73. extern word     *tstack;
  74. extern word     reg[maxregs];     /* registers */
  75. extern word    psw;    /* processor status word: currently (2/87) only
  76.                the lowest bit is used: a value of 0 indicates
  77.                that the last arithmetic operation resulted in
  78.                an integer value, while a value of 1 indicates
  79.                a floating-point result.    */
  80.  
  81. extern byte     *trap_vector[maxtraps];
  82. extern word    *hash_table[bucket_chain][2];
  83.  
  84. extern word *local_bottom;
  85. extern word *heap_bottom;
  86. extern word *trail_bottom;
  87.  
  88. extern byte *curr_fence; /* ptr to next free byte in perm space */
  89. extern byte *max_fence; /* ptr to last+1 free byte in perm space */
  90. extern byte *inst_begin; /* ptr to the beginning of inst. array */
  91.  
  92. extern word *ereg;                /* last activation record       */
  93. extern word *breg;                /* last choice point            */
  94. extern word *hreg;                /* top of heap                  */
  95. extern word *trreg;               /* top of trail stack           */
  96. extern word *hbreg;               /* heap back track point        */
  97. extern word *sreg;                /* current build or unify field */
  98. extern byte *cpreg;      /* return point register        */
  99. extern byte *pcreg;    /* program counter              */
  100.  
  101. extern word oprnd1, oprnd2, oprnd3;
  102.  
  103. extern byte flag;   /* read/write mode flag            */
  104.  
  105. extern word flags[10];  /* user flags, -u[0-9], from command line */
  106. extern byte trace;     /* 1 = trace on, 0 = trace off     */
  107. extern byte hitrace;   /* 1 = hitrace on, 0 = hitrace off */
  108. extern byte overflow_f; /* 1 = ignore stack overflow */
  109. extern byte disassem;
  110. extern byte trace_sta;  /* 1 = keep max stack size stats */
  111. extern byte call_intercept; /* hitrace or trace_sta for efficiency */
  112.  
  113. extern word term ;  /* defined in "unsafe.c" ?? */
  114.  
  115. extern int pcstop;  /* used in "dis.c" ?? */
  116.  
  117. extern int num_line;
  118.  
  119. extern word nil_sym, list_str;
  120.  
  121. extern struct psc_rec *interrupt_psc;
  122. extern struct psc_rec *list_psc;
  123. extern struct psc_rec *comma_psc;
  124.  
  125. extern int pspace_used; /* heap_used, stack_used, trail_used; */
  126. extern pw mheaptop, mlocaltop, mtrailtop;
  127.  
  128. extern byte *sav_pcreg, *sav_ereg; /* to save old values of pcreg and ereg to handle
  129.                   saving of Prolog states correctly */
  130.  
  131. extern int interrupt_code;
  132.