Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1186 | savelij | 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 | #include "stringlists.h" |
||
23 | |||
24 | typedef enum |
||
25 | { |
||
26 | UInt0 |
||
27 | ,UInt1 |
||
28 | ,UInt2 |
||
29 | ,UInt3 |
||
30 | ,SInt4 , UInt4 , Int4 |
||
31 | ,SInt5 , UInt5 , Int5 |
||
32 | ,SInt6 , UInt6 , Int6 |
||
33 | ,SInt7 , UInt7 |
||
34 | ,SInt8 , UInt8 , Int8 |
||
35 | ,SInt9 , UInt9 |
||
36 | ,UInt10 , Int10 |
||
37 | ,UInt11 |
||
38 | ,UInt12 , Int12 |
||
39 | ,UInt13 |
||
40 | ,UInt14 , Int14 |
||
41 | ,SInt15 , UInt15 , Int15 |
||
42 | ,SInt16 , UInt16 , Int16 |
||
43 | ,UInt17 |
||
44 | ,UInt18 |
||
45 | ,UInt19 |
||
46 | ,SInt20 , UInt20 , Int20 |
||
47 | ,UInt21 |
||
48 | ,UInt22 |
||
49 | ,UInt23 |
||
50 | ,SInt24 , UInt24 , Int24 |
||
51 | ,SInt30 , UInt30 , Int30 |
||
52 | ,SInt32 , UInt32 , Int32 |
||
53 | #ifdef HAS64 |
||
54 | ,SInt64 , UInt64 , Int64 |
||
55 | #endif |
||
56 | ,IntTypeCnt |
||
57 | } IntType; |
||
58 | |||
59 | #ifdef __cplusplus |
||
60 | # include "cppops.h" |
||
61 | DefCPPOps_Enum(IntType) |
||
62 | #endif |
||
63 | |||
64 | #ifdef HAS64 |
||
65 | #define LargeUIntType UInt64 |
||
66 | #define LargeSIntType SInt64 |
||
67 | #define LargeIntType Int64 |
||
68 | #else |
||
69 | #define LargeUIntType UInt32 |
||
70 | #define LargeSIntType SInt32 |
||
71 | #define LargeIntType Int32 |
||
72 | #endif |
||
73 | |||
74 | typedef struct |
||
75 | { |
||
76 | Word SignAndWidth; |
||
77 | LargeWord Mask; |
||
78 | LargeInt Min, Max; |
||
79 | } tIntTypeDef; |
||
80 | |||
81 | typedef enum |
||
82 | { |
||
83 | e_symbol_source_none, |
||
84 | e_symbol_source_label, |
||
85 | e_symbol_source_define |
||
86 | } as_symbol_source_t; |
||
87 | |||
88 | typedef enum |
||
89 | { |
||
90 | e_eval_flag_none = 0, |
||
91 | e_eval_flag_undefined_is_unknown = 1 << 0 |
||
92 | } as_eval_flags_t; |
||
93 | #ifdef __cplusplus |
||
94 | DefCPPOps_Mask(as_eval_flags_t) |
||
95 | #endif |
||
96 | |||
97 | typedef enum |
||
98 | { |
||
99 | e_symbol_entry_flag_defined = 1 << 0, |
||
100 | e_symbol_entry_flag_used = 1 << 1, |
||
101 | e_symbol_entry_flag_changed = 1 << 2, |
||
102 | e_symbol_entry_flag_changeable = 1 << 3 |
||
103 | } as_symbol_entry_flags_t; |
||
104 | #ifdef __cplusplus |
||
105 | DefCPPOps_Mask(as_symbol_entry_flags_t) |
||
106 | #endif |
||
107 | |||
108 | typedef struct _TFunction |
||
109 | { |
||
110 | struct _TFunction *Next; |
||
111 | Byte ArguCnt; |
||
112 | StringPtr Name, Definition; |
||
113 | StringList p_arg_list; |
||
114 | } TFunction, *PFunction; |
||
115 | |||
116 | typedef struct sEvalResult |
||
117 | { |
||
118 | Boolean OK; |
||
119 | tSymbolFlags Flags; |
||
120 | unsigned AddrSpaceMask; /* Welche Adressraeume genutzt ? */ |
||
121 | tSymbolSize DataSize; |
||
122 | } tEvalResult; |
||
123 | |||
124 | struct as_eval_cb_data; |
||
125 | typedef enum { e_eval_none, e_eval_fail, e_eval_ok } as_eval_cb_rtn_t; |
||
126 | typedef enum { e_operator, e_function } as_eval_cb_data_stack_elem_t; |
||
127 | #define DECLARE_AS_EVAL_CB(fnc) as_eval_cb_rtn_t fnc(struct as_eval_cb_data *p_data, struct sStrComp *p_arg, TempResult *p_res) |
||
128 | typedef DECLARE_AS_EVAL_CB((*as_eval_cb_t)); |
||
129 | typedef struct as_eval_cb_data_stack |
||
130 | { |
||
131 | struct as_eval_cb_data_stack *p_next; |
||
132 | as_eval_cb_data_stack_elem_t type; |
||
133 | const char *p_ident; |
||
134 | int arg_index; |
||
135 | } as_eval_cb_data_stack_t; |
||
136 | struct as_operator; |
||
137 | typedef struct as_eval_cb_data |
||
138 | { |
||
139 | as_eval_cb_t callback; |
||
140 | const struct as_operator *p_operators; |
||
141 | as_eval_cb_data_stack_t *p_stack; |
||
142 | TempResult *p_other_arg; |
||
143 | } as_eval_cb_data_t; |
||
144 | |||
145 | struct sStrComp; |
||
146 | struct as_nonz_dynstr; |
||
147 | struct sRelocEntry; |
||
148 | struct sSymbolEntry; |
||
149 | struct sStringRec; |
||
150 | |||
151 | extern tIntTypeDef IntTypeDefs[IntTypeCnt]; |
||
152 | extern LongInt MomLocHandle; |
||
153 | extern LongInt TmpSymCounter, |
||
154 | FwdSymCounter, |
||
155 | BackSymCounter; |
||
156 | extern char TmpSymCounterVal[10]; |
||
157 | extern LongInt LocHandleCnt; |
||
158 | extern LongInt MomLocHandle; |
||
159 | |||
160 | |||
161 | extern void AsmParsInit(void); |
||
162 | |||
163 | extern void InitTmpSymbols(void); |
||
164 | |||
165 | extern Boolean SingleBit(LargeInt Inp, LargeInt *Erg); |
||
166 | |||
167 | |||
168 | extern IntType GetSmallestUIntType(LargeWord MaxValue); |
||
169 | |||
170 | extern IntType GetUIntTypeByBits(unsigned Bits); |
||
171 | |||
172 | extern tErrorNum NonZString2Int(const struct as_nonz_dynstr *p_str, LargeInt *p_result); |
||
173 | |||
174 | extern Boolean Int2NonZString(struct as_nonz_dynstr *p_str, LargeInt Src); |
||
175 | |||
176 | extern int TempResultToInt(TempResult *pResult); |
||
177 | |||
178 | extern Boolean MultiCharToInt(TempResult *pResult, unsigned MaxLen); |
||
179 | |||
180 | |||
181 | extern Boolean RangeCheck(LargeInt Wert, IntType Typ); |
||
182 | |||
183 | extern Boolean ChkRangeByType(LargeInt value, IntType type, const struct sStrComp *p_comp); |
||
184 | extern Boolean ChkRangeWarnByType(LargeInt value, IntType type, const struct sStrComp *p_comp); |
||
185 | |||
186 | |||
187 | extern Boolean IdentifySection(const struct sStrComp *pName, LongInt *Erg); |
||
188 | |||
189 | |||
190 | extern struct sStrComp *ExpandStrSymbol(struct sStrComp *p_exp_comp, const struct sStrComp *pSrc, Boolean convert_upper); |
||
191 | |||
192 | extern void ChangeSymbol(struct sSymbolEntry *pEntry, LargeInt Value); |
||
193 | |||
194 | extern struct sSymbolEntry *EnterIntSymbolWithFlags(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange, tSymbolFlags Flags); |
||
195 | |||
196 | #define EnterIntSymbol(pName, Wert, addrspace, MayChange) EnterIntSymbolWithFlags(pName, Wert, addrspace, MayChange, eSymbolFlag_None) |
||
197 | |||
198 | extern void EnterExtSymbol(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange); |
||
199 | |||
200 | extern struct sSymbolEntry *EnterRelSymbol(const struct sStrComp *pName, LargeInt Wert, as_addrspace_t addrspace, Boolean MayChange); |
||
201 | |||
202 | extern void EnterFloatSymbol(const struct sStrComp *pName, as_float_t Wert, Boolean MayChange); |
||
203 | |||
204 | extern void EnterStringSymbol(const struct sStrComp *pName, const char *pValue, Boolean MayChange); |
||
205 | |||
206 | extern void EnterNonZStringSymbolWithFlags(const struct sStrComp *pName, const struct as_nonz_dynstr *p_value, Boolean MayChange, tSymbolFlags Flags); |
||
207 | |||
208 | extern void EnterRegSymbol(const struct sStrComp *pName, const tRegDescr *Value, tSymbolSize Size, Boolean MayChange, Boolean AddList); |
||
209 | |||
210 | #define EnterNonZStringSymbol(pName, pValue, MayChange) EnterNonZStringSymbolWithFlags(pName, pValue, MayChange, eSymbolFlag_None) |
||
211 | |||
212 | extern void LookupSymbol(const struct sStrComp *pName, TempResult *pValue, Boolean WantRelocs, TempType ReqType, |
||
213 | as_eval_flags_t eval_flags, as_symbol_entry_flags_t *p_symbol_entry_flags); |
||
214 | |||
215 | extern void PrintSymbolList(void); |
||
216 | |||
217 | extern void PrintDebSymbols(FILE *f); |
||
218 | |||
219 | extern void PrintNoISymbols(FILE *f); |
||
220 | |||
221 | extern void PrintSymbolTree(void); |
||
222 | |||
223 | extern void ClearSymbolList(void); |
||
224 | |||
225 | extern void ResetSymbolDefines(void); |
||
226 | |||
227 | extern void PrintSymbolDepth(void); |
||
228 | |||
229 | |||
230 | extern void EvalResultClear(tEvalResult *pResult); |
||
231 | |||
232 | extern void as_eval_cb_data_ini(struct as_eval_cb_data *p_data, as_eval_cb_t cb); |
||
233 | extern void as_dump_eval_cb_data_stack(const as_eval_cb_data_stack_t *p_stack); |
||
234 | extern unsigned as_eval_cb_data_stack_depth(const as_eval_cb_data_stack_t *p_stack); |
||
235 | extern Boolean as_eval_cb_data_stack_plain_add(const as_eval_cb_data_stack_t *p_stack); |
||
236 | extern Boolean as_eval_cb_data_stackelem_mul(const as_eval_cb_data_stack_t *p_stack); |
||
237 | |||
238 | extern void SetSymbolOrStructElemSize(const struct sStrComp *pName, tSymbolSize Size); |
||
239 | |||
240 | extern Boolean IsSymbolDefined(const struct sStrComp *pName); |
||
241 | |||
242 | extern Boolean IsSymbolUsed(const struct sStrComp *pName); |
||
243 | |||
244 | extern Integer GetSymbolType(const struct sStrComp *pName); |
||
245 | |||
246 | extern void EvalExpression(const char *pExpr, TempResult *Erg); |
||
247 | |||
248 | extern void EvalStrExpression(const struct sStrComp *pExpr, TempResult *pErg); |
||
249 | extern void EvalStrExpressionWithCallback(const struct sStrComp *pExpr, TempResult *pErg, as_eval_flags_t eval_flags, as_eval_cb_data_t *p_callback_data); |
||
250 | |||
251 | extern void SetIntConstModeByMask(LongWord Mask); |
||
252 | extern void SetIntConstMode(tIntConstMode Mode); |
||
253 | extern void SetIntConstRelaxedMode(Boolean NewRelaxedMode); |
||
254 | |||
255 | extern LargeInt EvalStrIntExpression(const struct sStrComp *pExpr, IntType Type, Boolean *pResult); |
||
256 | extern LargeInt EvalStrIntExpressionWithFlags(const struct sStrComp *pExpr, IntType Type, Boolean *pResult, tSymbolFlags *pFlags); |
||
257 | extern LargeInt EvalStrIntExpressionWithResult(const struct sStrComp *pExpr, IntType Type, struct sEvalResult *pResult); |
||
258 | extern LargeInt EvalStrIntExprWithResultAndCallback(const struct sStrComp *pExpr, IntType Type, struct sEvalResult *pResult, as_eval_cb_data_t *p_callback_data); |
||
259 | extern LargeInt EvalStrIntExpressionOffs(const struct sStrComp *pExpr, int Offset, IntType Type, Boolean *pResult); |
||
260 | extern LargeInt EvalStrIntExpressionOffsWithFlags(const struct sStrComp *pExpr, int Offset, IntType Type, Boolean *pResult, tSymbolFlags *pFlags); |
||
261 | extern LargeInt EvalStrIntExpressionOffsWithResult(const struct sStrComp *pExpr, int Offset, IntType Type, struct sEvalResult *pResult); |
||
262 | extern LargeInt EvalStrIntExprOffsWithResultAndCallback(const struct sStrComp *pExpr, int Offset, IntType Type, struct sEvalResult *pResult, as_eval_cb_data_t *p_callback_data); |
||
263 | |||
264 | extern as_float_t EvalStrFloatExpressionWithResult(const struct sStrComp *pExpr, struct sEvalResult *pResult); |
||
265 | extern as_float_t EvalStrFloatExpression(const struct sStrComp *pExpr, Boolean *pResult); |
||
266 | |||
267 | extern void EvalStrStringExpressionWithResult(const struct sStrComp *pExpr, struct sEvalResult *pResult, char *pEvalResult); |
||
268 | extern void EvalStrStringExpression(const struct sStrComp *pExpr, Boolean *pResult, char *pEvalResult); |
||
269 | |||
270 | extern tErrorNum EvalStrRegExpressionWithResult(const struct sStrComp *pExpr, struct sRegDescr *pResult, struct sEvalResult *pEvalResult); |
||
271 | typedef enum { eIsNoReg, eIsReg, eRegAbort } tRegEvalResult; |
||
272 | extern tRegEvalResult EvalStrRegExpressionAsOperand(const struct sStrComp *pArg, struct sRegDescr *pResult, struct sEvalResult *pEvalResult, tSymbolSize ReqSize, Boolean MustBeReg); |
||
273 | |||
274 | |||
275 | extern Boolean PushSymbol(const struct sStrComp *pSymName, const struct sStrComp *pStackName); |
||
276 | |||
277 | extern Boolean PopSymbol(const struct sStrComp *pSymName, const struct sStrComp *pStackName); |
||
278 | |||
279 | extern void ClearStacks(void); |
||
280 | |||
281 | |||
282 | extern void EnterFunction(const struct sStrComp *pComp, const char *FDefinition, Byte NewCnt, StringList *p_arg_list); |
||
283 | |||
284 | extern PFunction FindFunction(const char *Name); |
||
285 | |||
286 | extern void PrintFunctionList(void); |
||
287 | |||
288 | extern void ClearFunctionList(void); |
||
289 | |||
290 | |||
291 | extern void AddDefSymbol(char *Name, TempResult *Value); |
||
292 | |||
293 | extern void RemoveDefSymbol(char *Name); |
||
294 | |||
295 | extern void CopyDefSymbols(void); |
||
296 | |||
297 | extern const TempResult *FindDefSymbol(const char *pName); |
||
298 | |||
299 | extern void PrintCrossList(void); |
||
300 | |||
301 | extern void ClearCrossList(void); |
||
302 | |||
303 | |||
304 | extern LongInt GetSectionHandle(const char *SName, Boolean AddEmpt, LongInt Parent); |
||
305 | |||
306 | extern const char *GetSectionName(LongInt Handle); |
||
307 | |||
308 | extern void SetMomSection(LongInt Handle); |
||
309 | |||
310 | extern void AddSectionUsage(LongInt Start, LongInt Length); |
||
311 | |||
312 | extern void ClearSectionUsage(void); |
||
313 | |||
314 | extern void PrintSectionList(void); |
||
315 | |||
316 | extern void PrintDebSections(FILE *f); |
||
317 | |||
318 | extern void ClearSectionList(void); |
||
319 | |||
320 | |||
321 | extern void SetFlag(Boolean *Flag, const char *Name, Boolean Wert); |
||
322 | |||
323 | extern LongInt GetLocHandle(void); |
||
324 | |||
325 | extern void PushLocHandle(LongInt NewLoc); |
||
326 | |||
327 | extern void PopLocHandle(void); |
||
328 | |||
329 | extern void ClearLocStack(void); |
||
330 | |||
331 | |||
332 | extern void PrintRegDefs(void); |
||
333 | |||
334 | extern PTransTable FindCodepage(const char *p_name, PTransTable p_source); |
||
335 | |||
336 | extern void ClearCodepages(void); |
||
337 | |||
338 | extern void PrintCodepages(void); |
||
339 | |||
340 | |||
341 | extern void asmpars_init(void); |
||
342 | |||
343 | #endif /* _ASMPARS_H */ |