comparison lwasm/lwasm.h @ 342:7b4123dce741

Added basic symbol registration
author lost@starbug
date Wed, 24 Mar 2010 21:30:31 -0600
parents 1a6fc6ebb31c
children 0215a0fbf61b
comparison
equal deleted inserted replaced
341:4e1cff60c293 342:7b4123dce741
67 struct line_s 67 struct line_s
68 { 68 {
69 lw_expr_t addr; // assembly address of the line 69 lw_expr_t addr; // assembly address of the line
70 int len; // the "size" this line occupies (address space wise) (-1 if unknown) 70 int len; // the "size" this line occupies (address space wise) (-1 if unknown)
71 int insn; // number of insn in insn table 71 int insn; // number of insn in insn table
72 int symset; // set if the line symbol was consumed by the instruction
72 char *sym; // symbol, if any, on the line 73 char *sym; // symbol, if any, on the line
73 line_t *prev; 74 line_t *prev;
74 line_t *next; 75 line_t *next;
75 }; 76 };
77
78 enum
79 {
80 symbol_flag_set = 1, // symbol was used with "set"
81 symbol_flag_none = 0 // no flags
82 };
83
84 struct symtabe
85 {
86 char *symbol; // the name of the symbol
87 int context; // symbol context (-1 for global)
88 int version; // version of the symbol (for "set")
89 int flags; // flags for the symbol
90 lw_expr_t value; // symbol value
91 struct symtabe *next; // next symbol in the table
92 };
93
94 typedef struct
95 {
96 struct symtabe *head; // start of symbol table
97 } symtab_t;
76 98
77 typedef struct 99 typedef struct
78 { 100 {
79 int output_format; // output format 101 int output_format; // output format
80 int target; // assembly target 102 int target; // assembly target
82 int flags; // assembly flags 104 int flags; // assembly flags
83 int pragmas; // pragmas currently in effect 105 int pragmas; // pragmas currently in effect
84 106
85 line_t *line_head; // start of lines list 107 line_t *line_head; // start of lines list
86 line_t *line_tail; // tail of lines list 108 line_t *line_tail; // tail of lines list
109
110 int context; // the current "context"
111
112 symtab_t symtab; // meta data for the symbol table
87 113
88 char *list_file; // name of file to list to 114 char *list_file; // name of file to list to
89 char *output_file; // output file name 115 char *output_file; // output file name
90 lw_stringlist_t input_files; // files to assemble 116 lw_stringlist_t input_files; // files to assemble
91 void *input_data; // opaque data used by the input system 117 void *input_data; // opaque data used by the input system
92 lw_stringlist_t include_list; // include paths 118 lw_stringlist_t include_list; // include paths
93 lw_stack_t file_dir; // stack of the "current file" dir 119 lw_stack_t file_dir; // stack of the "current file" dir
94 } asmstate_t; 120 } asmstate_t;
95 121
122 #ifndef ___symbol_c_seen___
123
124 extern struct symtabe *register_symbol(asmstate_t *as, char *sym, lw_expr_t value, int flags);
125 extern struct symtabe *lookup_symbol(asmstate_t *as, char *sym, int context, int version);
126
127 #endif
128
96 #endif /* ___lwasm_h_seen___ */ 129 #endif /* ___lwasm_h_seen___ */