/*------------------------------------------------------------------*/ /* */ /* MC68000 Cross Assembler */ /* */ /* Copyright (c) 1985 by Brian R. Anderson */ /* */ /* Global variables - September 3, 1987 */ /* */ /* This program may be copied for personal, non-commercial use */ /* only, provided that the above copyright notice is included */ /* on all copies of the source code. Copying for any other use */ /* without the consent of the author is prohibited. */ /* */ /*------------------------------------------------------------------*/ /* */ /* Originally published (in Modula-2) in */ /* Dr. Dobb's Journal, April, May, and June 1986. */ /* */ /* AmigaDOS conversion copyright (c) 1987 by Charlie Gibbs. */ /* */ /*------------------------------------------------------------------*/ #ifdef PRIMARY #define GLOBAL #else #define GLOBAL extern #endif GLOBAL char SourceFN[MAXFN]; /* Source file name */ GLOBAL char HeaderFN[MAXFN]; /* Header file name */ GLOBAL FILE *InFile, *List, *Srec; /* File pointers */ GLOBAL char InclList[MAXLINE]; /* List of directories to search */ GLOBAL char IdntName[MAXLINE]; /* Program unit name */ GLOBAL int LnCnt; /* Number of lines on current page */ GLOBAL int LnMax; /* Maximum number of lines per page */ GLOBAL int PgCnt; /* Page number */ GLOBAL int XrefList; /* Produce a cross-reference listing */ GLOBAL int ListOff; /* Suppress the listing file */ GLOBAL int DumpSym; /* Dump the symbol table */ GLOBAL char TTLstring[MAXLINE]; /* Title string */ GLOBAL int LabLine; /* Last labeled line number */ GLOBAL int LineCount; /* Source line counter */ GLOBAL char Line[MAXLINE]; /* Current source line */ GLOBAL char Label[MAXLINE]; /* Instruction label */ GLOBAL char OpCode[MAXLINE]; /* Instruction mnemonic */ GLOBAL char SrcOp[MAXLINE]; /* First (source) operand */ GLOBAL char DestOp[MAXLINE]; /* Second (destination) operand */ GLOBAL int OpLoc, SrcLoc, DestLoc; /* Operands start here */ GLOBAL int Dir, PrevDir; /* Assembler directive */ GLOBAL int NumSyms; /* Number of symbols */ GLOBAL long ObjOp, ObjSrc, ObjDest; /* OpCode, Source, Dest. */ GLOBAL char ObjString[MAXLINE]; /* String data */ GLOBAL int nO, nS, nD, nX; /* Length of above components */ GLOBAL int PrntAddr; /* Print AddrCnt on listing */ GLOBAL int SuppList; /* Suppress listing file */ GLOBAL long Hunk2; /* Hunk number (from GetValue) */ GLOBAL int DefLine2; /* Definition line number */ GLOBAL int GotEqur; /* We have register equates */ GLOBAL int Pass2; /* Pass 2 flag */ GLOBAL long AddrCnt; /* Location counter */ GLOBAL long AddrAdv; /* Bump AddrCnt by this much */ GLOBAL long EndAddr; /* END statement transfer address */ GLOBAL long SectStart; /* Current section (or portion) starts here */ GLOBAL int SectLine; /* Line number where section started */ GLOBAL long HunkType; /* Current hunk type */ GLOBAL long HunkFlags; /* Hunk flags (MEMF_FAST or MEMF_CHIP) */ GLOBAL long CurrHunk; /* Current hunk number */ GLOBAL long NextHunk; /* Next available hunk number */ GLOBAL long LenPos; /* Seek position of current hunk length */ GLOBAL int SFormat; /* Generate S-record format */ GLOBAL long StartAddr; /* Address that record starts on */ GLOBAL long TempAddr; /* Address of where we are now */ struct SymTab { /* Symbol table */ char *Nam; /* Pointer to symbol (on heap) */ long Val; /* Value */ long Hunk; /* Hunk no. (~(external symbol heap offset) if < 0) */ int Defn; /* Line number where defined */ int Flags; /* Flags bits: 0 - XREF 1 - XDEF 2 - SET 3 - MACRO (symbol is preceded by blank) 4 - SECTION (name preceded by 2 blanks) 5 - register name (EQUR) 6 - register list (REG) */ struct Ref *Ref1; /* Pointer to first reference entry */ }; GLOBAL struct SymTab *SymStart; /* The symbol table starts here */ GLOBAL struct SymTab *Sym; /* ReadSymTab sets this up */ GLOBAL struct SymTab *Sect; /* Current section's entry */ struct Ref { /* Reference entry */ struct Ref *NextRef; /* Pointer to next reference entry */ int RefNum[MAXREF]; /* Reference line numbers */ }; GLOBAL struct Ref *RefStart; /* Reference entries start here */ struct RelTab { /* Relocation table - goes on the heap */ long Offset; /* Offset to relocatable value */ long Hunk; /* Hunk type to relocate relative to */ int Size; /* Size of relocatable value */ }; GLOBAL struct RelTab *RelStart; /* Relocation data starts here */ struct TermStack { /* Parser's term stack */ long value; /* Value */ int hunk; /* Hunk number */ int oploc; /* Location in source statement */ int defline; /* Line number where defined */ }; GLOBAL struct TermStack *Term; /* Term stack pointer */ struct OpStack { /* Parser's operator stack */ char chr; /* Operator character */ int prec; /* Precedence */ }; GLOBAL struct OpStack *Ops; /* Operator stack pointer */ GLOBAL char *Heap; /* Primary heap - allocated by "malloc" */ GLOBAL char *HeapLim; /* Next unused space on the heap */ GLOBAL char *HighHeap; /* High-water mark on the heap */ GLOBAL char *LowHeap; /* Low limit from top of heap */ GLOBAL int InFNum; /* Current input nesting level */ struct InFCtl { long Pos; /* Current position in input */ char *UPtr; /* Current position in user macro or 0 */ char *NPtr; /* File name stack pointer */ int Line; /* Current line number in this file */ int NArg; /* Number of macro arguments or -1 */ int MCnt; /* Macro expansion number (for \@) */ }; GLOBAL struct InFCtl *InF; /* Macro/include file stack pointer */ GLOBAL struct InFCtl *LowInF; /* "Low-water mark" for InF */ GLOBAL char *Heap2; /* Secondary heap */ GLOBAL char *NextFNS; /* Next input file path/name */ GLOBAL char *High2; /* Secondary high-water mark */ GLOBAL char *Low2; /* Low limit from top of heap */ GLOBAL int OuterMac; /* Level number of outermost macro */ GLOBAL int MacCount; /* Number of macros expanded */ GLOBAL int SkipNest; /* Skipped IF/ENDC nesting count */ struct OpConfig { /* Operand configuration */ long Value; /* Value */ long Hunk; /* Hunk number */ int Defn; /* Line number where defined */ int Mode; /* Addressing mode */ int Loc; /* Location of operand on Line */ int Rn; /* Register number */ int Xn; /* Index register number */ int Xsize; /* Size of index */ int X; /* Is index Data or Address reg? */ }; GLOBAL struct OpConfig Src, Dest; /* Source and destination operands */ GLOBAL int Size; /* size for OpCode */ GLOBAL int InstSize; /* Size of instruction, including operands */ GLOBAL int AdrModeA; /* Addressing modes for this instruction */ GLOBAL int AdrModeB; /* ditto */ GLOBAL int Op; /* Raw bit pattern for OpCode */ GLOBAL int ErrorCount; /* Error message tables */ GLOBAL int errlim, errcode[ERRMAX], errpos[ERRMAX];