const.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  1. /* Speed and space hacks for BCC */
  2. #ifdef __AS386_16__
  3. #define LOW_BYTE 0 /* must be changed for big-endian */
  4. #else
  5. #define S_ALIGNMENT sizeof(long)
  6. #endif
  7. /* const.h - constants for assembler */
  8. /* major switches */
  9. /* #define MC6809 */ /* generate 6809 code */
  10. #ifndef MC6809
  11. #define I80386 /* generate 80386 code */
  12. #endif
  13. #define MNSIZE /* allow byte size in mnemonic, e.g. "movb" */
  14. #undef SOS_EDOS /* source OS is EDOS */
  15. /* defaults */
  16. #define DIRCHAR '/' /* character separating filename from dir */
  17. #define INBUFSIZE 8192
  18. #define SOS_EOLSTR "\012"
  19. /* defaults modified by switches */
  20. #ifdef SOS_EDOS
  21. # undef INBUFSIZE
  22. # define INBUFSIZE 512
  23. # undef SOS_EOLSTR
  24. # define SOS_EOLSTR "\015\012"
  25. # define STAKSIZ 256 /* table grows up to stack less this */
  26. #endif
  27. #ifdef __AS386_16__
  28. # undef INBUFSIZE
  29. # define INBUFSIZE 512
  30. # define STAKSIZ 512 /* table grows up to stack less this */
  31. #endif
  32. /* booleans */
  33. #define FALSE 0
  34. #define TRUE 1
  35. /* ASCII constants */
  36. #define ETB 23
  37. /* C tricks */
  38. #define EXTERN extern
  39. #define FORWARD static
  40. #define PRIVATE static
  41. #define PUBLIC
  42. #define NUL_PTR ((void*)0)
  43. /* O/S constants */
  44. #define CREAT_PERMS 0666
  45. #define EOF (-1)
  46. #define STDIN 0
  47. #define STDOUT 1
  48. enum
  49. {
  50. /* Register codes (internal to assembler). */
  51. #ifdef I80386
  52. /* Index regs must be first. */
  53. BPREG,
  54. BXREG,
  55. DIREG,
  56. SIREG,
  57. #define MAX16BITINDREG SIREG
  58. EAXREG,
  59. EBPREG,
  60. EBXREG,
  61. ECXREG,
  62. EDIREG,
  63. EDXREG,
  64. ESIREG,
  65. ESPREG,
  66. #define MAXINDREG ESPREG
  67. AXREG,
  68. CXREG,
  69. DXREG,
  70. SPREG,
  71. AHREG,
  72. ALREG,
  73. BHREG,
  74. BLREG,
  75. CHREG,
  76. CLREG,
  77. DHREG,
  78. DLREG,
  79. CSREG,
  80. DSREG,
  81. ESREG,
  82. FSREG,
  83. GSREG,
  84. SSREG,
  85. CR0REG,
  86. CR2REG,
  87. CR3REG,
  88. DR0REG,
  89. DR1REG,
  90. DR2REG,
  91. DR3REG,
  92. DR6REG,
  93. DR7REG,
  94. TR3REG,
  95. TR4REG,
  96. TR5REG,
  97. TR6REG,
  98. TR7REG,
  99. ST0REG,
  100. ST1REG,
  101. ST2REG,
  102. ST3REG,
  103. ST4REG,
  104. ST5REG,
  105. ST6REG,
  106. ST7REG,
  107. #endif /* I80386 */
  108. #ifdef MC6809
  109. /* Index regs must be first, then PC. */
  110. SREG,
  111. UREG,
  112. XREG,
  113. YREG,
  114. #define MAXINDREG YREG
  115. PCREG,
  116. AREG,
  117. BREG,
  118. CCREG,
  119. DPREG,
  120. DREG,
  121. #endif /* MC6809 */
  122. NOREG
  123. };
  124. #ifdef I80386
  125. enum
  126. {
  127. /* Type and size keywords. */
  128. BYTEOP,
  129. DWORDOP,
  130. FWORDOP,
  131. FAROP,
  132. PTROP,
  133. PWORDOP,
  134. QWORDOP,
  135. TBYTEOP,
  136. WORDOP
  137. };
  138. #endif /* I80386 */
  139. /* special chars */
  140. #define EOL 0
  141. #define MACROCHAR '?'
  142. enum
  143. {
  144. /* Symbol codes. */
  145. /* The first 2 must be from chars in identifiers. */
  146. IDENT,
  147. INTCONST,
  148. /* The next few are best for other possibly-multi-char tokens. */
  149. ADDOP, /* also ++ */
  150. BINCONST,
  151. CHARCONST,
  152. GREATERTHAN, /* also >> and context-sensitive */
  153. HEXCONST,
  154. LESSTHAN, /* also << and context-sensitive */
  155. SUBOP, /* also -- */
  156. WHITESPACE,
  157. ANDOP,
  158. COMMA,
  159. EOLSYM,
  160. EQOP,
  161. IMMEDIATE,
  162. INDIRECT,
  163. LBRACKET,
  164. LPAREN,
  165. MACROARG,
  166. NOTOP,
  167. OROP,
  168. OTHERSYM,
  169. POSTINCOP,
  170. PREDECOP,
  171. RBRACKET,
  172. RPAREN,
  173. SLASH, /* context-sensitive */
  174. SLOP,
  175. SROP,
  176. STAR, /* context-sensitive */
  177. STRINGCONST,
  178. COLON
  179. };
  180. /* symbol table entry */
  181. /* type entry contains following flags */
  182. #define ENTBIT (1<<0) /* entry point (= OBJ_N_MASK) */
  183. #define COMMBIT (1<<1) /* common */
  184. #define LABIT (1<<2) /* label (a PC location or defined by EQU) */
  185. #define MNREGBIT (1<<3) /* mnemonic for op or pseudo-op, or register */
  186. #define MACBIT (1<<4) /* macro */
  187. #define REDBIT (1<<5) /* redefined (if with LABIT or VARBIT), to do
  188. * with SA_MASK (if with COMMBIT), otherwise
  189. * means globl */
  190. #define VARBIT (1<<6) /* variable (i.e. something defined by SET) */
  191. #define EXPBIT (1<<7) /* exported (= OBJ_E_MASK) */
  192. /* data entry contains following flags, valid */
  193. /* for expressions as well as syms */
  194. #define PAGE1 (1<<0) /* page 1 machine op = MNREGBIT | PAGE1 */
  195. #define PAGE2 (1<<1) /* page 2 machine op = MNREGBIT | PAGE2 */
  196. #define REGBIT (1<<2) /* register = MNREGBIT | REGBIT */
  197. #define SIZEBIT (1<<3) /* sizing mnemonic = MNREGBIT | SIZEBIT */
  198. #define SEGM 0x0F /* 1st 4 bits reused for segment if !MNREGBIT */
  199. #define RELBIT (1<<4) /* relative (= OBJ_A_MASK) */
  200. #define FORBIT (1<<5) /* forward referenced */
  201. #define IMPBIT (1<<6) /* imported (= OBJ_I_MASK) */
  202. #define UNDBIT (1<<7) /* undefined */
  203. /* object code format (Introl) */
  204. #define OBJ_SEGSZ_TWO 0x02 /* size 2 code for segment size descriptor */
  205. #define OBJ_MAX_ABS_LEN 64 /* max length of chunk of absolute code */
  206. #define OBJ_ABS 0x40 /* absolute code command */
  207. #define OBJ_OFFSET_REL 0x80 /* offset relocation command */
  208. #define OBJ_SET_SEG 0x20 /* set segment command */
  209. #define OBJ_SKIP_1 0x11 /* skip with 1 byte count */
  210. #define OBJ_SKIP_2 0x12 /* skip with 2 byte count */
  211. #define OBJ_SKIP_4 0x13 /* skip with 4 byte count */
  212. #define OBJ_SYMBOL_REL 0xC0 /* symbol relocation command */
  213. #define OBJ_A_MASK 0x10 /* absolute bit(symbols) */
  214. #if OBJ_A_MASK - RELBIT /* must match internal format (~byte 1 -> 0) */
  215. oops - RELBIT misplaced
  216. #endif
  217. #define OBJ_E_MASK 0x80 /* exported bit (symbols) */
  218. #if OBJ_E_MASK - EXPBIT /* must match internal format (byte 0 -> 0) */
  219. oops - EXPBIT misplaced
  220. #endif
  221. #define OBJ_I_MASK 0x40 /* imported bit (symbols) */
  222. #if OBJ_I_MASK - IMPBIT /* must match internal format (byte 1 -> 0) */
  223. oops - IMPBIT misplaced
  224. #endif
  225. #define OBJ_N_MASK 0x01 /* entry bit (symbols) */
  226. #if OBJ_N_MASK - ENTBIT /* must match internal format (byte 0 -> 1) */
  227. oops - ENTBIT misplaced
  228. #endif
  229. #define OBJ_SA_MASK 0x20 /* size allocation bit (symbols) */
  230. #define OBJ_SZ_ONE 0x40 /* size one code for symbol value */
  231. #define OBJ_SZ_TWO 0x80 /* size two code for symbol value */
  232. #define OBJ_SZ_FOUR 0xC0 /* size four code for symbol value */
  233. #define OBJ_R_MASK 0x20 /* PC-rel bit (off & sym reloc commands) */
  234. #define OBJ_SEGM_MASK 0x0F /* segment mask (symbols, off reloc command) */
  235. #define OBJ_OF_MASK 0x03 /* offset size code for symbol reloc */
  236. #define OBJ_S_MASK 0x04 /* symbol number size code for symbol reloc */
  237. #define SYMLIS_NAMELEN 26
  238. #define SYMLIS_LEN (sizeof (struct sym_listing_s))
  239. #define FILNAMLEN 64 /* max length of a file name */
  240. #define LINLEN 256 /* max length of input line */
  241. #define LINUM_LEN 5 /* length of formatted line number */
  242. #define SPTSIZ 1024 /* number of symbol ptrs */
  243. /* pseudo-op flags */
  244. #define POPHI 1 /* set to print hi byte of adr */
  245. #define POPLO 2 /* to print lo byte of ADR */
  246. #define POPLC 4 /* to print LC */
  247. #define POPLONG 8 /* to print high word of ADR */
  248. #define MAXBLOCK 8 /* max nesting level of BLOCK stack */
  249. #define MAXGET 8 /* max nesting level of GET stack */
  250. #define MAXIF 8 /* max nesting level of IF stack */
  251. #define MACPSIZ (128 / sizeof (struct schain_s))
  252. /* size of macro param buffer */
  253. #define MAXMAC 8 /* max nesting level of macro stack */
  254. #define NLOC 16 /* number of location counters */
  255. #ifdef I80386
  256. #define NO_SIB 0340 /* illegal sib (3 with 4) to mean no sib */
  257. #endif
  258. /* special segments */
  259. #define BSSLOC 3
  260. #define DATALOC 3
  261. #define DPLOC 2
  262. #define STRLOC 1
  263. #define TEXTLOC 0
  264. #include "errors.h"