comm1.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* $Id$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. /* @(#)comm1.h 1.5 */
  7. /*
  8. * variable declarations
  9. */
  10. #ifdef extern
  11. #define INIT(x) = x
  12. #else
  13. #define INIT(x) /* empty */
  14. #endif
  15. extern short pass INIT(PASS_1);
  16. /* PASS 1, 2 or 3 */
  17. extern short peekc; /* push back symbol (PASS_1) */
  18. extern short unresolved; /* number of unresolved references */
  19. extern long lineno; /* input line number */
  20. extern short hllino; /* high-level language line number */
  21. extern short nerrors; /* terminate at end of pass if set */
  22. extern short sflag INIT(SYM_DEF);
  23. /* -s option (symbol table info) */
  24. extern char *progname; /* for error messages */
  25. extern char *modulename; /* for error messages */
  26. extern common_t *commons; /* header of commons list */
  27. #ifdef ASLD
  28. extern short archmode; /* scanning archives */
  29. extern long archsize; /* size of individual archive entries */
  30. #else
  31. extern short uflag; /* if 1 make undefineds extern */
  32. /* symbol table index for last S_UND */
  33. #endif
  34. #ifdef LISTING
  35. extern short dflag; /* -d option (list mode) */
  36. #endif
  37. #ifdef ASLD
  38. #ifdef RELOCATION
  39. extern short rflag; /* -r option (relocation info) */
  40. #endif /* RELOCATION */
  41. #else
  42. #define rflag 1
  43. extern valu_t relonami;
  44. #endif /* ASLD */
  45. #ifdef THREE_PASS
  46. extern short bflag; /* -b option (no optimizations) */
  47. #endif
  48. extern char *aoutpath INIT("a.out");
  49. extern char temppath[512];
  50. extern FILE *input;
  51. extern FILE *tempfile;
  52. extern char *stringbuf; /* contains last string value */
  53. extern int stringlen; /* contains length of last string value */
  54. extern sect_t sect[SECTMAX];
  55. /*
  56. * specials for the location counter
  57. */
  58. extern sect_t *DOTSCT; /* &sect[DOTTYP-S_MIN] or NULL */
  59. extern ADDR_T DOTVAL; /* DOTSCT->s_size + DOTSCT->s_base */
  60. extern short DOTTYP; /* S_MIN..S_MAX or S_UND */
  61. extern unsigned short nname; /* Counts name table index in PASS_3 */
  62. extern item_t *hashtab[H_TOTAL];
  63. extern short hashindex; /* see item_search() */
  64. extern item_t *fb_ptr[4*FB_SIZE];
  65. #ifdef THREE_PASS
  66. #define BITCHUNK (8 * MEMINCR)
  67. extern int nbits;
  68. extern int bitindex; /* bitindex * MEMINCR * 8 + nbits gives
  69. number of decisions so far
  70. */
  71. #endif
  72. #ifdef LISTING
  73. extern short listmode; /* -d option for current pass */
  74. extern short listtemp; /* listmode if .list seen */
  75. extern short listflag; /* copied from listtemp at '\n' */
  76. extern short listcolm; /* column on output */
  77. extern short listeoln INIT(1);
  78. /* set by endline, tested by emit1 */
  79. extern FILE *listfile; /* copy of source text */
  80. extern char listpath[50];
  81. #endif
  82. #ifndef extern
  83. extern item_t keytab[];
  84. extern struct outhead outhead;
  85. #endif
  86. extern int curr_token;
  87. /* forward function declarations */
  88. int yyparse();
  89. /* ========== comm4.c prototypes =========== */
  90. void stop(int signal);
  91. int main(int argc, char *argv[]);
  92. int pass_1(int argc, char *argv[]);
  93. void parse(char *s);
  94. void pass_23(int n);
  95. void newmodule(char *s);
  96. void setupoutput(void);
  97. void commfinish(void);
  98. /* ========== comm5.c prototypes =========== */
  99. int yylex(void);
  100. void putval(int c);
  101. int getval(int c);
  102. int nextchar(void);
  103. void readcode(int n);
  104. int induo(int c);
  105. int inident(int c);
  106. int innumber(int c);
  107. int instring(int termc);
  108. int inescape(void);
  109. int infbsym(char *p);
  110. int hash(char *p);
  111. item_t *item_search(char *p);
  112. void item_insert(item_t *ip, int h);
  113. item_t *item_alloc(int typ);
  114. item_t *fb_alloc(int lab);
  115. item_t *fb_shift(int lab);
  116. #ifdef ASLD
  117. char *readident(int c);
  118. #endif
  119. /* ========== comm6.c prototypes =========== */
  120. void newequate(item_t *ip, int typ);
  121. void newident(item_t *ip, int typ);
  122. void newlabel(item_t *ip);
  123. void newsect(item_t *ip);
  124. void newbase(valu_t base);
  125. void newcomm(item_t *ip, valu_t val);
  126. void switchsect(int newtyp);
  127. void align(valu_t bytes);
  128. long new_string(char *s);
  129. void newsymb(char *name, int type, int desc, valu_t valu);
  130. void new_common(item_t *ip);
  131. #ifdef RELOCATION
  132. void newrelo(int s, int n);
  133. #endif
  134. /* ========== comm7.c prototypes =========== */
  135. valu_t load(item_t *ip);
  136. int store(item_t *ip, valu_t val);
  137. char *remember(char *s);
  138. int combine(int typ1, int typ2, int op);
  139. int small(int fitsmall, int gain);
  140. void emit1(int arg);
  141. void emit2(int arg);
  142. void emit4(long arg);
  143. void emitx(valu_t val, int n);
  144. void emitstr(int zero);
  145. void ffreopen(char *s, FILE *f);
  146. FILE *ffcreat(char *s);
  147. FILE *fftemp(char *path, char *tail);
  148. void yyerror(char *str);
  149. int printx(int ndig, valu_t val);
  150. void nosect(void);
  151. void wr_fatal(void);
  152. void fatal(char *s, ...);
  153. void assert1(void);
  154. void serror(char *s, ...);
  155. void warning(char *s, ...);
  156. void diag(char *tail, char *s, ...);
  157. void nofit(void);
  158. void listline(int textline);
  159. /* ========== Machine dependent C declarations ========== */
  160. #include "mach1.c"