Mercurial > hg-old > index.cgi
comparison src/lwasm.h @ 37:538e15927776
Added symbol handling to expression subsystem; adpated instruction handlers to the new scheme; misc fixes
author | lost |
---|---|
date | Sat, 03 Jan 2009 04:20:49 +0000 |
parents | 9bd0fbfe7405 |
children | 9bd584bb6296 |
comparison
equal
deleted
inserted
replaced
36:99e3b3310bac | 37:538e15927776 |
---|---|
22 | 22 |
23 | 23 |
24 #ifndef __lwasm_h_seen__ | 24 #ifndef __lwasm_h_seen__ |
25 #define __lwasm_h_seen__ | 25 #define __lwasm_h_seen__ |
26 | 26 |
27 #include "expr.h" | |
28 | |
27 #define OUTPUT_DECB 0 // DECB multirecord format | 29 #define OUTPUT_DECB 0 // DECB multirecord format |
28 #define OUTPUT_RAW 1 // raw sequence of bytes | 30 #define OUTPUT_RAW 1 // raw sequence of bytes |
29 #define OUTPUT_OBJ 2 // proprietary object file format | 31 #define OUTPUT_OBJ 2 // proprietary object file format |
32 | |
30 | 33 |
31 // structure for tracking errors | 34 // structure for tracking errors |
32 typedef struct lwasm_error_s lwasm_error_t; | 35 typedef struct lwasm_error_s lwasm_error_t; |
33 struct lwasm_error_s | 36 struct lwasm_error_s |
34 { | 37 { |
44 char *filename; // file name reference | 47 char *filename; // file name reference |
45 lwasm_line_t *next; // next line | 48 lwasm_line_t *next; // next line |
46 lwasm_line_t *prev; // previous line | 49 lwasm_line_t *prev; // previous line |
47 lwasm_error_t *err; // error messages | 50 lwasm_error_t *err; // error messages |
48 int fsize; // forced size (0 = no forced size) | 51 int fsize; // forced size (0 = no forced size) |
52 char *sym; // scratch area to record the presence of a symbol | |
53 }; | |
54 | |
55 // for keeping track of symbols | |
56 typedef struct lwasm_symbol_ent_s lwasm_symbol_ent_t; | |
57 struct lwasm_symbol_ent_s | |
58 { | |
59 char *sym; // the symbol | |
60 int context; // the context number of the symbol (-1 for global) | |
61 int value; // the value of the symbol | |
62 lwasm_symbol_ent_t *next; // next symbol in the table | |
63 lwasm_symbol_ent_t *prev; // previous symbol in the table | |
49 }; | 64 }; |
50 | 65 |
51 // keep track of current assembler state | 66 // keep track of current assembler state |
52 typedef struct { | 67 typedef struct { |
53 int dpval; // current dp value (setdp) | 68 int dpval; // current dp value (setdp) |
54 int addr; // current address | 69 int addr; // current address |
70 int context; // context counter (for local symbols) | |
55 int errorcount; // error count | 71 int errorcount; // error count |
56 int passnum; // which pass are we on? | 72 int passnum; // which pass are we on? |
57 int execaddr; // execution address for the program (END ....) | 73 int execaddr; // execution address for the program (END ....) |
58 int pragmas; // what pragmas are in effect? | 74 int pragmas; // what pragmas are in effect? |
59 | 75 |
60 lwasm_line_t *lineshead; // first line of source code | 76 lwasm_line_t *lineshead; // first line of source code |
61 lwasm_line_t *linestail; // last line of source code | 77 lwasm_line_t *linestail; // last line of source code |
78 | |
79 lwasm_symbol_ent_t *symhead; // first entry in symbol table | |
80 lwasm_symbol_ent_t *symtail; // last entry in symbol table | |
62 | 81 |
63 const char *infile; // input file | 82 const char *infile; // input file |
64 const char *outfile; // output file | 83 const char *outfile; // output file |
65 const char *listfile; // output listing file | 84 const char *listfile; // output listing file |
66 int debug; // debug mode | 85 int debug; // debug mode |
82 __lwasm_E__ void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b); | 101 __lwasm_E__ void lwasm_emit(asmstate_t *as, lwasm_line_t *l, int b); |
83 __lwasm_E__ void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o); | 102 __lwasm_E__ void lwasm_emitop(asmstate_t *as, lwasm_line_t *l, int o); |
84 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str); | 103 __lwasm_E__ int lwasm_lookupreg2(const char *reglist, char **str); |
85 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str); | 104 __lwasm_E__ int lwasm_lookupreg3(const char *rlist, const char **str); |
86 | 105 |
106 __lwasm_E__ lwasm_expr_stack_t *lwasm_evaluate_expr(asmstate_t *as, lwasm_line_t *l, const char *inp, const char **outp); | |
107 | |
87 #undef __lwasm_E__ | 108 #undef __lwasm_E__ |
88 | 109 |
89 | 110 |
90 #ifndef __symtab_c_seen__ | 111 #ifndef __symbol_c_seen__ |
91 //extern void register_symbol(asmstate_t *as, sourceline_t *cl, char *symstr, int val, int flags); | 112 #define __lwasm_E__ extern |
92 //extern int lookup_symbol(asmstate_t *as, char *symstr); | 113 #else |
93 //extern void list_symbols(asmstate_t *as, FILE *f); | 114 #define __lwasm_E__ |
94 #endif | 115 #endif |
116 | |
117 __lwasm_E__ int lwasm_register_symbol(asmstate_t *as, lwasm_line_t *l, char *sym, int val); | |
118 __lwasm_E__ lwasm_symbol_ent_t *lwasm_find_symbol(asmstate_t *as, char *sym, int scontext); | |
119 __lwasm_E__ int lwasm_set_symbol(asmstate_t *as, char *sym, int scontext, int val); | |
120 | |
121 #undef __lwasm_E__ | |
122 | |
95 | 123 |
96 | 124 |
97 #endif //__lwasm_h_seen__ | 125 #endif //__lwasm_h_seen__ |