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 / inst.h < prev    next >
Text File  |  1991-08-10  |  9KB  |  308 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. /* inst.h */
  26.  
  27. /* The followings are operand types of instructions. After these will 
  28.    be the set of all instructions. */
  29.  
  30. #define E  0
  31. #define PBB 1
  32. #define BW 2
  33. #define BC 3
  34. #define B  4
  35. #define PW  5
  36. #define PC  6
  37. #define PL  7
  38. #define BA 8
  39. #define BAA 9
  40. #define PA  10
  41. #define BL 11
  42. #define P  12
  43. #define BBB 13
  44. #define PWW 14
  45.  
  46. /* these are macros to use lpcreg as the instruction pointer and to
  47.     parse instruction operands into oprnd1, 2, and 3 */
  48.  
  49. #define parse_opPBB {lpcreg++; oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++;}
  50. #define parse_opBW {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  51. #define parse_opBC {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  52. #define parse_opB {oprnd1 = (word)*lpcreg++;}
  53. #define parse_opPW {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  54. #define parse_opPC {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  55. #define parse_opPL {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  56. #define parse_opBA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  57. #define parse_opBAA {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4; oprnd3 = *(pw)lpcreg; lpcreg+=4;}
  58. #define parse_opPA {lpcreg++; oprnd1 = *(pw)lpcreg; lpcreg+=4;}
  59. #define parse_opBL {oprnd1 = (word)*lpcreg++; oprnd2 = *(pw)lpcreg; lpcreg+=4;}
  60. #define parse_opP {oprnd1 = (word)*lpcreg++;}
  61. #define parse_opBBB {oprnd1 = (word)*lpcreg++; oprnd2 = (word)*lpcreg++; oprnd3 = (word)*lpcreg++;}
  62.  
  63.  
  64. extern int (*p_routine[])();
  65. /* extern int (*print_routine[])(); */
  66. extern int parse_table[];
  67. extern char *inst_name[];
  68. /* extern int (*jump_table[256])(); */
  69.  
  70. /**************************************************************************/
  71.  
  72. /*    The followings are the set of all instructions.                     */
  73.  
  74. /**************************************************************************/
  75.  
  76.  
  77. /* Basic term instructions (only those with a 00 annotation are now used) */
  78.  
  79. #define getpvar00       0x00
  80. #define getpval00       0x01
  81. #define getstrv00       0x02
  82. #define gettval00       0x03
  83. #define getcon00        0x04
  84. #define getnil00        0x05
  85. #define getstr00        0x06
  86. #define getlist00       0x07
  87. #define unipvar00       0x08
  88. #define unipval00       0x09
  89. #define unitvar00       0x0a
  90. #define unitval00       0x0b
  91. #define unicon00        0x0c
  92. #define uninil00        0x0d
  93. #define getnumcon    0x0e
  94. #define putnumcon    0x0f
  95. #define putpvar00       0x10
  96. #define putpval00       0x11
  97. #define puttvar00       0x12
  98. #define putstrv00       0x13
  99. #define putcon00        0x14
  100. #define putnil00        0x15
  101. #define putstr00        0x16
  102. #define putlist00       0x17
  103. #define bldpvar00       0x18
  104. #define bldpval00       0x19
  105. #define bldtvar00       0x1a
  106. #define bldtval00       0x1b
  107. #define bldcon00        0x1c
  108. #define bldnil00        0x1d
  109. #define uninumcon    0x1e
  110. #define bldnumcon    0x1f
  111. #define getfloatcon     0x20
  112. #define putfloatcon     0x21
  113. #define unifloatcon    0x22
  114. #define bldfloatcon     0x23
  115. #define getcon01        0x24
  116. #define getnil01        0x25
  117. #define getstr01        0x26
  118. #define getlist01       0x27
  119. #define unipvar01       0x28
  120. #define unipval01       0x29
  121. #define unitvar01       0x2a
  122. #define unitval01       0x2b
  123. #define unicon01        0x2c
  124. #define uninil01        0x2d
  125. #define putpvar01       0x30
  126. #define putpval01       0x31
  127. #define puttvar01       0x32
  128. #define putcon01        0x34
  129. #define putnil01        0x35
  130. #define putstr01        0x36
  131. #define putlist01       0x37
  132. #define bldpvar01       0x38
  133. #define bldpval01       0x39
  134. #define bldtvar01       0x3a
  135. #define bldtval01       0x3b
  136. #define bldcon01        0x3c
  137. #define bldnil01        0x3d
  138. #define getpvar10       0x40
  139. #define getpval10       0x41
  140. #define gettval10       0x43
  141. #define getcon10        0x44
  142. #define getnil10        0x45
  143. #define getstr10        0x46
  144. #define getlist10       0x47
  145. #define getlist_tvar_tvar    0x48
  146. #define getcomma    0x49
  147. #define getcomma_tvar_tvar    0x4a
  148. #define unicon10        0x4c
  149. #define uninil10        0x4d
  150. #define putpvar10       0x50
  151. #define putpval10       0x51
  152. #define puttvar10       0x52
  153. #define putcon10        0x54
  154. #define putnil10        0x55
  155. #define putstr10        0x56
  156. #define putlist10       0x57
  157. #define bldpvar10       0x58
  158. #define bldpval10       0x59
  159. #define bldtvar10       0x5a
  160. #define bldtval10       0x5b
  161. #define bldcon10        0x5c
  162. #define bldnil10        0x5d
  163. #define getpvar11       0x60
  164. #define getpval11       0x61
  165. #define gettval11       0x63
  166. #define getcon11        0x64
  167. #define getnil11        0x65
  168. #define getstr11        0x66
  169. #define getlist11       0x67
  170. #define unipvar11       0x68
  171. #define unipval11       0x69
  172. #define unitvar11       0x6a
  173. #define unitval11       0x6b
  174. #define unicon11        0x6c
  175. #define uninil11        0x6d
  176. #define putpvar11       0x70
  177. #define putpval11       0x71
  178. #define puttvar11       0x72
  179. #define putcon11        0x74
  180. #define putnil11        0x75
  181. #define putstr11        0x76
  182. #define putlist11       0x77
  183. #define bldpvar11       0x78
  184. #define bldpval11       0x79
  185. #define bldtvar11       0x7a
  186. #define bldtval11       0x7b
  187. #define bldcon11        0x7c
  188. #define bldnil11        0x7d
  189.  
  190.  
  191. /* Non-determinism instructions */
  192.  
  193. #define trymeelse       0xa0
  194. #define retrymeelse     0xa1
  195. #define trustmeelsefail 0xa2
  196. #define try             0xa3
  197. #define retry           0xa4
  198. #define trust           0xa5
  199. #define getpbreg        0xa6
  200. #define gettbreg    0xa7
  201. #define putpbreg    0xa8
  202. #define puttbreg    0xa9
  203. #define jumptbreg    0xaa
  204.  
  205.  
  206.  
  207. /* Indexing instructions */
  208.  
  209. #define switchonterm    0xb0
  210. #define switchoncon     0xb1
  211. #define switchonstr     0xb2
  212. #define switchonbound    0xb3
  213.  
  214.  
  215.  
  216. /* Numeric instructions */
  217.  
  218. #define movreg          0xd1
  219. #define negate        0xd2
  220. #define and         0xd3
  221. #define or         0xd4
  222. #define lshiftl        0xd5
  223. #define lshiftr        0xd6
  224. #define addreg          0xd7
  225. #define subreg          0xd8
  226. #define mulreg          0xd9
  227. #define divreg          0xda
  228.  
  229.  
  230. /* Unsafe term instructions (only those with a 00 annotation are now used) */
  231.  
  232. #define putdval00       0xe0
  233. #define putuval00       0xe1
  234.  
  235. #define getival         0xe2
  236.  
  237. #define putuval01       0xe3
  238. #define putdval10       0xe4
  239. #define putuval10       0xe5
  240. #define putdval11       0xe6
  241.  
  242.  
  243. /* Procedure instructions */
  244.  
  245. #define unexec          0xe7
  246. #define call            0xe8
  247. #define allocate        0xe9
  248. #define deallocate      0xea
  249. #define proceed         0xeb
  250. #define execute         0xec
  251. #define unexeci         0xed
  252. #define executev        0xee
  253. #define calld           0xef
  254.  
  255.  
  256.  
  257. /* Branching instructions */
  258.  
  259. #define jump            0xf0
  260. #define jumpz           0xf1
  261. #define jumpnz          0xf2
  262. #define jumplt          0xf3
  263. #define jumple          0xf4
  264. #define jumpgt          0xf5
  265. #define jumpge          0xf6
  266.  
  267.  
  268.  
  269. /* Miscellaneous instructions */
  270.  
  271. #define fail            0xf8
  272. #define noop            0xf9
  273. #define halt            0xfa
  274. #define builtin         0xfb
  275. #define hash        0xfe /* only used for disassembling */
  276. #define endfile         0xff
  277.     /* virtual instruction, used for disassembler to link different segs */
  278.  
  279.  
  280. extern int Switchoncon();
  281. extern int Switchonstr();
  282. extern int Switchonbound();
  283. extern int Builtin();
  284. /*
  285. extern int Getpval01();
  286. extern int Gettval01();
  287. extern int Getcon01();
  288. extern int Getnil01();
  289. extern int Getstr01();
  290. extern int Getlist01();
  291. extern int Bldpval01();
  292. extern int Bldtval01();
  293. extern int Unipvar01();
  294. extern int Unitvar01();
  295. extern int Unipval01();
  296. extern int Unitval01();
  297. extern int Unicon01();
  298. extern int Uninil01();
  299. extern int Getpval11();
  300. extern int Gettval11();
  301. extern int Getcon11();
  302. extern int Getnil11();
  303. extern int Getstr11();
  304. extern int Getlist11();
  305. extern int Bldpval11();
  306. extern int Bldtval11();
  307. */
  308.