UrForth: added UrAsm label list iteration words
[urasm.git] / src / urforth.h
blobc953241fd3d1c1da984edd81a54ae50badb3f077
1 // and now for something completely different...
2 // UrAsm built-in Forth Engine!
3 // GPLv3 ONLY
4 #ifndef URFORTH_HEADER
5 #define URFORTH_HEADER
7 #include <stddef.h>
8 #include <stdint.h>
11 enum {
12 UFO_ZX_LABEL_UNDEFINED = -1,
13 UFO_ZX_LABEL_UNKNOWN = 0, // referenced, but not defined yet
14 UFO_ZX_LABEL_VAR = 1, // a = value
15 UFO_ZX_LABEL_EQU = 2, // a equ value
16 UFO_ZX_LABEL_CODE = 3,
17 UFO_ZX_LABEL_DATA = 4,
18 UFO_ZX_LABEL_STOFS = 5, // structure offset
22 // should abort; defined by the main app
23 extern void ufoFatalError (void) __attribute__((noreturn));
25 extern void ufoZXPostInit (void);
27 // return pointer to line text or NULL
28 extern const char *ufoGetSrcLine (const char **fname, int *lnum);
30 // returns malloced string
31 extern char *ufoCreateIncludeName (const char *fname, int assystem, const char *lastIncPath);
33 // this also creates labels
34 extern void ufoZXSetLabelValue (const char *name, int type, int value);
35 extern int ufoZXGetLabelValue (const char *name);
36 // returns `UFO_ZX_LABEL_xxx`
37 extern int ufoZXGetLabelType (const char *name);
39 // should support at least 16 iterators
40 typedef uint32_t UFOZXLabelIterator;
42 extern UFOZXLabelIterator ufoZXNewLabelIter (void);
43 // should return 0 when finished
44 extern int ufoZXLabelIterNext (UFOZXLabelIterator it);
45 extern void ufoZXLabelIterClose (UFOZXLabelIterator it);
47 extern const char *ufoZXLabelIterGetName (UFOZXLabelIterator it);
48 extern int ufoZXIterGetValue (UFOZXLabelIterator it);
49 extern int ufoZXIterGetType (UFOZXLabelIterator it);
51 extern uint32_t ufoZXGetU8 (uint32_t addr);
52 extern void ufoZXPutU8 (uint32_t addr, uint32_t v);
53 extern uint32_t ufoZXGetU16 (uint32_t addr);
54 extern void ufoZXPutU16 (uint32_t addr, uint32_t v);
55 extern void ufoZXEmitU8 (uint32_t v);
56 extern void ufoZXEmitU16 (uint32_t v);
58 extern int ufoZXGetReserved (uint32_t addr);
59 extern void ufoZXSetReserved (uint32_t addr, int resvflag);
61 extern int ufoZXGetPass (void);
62 extern uint32_t ufoZXGetOrg (void);
63 extern void ufoZXSetOrg (uint32_t addr);
64 extern uint32_t ufoZXGetDisp (void);
65 extern void ufoZXSetDisp (uint32_t addr);
66 extern uint32_t ufoZXGetEnt (void);
67 extern void ufoZXSetEnt (uint32_t addr);
69 // can be called by the main app
70 void ufoFatal (const char *fmt, ...) __attribute__((noreturn)) __attribute__((format(printf, 1, 2)));
72 void ufoInlineRun (void);
73 uint32_t ufoIsMacro (const char *wname);
74 void ufoMacroRun (uint32_t cfaidx, const char *line, const char *fname, int lnum);
75 void ufoDeinit (void);
78 #endif