annotate src/lwasm.h @ 8:f1df096aa76f 1.1

Tagged 1.1 bugfix release
author lost
date Sun, 04 Jan 2009 05:46:07 +0000
parents 34568fab6058
children 05d4115b4860
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
1 /*
4
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
2 lwasm.h
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
3 Copyright © 2008 William Astle
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
4
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
5 This file is part of LWASM.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
6
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
7 LWASM is free software: you can redistribute it and/or modify it under the
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
8 terms of the GNU General Public License as published by the Free Software
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
9 Foundation, either version 3 of the License, or (at your option) any later
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
10 version.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
11
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
15 more details.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
16
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
17 You should have received a copy of the GNU General Public License along with
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
18 this program. If not, see <http://www.gnu.org/licenses/>.
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
19
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
20 Contains the main defs used by the assembler
34568fab6058 Fixed package to include all required files; also added copyright preamble to all source files
lost
parents: 0
diff changeset
21 */
0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
22
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
23
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
24 #ifndef __lwasm_h_seen__
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
25 #define __lwasm_h_seen__
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
26
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
27 #define MAX_OP_LEN 32
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
28 #define SYMCHAR_START "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
29 #define SYMCHAR "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_$."
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
30
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
31 #define MACROCHAR_START "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
32 #define MACROCHAR "_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
33
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
34
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
35 #define OPER_INH 0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
36 #define OPER_RTOR 1
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
37 #define OPER_RLIST 2
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
38 #define OPER_TFM 3
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
39 #define OPER_IMM8 4
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
40 #define OPER_IMM16 5
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
41 #define OPER_IMM32 6
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
42 #define OPER_DIR 7
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
43 #define OPER_EXT 8
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
44 #define OPER_INDEX 9 // indexed with no offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
45 #define OPER_DIREXT 10 // used as a placeholder when direct/extended unknown
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
46 #define OPER_BITBIT 11 // bit to bit direct page opers
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
47 #define OPER_REL8 12
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
48 #define OPER_REL16 13
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
49 #define OPER_INDEX5 14 // 5 bit offset indexed
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
50 #define OPER_INDEX8 15 // 8 bit offset indexed
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
51 #define OPER_INDEX16 16 // 16 bit offset indexed
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
52 #define OPER_INDEXV 17 // unknown size offset indexed
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
53 #define OPER_EXTIND 18 // extended indirect
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
54 #define OPER_LOGICD 19 // logic on mem, direct mode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
55 #define OPER_LOGICE 20 // logic on mem, extended mode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
56 #define OPER_LOGICEI 21 // logic on mem, extended indir mode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
57 #define OPER_LOGICI 22 // logic on mem, indexed no offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
58 #define OPER_LOGICI5 23 // logic on mem, 5 bit indexed offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
59 #define OPER_LOGICI8 24 // logic on mem, 8 bit indexed offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
60 #define OPER_LOGICI16 25 // logic on mem, 16 bit indexed offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
61 #define OPER_LOGICIV 26 // logic on mem, unknown size offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
62
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
63 #define OUTPUT_DECB 0 // DECB multirecord format
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
64 #define OUTPUT_RAW 1 // raw sequence of bytes
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
65 #define OUTPUT_RAWREL 2 // raw but with ORG as a relative offset
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
66
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
67 enum
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
68 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
69 ERR_NONE, // no error
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
70 ERR_BADOP, // bad opcode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
71 ERR_BADSYM, // illegal symbol
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
72 ERR_DUPSYM, // duplicate symbol definition
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
73 ERR_NOSYM, // symbol required but not present
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
74 ERR_FORWARD, // forward references not permitted here
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
75 ERR_OVERFLOW, // byte overflow
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
76 ERR_PHASE, // phasing error
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
77 ERR_BADOPER, // bad operand
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
78 ERR_SYM, // symbol present where not permitted
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
79 ERR_UNDEF, // undefined symbol
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
80 ERR_OVERFLOW3, // bit number out of range
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
81 ERR_BADEXPR, // invalid expression
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
82 ERR_BADREG, // invalid register
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
83 ERR_BADFN, // bad file name
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
84 ERR_ENDM, // end macro without macro
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
85 ERR_MACRO, // redefined macro
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
86 ERR_NESTNAME, // nested namespace
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
87 ERR_BADCOND, // bad condition
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
88 ERR_USER, // user error
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
89 ERR_PRAGMA, // bad pragma
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
90
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
91 ERR_MAXERR // last error in the list
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
92 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
93
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
94 typedef struct sourceline_s sourceline_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
95
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
96 // structure to keep track of errors
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
97 typedef struct errortab_s errortab_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
98 struct errortab_s {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
99 int errnum;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
100 sourceline_t *line;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
101 errortab_t *next;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
102 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
103
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
104 typedef struct macroline_s macroline_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
105 struct macroline_s
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
106 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
107 char *linetext;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
108 macroline_t *next;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
109 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
110
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
111 typedef struct macrotab_s macrotab_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
112 struct macrotab_s
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
113 {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
114 char *name; // name of the macro
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
115 macroline_t *linehead; // start of the macro lines
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
116 macroline_t *linetail; // last line of macro
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
117 macrotab_t *next;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
118 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
119
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
120
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
121 // structure to keep track of each line of the source
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
122 // this also keeps various bits of state about a line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
123 struct sourceline_s {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
124 char *sourcefile; // name of the source file
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
125 int lineno; // line number in the source file
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
126 char *symstr; // symbol on this line (if any)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
127 int opcode; // index to instab for this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
128 int opbytes; // actual bytes of opcode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
129 int postbyte; // post byte for the instruction
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
130 int numcodebytes; // how many code bytes for this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
131 unsigned char *codebytes; // actual code for this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
132 int codesize; // size of codebytes
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
133 // if minaddr and maxaddr are the same, we know exactly which address
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
134 // we are at so there can be no possible phase error with symbols defined
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
135 // here; these are *code* addresses
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
136 int len; // length of this insn
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
137 int in_macro; // set if it's a macro expansion line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
138 int code_symloc;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
139 int addrmode; // addressing mode of this insn
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
140 int addr; // the lowest possible address of this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
141 int dpval; // dp value at this point in the code
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
142 int hassym; // is there a symbol on this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
143 int addrset; // is this insn a point where the address is *set* (org)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
144 int isequ; // does this insn set a symbol address (equ)?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
145 int isset; // is the address setting from a "set"?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
146 int issetdp; // this insn sets DP
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
147 int symaddr; // address for the symbol (if we're setting one)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
148 // also used for "setdp"
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
149 int undef; // set if the symbol is undefined
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
150 int p1f16; // if we forced 16 bit on pass 1 so we can force it on pass 2
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
151 int nocode; // if set, there is no code to output (rmb)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
152 int notinsn; // if this is not a regular insn (used for formatting output)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
153 char *line; // the text of the line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
154 char *opcstr; // opcode string
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
155 char *operstr; // operand string
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
156 char *remainder; // remainder string (whole line if no opcode/operand
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
157 errortab_t *errors; // errors on this line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
158 sourceline_t *next; // next line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
159 sourceline_t *prev; // previous line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
160 macrotab_t *macro; // pointer to macro table entry if this is a macro
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
161 int skipped; // set if the line was skipped
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
162 char *user_error; // user error message
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
163 int macrodef; // set if it's a macro definition line
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
164 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
165
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
166 // structure to keep the symbol table
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
167 typedef struct symtab_s symtab_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
168 struct symtab_s {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
169 char *symbol; // symbol name
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
170 sourceline_t *line; // pointer to the line where symbol is defined
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
171 int addr; // address of symbol (-1 for unknown)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
172 int flags; // flags for symbol
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
173 symtab_t *next; // next symbol
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
174 };
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
175
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
176
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
177 // keep track of current assembler state
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
178 typedef struct {
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
179 int dpval; // current dp value (setdp)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
180 int addr; // current address
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
181 symtab_t *symbol_table;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
182 sourceline_t *source_head;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
183 sourceline_t *source_tail;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
184 int errorcount; // error count
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
185 int passnum; // which pass are we on?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
186 const char *infile; // input file
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
187 const char *outfile;// output file
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
188 const char *listfile; // output listing file
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
189 int debug; // debug mode
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
190 int outformat; // output format type: 0 = decb, 1 = raw
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
191 int execaddr; // execution address for the program (END ....)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
192 macrotab_t *macros; // pointer to macros
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
193 int inmacro; // are we in a macro?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
194 char *cur_namespace; // current namespace prefix
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
195 int skipcond; // are we skipping a condition?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
196 int skipcount; // number of endc we need before we stop skipping
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
197 int skipmacro; // are we skipping a macro definition?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
198 int noelse; // skipped an else?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
199 int pragmas; // what pragmas are in effect?
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
200 } asmstate_t;
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
201
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
202 #define PRAGMA_NOINDEX0TONONE 1
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
203
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
204
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
205 #ifndef __lwasm_c_seen__
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
206 extern int eval_expr(asmstate_t *as, sourceline_t *cl, char **optr, int *val);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
207 extern void register_error(asmstate_t *as, sourceline_t *cl, int errcode);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
208 extern int lookupreg3(const char *rlist, char **str);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
209 extern int lookupreg(const char *reglist, char **str);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
210 extern void lwasm_read_file(asmstate_t *as, char *fname);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
211 extern void addcodebyte(asmstate_t *as, sourceline_t *cl, int cb);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
212 #endif
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
213
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
214 #define SYMFLAG_NONE 0
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
215 #define SYMFLAG_SET 1
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
216
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
217 #ifndef __symtab_c_seen__
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
218 #include <stdio.h>
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
219 extern void register_symbol(asmstate_t *as, sourceline_t *cl, char *symstr, int val, int flags);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
220 extern int lookup_symbol(asmstate_t *as, char *symstr);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
221 extern void list_symbols(asmstate_t *as, FILE *f);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
222 #endif
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
223
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
224
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
225 #ifndef __index_c_seen__
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
226 extern int parse_index_expr(asmstate_t *as, sourceline_t *cl, char **optr, int *postbyte, int *opmode, int *v1);
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
227 #endif
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
228
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
229 #define emit(cb) do { addcodebyte(as, cl, (cb)); } while (0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
230 #define emitop(cb) do { if ((cb) > 0xff) addcodebyte(as, cl, (cb)>>8); addcodebyte(as, cl, (cb) & 0xff); } while (0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
231 #define errorp1(e) do { if (as -> passnum == 1) register_error(as, cl, (e)); } while (0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
232 #define errorp2(e) do { if (as -> passnum == 2) register_error(as, cl, (e)); } while (0)
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
233
57495da01900 Initial checking of LWASM
lost
parents:
diff changeset
234 #endif //__lwasm_h_seen__