home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 148_01 / a99.gbl < prev    next >
Text File  |  1987-09-28  |  5KB  |  182 lines

  1. /*
  2.     TMS990 Series Cross-Assembler  v. 1.0
  3.  
  4.     January, 1985
  5.  
  6.     Copyright (c) 1980 William C. Colley, III.
  7.     Modified for the 990 Series by Alexander Cameron.
  8.  
  9. File:    a99.gbl
  10.  
  11. Global macro substitutions and external variable declarations.
  12. */
  13.  
  14. /*  Set input line length:  */
  15.  
  16. #define    LINLEN    120
  17.  
  18. /*  Define disk buffer parameters:  */
  19.  
  20. #define NSECT 32
  21.  
  22. /*  Define symbol table parameters:  */
  23.  
  24. #define    SYMLEN    8    /*  Length of labels (must be an even number).    */
  25. #define    SYMBOLS    599    /*  Number of symbols in symbol table.        */
  26. #define    PADDING    "       "    /*  SYMLEN - 1 blanks.            */
  27.  
  28. /*  Number of if statements that can be nested:  */
  29.  
  30. #define    IFDEPTH    16
  31.  
  32. /*  BDOS functions called directly:  */
  33.  
  34. #define    LISTOUT    5    /*  Put character to list device.        */
  35. #define    LOGDISK    14    /*  Log in disk drive.                */
  36. #define    GETDISK    25    /*  Get currently logged in disk.        */
  37.  
  38. /*  Define flag values:  */
  39.  
  40. #define    TRUE    1    /*  General use.                */
  41. #define    FALSE    0
  42. #define    SKIP    TRUE    /*  Used with skip flag in getchr.        */
  43. #define    NOSKIP    FALSE
  44. #define    BIGST    TRUE    /*  Used to tell kind of string in getitem.    */
  45. #define    SMALST    FALSE
  46. #define    NOCODE    0    /*  Used to tell the hex generator what to do.    */
  47. #define    PUTCODE    1
  48. #define    FLUSH    2
  49. #define    NOMORE    3
  50.  
  51. /*  File descriptors:  */
  52.  
  53. #define    LODISK    0    /*  Lowest numbered disk.            */
  54. #define    NOFILE    -1    /*  No file specified.                */
  55. #define    CONO    -2    /*  Console output.                */
  56. #define    LST    -3    /*  List device.                */
  57.  
  58. /*  Items can have the following attributes:  */
  59.  
  60. #define    ALPHA    0    /*  Alphabetic character.            */
  61. #define    NUMERIC    1    /*  Numeric digit (0-9).            */
  62. #define    END_LIN    2    /*  End-of-Line marker (cr or ;).        */
  63. #define    COMMA    3    /*  Field separator (,).            */
  64. #define    OPERATR    4    /*  Operator (* - GE < ( SHR etc.).        */
  65. #define    BAS_DES    5    /*  Base designator ($ % @).            */
  66. #define    QUOTE    6    /*  String delimiter (" ').            */
  67. #define    TRASH    7
  68. #define    VALUE    8    /*  Evaluated expression.            */
  69. #define TRASH    9
  70. #define    BLANK    10    /*  White space (spc tab).            */
  71. #define    TRASH    11    /*  Other characters.                */
  72.  
  73. /*  Some tokens for composite operators:  */
  74.  
  75. #define    NO_OPR    0    /*  No operator.                */
  76. #define    GRTEQ    1    /*  Greater than or equal to.            */
  77. #define    NOTEQ    2    /*  Not equal to.                */
  78. #define    LESEQ    3    /*  Less than or equal to.            */
  79. #define    AND    4    /*  And.                    */
  80. #define    OR    5    /*  Or.                        */
  81. #define    XOR    6    /*  Exclusive or.                */
  82. #define    NOT    7    /*  1's complement.                */
  83. #define    MOD    8    /*  Mod--divide and return remainder.        */
  84. #define    SHL    9    /*  Shift left.                    */
  85. #define    SHR    10    /*  Shift right.                */
  86. #define    HIGH    11    /*  High byte of.                */
  87. #define    LOW    12    /*  Low byte of.                */
  88.  
  89. /*  Operator precedence values:  */
  90.  
  91. #define    UOP1    0    /*  Unary +, unary -.                */
  92. #define    MULT    1    /*  *, /, MOD, SHL, SHR.            */
  93. #define    ADDIT    2    /*  Binary +, binary -.                */
  94. #define    RELAT    3    /*  >, =, <, >=, <>, <=.            */
  95. #define    UOP2    4    /*  NOT.                    */
  96. #define    LOG1    5    /*  AND.                    */
  97. #define    LOG2    6    /*  OR, XOR.                    */
  98. #define    UOP3    7    /*  HIGH, LOW.                    */
  99. #define    RPREN    8    /*  ).                        */
  100. #define    LPREN    9    /*  (.                        */
  101. #define    ENDEX    10    /*  CR, ;, ,.                    */
  102. #define    START    11    /*  Start of expression.            */
  103.  
  104. /*  Bits of opcode attribute byte.  */
  105.  
  106. #define    PSOP    0x80    /*  Pseudo-op.                    */
  107. #define    DIROK    0x40    /*  Non-pseudo-op is OK for direct addressing.    */
  108. #define    IFGROUP    0x40    /*  Pseudo-op is IF, ELSE, ENDI.        */
  109.  
  110. /*  Address modes for the 9900 instruction set                 */
  111.  
  112. #define WREG        0
  113. #define    INDIRECT     1
  114. #define SYMBOLIC    2
  115. #define INDEXED     3
  116. #define AUTOINC        4
  117.  
  118. /*  Misc control chars */
  119.  
  120. #define CPMEOF    0x1A
  121. #define CTLS    19    /* Control S for stoppin */
  122. #define CTLC    3    /* Control C aborts */
  123. #define NOSORT TRUE    /* Controls whether or not we want the table sorted */
  124. #define SORT FALSE
  125.  
  126. struct diskbuf
  127. {
  128.     int fd;
  129.     char *pointr;
  130.     char space[NSECT*128];
  131. };
  132. struct diskbuf sorbuf,lstbuf,hexbuf;
  133.  
  134. /*  Set up the symbol table: */
  135.  
  136. struct symbtbl
  137. {
  138.     char symname[SYMLEN];
  139.     unsigned symvalu;
  140. };
  141. struct symbtbl symtbl[SYMBOLS], *symend, *sympoint;
  142.  
  143. /*  If stack and stack pointer.  */
  144.  
  145. char ifsp;
  146. unsigned ifstack[IFDEPTH+1];
  147.  
  148. /*  Buffer to hold current line:  */
  149.  
  150. char *linptr, linbuf[LINLEN];
  151.  
  152. /*  Buffer to hold the code generated by a line.  */
  153.  
  154. char nbytes, binbuf[255];
  155.  
  156. /*  Buffers for the hex generator.  */
  157.  
  158. char chksum, hxbytes, *hxlnptr, hxlnbuf[44];
  159.  
  160. /*  Miscellanious mailboxes:  */
  161.  
  162. char errcode;        /*  Error records.                */
  163. int errcount;
  164. char evalerr;        /*  Flag to tell of error in eval.        */
  165. char backflg, oldattr;    /*  Item push-back buffer.            */
  166. unsigned oldvalu;
  167. char curdrive;        /*  Place to save drive that was current
  168.                     disk when assembly started.        */
  169. char hexflg;        /*  Flag for asmline to tell hex
  170.                 generator what to do.            */
  171. char directok;        /*  All symbols on line pre-defined.        */
  172. unsigned pc;        /*  Assembly program counter.            */
  173. unsigned address;    /*  Address to be put into listed line.        */
  174. char pass;        /*  Which pass the assembly is in.        */
  175. char addrmode;
  176. char quitflag;        /*  Used in eval to detect INDEXED expressions  */
  177.  
  178. /*  Some trivial functions:  */
  179.  
  180. #define    backchr    linptr--        /*  Push back a character.    */
  181.  
  182.