home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oxcc1433.zip / SRC / OXBYTES.H < prev    next >
C/C++ Source or Header  |  1995-07-07  |  8KB  |  320 lines

  1. /* 
  2.     oxbytes.h -- v1.430 definition of bytecodes for oxbow interpreter `bterp'
  3.  
  4.     Copyright (c) 1995
  5.     Norman D. Culver dba
  6.     Oxbow Software
  7.     1323 S.E. 17th Street #662
  8.     Ft. Lauderdale, FL 33316
  9.     (305) 527-1663 Voice
  10.     (305) 760-7584 Fax
  11.     (305) 760-4679 Data
  12.     norman.culver@channel1.com
  13.     All rights reserved.
  14.  
  15.  * Redistribution and use in source and binary forms are permitted
  16.  * provided that: (1) source distributions retain this entire copyright
  17.  * notice and comment, and (2) distributions including binaries display
  18.  * the following acknowledgement:  ``This product includes software
  19.  * developed by Norman D. Culver dba Oxbow Software''
  20.  * in the documentation or other materials provided with the distribution
  21.  * and in all advertising materials mentioning features or use of this
  22.  * software.
  23.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  24.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  25.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  26.  
  27. */
  28.  
  29. #if NEED_BYTECODES
  30.  
  31. #if SUPPORT_LONG_DOUBLE
  32. #define XSZ (sizeof(long double))
  33. #else
  34. #define XSZ (sizeof(double))
  35. #endif
  36.  
  37.  
  38. #define A1 (0<<2)
  39. #define A2 (1<<2)
  40. #define A3 (2<<2)
  41. #define A4 (3<<2)
  42.  
  43. #define S1 (0<<2)
  44. #define S2 (1<<2)
  45. #define S3 (2<<2)
  46. #define S4 (3<<2)
  47.  
  48. #define D1 (0)
  49. #define D2 (1)
  50. #define D3 (2)
  51. #define D4 (3)
  52.  
  53. #define B1 (0)
  54. #define B2 (1)
  55. #define B4 (2)
  56. #define B8 (3)
  57. #define BX (4)
  58.  
  59. #define J1 (0)
  60. #define J2 (1)
  61. #define J3 (2)
  62. #define J4 (3)
  63.  
  64. #define BYTE    (0)
  65. #define SHORT    (1)
  66. #define LONG    (2)
  67. #define UBYTE    (3)
  68. #define USHORT    (4)
  69. #define ULONG    (5)
  70. #define FLOAT    (6)
  71. #define DOUBLE    (7)
  72.  
  73. #define SLONGLONG (6)
  74. #define SULONGLONG (7)
  75.  
  76. #define CLONGLONG    (8)
  77. #define CULONGLONG    (9)
  78. #define CLONGDOUBLE (10)    
  79.  
  80. #define LONGLONG    (0)
  81. #define ULONGLONG    (1)
  82. #define LONGDOUBLE    (2)
  83.  
  84. #define LS        (0x00)
  85. #define UNUSED1    (LS|A4)
  86. #define NEG        (0x10)
  87. #define MOVSS    (NEG|12)
  88. #define LM        (0x20)
  89. #define COMP    (0x30)
  90. #define JMP        (0x34)
  91. #define NOT        (0x38)
  92. #define SS        (0x40)
  93. #define UNUSED2    (SS|A4)
  94. #define TRUTHOF    (0x50)
  95. #define LI        (0x58)
  96. #define LUI        (0x5C)
  97. #define LAI        (0x60)
  98. #define SM        (0x70)
  99.  
  100. #define ADD        (0x80|(0<<3))
  101. #define SUB        (0x80|(1<<3))
  102. #define MUL        (0x80|(2<<3))
  103. #define DIV        (0x80|(3<<3))
  104. #define OR        (0x80|(4<<3))
  105. #define JMPT    (OR|4)
  106. #define AND        (0x80|(5<<3))
  107. #define JMPF    (AND|4)
  108. #define MOD        (0x80|(6<<3))
  109. #define MOVAAX    (MOD|6)
  110. #define XTD        (MOD|7)
  111. #define XOR        (0x80|(7<<3))
  112. #define MOVSM    (XOR|4)
  113. #define GT        (0x80|(8<<3))
  114. #define LT        (0x80|(9<<3))
  115. #define GE        (0x80|(10<<3))
  116. #define LE        (0x80|(11<<3))
  117. #define NE        (0x80|(12<<3))
  118. #define EQ        (0x80|(13<<3))
  119. #define ARG        (0x80|(14<<3))
  120. #define ARGA    (ARG|1)
  121. #define ARGF    (ARG|2)
  122. #define SWAP4DEEP    (ARG|3)
  123. #define LOCATE    (ARG|4)
  124. #define MOVMS    (0x80|(15<<3))
  125. #define MOVMM    (MOVMS|4)
  126.  
  127.  
  128. /* Immediate subgroup */
  129. #define SMI        (1<<4)
  130. #define SSI        (2<<4)
  131. #define MODI    (3<<4)
  132. #define DEREF    (4<<4)
  133. #define DEREF1    (5<<4)
  134.  
  135. /* Miscellaneous */
  136. #define DUMP    (NOT|4)
  137. #define CALL    (NOT|5)
  138. #define SWAP    (NOT|6)
  139. #define DUP        (NOT|7)
  140. #define LINENO    (TRUTHOF|0)
  141. #define CVT        (TRUTHOF|4)
  142. #define ABSSTK    (TRUTHOF|5)
  143. #define IMMED    (TRUTHOF|6)
  144. #define RET        (TRUTHOF|7)
  145. #define DUP4     (NEG|8)
  146. #define SWAP4     (NEG|9)
  147. #define MOVDA1    (NEG|10)
  148. #define MOVDA2    (NEG|11)
  149. #define MOVDA4    (LAI|4)
  150. #define MOVDA8    (LAI|5)
  151. #define MOVDAX    (LAI|6)
  152. #define MOVAA1    (LAI|7)
  153. #define LJMPT    (LAI|8)
  154. #define LJMPF    (LAI|12)
  155. #define NFUNC    (UNUSED1|0)
  156. #define NOP        (UNUSED1|1)
  157. #define MOVAAC    (UNUSED1|2)
  158. #define ABSMEM    (UNUSED1|3)
  159. #define MOVAA8    (UNUSED2|0)
  160. #define REGAIN    (UNUSED2|1)
  161. #define MOVAA2    (UNUSED2|2)
  162. #define MOVAA4    (UNUSED2|3)
  163.  
  164. /* extended subgroup */
  165. #define GETBITFIELD (LM|A4|1)
  166. #define PUTBITFIELD (LM|A4|2)
  167. #define CALLSETUP    (LM|A4|3)
  168. #define SWITCH        (SM|A4|1)
  169. #define PRUNESTRUCT (SM|A4|2)
  170. #define CLRDAT        (SM|A4|3)
  171. #define RETSTRUCT    (SM|A3|1)
  172. #define BUILTIN        (SM|A3|2)
  173. #define LSHI        (NEG|4)
  174. #define LSH            (NEG|8)
  175. #define RSH            (LAI)
  176. #define RSHI        (LAI|8)
  177.  
  178.  
  179. /* Interpreter builtins */
  180. #define ALLOCA 1
  181. #define SETJMP 2
  182. #define LONGJMP 3
  183. #define STRLEN 4
  184. #define STRCPY 5
  185. #define STRCAT 6
  186. #define MEMCPY 7
  187. #define MEMMOVE 8
  188. #define MEMSET 9
  189. #define BZERO 10
  190. #define MALLOC 11
  191. #define CALLOC 12
  192. #define REALLOC 13
  193. #define EXIT 14
  194. #define ABORT 15
  195. #define DEBUG 16
  196. #define NODEBUG 17
  197. #endif /* NEED_BYTECODES */
  198.  
  199. #if NEED_SPELLING
  200.  
  201. static char *Jbuf[] = {
  202. "J1","J2","J3","J4"
  203. };
  204. static int Jcnt[] = {
  205. 1,2,3,4
  206. };
  207. static char *Dbuf[] = {
  208. "D1","D2","D3","D4"
  209. };
  210. static int Dcnt[] = {
  211. 1,2,3,4
  212. };
  213. static char *SDbuf[] = {
  214. " S1|D1", " S1|D2", " S1|D3"," S1|D4",
  215. " S2|D1", " S2|D2", " S2|D3"," S2|D4",
  216. " S3|D1", " S3|D2", " S3|D3"," S3|D4",
  217. " S4|D1", " S4|D2", " S4|D3"," S4|D4"
  218. };
  219. static int SDcnt[] = {
  220. 2,3,4,5,3,4,5,6,4,5,6,7,5,6,7,8
  221. };
  222. static char *ABbuf[] = {
  223. "A1|B1","A1|B2","A1|B4","A1|B8",
  224. "A2|B1","A2|B2","A2|B4","A2|B8",
  225. "A3|B1","A3|B2","A3|B4","A3|B8",
  226. "A4|B1","A4|B2","A4|B4","A4|B8"
  227. };
  228. static int ABcnt[] = {
  229. 2,3,5,9,3,4,6,10,4,5,9,11,5,6,8,16
  230. };
  231. static char *Abuf[] = {
  232. "A1","A2","A3","A4"
  233. };
  234. static int Acnt[] = {
  235. 1,2,3,4
  236. };
  237. static char *Bbuf[] = {
  238. "B1","B2","B4","B8","BX"
  239. };
  240. static int Bcnt[] = {
  241. 1,2,4,8
  242. };
  243. static char *Tbuf[] = {
  244. "BYTE","SHORT","LONG","UBYTE","USHORT","ULONG","FLOAT","DOUBLE",
  245. "LONGLONG","ULONGLONG","LONGDOUBLE"
  246. };
  247. static char *XTbuf[] = {
  248. "LONGLONG","ULONGLONG","LONGDOUBLE","","","","LONGLONG","ULONGLONG"
  249. };
  250. static char *BUbuf[] = {"",
  251. "alloca ","setjmp ","longjmp ","strlen ","strcpy ","strcat ",
  252. "memcpy ","memmove ","memset ","bzero ","malloc ","calloc ",
  253. "realloc ","exit ","abort ","bterpdebug ", "bterpnodebug "
  254. };
  255.  
  256. #endif /* NEED_SPELLING */
  257.  
  258. #if NEED_AOUT_FORMAT
  259.  
  260. /* OUTPUT FORMAT IS A VARIANT OF A.OUT */
  261.  
  262. struct exec
  263. {
  264.   unsigned long a_info;         /* Contains MAGIC number */
  265.   unsigned a_text;              /* length of text, in bytes */
  266.   unsigned a_data;              /* length of data, in bytes */
  267.   unsigned a_bss;               /* length of uninitialized data area for file, in bytes */
  268.   unsigned a_syms;              /* length of symbol table data in file, in bytes */
  269.   unsigned a_entry;             /* start address */
  270.   unsigned a_trsize;            /* length of relocation info for text, in bytes */
  271.   unsigned a_drsize;            /* length of relocation info for data, in bytes */
  272. };
  273.  
  274. #define OMAGIC 0407
  275. #define NMAGIC 0410
  276. #define ZMAGIC 0413
  277.  
  278. /* a.out symbol table struct */
  279. struct nlist {
  280.   union {
  281.     char *n_name;
  282.     struct nlist *n_next;
  283.     long n_strx;
  284.   } n_un;
  285.   unsigned char n_type;
  286.   char n_other;
  287.   short n_desc;
  288.   unsigned long n_value;
  289. };
  290. #define N_UNDF 0x00
  291. #define N_ABS 0x02
  292. #define N_TEXT 0x04
  293. #define N_DATA 0x06
  294. #define N_BSS 0x08
  295. #define N_NDC 0x10
  296. #define N_COMM 0x12
  297. #define N_FN 0x0f
  298. #define N_EXT 0x01
  299. #define N_TYPE 0x1e
  300. #define N_STAB 0xe0
  301. #define N_INDR 0x0a                /* Symbol is indirect */
  302. #define N_SETA  0x14            /* Absolute set element symbol */
  303. #define N_SETT  0x16            /* Text set element symbol */
  304. #define N_SETD  0x18            /* Data set element symbol */
  305. #define N_SETB  0x1A            /* Bss set element symbol */
  306. #define N_SETV  0x1C            /* Pointer to set vector in data area.  */
  307. #define N_SWTAB 0x20            /* A switch table entry */
  308.  
  309. struct relocation_info
  310. {
  311.   long r_address;
  312.   unsigned long r_symbolnum:24;
  313.   unsigned long r_pcrel:1;
  314.   unsigned long r_length:2;
  315.   unsigned long r_extern:1;
  316.   unsigned long r_pad:4;
  317. };
  318.  
  319. #endif /* NEED_AOUT_FORMAT */
  320.