Mercurial > hg-old > index.cgi
annotate src/lwasm.h @ 38:9bd584bb6296
Added debugging message infrastructure
author | lost |
---|---|
date | Sat, 03 Jan 2009 04:53:49 +0000 |
parents | 538e15927776 |
children | 4bb7b723e5b7 |
rev | line source |
---|---|
0 | 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 | 22 |
23 | |
24 #ifndef __lwasm_h_seen__ | |
25 #define __lwasm_h_seen__ | |
26 | |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
27 #include "expr.h" |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
28 |
0 | 29 #define OUTPUT_DECB 0 // DECB multirecord format |
30 #define OUTPUT_RAW 1 // raw sequence of bytes | |
21 | 31 #define OUTPUT_OBJ 2 // proprietary object file format |
32 | |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
33 |
26 | 34 // structure for tracking errors |
35 typedef struct lwasm_error_s lwasm_error_t; | |
36 struct lwasm_error_s | |
37 { | |
38 char *mess; // the actual error message | |
39 lwasm_error_t *next; // ptr to next error | |
40 }; | |
41 | |
21 | 42 // structure for keeping track of lines |
43 typedef struct lwasm_line_s lwasm_line_t; | |
44 struct lwasm_line_s { | |
45 char *text; // the actual text of the line | |
46 int lineno; // line number within the file | |
47 char *filename; // file name reference | |
48 lwasm_line_t *next; // next line | |
49 lwasm_line_t *prev; // previous line | |
26 | 50 lwasm_error_t *err; // error messages |
28 | 51 int fsize; // forced size (0 = no forced size) |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
52 char *sym; // scratch area to record the presence of a symbol |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
53 }; |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
54 |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
55 // for keeping track of symbols |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
56 typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t; |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
57 struct lwasm_symbol_ent_s |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
58 { |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
59 char *sym; // the symbol |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
60 int context; // the context number of the symbol (-1 for global) |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
61 int value; // the value of the symbol |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
62 lwasm_symbol_ent_t *next; // next symbol in the table |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
63 lwasm_symbol_ent_t *prev; // previous symbol in the table |
21 | 64 }; |
0 | 65 |
66 // keep track of current assembler state | |
67 typedef struct { | |
13
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
68 int dpval; // current dp value (setdp) |
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
69 int addr; // current address |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
70 int context; // context counter (for local symbols) |
13
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
71 int errorcount; // error count |
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
72 int passnum; // which pass are we on? |
21 | 73 int execaddr; // execution address for the program (END ....) |
74 int pragmas; // what pragmas are in effect? | |
75 | |
76 lwasm_line_t *lineshead; // first line of source code | |
77 lwasm_line_t *linestail; // last line of source code | |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
78 |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
79 lwasm_symbol_ent_t *symhead; // first entry in symbol table |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
80 lwasm_symbol_ent_t *symtail; // last entry in symbol table |
21 | 81 |
13
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
82 const char *infile; // input file |
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
83 const char *outfile; // output file |
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
84 const char *listfile; // output listing file |
05d4115b4860
Started work on new expression evaluator system and major code re-work for next release
lost
parents:
4
diff
changeset
|
85 int outformat; // output format type |
21 | 86 char **filelist; // files that have been read |
87 int filelistlen; // number of files in the list | |
0 | 88 } asmstate_t; |
89 | |
90 #define PRAGMA_NOINDEX0TONONE 1 | |
91 | |
26 | 92 #ifndef __lwasm_c_seen__ |
93 #define __lwasm_E__ extern | |
94 #else | |
95 #define __lwasm_E__ | |
96 #endif | |
97 | |
38 | 98 __lwasm_E__ int debug_level; |
99 | |
26 | 100 __lwasm_E__ int register_error(asmstate_t *as, lwasm_line_t *l, int pass, const char *fmt, ...); |
38 | 101 __lwasm_E__ void debug_message(int level, const char *fmt, ...); |
26 | 102 |
27
f736579569b4
Added handlers for inherent and register to register instructions
lost
parents:
26
diff
changeset
|
103 __lwasm_E__ void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b); |
f736579569b4
Added handlers for inherent and register to register instructions
lost
parents:
26
diff
changeset
|
104 __lwasm_E__ void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o); |
f736579569b4
Added handlers for inherent and register to register instructions
lost
parents:
26
diff
changeset
|
105 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str); |
32 | 106 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str); |
27
f736579569b4
Added handlers for inherent and register to register instructions
lost
parents:
26
diff
changeset
|
107 |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
108 __lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp); |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
109 |
26 | 110 #undef __lwasm_E__ |
111 | |
112 | |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
113 #ifndef __symbol_c_seen__ |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
114 #define __lwasm_E__ extern |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
115 #else |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
116 #define __lwasm_E__ |
0 | 117 #endif |
118 | |
37
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
119 __lwasm_E__ int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val); |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
120 __lwasm_E__ lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext); |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
121 __lwasm_E__ int lwasm_set_symbol(asmstate_t *as, char *sym, int scontext, int val); |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
122 |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
123 #undef __lwasm_E__ |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
124 |
538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
lost
parents:
32
diff
changeset
|
125 |
0 | 126 |
127 #endif //__lwasm_h_seen__ |