home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 042.lha / assembler / A68kglb.h < prev    next >
C/C++ Source or Header  |  1987-06-25  |  7KB  |  170 lines

  1. /*------------------------------------------------------------------*/
  2. /*                                    */
  3. /*              MC68000 Cross Assembler                */
  4. /*                                    */
  5. /*           Copyright (c) 1985 by Brian R. Anderson            */
  6. /*                                    */
  7. /*           Global variables - May 31, 1987            */
  8. /*                                    */
  9. /*   This program may be copied    for personal, non-commercial use    */
  10. /*   only, provided that the above copyright notice is included        */
  11. /*   on    all copies of the source code.    Copying    for any    other use   */
  12. /*   without the consent of the    author is prohibited.            */
  13. /*                                    */
  14. /*------------------------------------------------------------------*/
  15. /*                                    */
  16. /*        Originally published (in Modula-2) in            */
  17. /*        Dr.    Dobb's Journal, April, May, and June 1986.          */
  18. /*                                    */
  19. /*    AmigaDOS conversion copyright (c) 1987 by Charlie Gibbs.    */
  20. /*                                    */
  21. /*------------------------------------------------------------------*/
  22.  
  23. #ifdef PRIMARY
  24. #define    GLOBAL
  25. #else
  26. #define    GLOBAL extern
  27. #endif
  28.  
  29. GLOBAL char SourceFN[MAXFN];        /* Source file name */
  30. GLOBAL FILE *InFile, *List, *Srec;    /* File    pointers */
  31. GLOBAL char InclList[MAXLINE];        /* List    of directories to search */
  32. GLOBAL char IdntName[MAXLINE];        /* Program unit    name */
  33. GLOBAL int LnCnt;    /* Number of lines on current page */
  34. GLOBAL int LnMax;    /* Maximum number of lines per page */
  35. GLOBAL int PgCnt;    /* Page    number */
  36. GLOBAL int XrefList;    /* Produce a cross-reference listing */
  37. GLOBAL int ListOff;    /* Suppress the    listing    file */
  38. GLOBAL int DumpSym;    /* Dump    the symbol table */
  39.  
  40. GLOBAL char TTLstring[MAXLINE];        /* Title string    */
  41.  
  42. GLOBAL int  LabLine;            /* Last    labeled    line number */
  43. GLOBAL int  LineCount;            /* Source line counter */
  44. GLOBAL char Line[MAXLINE];        /* Current source line */
  45. GLOBAL char Label[MAXLINE];        /* Instruction label */
  46. GLOBAL char OpCode[MAXLINE];        /* Instruction mnemonic    */
  47. GLOBAL char SrcOp[MAXLINE];        /* First (source) operand */
  48. GLOBAL char DestOp[MAXLINE];        /* Second (destination)    operand    */
  49. GLOBAL int  OpLoc, SrcLoc, DestLoc;    /* Operands start here */
  50. GLOBAL int  Dir, PrevDir;        /* Assembler directive */
  51. GLOBAL int  NumSyms;            /* Number of symbols */
  52. GLOBAL long ObjOp, ObjSrc, ObjDest;    /* OpCode, Source, Dest. */
  53. GLOBAL char ObjString[MAXLINE];        /* String data */
  54. GLOBAL int  nO,    nS, nD,    nX;        /* Length of above components */
  55. GLOBAL int  PrntAddr;            /* Print AddrCnt on listing */
  56. GLOBAL int  SuppList;            /* Suppress listing file */
  57. GLOBAL long Hunk2;            /* Hunk    number (from GetValue) */
  58. GLOBAL int  DefLine2;            /* Definition line number */
  59. GLOBAL int  GotEqur;            /* We have register equates */
  60.  
  61. GLOBAL int  Pass2;    /* Pass    2 flag */
  62. GLOBAL long AddrCnt;    /* Location counter */
  63. GLOBAL long AddrAdv;    /* Bump    AddrCnt    by this    much */
  64. GLOBAL long EndAddr;    /* END statement transfer address */
  65. GLOBAL long SectStart;    /* Current section (or portion)    starts here */
  66. GLOBAL int  SectLine;    /* Line    number where section started */
  67. GLOBAL long HunkType;    /* Current hunk    type */
  68. GLOBAL long HunkFlags;    /* Hunk    flags (MEMF_FAST or MEMF_CHIP) */
  69. GLOBAL long CurrHunk;    /* Current hunk    number */
  70. GLOBAL long NextHunk;    /* Next    available hunk number */
  71. GLOBAL long LenPos;    /* Seek    position of current hunk length    */
  72.  
  73. GLOBAL int  SFormat;    /* Generate S-record format */
  74. GLOBAL long StartAddr;    /* Address that    record starts on */
  75. GLOBAL long TempAddr;    /* Address of where we are now */
  76.  
  77. struct SymTab {                /* Symbol table    */
  78.     char *Nam;    /* Pointer to symbol (on heap) */
  79.     long Val;    /* Value */
  80.     long Hunk;    /* Hunk    no. (~(external    symbol heap offset) if < 0) */
  81.     int     Defn;    /* Line    number where defined */
  82.     int     Flags;    /* Flags bits:    0 - XREF
  83.                 1 - XDEF
  84.                 2 - SET
  85.                 3 - MACRO (symbol is preceded by blank)
  86.                 4 - SECTION (name preceded by 2    blanks)
  87.                 5 - register name (EQUR)
  88.                 6 - register list (REG)    */
  89.     struct Ref *Ref1;    /* Pointer to first reference entry */
  90. };
  91. GLOBAL struct SymTab *SymStart;    /* The symbol table starts here    */
  92. GLOBAL struct SymTab *Sym;    /* ReadSymTab sets this    up */
  93. GLOBAL struct SymTab *Sect;    /* Current section's entry */
  94.  
  95. struct Ref {        /* Reference entry */
  96.     struct Ref *NextRef;    /* Pointer to next reference entry */
  97.     int    RefNum[MAXREF];        /* Reference line numbers */
  98. };
  99. GLOBAL struct Ref *RefStart;    /* Reference entries start here    */
  100.  
  101. struct RelTab {        /* Relocation table - goes on the heap */
  102.     long Offset;    /* Offset to relocatable value */
  103.     long Hunk;        /* Hunk    type to    relocate relative to */
  104.     int    Size;        /* Size    of relocatable value */
  105. };
  106. GLOBAL struct RelTab *RelStart;    /* Relocation data starts here */
  107.  
  108. struct TermStack {        /* Parser's term stack */
  109.     long value;        /* Value */
  110.     int     hunk;        /* Hunk    number */
  111.     int     oploc;        /* Location in source statement    */
  112.     int     defline;    /* Line    number where defined */
  113. };
  114. GLOBAL struct TermStack    *Term;    /* Term    stack pointer */
  115.  
  116. struct OpStack {        /* Parser's operator stack */
  117.     char chr;        /* Operator character */
  118.     int     prec;        /* Precedence */
  119. };
  120. GLOBAL struct OpStack *Ops;    /* Operator stack pointer */
  121.  
  122. GLOBAL char *Heap;    /* Primary heap    - allocated by "malloc" */
  123. GLOBAL char *HeapLim;    /* Next    unused space on    the heap */
  124. GLOBAL char *HighHeap;    /* High-water mark on the heap */
  125. GLOBAL char *LowHeap;    /* Low limit from top of heap */
  126.  
  127. GLOBAL int  InFNum;        /* Current input nesting level */
  128. struct InFCtl {
  129.     long Pos;            /* Current position in input */
  130.     char *UPtr;            /* Current position in user macro or 0 */
  131.     char *NPtr;            /* File    name stack pointer */
  132.     int     Line;            /* Current line    number in this file */
  133.     int     NArg;            /* Number of macro arguments or    -1 */
  134.     int     MCnt;            /* Macro expansion number (for \@) */
  135. };
  136. GLOBAL struct InFCtl *InF;    /* Macro/include file stack pointer */
  137. GLOBAL struct InFCtl *LowInF;    /* "Low-water mark" for InF */
  138. GLOBAL char *Heap2;        /* Secondary heap */
  139. GLOBAL char *NextFNS;        /* Next    input file path/name */
  140. GLOBAL char *High2;        /* Secondary high-water    mark */
  141. GLOBAL char *Low2;        /* Low limit from top of heap */
  142.  
  143. GLOBAL int  OuterMac;        /* Level number    of outermost macro */
  144. GLOBAL int  MacCount;        /* Number of macros expanded */
  145. GLOBAL int  SkipNest;        /* Skipped IF/ENDC nesting count */
  146.  
  147. struct OpConfig    {        /* Operand configuration */
  148.     long Value;    /* Value */
  149.     long Hunk;    /* Hunk    number */
  150.     int     Defn;    /* Line    number where defined */
  151.     int     Mode;    /* Addressing mode */
  152.     int     Loc;    /* Location of operand on Line */
  153.     int     Rn;    /* Register number */
  154.     int     Xn;    /* Index register number */
  155.     int     Xsize;    /* Size    of index */
  156.     int     X;    /* Is index Data or Address reg? */
  157. };
  158. GLOBAL struct OpConfig Src, Dest;   /* Source and destination operands */
  159.  
  160. GLOBAL int Size;    /* size    for OpCode */
  161. GLOBAL int InstSize;    /* Size    of instruction,    including operands */
  162. GLOBAL int AdrModeA;    /* Addressing modes for    this instruction */
  163. GLOBAL int AdrModeB;    /*         ditto             */
  164. GLOBAL int Op;        /* Raw bit pattern for OpCode */
  165.  
  166. GLOBAL int ErrorCount;
  167.  
  168. /* Error message tables    */
  169. GLOBAL int errlim, errcode[ERRMAX], errpos[ERRMAX];
  170.