comparison src/lwasm.h @ 57:035b95a3690f

Added conditional assembly and macros
author lost
date Mon, 05 Jan 2009 00:01:21 +0000
parents 8e32696380f3
children b1d81800bc91
comparison
equal deleted inserted replaced
56:55260a178667 57:035b95a3690f
28 28
29 #define OUTPUT_DECB 0 // DECB multirecord format 29 #define OUTPUT_DECB 0 // DECB multirecord format
30 #define OUTPUT_RAW 1 // raw sequence of bytes 30 #define OUTPUT_RAW 1 // raw sequence of bytes
31 #define OUTPUT_OBJ 2 // proprietary object file format 31 #define OUTPUT_OBJ 2 // proprietary object file format
32 #define OUTPUT_RAWREL 3 // raw bytes where ORG causes a SEEK in the file 32 #define OUTPUT_RAWREL 3 // raw bytes where ORG causes a SEEK in the file
33
34 // structure for tracking macros
35 typedef struct macrotab_s macrotab_t;
36 struct macrotab_s
37 {
38 char *name;
39 char **lines;
40 int numlines;
41 macrotab_t *next;
42 };
33 43
34 // structure for tracking errors 44 // structure for tracking errors
35 typedef struct lwasm_error_s lwasm_error_t; 45 typedef struct lwasm_error_s lwasm_error_t;
36 struct lwasm_error_s 46 struct lwasm_error_s
37 { 47 {
83 lwasm_line_t *lineshead; // first line of source code 93 lwasm_line_t *lineshead; // first line of source code
84 lwasm_line_t *linestail; // last line of source code 94 lwasm_line_t *linestail; // last line of source code
85 95
86 lwasm_symbol_ent_t *symhead; // first entry in symbol table 96 lwasm_symbol_ent_t *symhead; // first entry in symbol table
87 lwasm_symbol_ent_t *symtail; // last entry in symbol table 97 lwasm_symbol_ent_t *symtail; // last entry in symbol table
98
99 macrotab_t *macros; // macro table
88 100
89 const char *infile; // input file 101 const char *infile; // input file
90 const char *outfile; // output file 102 const char *outfile; // output file
91 const char *listfile; // output listing file 103 const char *listfile; // output listing file
92 int outformat; // output format type 104 int outformat; // output format type
93 char **filelist; // files that have been read 105 char **filelist; // files that have been read
94 int filelistlen; // number of files in the list 106 int filelistlen; // number of files in the list
95 107
96 int endseen; // set to true if "end" has been seen 108 int endseen; // set to true if "end" has been seen
109 int skipcond; // skipping a condition?
110 int skipcount; // how many?
111 int skipmacro; // skipping a macro?
112 int inmacro; // are we currently in a macro?
113 int macroex; // current depth of macro expansion
114 int nextcontext; // next context number
115 int skiplines; // number of lines to skip
97 } asmstate_t; 116 } asmstate_t;
98 117
99 #define PRAGMA_NOINDEX0TONONE 1 118 #define PRAGMA_NOINDEX0TONONE 1
100 119
101 #ifndef __lwasm_c_seen__ 120 #ifndef __lwasm_c_seen__
114 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str); 133 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str);
115 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str); 134 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str);
116 135
117 __lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp); 136 __lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp);
118 137
138
139 // return next context number and update it
140 __lwasm_E__ int lwasm_next_context(asmstate_t *as);
119 141
120 // also throw an error on expression eval failure 142 // also throw an error on expression eval failure
121 // return 0 on ok, -1 on error 143 // return 0 on ok, -1 on error
122 #define EXPR_NOFLAG 0 144 #define EXPR_NOFLAG 0
123 #define EXPR_PASS1CONST 1 145 #define EXPR_PASS1CONST 1