home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 113_01 / a68.h < prev    next >
Text File  |  1985-03-10  |  7KB  |  219 lines

  1. /*
  2.     HEADER:        CUG113;
  3.     TITLE:        6800 Cross-Assembler (BDS C Version);
  4.     FILENAME:    A68.H;
  5.     VERSION:    2.6;
  6.     DATE:        07/22/1985;
  7.  
  8.     DESCRIPTION:    "This program lets you use your CP/M-80-based computer
  9.             to assemble code for the Motorola 6800, 6801, 6802,
  10.             6803, 6808, and 68701 microprocessors.  The program is
  11.             written in BDS C for the best possible performance on
  12.             8-bit machines.  All assembler features are supported
  13.             except relocation, linkage, listing control, and
  14.             macros.";
  15.  
  16.     KEYWORDS:    Software Development, Assemblers, Cross-Assemblers,
  17.             Motorola, MC6800, MC6801;
  18.  
  19.     SEE-ALSO:    CUG149, 6801 Cross-Assembler (Portable);
  20.  
  21.     SYSTEM:        CP/M-80;
  22.     COMPILERS:    BDS C;
  23.  
  24.     WARNINGS:    "This package is specifically tailored to CP/M-80
  25.             machines and the rather non-standard, but high-
  26.             performance BDS C compiler.  For other environments,
  27.             use the portable version of this package on CUG149.";
  28.  
  29.     AUTHORS:    William C. Colley III;
  30. */
  31.  
  32. /*
  33.     6800/6801 Cross-Assembler  v. 2.6
  34.  
  35.     May, 1980
  36.  
  37.     July, 1980 -- Rev. 2.2 consisting of fixing the M errors that
  38.         come from forward references in FDB and FCB pseudo-ops.
  39.  
  40.     October, 1980 -- Rev. 2.3 consisting of updating the assembly
  41.         language file and I/O routines to match and take
  42.         advantage of BDS C V1.4.
  43.  
  44.     October, 1983 -- Rev. 2.4 consisting of adding the CPU pseudo-op,
  45.         adding the 6801 CPU's extra opcodes, and speeding up the
  46.         code a bit.
  47.  
  48.     September, 1984 -- Rev. 2.5 consisting of fixing bugs with the symbol
  49.         table sort, the writing of files to specified drives, and the
  50.         handling of blank input lines.
  51.  
  52.     June, 1985 -- Rev. 2.6 consisting of fixing a bug in the IF block
  53.         nesting mechanism.
  54.  
  55.     Copyright (c) 1980,83,84,85 William C. Colley, III.
  56.  
  57. File:    a68.h
  58.  
  59. Global macro substitutions and external variable declarations.
  60. */
  61.  
  62. /*  For the benefit of BDS C V1.4's library functions:            */
  63.  
  64. #include <bdscio.h>
  65.             /*  Note:  The cross assembler will run more
  66.                 efficiently and with less head racket
  67.                 if the number of sectors of disk buffer
  68.                 specified by BDSCIO.H is at least 8.    */
  69.  
  70. /*  Set input line length:  */
  71.  
  72. #define    LINLEN    120    /* Length of input line in characters.        */
  73.  
  74. /*  Define symbol table parameters:  */
  75.  
  76. #define    SYMLEN    8    /*  Length of labels (must be an even number).    */
  77. #define    SYMBOLS    500    /*  Number of symbols in symbol table.        */
  78. #define    PADDING    "       "    /*  SYMLEN - 1 blanks.            */
  79.  
  80. /*  Number of if statements that can be nested:  */
  81.  
  82. #define    IFDEPTH    16
  83.  
  84. #define    ON    1
  85. #define    OFF    -1
  86.  
  87. /*  BDOS functions called directly:  */
  88.  
  89. #define    GETDISK    25    /*  Get currently logged in disk.        */
  90.  
  91. /*  Define flag values:  */
  92.  
  93. #define    SKIP    TRUE    /*  Used with skip flag in getchr.        */
  94. #define    NOSKIP    FALSE
  95. #define    BIGST    TRUE    /*  Used to tell kind of string in getitem.    */
  96. #define    SMALST    FALSE
  97. #define    NOCODE    0    /*  Used to tell the hex generator what to do.    */
  98. #define    PUTCODE    1
  99. #define    FLUSH    2
  100. #define    NOMORE    3
  101.  
  102. /*  File descriptors:  */
  103.  
  104. #define    NOFILE    -1    /*  No file specified.                */
  105. #define    CONO    1    /*  Console output.                */
  106. #define    LST    2    /*  List device.                */
  107. #define    LODISK    4    /*  Lowest numbered disk.            */
  108.  
  109. /*  Items can have the following attributes:  */
  110.  
  111. #define    ALPHA    0    /*  Alphabetic character.            */
  112. #define    NUMERIC    1    /*  Numeric digit (0-9).            */
  113. #define    END_LIN    2    /*  End-of-Line marker (cr or ;).        */
  114. #define    COMMA    3    /*  Field separator (,).            */
  115. #define    OPERATR    4    /*  Operator (* - GE < ( SHR etc.).        */
  116. #define    BAS_DES    5    /*  Base designator ($ % @).            */
  117. #define    QUOTE    6    /*  String delimiter (" ').            */
  118. #define    IMMED    7    /*  Immediate mode indicator (#).        */
  119. #define    VALUE    8    /*  Evaluated expression.            */
  120. #define    REGISTR    9    /*  Register designator (A B X).        */
  121. #define    BLANK    10    /*  White space (spc tab).            */
  122. #define    TRASH    11    /*  Other characters.                */
  123.  
  124. /*  Some tokens for composite operators:  */
  125.  
  126. #define    NO_OPR    0    /*  No operator.                */
  127. #define    GRTEQ    1    /*  Greater than or equal to.            */
  128. #define    NOTEQ    2    /*  Not equal to.                */
  129. #define    LESEQ    3    /*  Less than or equal to.            */
  130. #define    AND    4    /*  And.                    */
  131. #define    OR    5    /*  Or.                        */
  132. #define    XOR    6    /*  Exclusive or.                */
  133. #define    NOT    7    /*  1's complement.                */
  134. #define    MOD    8    /*  Mod--divide and return remainder.        */
  135. #define    SHL    9    /*  Shift left.                    */
  136. #define    SHR    10    /*  Shift right.                */
  137. #define    HIGH    11    /*  High byte of.                */
  138. #define    LOW    12    /*  Low byte of.                */
  139.  
  140. /*  Operator precedence values:  */
  141.  
  142. #define    UOP1    0    /*  Unary +, unary -.                */
  143. #define    MULT    1    /*  *, /, MOD, SHL, SHR.            */
  144. #define    ADDIT    2    /*  Binary +, binary -.                */
  145. #define    RELAT    3    /*  >, =, <, >=, <>, <=.            */
  146. #define    UOP2    4    /*  NOT.                    */
  147. #define    LOG1    5    /*  AND.                    */
  148. #define    LOG2    6    /*  OR, XOR.                    */
  149. #define    UOP3    7    /*  HIGH, LOW.                    */
  150. #define    RPREN    8    /*  ).                        */
  151. #define    LPREN    9    /*  (.                        */
  152. #define    ENDEX    10    /*  CR, ;, ,.                    */
  153. #define    START    11    /*  Start of expression.            */
  154.  
  155. /*  Bits of opcode attribute byte.  */
  156.  
  157. #define    PSOP    0x80    /*  Pseudo-op.                    */
  158. #define    DIROK    0x40    /*  Non-pseudo-op is OK for direct addressing.    */
  159. #define    IFGROUP    0x40    /*  Pseudo-op is IF, ELSE, ENDI.        */
  160. #define    REL    0x20    /*  Relative addressing required.        */
  161. #define    REGREQ    0x10    /*  A, B must be specified.            */
  162. #define    IMM16    0x08    /*  16-bit immediate addressing OK.        */
  163. #define    IMM8    0x04    /*  8-bit immediate addressing OK.        */
  164. #define    INDEX    0x02    /*  Indexed or extended addressing OK.        */
  165. #define    REGOPT    0x01    /*  A, B optional.                */
  166. #define    IS6801    0x11    /*  6801 opcode.                */
  167.  
  168. /*  Set up disk I/O buffers:  */
  169.  
  170. struct _buf _source, _list, _hex, *source, *list, *hex;
  171.  
  172. /*  Set up the symbol table: */
  173.  
  174. struct symbtbl
  175. {
  176.     char symname[SYMLEN];
  177.     unsigned symvalu;
  178. }
  179. symtbl[SYMBOLS], *symend, *sympoint;
  180.  
  181. /*  If stack and stack pointer.  */
  182.  
  183. char ifsp;
  184. unsigned ifstack[IFDEPTH+1];
  185.  
  186. /*  Buffer to hold current line:  */
  187.  
  188. char *linptr, linbuf[LINLEN];
  189.  
  190. /*  Buffer to hold the code generated by a line.  */
  191.  
  192. char nbytes, binbuf[255];
  193.  
  194. /*  Buffers for the hex generator.  */
  195.  
  196. char chksum, hxbytes, *hxlnptr, hxlnbuf[44];
  197.  
  198. /*  Miscellanious mailboxes:  */
  199.  
  200. char errcode;        /*  Error records.                */
  201. int errcount;
  202. char evalerr;        /*  Flag to tell of error in eval.        */
  203. char backflg, oldattr;    /*  Item push-back buffer.            */
  204. unsigned oldvalu;
  205. char curdrive;        /*  Place to save drive that was current
  206.                     disk when assembly started.        */
  207. char hexflg;        /*  Flag for asmline to tell hex
  208.                 generator what to do.            */
  209. char directok;        /*  All symbols on line pre-defined.        */
  210. unsigned pc;        /*  Assembly program counter.            */
  211. unsigned address;    /*  Address to be put into listed line.        */
  212. char pass;        /*  Which pass the assembly is in.        */
  213. char extend;        /*  6801 extensions enabled/disabled.        */
  214.  
  215. /*  Some trivial functions:  */
  216.  
  217. #define    backchr    --linptr        /*  Push back a character.    */
  218.  
  219. uffer to ho