1 /* asxxxx.h */
2 
3 /*
4  *  Copyright (C) 1989-2012  Alan R. Baldwin
5  *
6  *  This program is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  *
20  * Alan R. Baldwin
21  * 721 Berkeley St.
22  * Kent, Ohio  44240
23  *
24  *   With enhancements from
25  *
26  *      John L. Hartman (JLH)
27  *      jhartman at compuserve dot com
28  *
29  *      Bill McKinnon (BM)
30  *      w_mckinnon at conknet dot com
31  *
32  *      Boisy G. Petri (BGP)
33  *      boisy at boisypitre dot com
34  *
35  *      Mike McCarty
36  *      mike dot mccarty at sbcglobal dot net
37  */
38 
39 /*
40  * 28-Oct-97 JLH:
41  *      - add proto for strsto
42  *      - change s_id from [NCPS] to pointer
43  *      - change m_id from [NCPS] to pointer
44  *      - change NCPS to 80
45  *      - case sensitive
46  *      - add R_J11 for 8051 assembler
47  *      - add outr11 prototype for 8051 assembler
48  *      - always define "ccase"
49  *  2-Nov-97 JLH:
50  *      - add jflag for debug control
51  *      - prototypes for DefineNoICE_Line
52  * 30-Jan-98 JLH:
53  *      - add memory space flags to a_flag for 8051
54  *
55  *  3-Feb-00 KV:
56  *      - add DS80C390 flat mode support.
57  * 10-Nov-07 borutr:
58  *      - change a_id from [NCPS] to pointer
59  */
60 
61 /*
62  * System Include Files
63  */
64 
65 #include <stdlib.h>
66 #include <stdio.h>
67 #include <setjmp.h>
68 #include <string.h>
69 
70 /*
71  * Local Definitions
72  */
73 
74 #define VERSION "V02.00 + NoICE + SDCC mods"
75 #define COPYRIGHT "2012"
76 
77 /*
78  * To include NoICE Debugging set non-zero
79  */
80 #define NOICE   1
81 
82 /*
83  * To include SDCC Debugging set non-zero
84  */
85 #define SDCDB   1
86 
87 
88 /*
89  * The assembler requires certain variables to have
90  * at least 32 bits to allow correct address processing.
91  *
92  * The type INT32 is defined so that compiler dependent
93  * variable sizes may be specified in one place.
94  *
95  * LONGINT is defined when INT32 is 'long' to
96  * select the 'l' forms for format strings
97  * and constants.
98  */
99 
100 /* Turbo C++ 3.0 for DOS */
101 /* 'int' is 16-bits, 'long' is 32-bits */
102 
103 #ifdef  __TURBOC__
104 #define         INT32   long
105 #define         LONGINT
106 #endif
107 
108 /* Symantec C++ V6.x/V7.x for DOS (not DOSX) */
109 /* 'int' is 16-bits, 'long' is 32-bits */
110 
111 #ifdef  __SC__
112 #define         INT32   long
113 #define         LONGINT
114 #endif
115 
116 /* The DEFAULT is 'int' is 32 bits */
117 #ifndef INT32
118 #define         INT32   int
119 #endif
120 
121 #if !defined(__BORLANDC__) && !defined(_MSC_VER)
122 #include <unistd.h>
123 #endif
124 
125 /*)Module       asxxxx.h
126  *
127  *      The module asxxxx.h contains the definitions for constants,
128  *      structures, global variables, and ASxxxx functions
129  *      contained in the ASxxxx.c files.  The functions and
130  *      global variables from the machine dependent files are
131  *      also defined.
132  */
133 
134 /*
135  *       compiler/operating system specific definitions
136  */
137 
138 /* DECUS C void definition */
139 /* File/extension seperator */
140 
141 #ifdef  DECUS
142 #define VOID    char
143 #define FSEPX   '.'
144 #endif
145 
146 /* PDOS C void definition */
147 /* File/extension seperator */
148 
149 #ifdef  PDOS
150 #define VOID    char
151 #define FSEPX   ':'
152 #endif
153 
154 /* Default void definition */
155 /* File/extension seperator */
156 
157 #ifndef VOID
158 #define VOID    void
159 #define FSEPX   '.'
160 #define OTHERSYSTEM
161 #endif
162 
163 /*
164  * PATH_MAX
165  */
166 #include <limits.h>
167 #ifndef PATH_MAX                                    /* POSIX, but not required */
168 #  if defined(_MSC_VER) || defined(__BORLANDC__)    /* Microsoft C or Borland C */
169 #    define PATH_MAX        _MAX_PATH
170 #  else
171 #    define PATH_MAX        FILENAME_MAX            /* define a reasonable value */
172 #  endif
173 #endif
174 
175 #ifdef _WIN32           /* WIN32 native */
176 #  define NATIVE_WIN32          1
177 #  ifdef __MINGW32__    /* GCC MINGW32 depends on configure */
178 #    include "../../sdccconf.h"
179 #  else
180 #    include "../../sdcc_vc.h"
181 #    define PATH_MAX    _MAX_PATH
182 #  endif
183 #else                   /* Assume *nix style system */
184 #  include "../../sdccconf.h"
185 #endif
186 
187 /*
188  * Error definitions
189  */
190 #define ER_NONE     0           /* No error */
191 #define ER_WARNING  1           /* Warning */
192 #define ER_ERROR    2           /* Assembly error */
193 #define ER_FATAL    3           /* Fatal error */
194 
195 /*
196  * Assembler definitions.
197  */
198 #define LFTERM      '('         /* Left expression delimeter */
199 #define RTTERM      ')'         /* Right expression delimeter */
200 
201 #define NCPS        80          /* Characters per symbol */
202 #define ASXHUGE     1000        /* A huge number */
203 #define NERR        3           /* Errors per line */
204 #define NINPUT      1024        /* Input buffer size */
205 #define NCODE       128         /* Listing code buffer size */
206 #define NTITL       80          /* Title buffer size */
207 #define NSBTL       80          /* SubTitle buffer size */
208 #define NHASH       (1 << 6)    /* Buckets in hash table */
209 #define HMASK       (NHASH - 1) /* Hash mask */
210 #define NLPP        60          /* Lines per page */
211 #define MAXMCR      20          /* Maximum nesting of macro expansions */
212 #define MAXIF       10          /* Maximum nesting of if/else/endif */
213 #define FILSPC      PATH_MAX    /* Chars. in filespec */
214 
215 #define NLIST       0           /* No listing */
216 #define SLIST       1           /* Source only */
217 #define ALIST       2           /* Address only */
218 #define BLIST       3           /* Address only with allocation */
219 #define CLIST       4           /* Code */
220 #define ELIST       5           /* Equate only */
221 
222 #define LIST_ERR        0x0001  /* Error Code(s) */
223 #define LIST_LOC        0x0002  /* Location */
224 #define LIST_BIN        0x0004  /* Generated Binary Value(s)*/
225 #define LIST_EQT        0x0008  /* Assembler Equate Value */
226 #define LIST_CYC        0x0010  /* Opcode Cycles */
227 #define LIST_LIN        0x0020  /* Line Numbers */
228 #define LIST_SRC        0x0040  /* Assembler Source Code */
229 
230 #define LIST_PAG        0x0080  /* Assembler Pagination */
231 #define LIST_LST        0x0100  /* .LIST/.NLIST Listing */
232 
233 #define LIST_MD         0x0200  /* Macro Definition */
234 #define LIST_ME         0x0400  /* Macro Expansion */
235 #define LIST_MEB        0x0800  /* Macro Expansion Binary */
236 
237 #define LIST_BITS       0x0FFF  /* LIST  Flags Mask */
238 
239 #define LIST_NONE       0x0000  /* NLIST Flags Mask */
240 #define LIST_ASM        0x007F  /* LIST  Flags Mask for Assembler Line */
241 #define LIST_NORM       0x03FF  /* LIST  Flags Mask */
242 
243 #define LIST_NOT        0x1000  /* Force Complement of Listing Mode */
244 
245 #define LIST_TORF       0x8000  /* IF-ENDIF Conditional Overide Flag */
246 
247 #define T_ASM   0               /* Assembler Source File */
248 #define T_INCL  1               /* Assembler Include File */
249 #define T_MACRO 2               /* Assembler Macro */
250 
251 /*
252  * Opcode Cycle definitions (Must Be The Same In ASxxxx / ASLink)
253  */
254 #define CYCNT_BGN       '['     /* Cycle count begin delimiter */
255 #define CYCNT_END       ']'     /* Cycle count end   delimiter */
256 
257 /*
258  * OPCY_NONE bit set signifies no opcode cycles set.
259  */
260 #define OPCY_NONE       ((char) 0x80)   /* Opcode Cycle Count Not Set */
261 #define OPCY_MASK       ((char) 0x7F)   /* Opcode Cycle Count MASK */
262 
263 /*
264  * NTXT must be defined to have the same value in
265  * the ASxxxx assemblers and ASLink.
266  *
267  * The R Line coding allows only 4-bits for coding
268  * the T Line index.  The MAXIMUM value for NTXT
269  * is 16.  It should not be changed.
270  */
271 #define NTXT    16              /* Maximum T Line Values */
272 #define NREL    16              /* Maximum R Line Values */
273 
274 /*
275  * Internal Definitions
276  */
277 #define dot     sym[0]          /* Dot, current loc */
278 #define dca     area[0]         /* Dca, default code area */
279 
280 #define hilo    sym[3].s_addr   /* hilo, byte order flag */
281 #define mls     sym[4]          /* Mls, Macro local symbol */
282 
283 /*
284  *      The defined type 'a_uint' is used for all address and
285  *      unsigned variable value calculations.  Its size is
286  *      required to be at least 32-bits to allow upto
287  *      32-bit addressing or 32-bit value manipulation.
288  */
289 typedef unsigned INT32 a_uint;
290 
291 /*
292  *      The defined type 'v_sint' is used for address and
293  *      variable value calculations requiring a sign.
294  *      Its size is required to be at least 32-bits to allow
295  *      upto 32-bit addressing or 32-bit value manipulation.
296  */
297 typedef signed INT32 v_sint;
298 
299 /*
300  *      The area structure contains the parameter values for a
301  *      specific program or data section.  The area structure
302  *      is a linked list of areas.  The initial default area
303  *      is "_CODE" defined in asdata.c, the next area structure
304  *      will be linked to this structure through the structure
305  *      element 'struct area *a_ap'.  The structure contains the
306  *      area name, area reference number ("_CODE" is 0) determined
307  *      by the order of .area directives, area size determined
308  *      from the total code and/or data in an area, area fuzz is
309  *      a variable used to track pass to pass changes in the
310  *      area size caused by variable length instruction formats,
311  *      and area flags which specify the area's relocation type.
312  */
313 struct  area
314 {
315         struct  area *a_ap;     /* Area link */
316         char *  a_id;           /* Area Name */
317         int     a_ref;          /* Ref. number */
318         a_uint  a_size;         /* Area size */
319         a_uint  a_fuzz;         /* Area fuzz */
320         int     a_flag;         /* Area flags */
321 /* sdas specific */
322         a_uint  a_addr;         /* Area address */
323 /* end sdas specific */
324 };
325 
326 /*
327  *      The "A_" area constants define values used in
328  *      generating the assembler area output data.
329  *
330  * Area flags
331  *
332  *         7     6     5     4     3     2     1     0
333  *      +-----+-----+-----+-----+-----+-----+-----+-----+
334  *      | BIT |XDATA|DATA | PAG | ABS | OVR |     |     |
335  *      +-----+-----+-----+-----+-----+-----+-----+-----+
336  */
337 
338 #define A_CON   0000            /* Concatenating */
339 #define A_OVR   0004            /* Overlaying */
340 #define A_REL   0000            /* Relocatable */
341 #define A_ABS   0010            /* absolute */
342 #define A_NOPAG 0000            /* Non-Paged */
343 #define A_PAG   0020            /* Paged */
344 
345 /* sdas specific */
346 /* Additional flags for 8051 address spaces */
347 #define A_DATA  0000            /* data space (default)*/
348 #define A_CODE  0040            /* code space */
349 #define A_XDATA 0100            /* external data space */
350 #define A_BIT   0200            /* bit addressable space */
351 
352 #define A_NOLOAD  0400          /* nonloadable */
353 #define A_LOAD  0000            /* loadable (default) */
354 /* end sdas specific */
355 
356 /*
357  *      The "R_" relocation constants define values used in
358  *      generating the assembler relocation output data for
359  *      areas, symbols, and code.
360  *
361  * Relocation flags
362  *
363  *         7     6     5     4     3     2     1     0
364  *      +-----+-----+-----+-----+-----+-----+-----+-----+
365  *      | MSB | PAGn| PAG0| USGN| BYT2| PCR | SYM | BYT |
366  *      +-----+-----+-----+-----+-----+-----+-----+-----+
367  */
368 
369 #define R_BYTE  0x01            /*  8 bit */
370 #define R_WORD  0x00            /* 16 bit */
371 
372 #define R_BYT1  0x00            /* Byte count for R_BYTE = 1 */
373 #define R_BYTX  0x08            /* Byte count for R_BYTE = 2 */
374 #define R_HIB   0x200           /* If R_BYTE & R_BYT3 are set, linker
375                                  * will select byte 3 of the relocated
376                                  * 24 bit address.
377                                  */
378 
379 #define R_SGND  0x00            /* Signed Byte */
380 #define R_USGN  0x10            /* Unsigned Byte */
381 
382 #define R_LSB   0x00            /* low byte */
383 #define R_MSB   0x80            /* high byte */
384 
385 #define R_BIT   0x400           /* Linker will convert from byte-addressable
386                                  * space to bit-addressable space.
387                                  */
388 
389 
390 #define R_AREA  0x00            /* Base type */
391 #define R_SYM   0x02
392 
393 /*
394  * Note:  The PAGE modes and PCR modes are mutually exclusive !!!
395  *
396  *
397  * Paging Modes:
398  */
399 
400 #define R_NOPAG 0x0000          /* Page Mode */
401 #define R_PAG0  0x0020          /* Page '0' */
402 #define R_PAGN  0x0040          /* Page 'nnn' */
403 #define R_PAGX  0x0060          /* Page 'x', Extended Relocation Mode */
404 
405 /*
406  * PCR Modes:
407  */
408 
409 #define R_PCR   0x04
410 
411 #define R_J11           (R_WORD|R_BYTX)          /* JLH: 11 bit JMP and CALL (8051) */
412 #define R_J19           (R_WORD|R_BYTX|R_MSB)   /* 19 bit JMP/CALL (DS80C390)      */
413 #define R_C24           (R_WORD|R_BYT1|R_MSB)   /* 24 bit address (DS80C390)       */
414 #define R_J19_MASK      (R_BYTE|R_BYTX|R_MSB)
415 
416 #define IS_R_J19(x)     (((x) & R_J19_MASK) == R_J19)
417 #define IS_R_J11(x)     (((x) & R_J19_MASK) == R_J11)
418 #define IS_C24(x)       (((x) & R_J19_MASK) == R_C24)
419 
420 /*
421  * Basic Relocation Modes
422  */
423 
424 #define R_NORM  0x0000          /* No Bit Positioning */
425 
426 /*
427  * Extended Relocation Modes are defined in
428  * the ___pst.c files.
429  *
430  *      #define R_0100  0x0100  Extended mode 1
431  *      ...
432  *      #define R_0F00  0x0F00  Extended mode 15
433  */
434 
435 #define R_ESCAPE_MASK   0xf0    /* Used to escape relocation modes
436                                  * greater than 0xff in the .rel
437                                  * file.
438                                  */
439 
440 /*
441  * Listing Control Flags
442  */
443 
444 #define R_HIGH  0040000         /* High Byte */
445 #define R_BYT3  0x100           /* if R_BYTE is set, this is a
446                                  * 3 byte address, of which
447                                  * the linker must select one byte.
448                                  */
449 #define R_RELOC 0100000         /* Relocation */
450 
451 #define R_DEF   00              /* Global def. */
452 #define R_REF   01              /* Global ref. */
453 #define R_REL   00              /* Relocatable */
454 #define R_ABS   02              /* Absolute */
455 #define R_GBL   00              /* Global */
456 #define R_LCL   04              /* Local */
457 
458 /*
459  *      The mne structure is a linked list of the assembler
460  *      mnemonics and directives.  The list of mnemonics and
461  *      directives contained in the device dependent file
462  *      xxxpst.c are hashed and linked into NHASH lists in
463  *      module assym.c by syminit().  The structure contains
464  *      the mnemonic/directive name, a subtype which directs
465  *      the evaluation of this mnemonic/directive, a flag which
466  *      is used to detect the end of the mnemonic/directive
467  *      list in xxxpst.c, and a value which is normally
468  *      associated with the assembler mnemonic base instruction
469  *      value.
470  */
471 struct  mne
472 {
473         struct  mne *m_mp;      /* Hash link */
474         char    *m_id;          /* Mnemonic (JLH) */
475         char    m_type;         /* Mnemonic subtype */
476         char    m_flag;         /* Mnemonic flags */
477         a_uint  m_valu;         /* Value */
478 };
479 
480 /*
481  *      The sym structure is a linked list of symbols defined
482  *      in the assembler source files.  The first symbol is "."
483  *      defined in asdata.c.  The entry 'struct tsym *s_tsym'
484  *      links any temporary symbols following this symbol and
485  *      preceeding the next normal symbol.  The structure also
486  *      contains the symbol's name, type (NEW or USER),
487  *      flag (global, assigned, and multiply defined), a pointer
488  *      to the area structure defining where the symbol is
489  *      located, a reference number assigned by outgsd() in
490  *      asout.c, and the symbols address relative to the base
491  *      address of the area where the symbol is located.
492  */
493 struct  sym
494 {
495         struct  sym  *s_sp;     /* Hash link */
496         struct  tsym *s_tsym;   /* Temporary symbol link */
497         char    *s_id;          /* Symbol (JLH) */
498         char    s_type;         /* Symbol subtype */
499         char    s_flag;         /* Symbol flags */
500         struct  area *s_area;   /* Area line, 0 if absolute */
501         int     s_ref;          /* Ref. number */
502         a_uint  s_addr;         /* Address */
503 /* sdas specific */
504         a_uint  s_org;          /* Start Address if absolute */
505 /* end sdas specific */
506 };
507 
508 #define S_EOL           040     /* End mark for ___pst files */
509 
510 #define S_LCL           001     /* Local Variable */
511 #define S_GBL           002     /* Global Variable */
512 #define S_ASG           004     /* Assigned Value */
513 #define S_MDF           010     /* Multiple Definition */
514 
515 #define S_NEW           0       /* New  Name (External) */
516 #define S_USER          1       /* User Name (Assigned) */
517 #define S_SPARE         2       /* Spare Definition */
518 #define S_PAGE          3       /* .page */
519 #define S_HEADER        4       /* .title, .sbttl */
520 #define   O_TITLE    0          /* .title */
521 #define   O_SBTTL    1          /* .sbttl */
522 #define S_MODUL         5       /* .module */
523 #define S_INCL          6       /* .include */
524 #define S_AREA          7       /* .area */
525 #define S_ATYP          8       /* .area type */
526 #define S_ORG           11      /* .org */
527 #define S_RADIX         12      /* .radix */
528 #define S_GLOBL         13      /* .globl */
529 #define S_LOCAL         14      /* .local */
530 #define S_CONDITIONAL   15      /* .if, .iif, .else, .endif, ... */
531 #define   O_IF       0          /* .if */
532 #define   O_IFF      1          /* .iff */
533 #define   O_IFT      2          /* .ift */
534 #define   O_IFTF     3          /* .iftf */
535 #define   O_IFGT     6          /* .ifgt (BGP) */
536 #define   O_IFLT     7          /* .iflt (BGP) */
537 #define   O_IFGE     8          /* .ifge (BGP) */
538 #define   O_IFLE     9          /* .ifle (BGP) */
539 #define   O_IFEQ     10         /* .ifeq (BGP) */
540 #define   O_IFNE     11         /* .ifne (BGP) */
541 #define   O_IFEND    20         /* end of .if conditionals */
542 #define   O_IIF      20         /* .iif */
543 #define   O_IIFF     21         /* .iiff */
544 #define   O_IIFT     22         /* .iift */
545 #define   O_IIFTF    23         /* .iiftf */
546 #define   O_IIFGT    26         /* .iifgt */
547 #define   O_IIFLT    27         /* .iiflt */
548 #define   O_IIFGE    28         /* .iifge */
549 #define   O_IIFLE    29         /* .iifle */
550 #define   O_IIFEQ    30         /* .iifeq */
551 #define   O_IIFNE    31         /* .iifne */
552 #define   O_IIFEND   40         /* end of .iif conditionals */
553 #define   O_ELSE     40         /* .else */
554 #define   O_ENDIF    41         /* .endif */
555 #define S_LISTING       16      /* .nlist, .list */
556 #define   O_LIST     0          /* .list */
557 #define   O_NLIST    1          /* .nlist */
558 #define S_EQU           17      /* .equ, .gblequ, .lclequ */
559 #define   O_EQU      0          /* .equ */
560 #define   O_GBLEQU   1          /* .gblequ */
561 #define   O_LCLEQU   2          /* .lclequ */
562 #define S_DATA          18      /* .byte, .word, .3byte, .4byte, .db, .dw, .fcb, .fdb */
563 #define   O_1BYTE    1          /* .byte, .db, .fcb */
564 #define   O_2BYTE    2          /* .word, .dw, .fdb */
565 #define   O_3BYTE    3          /* .3byte */
566 #define   O_4BYTE    4          /* .4byte */
567 #define S_BLK           19      /* .blkb or .blkw */
568 #define S_ASCIX         20      /* .ascii, .ascis, .asciz, .str, .strs, .strz */
569 #define   O_ASCII    0          /* .ascii */
570 #define   O_ASCIS    1          /* .ascis */
571 #define   O_ASCIZ    2          /* .asciz */
572 #define S_BOUNDARY      22      /* .even, .odd */
573 #define   O_EVEN     0          /* .even */
574 #define   O_ODD      1          /* .odd */
575 #define   O_BNDRY    2          /* .bndry */
576 #define S_BITS          26      /* .8bit, .16bit, .24bit, .32bit */
577 /*        O_1BYTE    1  */      /* .8bit */
578 /*        O_2BYTE    2  */      /* .16bit */
579 /*        O_3BYTE    3  */      /* .24bit */
580 /*        O_4BYTE    4  */      /* .32bit */
581 #define S_END           27      /* .end */
582 #define S_MACRO         28      /* .macro, .endm, .mexit, ... */
583 #define   O_MACRO    0          /* .macro */
584 #define   O_ENDM     1          /* .endm */
585 #define   O_MEXIT    2          /* .mexit */
586 #define   O_NCHR     3          /* .nchr */
587 #define   O_NARG     4          /* .narg */
588 #define   O_NTYP     5          /* .ntyp */
589 #define   O_IRP      6          /* .irp */
590 #define   O_IRPC     7          /* .irpc */
591 #define   O_REPT     8          /* .rept */
592 #define   O_NVAL     9          /* .nval */
593 #define   O_MDEL     10         /* .mdelete */
594 #define   O_CHECK    255        /* Building/Exiting a Macro Check */
595 
596 #define S_DIREOL        30      /* Assembler Directive End Of List */
597 
598 /* sdas specific */
599 #define S_FLOAT         32      /* .df */
600 #define S_ULEB128       33      /* .uleb128 */
601 #define S_SLEB128       34      /* .sleb128 */
602 #define S_OPTSDCC       35      /* .optsdcc */
603 /* end sdas specific */
604 
605 /*
606  *      The tsym structure is a linked list of temporary
607  *      symbols defined in the assembler source files following
608  *      a normal symbol.  The structure contains the temporary
609  *      symbols number, a flag (multiply defined), a pointer to the
610  *      area structure defining where the temporary structure
611  *      is located, and the temporary symbol's address relative
612  *      to the base address of the area where the symbol
613  *      is located.
614  */
615 struct  tsym
616 {
617         struct  tsym *t_lnk;    /* Link to next */
618         a_uint  t_num;          /* 0-65535$      for a 16-bit int */
619                                 /* 0-4294967295$ for a 32-bit int */
620         int     t_flg;          /* flags */
621         struct  area *t_area;   /* Area */
622         a_uint  t_addr;         /* Address */
623 };
624 
625 /*
626  *      The def structure is used by the .define assembler
627  *      directive to define a substitution string for a
628  *      single word.  The def structure contains the
629  *      string being defined, the string to substitute
630  *      for the defined string, and a link to the next
631  *      def structure.  The defined string is a sequence
632  *      of characters not containing any white space
633  *      (i.e. NO SPACEs or TABs).  The substitution string
634  *      may contain SPACES and/or TABs.
635  */
636 struct def
637 {
638         struct def      *d_dp;          /* link to next define */
639         char            *d_id;          /* defined string */
640         char            *d_define;      /* string to substitute for defined string */
641         int             d_dflag;        /* (1) .defined / (0) .undefined */
642 };
643 
644 /*
645  *      The mode structure contains the specification of one of the
646  *      assemblers' merge modes.  Each assembler must specify
647  *      at least one merge mode.  The merging specification
648  *      allows arbitrarily defined active bits and bit positions.
649  *      The 32 element arrays are indexed from 0 to 31.
650  *      Index 0 corresponds to bit 0, ..., and 31 corresponds to bit 31
651  *      of a normal integer value.
652  *
653  *      The value of the element specifies if the normal integer bit
654  *      is active (bit <7> is set, 0x80) and what destination bit
655  *      (bits <4:0>, 0 - 31) should be loaded with this normal
656  *      integer bit.
657  *
658  *      The specification for a 32-bit integer:
659  *
660  *      char mode_[32] = {
661  *              '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
662  *              '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
663  *              '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
664  *              '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237'
665  *      };
666  *
667  *
668  *      The specification for the 11-bit 8051 addressing mode:
669  *
670  *      char mode_[32] = {
671  *              '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
672  *              '\215', '\216', '\217', '\013', '\014', '\015', '\016', '\017',
673  *              '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
674  *              '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037'
675  *      };
676  *
677  *
678  *     *m_def is a pointer to the bit relocation definition.
679  *      m_flag indicates that bit position swapping is required.
680  *      m_dbits contains the active bit positions for the output.
681  *      m_sbits contains the active bit positions for the input.
682  */
683 struct  mode
684 {
685         char *  m_def;          /* Bit Relocation Definition */
686         a_uint  m_flag;         /* Bit Swapping Flag */
687         a_uint  m_dbits;        /* Destination Bit Mask */
688         a_uint  m_sbits;        /* Source Bit Mask */
689 };
690 
691 /*
692  * Definitions for Character Types
693  */
694 #define SPACE   '\000'
695 #define ETC     '\000'
696 #define LETTER  '\001'
697 #define DIGIT   '\002'
698 #define BINOP   '\004'
699 #define RAD2    '\010'
700 #define RAD8    '\020'
701 #define RAD10   '\040'
702 #define RAD16   '\100'
703 #define ILL     '\200'
704 
705 #define DGT2    (DIGIT|RAD16|RAD10|RAD8|RAD2)
706 #define DGT8    (DIGIT|RAD16|RAD10|RAD8)
707 #define DGT10   (DIGIT|RAD16|RAD10)
708 #define LTR16   (LETTER|RAD16)
709 
710 /*
711  *      The expr structure is used to return the evaluation
712  *      of an expression.  The structure supports three valid
713  *      cases:
714  *      (1)     The expression evaluates to a constant,
715  *              mode = S_USER, flag = 0, addr contains the
716  *              constant, and base = NULL.
717  *      (2)     The expression evaluates to a defined symbol
718  *              plus or minus a constant, mode = S_USER,
719  *              flag = 0, addr contains the constant, and
720  *              base = pointer to area symbol.
721  *      (3)     The expression evaluates to a external
722  *              global symbol plus or minus a constant,
723  *              mode = S_NEW, flag = 1, addr contains the
724  *              constant, and base = pointer to symbol.
725  */
726 struct  expr
727 {
728         char    e_mode;         /* Address mode */
729         char    e_flag;         /* Symbol flag */
730         a_uint  e_addr;         /* Address */
731         union   {
732                 struct area *e_ap;
733                 struct sym  *e_sp;
734         } e_base;               /* Rel. base */
735         int     e_rlcf;         /* Rel. flags */
736 };
737 
738 /*
739  *      The asmf structure contains the information
740  *      pertaining to an assembler source file/macro.
741  *
742  * The Parameters:
743  *      next    is a pointer to the next object in the linked list
744  *      objtyp  specifies the object type - T_ASM, T_INCL, T_MACRO
745  *      line    is the saved line number of the parent object
746  *      flevel  is the saved flevel of the parent object
747  *      tlevel  is the saved tlevel of the parent object
748  *      lnlist  is the saved lnlist of the parent object
749  *      fp      is the source FILE handle
750  *      afp     is the file path length (excludes the files name.ext)
751  *      afn[]   is the assembler/include file path/name.ext
752  */
753 struct  asmf
754 {
755         struct  asmf *next;     /* Link to Next Object */
756         int     objtyp;         /* Object Type */
757         int     line;           /* Saved Line Counter */
758         int     flevel;         /* saved flevel */
759         int     tlevel;         /* saved tlevel */
760         int     lnlist;         /* saved lnlist */
761         FILE *  fp;             /* FILE Handle */
762         int     afp;            /* File Path Length */
763         char    afn[FILSPC];    /* File Name */
764 };
765 
766 /*
767  *      The macrofp structure masquerades as a FILE Handle
768  *      for inclusion in an asmf structure.  This structure
769  *      contains the reference to the macro to be inserted
770  *      into the assembler stream and information to
771  *      restore the assembler state at macro completion.
772  *
773  * The Parameters:
774  *      np      is a pointer to the macro definition
775  *      lstptr  is a pointer to the next macro line
776  *      rptcnt  is the macro repeat counter
777  *      rptidx  is the current repeat count
778  *      flevel  is the saved assembler flevel
779  *      tlevel  is the saved assembler tlevel
780  *      lnlist  is the saved assembler lnlist
781  *      npexit  non zero if an .mexit is encountered
782  */
783 struct  macrofp {
784         struct mcrdef * np;             /* pointer to macro definition */
785         struct strlst * lstptr;         /* pointer to next line of macro */
786         int             rptcnt;         /* repeat counter */
787         int             rptidx;         /* repeat index */
788         int             flevel;         /* saved flevel */
789         int             tlevel;         /* saved tlevel */
790         int             lnlist;         /* saved lnlist */
791         int             npexit;         /* .mexit called */
792 };
793 
794 /*
795  *      The mcrdef structure contains the
796  *      information about a macro definition.
797  *
798  *      When the macro is defined the definition
799  *      arguments are packed into a linked list of
800  *      strings beginning with bgnarg and ending with
801  *      endarg. The number of args is placed in narg.
802  *
803  *      When the macro is invoked the expansion
804  *      argument strings are placed into a linked
805  *      list of strings beginning with bgnxrg and
806  *      ending with endxrg. The number of expansion
807  *      arguments is placed in xarg.
808  *
809  * The Parameters:
810  *      next    is a pointer to the next macro definition structure
811  *      name    is a pointer to the macro name string
812  *      bgnlst  is a pointer to the first text line of the macro
813  *      endlst  is a pointer to the last  text line of the macro
814  *      type    is the macro type - .macro, .irp, .irpc, or .rept
815  *      rptcnt  is the repeat count for the macro
816  *      nest    is the macro nesting counter
817  *      narg    is the number of macro definition arguments
818  *      bgnarg  is a pointer to the first definition argument string
819  *      endarg  is a pointer to the last  definition argument string
820  *      xarg    is the number of expansion arguments at macro invocation
821  *      bgnxrg  is a pointer to the first expansion argument string
822  *      endxrg  is a pointer to the last  expansion argument string
823  */
824 struct  mcrdef {
825         struct mcrdef * next;           /* link to next macro definition */
826         char *          name;           /* pointer to the macro name */
827         struct strlst * bgnlst;         /* link to first text line of macro */
828         struct strlst * endlst;         /* link to last text line of macro */
829         int             type;           /* macro type */
830         int             rptcnt;         /* repeat counter */
831         int             nest;           /* macro nesting counter */
832         int             narg;           /* number of macro defintion arguments */
833         struct strlst * bgnarg;         /* link to first macro defintion argument */
834         struct strlst * endarg;         /* link to last macro definition argument */
835         int             xarg;           /* number of macro expansion arguments */
836         struct strlst * bgnxrg;         /* link to first macro expansion argument */
837         struct strlst * endxrg;         /* link to last macro xpansion argument */
838 };
839 
840 /*
841  *      The strlst structure is a linked list of strings.
842  *
843  * The Parameters:
844  *      next    is a pointer to the next string.
845  *      text    is a pointer to a text string.
846  */
847 struct  strlst {
848         struct strlst * next;           /* pointer to next string */
849         char *          text;           /* pointer to string text */
850 };
851 
852 /*
853  *      The memlnk structure is a linked list
854  *      of memory allocations.
855  *
856  *      The function new() uses the memlnk structure
857  *      to create a linked list of allocated memory
858  *      that can be traversed by asfree() to release
859  *      the allocated memory.
860  *
861  *      The function mhunk() uses the memlnk structure
862  *      to create a linked list of allocated memory
863  *      that can be reused.
864  *
865  * The Parameters:
866  *      next    is a pointer to the next memlnk structure.
867  *      ptr     is a pointer to the allocated memory.
868  */
869 struct  memlnk {
870         struct memlnk * next;           /* link to next memlnk */
871         VOID *          ptr;            /* pointer to allocated memory */
872 };
873 
874 /*
875  *      External Definitions for all Global Variables
876  */
877 
878 extern  int     aserr;          /*      ASxxxx error counter
879                                  */
880 extern  jmp_buf jump_env;       /*      compiler dependent structure
881                                  *      used by setjmp() and longjmp()
882                                  */
883 extern  struct  asmf    *asmp;  /*      The pointer to the first assembler
884                                  *      source file structure of a linked list
885                                  */
886 extern  struct  asmf    *asmc;  /*      Pointer to the current
887                                  *      source input structure
888                                  */
889 extern  struct  asmf    *asmi;  /*      Queued pointer to an include file
890                                  *      source input structure
891                                  */
892 extern  struct  asmf    *asmq;  /*      Queued pointer to a macro
893                                  *      source input structure
894                                  */
895 extern  struct mcrdef * mcrlst; /*      link to list of defined macros
896                                  */
897 extern  struct mcrdef * mcrp;   /*      link to list of defined macros
898                                  */
899 extern  struct memlnk * pmcrmem;/*      First Macro Memory Allocation Structure
900                                  */
901 extern  struct memlnk * mcrmem; /*      Macro Memory Allocation Structure
902                                  */
903 extern  int     mcrblk;         /*      Macro data blocks allocated
904                                  */
905 extern  int     incfil;         /*      include file nesting counter
906                                  */
907 extern  int     maxinc;         /*      maximum include file nesting encountered
908                                  */
909 extern  int     mcrfil;         /*      macro nesting counter
910                                  */
911 extern  int     maxmcr;         /*      maximum macro nesting encountered
912                                  */
913 extern  int     flevel;         /*      IF-ELSE-ENDIF flag will be non
914                                  *      zero for false conditional case
915                                  */
916 extern  int     ftflevel;       /*      IIFF-IIFT-IIFTF FLAG
917                                  */
918 extern  int     tlevel;         /*      current conditional level
919                                  */
920 extern  int     lnlist;         /*      LIST-NLIST options
921                                  */
922 extern  int     ifcnd[MAXIF+1]; /*      array of IF statement condition
923                                  *      values (0 = FALSE) indexed by tlevel
924                                  */
925 extern  int     iflvl[MAXIF+1]; /*      array of IF-ELSE-ENDIF flevel
926                                  *      values indexed by tlevel
927                                  */
928 extern  char    afn[FILSPC];    /*      current input file specification
929                                  */
930 extern  int     afp;            /*      current input file path length
931                                  */
932 extern  char    afntmp[FILSPC]; /*      temporary input file specification
933                                  */
934 extern  int     afptmp;         /*      temporary input file path length
935                                  */
936 extern  int     srcline;        /*      current source line number
937                                  */
938 extern  int     asmline;        /*      current assembler file line number
939                                  */
940 extern  int     incline;        /*      current include file line number
941                                  */
942 extern  int     mcrline;        /*      current macro line number
943                                  */
944 extern  int     radix;          /*      current number conversion radix:
945                                  *      2 (binary), 8 (octal), 10 (decimal),
946                                  *      16 (hexadecimal)
947                                  */
948 extern  int     line;           /*      current assembler source line number
949                                  */
950 extern  int     page;           /*      current page number
951                                  */
952 extern  int     lop;            /*      current line number on page
953                                  */
954 extern  int     pass;           /*      assembler pass number
955                                  */
956 extern  int     aflag;          /*      -a, make all symbols global flag
957                                  */
958 extern  int     bflag;          /*      -b(b), listing mode flag
959                                  */
960 extern  int     cflag;          /*      -c, disable cycle counts in listing flag
961                                  */
962 extern  int     fflag;          /*      -f(f), relocations flagged flag
963                                  */
964 extern  int     gflag;          /*      -g, make undefined symbols global flag
965                                  */
966 #if NOICE
967 extern  int     jflag;          /*      -j, generate debug information flag
968                                  */
969 #endif
970 
971 extern  int     lflag;          /*      -l, generate listing flag
972                                  */
973 extern  int     oflag;          /*      -o, generate relocatable output flag
974                                  */
975 extern  int     pflag;          /*      -p, disable listing pagination
976                                  */
977 extern  int     sflag;          /*      -s, generate symbol table flag
978                                  */
979 extern  int     uflag;          /*      -u, disable .list/.nlist processing flag
980                                  */
981 extern  int     wflag;          /*      -w, enable wide listing format
982                                  */
983 extern  int     xflag;          /*      -x, listing radix flag
984                                  */
985 
986 #if SDCDB
987 extern  int     yflag;          /*      -y, enable SDCC Debug Symbols
988                                  */
989 #endif
990 
991 extern  int     zflag;          /*      -z, disable symbol case sensitivity
992                                  */
993 extern  int     waddrmode;      /*      WORD Address mode flag
994                                  */
995 extern  int     a_bytes;        /*      REL file T Line address length
996                                  */
997 extern  a_uint  a_mask;         /*      Address Mask
998                                  */
999 extern  a_uint  s_mask;         /*      Sign Mask
1000                                  */
1001 extern  a_uint  v_mask;         /*      Value Mask
1002                                  */
1003 extern  a_uint  laddr;          /*      address of current assembler line,
1004                                  *      equate, or value of .if argument
1005                                  */
1006 extern  a_uint  fuzz;           /*      tracks pass to pass changes in the
1007                                  *      address of symbols caused by
1008                                  *      variable length instruction formats
1009                                  */
1010 extern  int     lmode;          /*      listing mode
1011                                  */
1012 extern  char    txt[NTXT];      /*      T Line Values
1013                                  */
1014 extern  char    rel[NREL];      /*      R Line Values
1015                                  */
1016 extern  char    *txtp;          /*      Pointer to T Line Values
1017                                  */
1018 extern  char    *relp;          /*      Pointer to R Line Values
1019                                  */
1020 extern  struct  area    *areap; /*      pointer to an area structure
1021                                  */
1022 extern  struct  area    area[]; /*      array of 1 area
1023                                  */
1024 extern  struct  sym     sym[];  /*      array of 1 symbol
1025                                  */
1026 extern  struct  sym     *symp;  /*      pointer to a symbol structure
1027                                  */
1028 extern  struct  sym *symhash[NHASH]; /* array of pointers to NHASH
1029                                       * linked symbol lists
1030                                       */
1031 extern  struct  mne *mnehash[NHASH]; /* array of pointers to NHASH
1032                                       * linked mnemonic/directive lists
1033                                       */
1034 extern  char    *ep;            /*      pointer into error list
1035                                  *      array eb[NERR]
1036                                  */
1037 extern  char    eb[NERR];       /*      array of generated error codes
1038                                  */
1039 extern  char    *ip;            /*      pointer into the assembler-source
1040                                  *      text line in ib[]
1041                                  */
1042 extern  char    *ib;            /*      assembler-source text line for processing
1043                                  */
1044 extern  char    *ic;            /*      assembler-source text line for listing
1045                                  */
1046 extern  char    *cp;            /*      pointer to assembler output
1047                                  *      array cb[]
1048                                  */
1049 extern  char    cb[NCODE];      /*      array of assembler output values
1050                                  */
1051 extern  int     *cpt;           /*      pointer to assembler relocation type
1052                                  *      output array cbt[]
1053                                  */
1054 extern  int     cbt[NCODE];     /*      array of assembler relocation types
1055                                  *      describing the data in cb[]
1056                                  */
1057 extern  int     opcycles;       /*      opcode execution cycles
1058                                  */
1059 extern  char    tb[NTITL];      /*      Title string buffer
1060                                  */
1061 extern  char    stb[NSBTL];     /*      Subtitle string buffer
1062                                  */
1063 extern  char    erb[NINPUT+4];  /*      Error string buffer
1064                                  */
1065 extern  char    symtbl[];       /*      string "Symbol Table"
1066                                  */
1067 extern  char    aretbl[];       /*      string "Area Table"
1068                                  */
1069 extern  char    module[NCPS+2]; /*      module name string
1070                                  */
1071 extern  FILE    *lfp;           /*      list output file handle
1072                                  */
1073 extern  FILE    *ofp;           /*      relocation output file handle
1074                                  */
1075 extern  FILE    *tfp;           /*      symbol table output file handle
1076                                  */
1077 extern  unsigned char ctype[256]; /*    array of character types, one per
1078                                  *      ASCII/OEM character
1079                                  */
1080 extern  char    ccase[256];     /*      an array of characters which
1081                                  *      perform the case translation function
1082                                  */
1083 /*sdas specific */
1084 extern  int     asfatal;        /*      ASxxxx fatal error counter
1085                                  */
1086 extern  int     org_cnt;        /*      .org directive counter
1087                                  */
1088 extern  char    *optsdcc;       /*      sdcc compile options
1089                                  */
1090 /*end sdas specific */
1091 
1092 /* C Library functions */
1093 /* for reference only
1094 extern  VOID            exit();
1095 extern  int             fclose();
1096 extern  char *          fgets();
1097 extern  FILE *          fopen();
1098 extern  int             fprintf();
1099 extern  VOID            free();
1100 extern  VOID            longjmp();
1101 extern  VOID *          malloc();
1102 extern  int             printf();
1103 extern  char            putc();
1104 extern  int             rewind();
1105 extern  int             setjmp();
1106 extern  int             strcmp();
1107 extern  char *          strcpy();
1108 extern  int             strlen();
1109 extern  char *          strncpy();
1110 extern  char *          strrchr();
1111 */
1112 
1113 /* Machine independent functions */
1114 
1115 #ifdef  OTHERSYSTEM
1116 
1117 /* asmain.c */
1118 extern  FILE *          afile(char *fn, char *ft, int wf);
1119 extern  VOID            afilex(char *fn, char *ft);
1120 extern  VOID            asexit(int i);
1121 extern  VOID            asmbl(void);
1122 extern  VOID            equate(char *id,struct expr *e1,a_uint equtype);
1123 extern  int             fndidx(char *str);
1124 extern  int             intsiz(void);
1125 extern  VOID            newdot(struct area *nap);
1126 extern  VOID            phase(struct area *ap, a_uint a);
1127 extern  VOID            usage(int n);
1128 
1129 /* asmcro.c */
1130 extern  char *          fgetm(char *ptr, int len, FILE *fp);
1131 extern  VOID            getdarg(struct mcrdef *np);
1132 extern  VOID            getxarg(struct mcrdef *np);
1133 extern  VOID            getxstr(char *id);
1134 extern  VOID            macro(struct mcrdef * np);
1135 extern  VOID            macroscn(struct macrofp *nfp);
1136 extern  int             macrosub(char *id, struct macrofp *nfp);
1137 extern  VOID            mcrinit(void);
1138 extern  int             mcrprc(int code);
1139 extern  VOID *          mhunk(void);
1140 extern  char *          mstring(char *str);
1141 extern  char *          mstruct(int n);
1142 extern  struct mcrdef * newdef(int code, char *id);
1143 extern  struct mcrdef * nlookup(char *id);
1144 
1145 /* aslex.c */
1146 extern  int             comma(int flag);
1147 extern  char            endline(void);
1148 extern  int             get(void);
1149 extern  int             getdlm(void);
1150 extern  VOID            getdstr(char *str, int slen);
1151 extern  VOID            getid(char *id, int c);
1152 extern  int             getmap(int d);
1153 extern  int             getnb(void);
1154 extern  int             getlnm(void);
1155 extern  VOID            getst(char *id, int c);
1156 extern  int             more(void);
1157 extern  int             nxtline(void);
1158 extern  VOID            unget(int c);
1159 
1160 /* assym.c */
1161 extern  VOID            allglob(void);
1162 extern  struct  area *  alookup(char *id);
1163 extern  int             hash(const char *p, int flag);
1164 extern  struct  sym *   lookup(const char *id);
1165 extern  struct  mne *   mlookup(char *id);
1166 extern  char *          new(unsigned int n);
1167 extern  char *          strsto(const char *str);
1168 extern  int             symeq(const char *p1, const char *p2, int flag);
1169 extern  VOID            syminit(void);
1170 extern  VOID            symglob(void);
1171 
1172 /* assubr.c */
1173 extern  VOID            aerr(void);
1174 extern  VOID            diag(void);
1175 extern  VOID            err(int c);
1176 extern  char *          geterr(int c);
1177 extern  VOID            qerr(void);
1178 extern  VOID            rerr(void);
1179 /* sdas specific */
1180 extern  VOID            warnBanner(void);
1181 /* end sdas specific */
1182 
1183 /* asexpr.c */
1184 extern  VOID            abscheck(struct expr *esp);
1185 extern  a_uint          absexpr(void);
1186 extern  VOID            clrexpr(struct expr *esp);
1187 extern  int             digit(int c, int r);
1188 extern  VOID            exprmasks(int n);
1189 extern  VOID            expr(struct expr *esp, int n);
1190 extern  int             is_abs(struct expr *esp);
1191 extern  int             oprio(int c);
1192 extern  a_uint          rngchk(a_uint n);
1193 extern  VOID            term(struct expr *esp);
1194 
1195 /* asdbg */
1196 extern  char *          BaseFileName(struct asmf *currFile, int spacesToUnderscores);
1197 extern  VOID            DefineNoICE_Line(void);
1198 extern  VOID            DefineSDCC_Line(void);
1199 
1200 /* aslist.c */
1201 extern  VOID            list(void);
1202 extern  VOID            list1(char *wp, int *wpt, int nb, int n, int f, int g);
1203 extern  VOID            list2(int t);
1204 extern  VOID            lstsym(FILE *fp);
1205 extern  VOID            slew(FILE *fp, int flag);
1206 
1207 /* asout.c */
1208 extern  int             lobyte(a_uint v);
1209 extern  int             hibyte(a_uint v);
1210 extern  int             thrdbyte(a_uint v);
1211 extern  int             frthbyte(a_uint v);
1212 extern  VOID            out(char *p, int n);
1213 extern  VOID            outarea(struct area *ap);
1214 extern  VOID            outdp(struct area *carea, struct expr *esp, int r);
1215 extern  VOID            outall(void);
1216 extern  VOID            outdot(void);
1217 extern  VOID            outbuf(char *s);
1218 extern  VOID            outchk(int nt, int nr);
1219 extern  VOID            outradix(void);
1220 extern  VOID            outgsd(void);
1221 extern  VOID            outsym(struct sym *sp);
1222 extern  VOID            outab(a_uint v);
1223 extern  VOID            outaw(a_uint v);
1224 extern  VOID            outa3b(a_uint v);
1225 extern  VOID            outa4b(a_uint v);
1226 extern  VOID            outaxb(int i, a_uint v);
1227 extern  VOID            outatxb(int i, a_uint v);
1228 extern  VOID            outrb(struct expr *esp, int r);
1229 extern  VOID            outrw(struct expr *esp, int r);
1230 extern  VOID            outr3b(struct expr *esp, int r);
1231 extern  VOID            outrxb(int i, struct expr *esp, int r);
1232 extern  VOID            outrwm(struct expr *esp, int r, a_uint v);
1233 extern  VOID            outrwp(struct expr *esp, a_uint op, a_uint mask, int jump);
1234 extern  VOID            outr3bm(struct expr *esp, int r, a_uint v);
1235 extern  VOID            out_lb(a_uint v, int t);
1236 extern  VOID            out_lw(a_uint v, int t);
1237 extern  VOID            out_l3b(a_uint v, int t);
1238 extern  VOID            out_l4b(a_uint v, int t);
1239 extern  VOID            out_lxb(int i, a_uint v, int t);
1240 extern  VOID            out_rw(a_uint v);
1241 extern  VOID            out_txb(int i, a_uint v);
1242 
1243 /* Machine dependent variables */
1244 
1245 extern  char *          cpu;
1246 extern  char *          dsft;
1247 extern  struct  mne     mne[];
1248 
1249 /* Machine dependent functions */
1250 
1251 extern  VOID            machine(struct mne *mp);
1252 extern  VOID            minit(void);
1253 
1254 
1255 /* sdas specific */
1256 /* strcmpi.c */
1257 extern  int as_strcmpi(const char *s1, const char *s2);
1258 extern  int as_strncmpi(const char *s1, const char *s2, size_t n);
1259 /* end sdas specific */
1260 
1261 #else
1262 
1263 /* asmain.c */
1264 extern  FILE *          afile();
1265 extern  VOID            afilex();
1266 extern  VOID            asexit();
1267 extern  VOID            asmbl();
1268 extern  VOID            equate();
1269 extern  int             fndidx();
1270 extern  int             intsiz();
1271 extern  int             main();
1272 extern  VOID            newdot();
1273 extern  VOID            phase();
1274 extern  VOID            usage();
1275 
1276 /* asmcro.c */
1277 extern  char *          fgetm();
1278 extern  VOID            getdarg();
1279 extern  VOID            getxarg();
1280 extern  VOID            getxstr();
1281 extern  VOID            macro();
1282 extern  VOID            macroscn();
1283 extern  int             macrosub();
1284 extern  VOID            mcrinit();
1285 extern  int             mcrprc();
1286 extern  VOID *          mhunk();
1287 extern  char *          mstring();
1288 extern  char *          mstruct();
1289 extern  struct mcrdef * newdef();
1290 extern  struct mcrdef * nlookup();
1291 
1292 /* aslex.c */
1293 extern  int             comma();
1294 extern  char            endline();
1295 extern  int             get();
1296 extern  int             getdlm();
1297 extern  VOID            getdstr();
1298 extern  VOID            getid();
1299 extern  int             getmap();
1300 extern  int             getnb();
1301 extern  int             getlnm();
1302 extern  VOID            getst();
1303 extern  int             more();
1304 extern  int             nxtline();
1305 extern  VOID            unget();
1306 
1307 /* assym.c */
1308 extern  VOID            allglob();
1309 extern  struct  area *  alookup();
1310 
1311 extern  int             hash();
1312 extern  struct  sym *   lookup();
1313 extern  struct  mne *   mlookup();
1314 extern  char *          new();
1315 extern  char *          strsto();
1316 extern  int             symeq();
1317 extern  VOID            syminit();
1318 extern  VOID            symglob();
1319 
1320 /* assubr.c */
1321 extern  VOID            aerr();
1322 extern  VOID            diag();
1323 extern  VOID            err();
1324 extern  char *          geterr();
1325 extern  VOID            qerr();
1326 extern  VOID            rerr();
1327 /* sdas specific */
1328 extern  VOID            warnBanner();
1329 /* end sdas specific */
1330 
1331 /* asexpr.c */
1332 extern  VOID            abscheck();
1333 extern  a_uint          absexpr();
1334 extern  VOID            clrexpr();
1335 extern  int             digit();
1336 extern  VOID            exprmasks();
1337 extern  VOID            expr();
1338 extern  int             is_abs();
1339 extern  int             oprio();
1340 extern  a_uint          rngchk();
1341 extern  VOID            term();
1342 
1343 /* asdbg */
1344 extern  char *          BaseFileName();
1345 extern  VOID            DefineNoICE_Line();
1346 extern  VOID            DefineSDCC_Line();
1347 
1348 /* aslist.c */
1349 extern  VOID            list();
1350 extern  VOID            list1();
1351 extern  VOID            list2();
1352 extern  VOID            lstsym();
1353 extern  VOID            slew();
1354 
1355 /* asout.c */
1356 extern  int             lobyte();
1357 extern  int             hibyte();
1358 extern  int             thrdbyte();
1359 extern  int             frthbyte();
1360 extern  VOID            out();
1361 extern  VOID            outarea();
1362 extern  VOID            outdp();
1363 extern  VOID            outall();
1364 extern  VOID            outdot();
1365 extern  VOID            outbuf();
1366 extern  VOID            outchk();
1367 extern  VOID            outradix();
1368 extern  VOID            outgsd();
1369 extern  VOID            outsym();
1370 extern  VOID            outab();
1371 extern  VOID            outaw();
1372 extern  VOID            outa3b();
1373 extern  VOID            outa4b();
1374 extern  VOID            outaxb();
1375 extern  VOID            outatxb();
1376 extern  VOID            outrb();
1377 extern  VOID            outrw();
1378 extern  VOID            outr3b();
1379 extern  VOID            outrxb();
1380 extern  VOID            outrwm();
1381 extern  VOID            outrwp();
1382 extern  VOID            outr3bm();
1383 extern  VOID            out_lb();
1384 extern  VOID            out_lw();
1385 extern  VOID            out_rw();
1386 extern  VOID            out_tw();
1387 
1388 /* Machine dependent variables */
1389 
1390 extern  int             hilo;
1391 extern  char *          cpu;
1392 extern  char *          dsft;
1393 extern  struct  mne     mne[];
1394 
1395 /* Machine dependent functions */
1396 
1397 extern  VOID            machine();
1398 extern  VOID            minit();
1399 
1400 /* sdas specific */
1401 /* strcmpi.c */
1402 extern  int as_strcmpi();
1403 extern  int as_strncmpi();
1404 /* end sdas specific */
1405 #endif
1406