annotate old-trunk/lwasm/old/lwasm.h @ 348:11a95c6414b4

Added third func to instab to split resolve and emit logic
author lost@starbug
date Sat, 27 Mar 2010 22:15:07 -0600
parents eb230fa7d28e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
339
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
1 /*
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
2 lwasm.h
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
3 Copyright © 2008 William Astle
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
4
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
5 This file is part of LWASM.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
6
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
8 terms of the GNU General Public License as published by the Free Software
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
10 version.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
11
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
15 more details.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
16
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
17 You should have received a copy of the GNU General Public License along with
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
19
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
20 Contains the main defs used by the assembler
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
21 */
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
22
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
23
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
24 #ifndef __lwasm_h_seen__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
25 #define __lwasm_h_seen__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
26
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
27 #include <stdio.h>
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
28 #include "expr.h"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
29
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
30 #define OUTPUT_DECB 0 // DECB multirecord format
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
31 #define OUTPUT_RAW 1 // raw sequence of bytes
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
32 #define OUTPUT_OBJ 2 // proprietary object file format
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
33 #define OUTPUT_RAWREL 3 // raw bytes where ORG causes a SEEK in the file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
34 #define OUTPUT_OS9 4 // os9 module target
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
35
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
36 // structure for tracking sections
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
37 typedef struct section_reloc_list_s section_reloc_list_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
38 struct section_reloc_list_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
39 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
40 int offset; // offset into section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
41 int relocsize; // size of relocation in bytes
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
42 lwasm_expr_stack_t *expr; // value definition
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
43 int context; // symbol context (for local syms)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
44 section_reloc_list_t *next; // next relocation
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
45 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
46
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
47 typedef struct export_list_s export_list_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
48 struct export_list_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
49 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
50 int offset; // offset of symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
51 char *sym; // name of symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
52 export_list_t *next; // next export
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
53 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
54
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
55 #define SECTION_BSS 1 // the section contains no actual code - just uninit vars
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
56 typedef struct sectiontab_s sectiontab_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
57 struct sectiontab_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
58 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
59 char *name; // name of the section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
60 int offset; // current offset in the section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
61 int flags; // section flags
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
62 sectiontab_t *next; // next section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
63 // the following are used during code output
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
64 unsigned char *obytes; // output bytes
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
65 int oblen; // how many bytes output so far?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
66 int obsize; // how big is output buffer so far?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
67 section_reloc_list_t *rl; // relocation list
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
68 export_list_t *exports; // export list for the section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
69 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
70
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
71 // structure for tracking macros
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
72 typedef struct macrotab_s macrotab_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
73 struct macrotab_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
74 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
75 char *name;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
76 char **lines;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
77 int numlines;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
78 macrotab_t *next;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
79 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
80
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
81 // structure for tracking errors
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
82 typedef struct lwasm_error_s lwasm_error_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
83 struct lwasm_error_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
84 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
85 char *mess; // the actual error message
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
86 lwasm_error_t *next; // ptr to next error
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
87 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
88
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
89 // structure for keeping track of lines
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
90 // it also as space for 4 expressions which is enough for all known
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
91 // instructions and addressing modes
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
92 // on pass 1, the expressions are parsed, on pass 2 they are re-evaluated
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
93 // to determine constancy
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
94 typedef struct lwasm_line_s lwasm_line_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
95 struct lwasm_line_s {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
96 char *text; // the actual text of the line
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
97 int lineno; // line number within the file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
98 char *filename; // file name reference
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
99 lwasm_line_t *next; // next line
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
100 lwasm_line_t *prev; // previous line
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
101 lwasm_error_t *err; // error messages
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
102 int fsize; // forced size (0 = no forced size)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
103 char *sym; // scratch area to record the presence of a symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
104 unsigned char *bytes; // actual bytes emitted
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
105 int codelen; // number of bytes emitted
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
106 int codesize; // the size of the code buffer
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
107 int codeaddr; // address the code goes at
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
108 int nocodelen; // for "RMB" type instructions
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
109 int addrset; // set if this instruction sets the assembly address
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
110 int symaddr; // set if this instruction sets a symbol addr with EQU or the like
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
111 int badop; // bad operation - ignore it
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
112 int context; // the symbol context for this line
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
113 int forceglobal; // force a "global" symbol definition if constant
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
114
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
115 // the following are used for obj format - for external references, inter-section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
116 // references, and intrasection relocations
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
117 int relocoff; // offset into insn where relocation value goes
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
118 int reloc8bit; // size of relocation (0 = 16 bit, 1 = 8 bit)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
119 lwasm_expr_stack_t *exprs[4]; // non-constant expression values
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
120 int exprvals[4]; // constant expression values
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
121 char *exprends[4]; // pointer to character after end of expression
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
122 int inmod; // in an os9 module
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
123
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
124 sectiontab_t *sect; // which section is the line in?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
125 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
126
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
127 // for keeping track of symbols
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
128 #define SYMBOL_SET 1 // the symbol was used for "SET"
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
129 #define SYMBOL_COMPLEX 2 // register symbol as a complex symbol (from l -> expr)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
130 #define SYMBOL_FORCE 4 // force resetting the symbol value if it already exists on pass 2
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
131 #define SYMBOL_NORM 0 // no flags
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
132 #define SYMBOL_EXTERN 8 // the symbol is an external reference
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
133 #define SYMBOL_GLOBAL 16 // force global if non-complex symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
134 typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
135 struct lwasm_symbol_ent_s
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
136 {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
137 char *sym; // the symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
138 int context; // the context number of the symbol (-1 for global)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
139 int value; // the value of the symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
140 int flags; // flags for the symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
141 char *externalname; // for external references that are aliased locally
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
142 sectiontab_t *sect; // the section the symbol exists in; NULL for none
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
143 lwasm_expr_stack_t *expr; // expression for a symbol that is not constant NULL for const
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
144 lwasm_symbol_ent_t *next; // next symbol in the table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
145 lwasm_symbol_ent_t *prev; // previous symbol in the table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
146 };
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
147
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
148 // keep track of current assembler state
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
149 typedef struct {
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
150 int dpval; // current dp value (setdp)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
151 int addr; // current address
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
152 int context; // context counter (for local symbols)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
153 int errorcount; // error count
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
154 int passnum; // which pass are we on?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
155 int execaddr; // execution address for the program (END ....)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
156 int pragmas; // what pragmas are in effect?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
157
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
158 lwasm_line_t *lineshead; // first line of source code
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
159 lwasm_line_t *linestail; // last line of source code
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
160
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
161 lwasm_symbol_ent_t *symhead; // first entry in symbol table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
162 lwasm_symbol_ent_t *symtail; // last entry in symbol table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
163
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
164 macrotab_t *macros; // macro table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
165
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
166 const char *infile; // input file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
167 const char *outfile; // output file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
168 const char *listfile; // output listing file
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
169 int outformat; // output format type
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
170 char **filelist; // files that have been read
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
171 int filelistlen; // number of files in the list
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
172
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
173 int endseen; // set to true if "end" has been seen
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
174 int skipcond; // skipping a condition?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
175 int skipcount; // how many?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
176 int skipmacro; // skipping a macro?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
177 int inmacro; // are we currently in a macro?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
178 int macroex; // current depth of macro expansion
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
179 int nextcontext; // next context number
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
180 int skiplines; // number of lines to skip
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
181
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
182 // items used only for the "object" target
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
183 sectiontab_t *sections; // pointer to section table
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
184 sectiontab_t *csect; // current section - NULL if not in one
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
185
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
186 // only 6809 ops?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
187 int no6309;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
188
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
189 // for os9 mode
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
190 int inmod; // in a module?
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
191 unsigned char crc[3]; // running crc count
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
192 } asmstate_t;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
193
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
194 // do not rewrite XXX,r to ,r if XXX evaluates to 0
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
195 #define PRAGMA_NOINDEX0TONONE 1
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
196 // any undefined symbols are considered external
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
197 #define PRAGMA_UNDEFEXTERN 2
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
198 // allow C-style escapes in fcc, fcs, and fcn directives
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
199 #define PRAGMA_CESCAPES 4
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
200 // allow "export <undefsym>" to import the symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
201 #define PRAGMA_IMPORTUNDEFEXPORT 8
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
202 // don't have $ as a local symbol
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
203 #define PRAGMA_DOLLARNOTLOCAL 16
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
204
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
205 #ifndef __lwasm_c_seen__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
206 #define __lwasm_E__ extern
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
207 #else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
208 #define __lwasm_E__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
209 #endif
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
210
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
211 __lwasm_E__ int debug_level;
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
212
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
213 __lwasm_E__ int register_error(asmstate_t *as, lwasm_line_t *l, int pass, const char *fmt, ...);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
214 __lwasm_E__ void debug_message(int level, const char *fmt, ...);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
215
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
216 __lwasm_E__ void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
217 __lwasm_E__ void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
218 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
219 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
220
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
221 __lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp, int flags);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
222
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
223
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
224 // return next context number and update it
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
225 __lwasm_E__ int lwasm_next_context(asmstate_t *as);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
226
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
227 // also throw an error on expression eval failure
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
228 // return 0 on ok, -1 on error, 1 if a complex expression was returned
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
229 #define EXPR_NOFLAG 0
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
230 #define EXPR_PASS1CONST 1 // no forward references on pass 1
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
231 #define EXPR_SECTCONST 2 // resolve symbols local to section
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
232 #define EXPR_REEVAL 4 // re-evaluate the expression
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
233 __lwasm_E__ int lwasm_expr_result(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
234 __lwasm_E__ int lwasm_expr_result2(asmstate_t *as, lwasm_line_t *l, char **inp, int flag, int *val, int slot);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
235
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
236 #undef __lwasm_E__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
237
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
238
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
239 #ifndef __symbol_c_seen__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
240 #define __lwasm_E__ extern
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
241 #else
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
242 #define __lwasm_E__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
243 #endif
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
244
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
245 __lwasm_E__ int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val, int flags);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
246 __lwasm_E__ lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
247 __lwasm_E__ int lwasm_set_symbol(asmstate_t *as, char *sym, int scontext, int val);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
248 __lwasm_E__ void lwasm_list_symbols(asmstate_t *as, FILE *f);
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
249 #undef __lwasm_E__
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
250
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
251
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
252 #define skip_operand(p) do { char **p2 = (char **)(p); for ( ; **p2; (*p2)++ ) ; } while (0)
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
253
eb230fa7d28e Prepare for migration to hg
lost
parents:
diff changeset
254 #endif //__lwasm_h_seen__