Subversion Repositories pentevo

Rev

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

  1. #ifndef _ASMPARS_H
  2. #define _ASMPARS_H
  3. /* asmpars.h */
  4. /*****************************************************************************/
  5. /* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only                     */
  6. /*                                                                           */
  7. /* AS-Portierung                                                             */
  8. /*                                                                           */
  9. /* Verwaltung von Symbolen und das ganze Drumherum...                        */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12.  
  13. #include <stddef.h>
  14.  
  15. #include "symbolsize.h"
  16. #include "symflags.h"
  17. #include "tempresult.h"
  18. #include "intformat.h"
  19. #include "lstmacroexp.h"
  20. #include "errmsg.h"
  21. #include "addrspace.h"
  22.  
  23. typedef enum
  24. {
  25.   UInt0    ,
  26.   UInt1    ,
  27.   UInt2    ,
  28.   UInt3    ,
  29.   SInt4    , UInt4   , Int4    ,
  30.   SInt5    , UInt5   , Int5    ,
  31.   SInt6    , UInt6   ,
  32.   SInt7    , UInt7   ,
  33.   SInt8    , UInt8   , Int8    ,
  34.   SInt9    , UInt9    ,
  35.   UInt10   , Int10   ,
  36.   UInt11   ,
  37.   UInt12   , Int12   ,
  38.   UInt13   ,
  39.   UInt14   , Int14   ,
  40.   SInt15   , UInt15  , Int15   ,
  41.   SInt16   , UInt16  , Int16   ,
  42.   UInt17   ,
  43.   UInt18   ,
  44.   UInt19   ,
  45.   SInt20   , UInt20  , Int20   ,
  46.   UInt21   ,
  47.   UInt22   ,
  48.   UInt23   ,
  49.   SInt24   , UInt24  , Int24   ,
  50.   SInt30   , UInt30  , Int30   ,
  51.   SInt32   , UInt32  , Int32   ,
  52. #ifdef HAS64
  53.   SInt64   , UInt64  , Int64   ,
  54. #endif
  55.   IntTypeCnt
  56. } IntType;
  57.  
  58. #ifdef __cplusplus
  59. # include "cppops.h"
  60. DefCPPOps_Enum(IntType)
  61. #endif
  62.  
  63. #ifdef HAS64
  64. #define LargeUIntType UInt64
  65. #define LargeSIntType SInt64
  66. #define LargeIntType Int64
  67. #else
  68. #define LargeUIntType UInt32
  69. #define LargeSIntType SInt32
  70. #define LargeIntType Int32
  71. #endif
  72.  
  73. typedef struct
  74. {
  75.   Word SignAndWidth;
  76.   LargeWord Mask;
  77.   LargeInt Min, Max;
  78. } tIntTypeDef;
  79.  
  80. typedef enum
  81. {
  82.   Float32,
  83.   Float64,
  84.   Float80,
  85.   FloatDec,
  86.   FloatCo,
  87.   Float16,
  88.   FloatTypeCnt
  89. } FloatType;
  90.  
  91. typedef enum
  92. {
  93.   e_symbol_source_none,
  94.   e_symbol_source_label,
  95.   e_symbol_source_define
  96. } as_symbol_source_t;
  97.  
  98. typedef struct _TFunction
  99. {
  100.   struct _TFunction *Next;
  101.   Byte ArguCnt;
  102.   StringPtr Name, Definition;
  103. } TFunction, *PFunction;
  104.  
  105. typedef struct sEvalResult
  106. {
  107.   Boolean OK;
  108.   tSymbolFlags Flags;
  109.   unsigned AddrSpaceMask; /* Welche Adressraeume genutzt ? */
  110.   tSymbolSize DataSize;
  111. } tEvalResult;
  112.  
  113. struct sStrComp;
  114. struct as_nonz_dynstr;
  115. struct sRelocEntry;
  116. struct sSymbolEntry;
  117.  
  118. extern tIntTypeDef IntTypeDefs[IntTypeCnt];
  119. extern LongInt MomLocHandle;
  120. extern LongInt TmpSymCounter,
  121.                FwdSymCounter,
  122.                BackSymCounter;
  123. extern char TmpSymCounterVal[10];
  124. extern LongInt LocHandleCnt;
  125. extern LongInt MomLocHandle;
  126.  
  127.  
  128. extern void AsmParsInit(void);
  129.  
  130. extern void InitTmpSymbols(void);
  131.  
  132. extern Boolean SingleBit(LargeInt Inp, LargeInt *Erg);
  133.  
  134.  
  135. extern IntType GetSmallestUIntType(LargeWord MaxValue);
  136.  
  137. extern IntType GetUIntTypeByBits(unsigned Bits);
  138.  
  139. extern tErrorNum NonZString2Int(const struct as_nonz_dynstr *p_str, LargeInt *p_result);
  140.  
  141. extern Boolean Int2NonZString(struct as_nonz_dynstr *p_str, LargeInt Src);
  142.  
  143. extern int TempResultToInt(TempResult *pResult);
  144.  
  145. extern Boolean MultiCharToInt(TempResult *pResult, unsigned MaxLen);
  146.  
  147.  
  148. extern Boolean RangeCheck(LargeInt Wert, IntType Typ);
  149.  
  150. extern Boolean ChkRangeByType(LargeInt value, IntType type, const struct sStrComp *p_comp);
  151. extern Boolean ChkRangeWarnByType(LargeInt value, IntType type, const struct sStrComp *p_comp);
  152.  
  153. extern Boolean FloatRangeCheck(Double Wert, FloatType Typ);
  154.  
  155.  
  156. extern Boolean IdentifySection(const struct sStrComp *pName, LongInt *Erg);
  157.  
  158.  
  159. extern struct sStrComp *ExpandStrSymbol(struct sStrComp *p_exp_comp, const struct sStrComp *pSrc, Boolean convert_upper);
  160.  
  161. extern void ChangeSymbol(struct sSymbolEntry *pEntry, LargeInt Value);
  162.  
  163. extern struct sSymbolEntry *EnterIntSymbolWithFlags(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange, tSymbolFlags Flags);
  164.  
  165. #define EnterIntSymbol(pName, Wert, addrspace, MayChange) EnterIntSymbolWithFlags(pName, Wert, addrspace, MayChange, eSymbolFlag_None)
  166.  
  167. extern void EnterExtSymbol(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange);
  168.  
  169. extern struct sSymbolEntry *EnterRelSymbol(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange);
  170.  
  171. extern void EnterFloatSymbol(const struct sStrComp *pName, Double Wert, Boolean MayChange);
  172.  
  173. extern void EnterStringSymbol(const struct sStrComp *pName, const char *pValue, Boolean MayChange);
  174.  
  175. extern void EnterNonZStringSymbolWithFlags(const struct sStrComp *pName, const struct as_nonz_dynstr *p_value, Boolean MayChange, tSymbolFlags Flags);
  176.  
  177. extern void EnterRegSymbol(const struct sStrComp *pName, const tRegDescr *Value, tSymbolSize Size, Boolean MayChange, Boolean AddList);
  178.  
  179. #define EnterNonZStringSymbol(pName, pValue, MayChange) EnterNonZStringSymbolWithFlags(pName, pValue, MayChange, eSymbolFlag_None)
  180.  
  181. extern void LookupSymbol(const struct sStrComp *pName, TempResult *pValue, Boolean WantRelocs, TempType ReqType);
  182.  
  183. extern void PrintSymbolList(void);
  184.  
  185. extern void PrintDebSymbols(FILE *f);
  186.  
  187. extern void PrintNoISymbols(FILE *f);
  188.  
  189. extern void PrintSymbolTree(void);
  190.  
  191. extern void ClearSymbolList(void);
  192.  
  193. extern void ResetSymbolDefines(void);
  194.  
  195. extern void PrintSymbolDepth(void);
  196.  
  197.  
  198. extern void EvalResultClear(tEvalResult *pResult);
  199.  
  200.  
  201. extern void SetSymbolOrStructElemSize(const struct sStrComp *pName, tSymbolSize Size);
  202.  
  203. extern ShortInt GetSymbolSize(const struct sStrComp *pName);
  204.  
  205. extern Boolean IsSymbolDefined(const struct sStrComp *pName);
  206.  
  207. extern Boolean IsSymbolUsed(const struct sStrComp *pName);
  208.  
  209. extern Boolean IsSymbolChangeable(const struct sStrComp *pName);
  210.  
  211. extern Integer GetSymbolType(const struct sStrComp *pName);
  212.  
  213. extern void EvalExpression(const char *pExpr, TempResult *Erg);
  214.  
  215. extern void EvalStrExpression(const struct sStrComp *pExpr, TempResult *pErg);
  216.  
  217. extern void SetIntConstModeByMask(LongWord Mask);
  218. extern void SetIntConstMode(tIntConstMode Mode);
  219. extern void SetIntConstRelaxedMode(Boolean NewRelaxedMode);
  220.  
  221. extern LargeInt EvalStrIntExpression(const struct sStrComp *pExpr, IntType Type, Boolean *pResult);
  222. extern LargeInt EvalStrIntExpressionWithFlags(const struct sStrComp *pExpr, IntType Type, Boolean *pResult, tSymbolFlags *pFlags);
  223. extern LargeInt EvalStrIntExpressionWithResult(const struct sStrComp *pExpr, IntType Type, struct sEvalResult *pResult);
  224. extern LargeInt EvalStrIntExpressionOffs(const struct sStrComp *pExpr, int Offset, IntType Type, Boolean *pResult);
  225. extern LargeInt EvalStrIntExpressionOffsWithFlags(const struct sStrComp *pExpr, int Offset, IntType Type, Boolean *pResult, tSymbolFlags *pFlags);
  226. extern LargeInt EvalStrIntExpressionOffsWithResult(const struct sStrComp *pExpr, int Offset, IntType Type, struct sEvalResult *pResult);
  227.  
  228. extern Double EvalStrFloatExpressionWithResult(const struct sStrComp *pExpr, FloatType Typ, struct sEvalResult *pResult);
  229. extern Double EvalStrFloatExpression(const struct sStrComp *pExpr, FloatType Typ, Boolean *pResult);
  230.  
  231. extern void EvalStrStringExpressionWithResult(const struct sStrComp *pExpr, struct sEvalResult *pResult, char *pEvalResult);
  232. extern void EvalStrStringExpression(const struct sStrComp *pExpr, Boolean *pResult, char *pEvalResult);
  233.  
  234. extern tErrorNum EvalStrRegExpressionWithResult(const struct sStrComp *pExpr, struct sRegDescr *pResult, struct sEvalResult *pEvalResult);
  235. typedef enum { eIsNoReg, eIsReg, eRegAbort } tRegEvalResult;
  236. extern tRegEvalResult EvalStrRegExpressionAsOperand(const struct sStrComp *pArg, struct sRegDescr *pResult, struct sEvalResult *pEvalResult, tSymbolSize ReqSize, Boolean MustBeReg);
  237.  
  238.  
  239. extern Boolean PushSymbol(const struct sStrComp *pSymName, const struct sStrComp *pStackName);
  240.  
  241. extern Boolean PopSymbol(const struct sStrComp *pSymName, const struct sStrComp *pStackName);
  242.  
  243. extern void ClearStacks(void);
  244.  
  245.  
  246. extern void EnterFunction(const struct sStrComp *pComp, char *FDefinition, Byte NewCnt);
  247.  
  248. extern PFunction FindFunction(const char *Name);
  249.  
  250. extern void PrintFunctionList(void);
  251.  
  252. extern void ClearFunctionList(void);
  253.  
  254.  
  255. extern void AddDefSymbol(char *Name, TempResult *Value);
  256.  
  257. extern void RemoveDefSymbol(char *Name);
  258.  
  259. extern void CopyDefSymbols(void);
  260.  
  261. extern const TempResult *FindDefSymbol(const char *pName);
  262.  
  263. extern void PrintCrossList(void);
  264.  
  265. extern void ClearCrossList(void);
  266.  
  267.  
  268. extern LongInt GetSectionHandle(const char *SName, Boolean AddEmpt, LongInt Parent);
  269.  
  270. extern const char *GetSectionName(LongInt Handle);
  271.  
  272. extern void SetMomSection(LongInt Handle);
  273.  
  274. extern void AddSectionUsage(LongInt Start, LongInt Length);
  275.  
  276. extern void ClearSectionUsage(void);
  277.  
  278. extern void PrintSectionList(void);
  279.  
  280. extern void PrintDebSections(FILE *f);
  281.  
  282. extern void ClearSectionList(void);
  283.  
  284.  
  285. extern void SetFlag(Boolean *Flag, const char *Name, Boolean Wert);
  286.  
  287. extern LongInt GetLocHandle(void);
  288.  
  289. extern void PushLocHandle(LongInt NewLoc);
  290.  
  291. extern void PopLocHandle(void);
  292.  
  293. extern void ClearLocStack(void);
  294.  
  295.  
  296. extern void PrintRegDefs(void);
  297.  
  298. extern PTransTable FindCodepage(const char *p_name, PTransTable p_source);
  299.  
  300. extern void ClearCodepages(void);
  301.  
  302. extern void PrintCodepages(void);
  303.  
  304.  
  305. extern void asmpars_init(void);
  306.  
  307. #endif /* _ASMPARS_H */
  308.