Subversion Repositories pentevo

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. #ifndef _ASMDEF_H
  2. #define _ASMDEF_H
  3. /* asmdef.h */
  4. /*****************************************************************************/
  5. /* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
  6. /*                                                                           */
  7. /* AS-Portierung                                                             */
  8. /*                                                                           */
  9. /* global benutzte Variablen und Definitionen                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. #include <stddef.h>
  14. #include <stdio.h>
  15.  
  16. #include "chunks.h"
  17. #include "fileformat.h"
  18. #include "dynstr.h"
  19. #include "intformat.h"
  20. #include "strcomp.h"
  21. #include "striter.h"
  22. #include "lstmacroexp.h"
  23. #include "cpulist.h"
  24. #include "tempresult.h"
  25. #include "addrspace.h"
  26. #include "chartrans.h"
  27.  
  28. typedef struct _TCrossRef
  29. {
  30.   struct _TCrossRef *Next;
  31.   Byte FileNum;
  32.   LongInt LineNum;
  33.   Integer OccNum;
  34. } TCrossRef,*PCrossRef;
  35.  
  36.  
  37. typedef struct _TPatchEntry
  38. {
  39.   struct _TPatchEntry *Next;
  40.   LargeWord Address;
  41.   char *Ref;
  42.   Word len;
  43.   LongWord RelocType;
  44. } TPatchEntry, *PPatchEntry;
  45.  
  46. typedef struct _TExportEntry
  47. {
  48.   struct _TExportEntry *Next;
  49.   char *Name;
  50.   Word len;
  51.   LongWord Flags;
  52.   LargeWord Value;
  53. } TExportEntry, *PExportEntry;
  54.  
  55. typedef enum
  56. {
  57.   DebugNone,
  58.   DebugMAP,
  59.   DebugAOUT,
  60.   DebugCOFF,
  61.   DebugELF,
  62.   DebugAtmel,
  63.   DebugNoICE
  64. } DebugType;
  65.  
  66. #define Char_NUL 0
  67. #define Char_BEL '\a'
  68. #define Char_BS '\b'
  69. #define Char_HT 9
  70. #define Char_LF '\n'
  71. #define Char_FF 12
  72. #define Char_CR 13
  73. #define Char_ESC 27
  74.  
  75. #define ListMask_FormFeed         (1 << 0)
  76. #define ListMask_SymbolList       (1 << 1)
  77. #define ListMask_MacroList        (1 << 2)
  78. #define ListMask_FunctionList     (1 << 3)
  79. #define ListMask_LineNums         (1 << 4)
  80. #define ListMask_DefineList       (1 << 5)
  81. #define ListMask_RegDefList       (1 << 6)
  82. #define ListMask_Codepages        (1 << 7)
  83. #define ListMask_StructList       (1 << 8)
  84.  
  85. extern char SrcSuffix[],IncSuffix[],PrgSuffix[],LstSuffix[],
  86.             MacSuffix[],PreSuffix[],LogSuffix[],MapSuffix[],
  87.             OBJSuffix[];
  88.  
  89. #define MomCPUName       "MOMCPU"     /* mom. Prozessortyp */
  90. #define MomCPUIdentName  "MOMCPUNAME" /* mom. Prozessortyp */
  91. #define MomFPUIdentName  "MOMFPUNAME" /* mom. Koprozessortyp */
  92. #define MomPMMUIdentName  "MOMPMMUNAME" /* mom. MMU-Typ */
  93. #define DoPaddingName    "PADDING"    /* Padding an */
  94. #define PackingName      "PACKING"    /* gepackte Ablage an */
  95. #define ListOnName       "LISTON"     /* Listing an/aus */
  96. #define RelaxedName      "RELAXED"    /* alle Zahlenschreibweisen zugelassen */
  97. #define BranchExtName    "BRANCHEXT"  /* Spruenge autom. verlaengern */
  98. #define FlagTrueName     "TRUE"       /* Flagkonstanten */
  99. #define FlagFalseName    "FALSE"
  100. #define PiName           "CONSTPI"    /* Zahl Pi */
  101. #define FloatMaxName     "FLOATMAX"   /* largest floating point number */
  102. #define DateName         "DATE"       /* Datum & Zeit */
  103. #define TimeName         "TIME"
  104. #define VerName          "VERSION"    /* speichert Versionsnummer */
  105. #define CaseSensName     "CASESENSITIVE" /* zeigt Gross/Kleinunterscheidung an */
  106. #define Has64Name        "HAS64"         /* arbeitet Parser mit 64-Bit-Integers ? */
  107. #define ArchName         "ARCHITECTURE"  /* Zielarchitektur von AS */
  108. #define AttrName         "ATTRIBUTE"  /* Attributansprache in Makros */
  109. #define LabelName        "__LABEL__"  /* Labelansprache in Makros */
  110. #define ArgCName         "ARGCOUNT"   /* Argumentzahlansprache in Makros */
  111. #define AllArgName       "ALLARGS"    /* Ansprache Argumentliste in Makros */
  112. #define DefStackName     "DEFSTACK"   /* Default-Stack */
  113. #define NestMaxName      "NESTMAX"    /* max. nesting level of a macro */
  114. #define DottedStructsName "DOTTEDSTRUCTS" /* struct elements by default with . */
  115.  
  116. extern const char *EnvName;
  117.  
  118. /* This results from the tokenized representation of macro arguments
  119.    in macro bodys: (31*16) - 4 for special arguments: */
  120.  
  121. #define ArgCntMax 476
  122.  
  123. #define ChapMax 4
  124.  
  125. #define AscOfs '0'
  126.  
  127. #define MaxCodeLen_Ini 256
  128. #define MaxCodeLen_Max 65535
  129. extern LongWord MaxCodeLen;
  130.  
  131. #define DEF_NESTMAX 256
  132.  
  133. #define LOCSYMSIGHT 3       /* max. sight for nameless temporary symbols */
  134.  
  135. typedef void (*SimpProc)(
  136. #ifdef __PROTOS__
  137. void
  138. #endif
  139. );
  140.  
  141. typedef void (*DissectBitProc)(
  142. #ifdef __PROTOS__
  143. char *pDest, size_t DestSize, LargeWord Inp
  144. #endif
  145. );
  146.  
  147. typedef Word WordField[6];          /* fuer Zahlenumwandlung */
  148. typedef struct _TTransTable
  149. {
  150.   struct _TTransTable *Next;
  151.   char *Name;
  152.   as_chartrans_table_t *p_table;
  153. } TTransTable, *PTransTable;
  154.  
  155. typedef struct _TSaveState
  156. {
  157.   struct _TSaveState *Next;
  158.   CPUVar SaveCPU;
  159.   char *pSaveCPUArgs;
  160.   as_addrspace_t SavePC;
  161.   Byte SaveListOn;
  162.   tLstMacroExp SaveLstMacroExp;
  163.   tLstMacroExpMod SaveLstMacroExpModDefault,
  164.                   SaveLstMacroExpModOverride;
  165.   PTransTable SaveTransTable;
  166.   Integer SaveEnumSegment;
  167.   LongInt SaveEnumCurrentValue, SaveEnumIncrement;
  168. } TSaveState,*PSaveState;
  169.  
  170. typedef struct _TForwardSymbol
  171. {
  172.   struct _TForwardSymbol *Next;
  173.   StringPtr Name;
  174.   LongInt DestSection;
  175.   StringPtr pErrorPos;
  176. } TForwardSymbol, *PForwardSymbol;
  177.  
  178. typedef struct _TSaveSection
  179. {
  180.   struct _TSaveSection *Next;
  181.   PForwardSymbol LocSyms, GlobSyms, ExportSyms;
  182.   LongInt Handle;
  183. } TSaveSection, *PSaveSection;
  184.  
  185. typedef struct sSavePhase
  186. {
  187.   struct sSavePhase *pNext;
  188.   LargeWord SaveValue;
  189. } tSavePhase;
  190.  
  191. typedef struct _TDefinement
  192. {
  193.   struct _TDefinement *Next;
  194.   StringPtr TransFrom, TransTo;
  195.   Byte Compiled[256];
  196. } TDefinement, *PDefinement;
  197.  
  198. typedef struct _ASSUMERec
  199. {
  200.   const char *Name;
  201.   LongInt *Dest;
  202.   LongInt Min,Max;
  203.   LongInt NothingVal;
  204.   void (*pPostProc)(void);
  205. } ASSUMERec;
  206.  
  207. extern StringPtr SourceFile;
  208.  
  209. extern StringPtr CursUp;
  210.  
  211. extern LargeWord *PCs;
  212. extern Boolean RelSegs;
  213. extern LargeWord StartAdr;
  214. extern LargeWord AfterBSRAddr;
  215. extern Boolean StartAdrPresent;
  216. extern LargeWord *Phases;
  217. extern Word Grans[SegCountPlusStruct];
  218. extern Word ListGrans[SegCountPlusStruct];
  219. extern ChunkList SegChunks[SegCountPlusStruct];
  220. extern as_addrspace_t ActPC;
  221. extern Boolean PCsUsed[SegCountPlusStruct];
  222. extern LargeWord *SegInits;
  223. extern LargeWord *SegLimits;
  224. extern LongInt ValidSegs;
  225. extern Boolean ENDOccured;
  226. extern Boolean Retracted;
  227. extern Boolean ListToStdout,ListToNull;
  228.  
  229. extern unsigned ASSUMERecCnt;
  230. extern const ASSUMERec *pASSUMERecs;
  231. extern void (*pASSUMEOverride)(void);
  232.  
  233. extern Integer PassNo;
  234. extern Integer JmpErrors;
  235. extern Boolean ThrowErrors;
  236. extern Boolean Repass;
  237. extern Byte MaxSymPass;
  238. extern Byte ShareMode;
  239. extern DebugType DebugMode;
  240. extern Word NoICEMask;
  241. extern Byte ListMode;
  242. extern Byte ListOn;
  243. extern Integer MaxIncludeLevel;
  244. extern Boolean MakeUseList;
  245. extern Boolean MakeCrossList;
  246. extern Boolean MakeSectionList;
  247. extern Boolean MakeIncludeList;
  248. extern Boolean DefRelaxedMode;
  249. extern as_dynstr_t def_int_syntax;
  250. extern Word ListMask;
  251. extern Boolean list_macro_handles;
  252. extern ShortInt ExtendErrors;
  253. extern Integer EnumSegment;
  254. extern LongInt EnumIncrement, EnumCurrentValue;
  255. extern LongWord MaxErrors;
  256.  
  257. extern LongInt MomSectionHandle;
  258. extern PSaveSection SectionStack;
  259. extern tSavePhase *pPhaseStacks[SegCount];
  260.  
  261. extern tSymbolSize AttrPartOpSize[2];
  262. extern LongInt CodeLen;
  263. extern Byte *BAsmCode;
  264. extern Word *WAsmCode;
  265. extern LongWord *DAsmCode;
  266.  
  267. extern Boolean DontPrint;
  268. extern Word ActListGran;
  269.  
  270. extern Boolean NumericErrors;
  271. extern Boolean CodeOutput;
  272. extern Boolean MacProOutput;
  273. extern Boolean MacroOutput;
  274. extern Boolean HardRanges;
  275. extern const char *DivideChars;
  276. extern Boolean HasAttrs;
  277. extern const char *AttrChars;
  278. extern Boolean MsgIfRepass;
  279. extern Integer PassNoForMessage;
  280. extern Boolean CaseSensitive;
  281. extern LongInt NestMax;
  282. extern Boolean GNUErrors;
  283.  
  284. extern FILE *PrgFile;
  285.  
  286. extern StringPtr ErrorPath,ErrorName;
  287. extern StringPtr OutName;
  288. extern Integer CurrIncludeLevel;
  289. extern StringPtr CurrFileName;
  290. extern LongInt CurrLine;
  291. extern LongInt LineSum;
  292. extern LongInt MacLineSum;
  293.  
  294. extern LongInt NOPCode;
  295. extern Boolean TurnWords;
  296. extern Byte HeaderID;
  297. extern const char *PCSymbol;
  298. extern tIntConstMode IntConstMode;
  299. extern Boolean IntConstModeIBMNoTerm;
  300. extern Boolean (*SetIsOccupiedFnc)(void),
  301.                (*SaveIsOccupiedFnc)(void),
  302.                (*RestoreIsOccupiedFnc)(void);
  303. extern Boolean SwitchIsOccupied, PageIsOccupied, ShiftIsOccupied;
  304. extern Boolean multi_char_le;
  305. extern Boolean (*DecodeAttrPart)(void);
  306. extern void (*MakeCode)(void);
  307. extern Boolean (*ChkPC)(LargeWord Addr);
  308. extern Boolean (*IsDef)(void);
  309. extern void (*SwitchFrom)(void);
  310. extern void (*InternSymbol)(char *Asc, TempResult *Erg);
  311. extern DissectBitProc DissectBit;
  312. extern DissectRegProc DissectReg;
  313. extern as_qualify_quote_fnc_t QualifyQuote;
  314.  
  315. extern StringPtr IncludeList;
  316. extern Integer IncDepth, NextIncDepth, MaxIncDepth;
  317. extern FILE *ErrorFile;
  318. extern FILE *LstFile;
  319. extern FILE *ShareFile;
  320. extern FILE *MacProFile;
  321. extern FILE *MacroFile;
  322. extern Boolean InMacroFlag;
  323. extern StringPtr LstName, MacroName, MacProName;
  324. extern tLstMacroExp DoLst, NextDoLst;
  325. extern StringPtr ShareName;
  326. extern CPUVar MomCPU, MomVirtCPU;
  327. extern StringPtr MomCPUArgs;
  328. extern char DefCPU[20];
  329. extern char MomCPUIdent[20],
  330.             MomFPUIdent[20],
  331.             MomPMMUIdent[20];
  332.  
  333. extern int OutRadixBase, ListRadixBase;
  334. extern Boolean ListPCZeroPad;
  335. extern const char *pCommentLeadIn;
  336.  
  337. extern tStrComp *ArgStr;
  338. extern tStrComp LabPart, CommPart, ArgPart, OpPart, AttrPart;
  339. extern char AttrSplit;
  340. extern Boolean oppart_leading_dot;
  341. extern int ArgCnt;
  342. extern as_dynstr_t OneLine;
  343. #ifdef PROFILE_MEMO
  344. extern unsigned NumMemo;
  345. extern unsigned long NumMemoSum, NumMemoCnt;
  346. #endif
  347.  
  348. #define forallargs(pArg, cond) \
  349.         for (pArg = ArgStr + 1; (cond) && (pArg <= ArgStr + ArgCnt); pArg++)
  350.  
  351. extern Byte LstCounter;
  352. extern Word PageCounter[ChapMax+1];
  353. extern Byte ChapDepth;
  354. extern StringPtr ListLine;
  355. extern Byte PageLength, PageWidth;
  356. extern tLstMacroExpMod LstMacroExpModOverride, LstMacroExpModDefault;
  357. extern Boolean DottedStructs;
  358. extern StringPtr PrtInitString;
  359. extern StringPtr PrtExitString;
  360. extern StringPtr PrtTitleString;
  361.  
  362. extern Byte StopfZahl;
  363.  
  364. extern Boolean SuppWarns;
  365.  
  366. extern PTransTable TransTables, CurrTransTable;
  367.  
  368. extern PDefinement FirstDefine;
  369.  
  370. extern PSaveState FirstSaveState;
  371.  
  372. extern Boolean MakeDebug;
  373. extern FILE *Debug;
  374.  
  375. extern Boolean WasIF, WasMACRO;
  376.  
  377. extern void AsmDefInit(void);
  378.  
  379. extern void NullProc(void);
  380.  
  381. extern int SetMaxCodeLen(LongWord NewMaxCodeLen);
  382.  
  383. extern void Default_InternSymbol(char *Asc, TempResult *Erg);
  384.  
  385. extern void Default_DissectBit(char *pDest, size_t DestSize, LargeWord BitSpec);
  386.  
  387. extern void AppendArg(size_t ReqSize);
  388. extern void InsertArg(int Index, size_t ReqSize);
  389.  
  390. extern Boolean memo_set_pseudo(void);
  391. extern Boolean is_set_pseudo(void);
  392. extern Boolean is_save_pseudo(void);
  393. extern Boolean is_restore_pseudo(void);
  394. extern Boolean memo_switch_pseudo(void);
  395. extern Boolean memo_shift_pseudo(void);
  396. extern Boolean is_page_pseudo(void);
  397.  
  398. extern void free_forward_symbol(PForwardSymbol p_symbol);
  399.  
  400. extern void asmdef_init(void);
  401. #endif /* _ASMDEF_H */
  402.