Mercurial > hg-old > index.cgi
changeset 54:360d53062bb9
Fixed typo in instruction table and added END directive
author | lost |
---|---|
date | Sun, 04 Jan 2009 20:38:12 +0000 |
parents | 493cb8ea50a0 |
children | 8e32696380f3 |
files | src/instab.c src/lwasm.h src/pass1.c src/pass2.c src/pseudo.c |
diffstat | 5 files changed, 40 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/instab.c Sun Jan 04 20:28:30 2009 +0000 +++ b/src/instab.c Sun Jan 04 20:38:12 2009 +0000 @@ -50,6 +50,7 @@ extern OPFUNC(pseudo_zmd); extern OPFUNC(pseudo_zmq); extern OPFUNC(pseudo_include); +extern OPFUNC(pseudo_end); instab_t instab[] = { @@ -302,9 +303,11 @@ { "rmd", { -1, -1, -1, -1 }, pseudo_rmd }, { "rmq", { -1, -1, -1, -1 }, pseudo_rmq }, - { "zmb", { -1, -1, -1, -1 }, pseudo_rmb }, - { "zmd", { -1, -1, -1, -1 }, pseudo_rmd }, - { "zmq", { -1, -1, -1, -1 }, pseudo_rmq }, + { "zmb", { -1, -1, -1, -1 }, pseudo_zmb }, + { "zmd", { -1, -1, -1, -1 }, pseudo_zmd }, + { "zmq", { -1, -1, -1, -1 }, pseudo_zmq }, + + { "end", { -1, -1, -1, -1 }, pseudo_end }, { "include", { -1, -1, -1, -1 }, pseudo_include },
--- a/src/lwasm.h Sun Jan 04 20:28:30 2009 +0000 +++ b/src/lwasm.h Sun Jan 04 20:38:12 2009 +0000 @@ -92,6 +92,8 @@ int outformat; // output format type char **filelist; // files that have been read int filelistlen; // number of files in the list + + int endseen; // set to true if "end" has been seen } asmstate_t; #define PRAGMA_NOINDEX0TONONE 1
--- a/src/pass1.c Sun Jan 04 20:28:30 2009 +0000 +++ b/src/pass1.c Sun Jan 04 20:38:12 2009 +0000 @@ -148,6 +148,8 @@ if (!(as -> lineshead)) as -> lineshead = nl; lwasm_parse_line(as, nl); + if (as -> endseen) + break; } if (c == EOF) break;
--- a/src/pass2.c Sun Jan 04 20:28:30 2009 +0000 +++ b/src/pass2.c Sun Jan 04 20:38:12 2009 +0000 @@ -36,8 +36,9 @@ as -> passnum = 2; as -> addr = 0; as -> context = 0; + as -> endseen = 0; // iterate over all the lines and re-parse them - for (l = as -> lineshead; l; l = l -> next) + for (l = as -> lineshead; l && !(as -> endseen); l = l -> next) lwasm_parse_line(as, l); }
--- a/src/pseudo.c Sun Jan 04 20:28:30 2009 +0000 +++ b/src/pseudo.c Sun Jan 04 20:38:12 2009 +0000 @@ -274,30 +274,41 @@ } } -/* -void pseudo_end(asmstate_t *as, sourceline_t *cl, char **optr) +OPFUNC(pseudo_end) { - int rval, v1; + int rval; + lwasm_expr_stack_t *s; + + + as -> endseen = 1; - while (**optr && isspace(**optr)) - ; - if (**optr && **optr != '*' && **optr != ';') + // address only matters for DECB output + if (as -> outformat != OUTPUT_DECB) + return; + + s = lwasm_evaluate_expr(as, l, *p, NULL); + if (!s) { - rval = eval_expr(as, cl, optr, &v1); - if (rval < 0) - { - errorp1(ERR_FORWARD); - return; - } + register_error(as, l, 1, "Bad expression"); + return; + } + if (!lwasm_expr_is_constant(s)) + { + register_error(as, l, 2, "Incomplete reference"); } - else + rval = lwasm_expr_get_value(s); + lwasm_expr_stack_free(s); + + rval = rval & 0xffff; + if (as -> passnum == 2) { - v1 = 0; + as -> execaddr = rval; + l -> symaddr = rval; + l -> addrset = 2; } - if (as -> passnum == 2) - as -> execaddr = v1; -} +} +/* void pseudo_align(asmstate_t *as, sourceline_t *cl, char **optr) { int rval, v1;