Mercurial > hg-old > index.cgi
diff lwasm/lwasm.h @ 346:a82c55070624
Added expression parsing infrastructure and misc fixes
author | lost@starbug |
---|---|
date | Sat, 27 Mar 2010 19:04:03 -0600 |
parents | 7416c3f9c321 |
children | 1649bc7bda5a |
line wrap: on
line diff
--- a/lwasm/lwasm.h Thu Mar 25 23:17:54 2010 -0600 +++ b/lwasm/lwasm.h Sat Mar 27 19:04:03 2010 -0600 @@ -26,9 +26,20 @@ #include <lw_stringlist.h> #include <lw_stack.h> + +// these are allowed chars BELOW 0x80 for symbols +// first is symbol start chars, second is anywhere in symbol +#define SSYMCHARS "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_@$" +#define SYMCHARS SSYMCHARS ".?0123456789" + +typedef struct asmstate_s asmstate_t; + enum { - lwasm_expr_linelen = 1 + lwasm_expr_linelen = 1, // length of ref'd line + lwasm_expr_lineaddr = 2, // addr of ref'd line + lwasm_expr_nextbp = 3, // next branch point + lwasm_expr_prevbp = 4 // previous branch point }; enum lwasm_output_e @@ -78,9 +89,13 @@ int insn; // number of insn in insn table int symset; // set if the line symbol was consumed by the instruction char *sym; // symbol, if any, on the line + unsigned char *output; // output bytes + int outputl; // size of output + int outputbl; // size of output buffer lwasm_error_t *err; // list of errors line_t *prev; // previous line line_t *next; // next line + asmstate_t *as; // assembler state data ptr }; enum @@ -113,7 +128,7 @@ macrotab_t *next; // next macro in list }; -typedef struct +struct asmstate_s { int output_format; // output format int target; // assembly target @@ -127,6 +142,8 @@ line_t *line_head; // start of lines list line_t *line_tail; // tail of lines list + + line_t *cl; // current line pointer int context; // the current "context" int nextcontext; // the next available context @@ -140,7 +157,7 @@ void *input_data; // opaque data used by the input system lw_stringlist_t include_list; // include paths lw_stack_t file_dir; // stack of the "current file" dir -} asmstate_t; +}; #ifndef ___symbol_c_seen___ @@ -153,8 +170,11 @@ extern void lwasm_register_error(asmstate_t *as, line_t *cl, const char *msg, ...); extern int lwasm_next_context(asmstate_t *as); +extern void lwasm_emit(line_t *cl, int byte); +extern void lwasm_emitop(line_t *cl, int opc); #endif +#define OPLEN(op) (((op)>0xFF)?2:1) #endif /* ___lwasm_h_seen___ */