Mercurial > hg > index.cgi
changeset 380:17fcd0c3ee45
Allow multibyte ascii constants in m80ext mode
Allow multibyte ascii constants using ' in m80ext mode, with the allowed
size depending on the actual size of the register being referenced.
Thanks to Erik G <erik@6809.org> for the patch.
author | William Astle <lost@l-w.ca> |
---|---|
date | Mon, 13 Jul 2015 21:04:39 -0600 |
parents | d791d47afc48 |
children | e3f4aaa2a4e8 |
files | lwasm/insn_gen.c lwasm/lwasm.c lwasm/lwasm.h |
diffstat | 3 files changed, 26 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/lwasm/insn_gen.c Mon Jul 13 20:59:02 2015 -0600 +++ b/lwasm/insn_gen.c Mon Jul 13 21:04:39 2015 -0600 @@ -320,6 +320,7 @@ PARSEFUNC(insn_parse_gen8) { + l -> genmode = 8; if (**p == '#') { lw_expr_t e; @@ -393,6 +394,7 @@ PARSEFUNC(insn_parse_gen16) { + l -> genmode = 16; if (**p == '#') { lw_expr_t e; @@ -454,6 +456,7 @@ PARSEFUNC(insn_parse_gen32) { + l -> genmode = 32; if (**p == '#') { lw_expr_t e;
--- a/lwasm/lwasm.c Mon Jul 13 20:59:02 2015 -0600 +++ b/lwasm/lwasm.c Mon Jul 13 21:04:39 2015 -0600 @@ -520,6 +520,28 @@ return lw_expr_build(lw_expr_type_int, v); } + /* double ASCII constant, like LDD #'MG */ + if (CURPRAGMA(as->cl, PRAGMA_M80EXT)) + { + if (((**p == '"') || (**p == '\'')) && (as->cl->genmode == 16)) + { + int v; + (*p)++; + if (!**p) + return NULL; + if (!*((*p) + 1)) + return NULL; + v = (unsigned char) **p << 8 | (unsigned char) *((*p) + 1); + (*p) += 2; + + if ((**p == '"') || (**p == '\'')) + (*p)++; + + return lw_expr_build(lw_expr_type_int, v); + } + } + + /* single ASCII constant, like LDA #'E */ if (**p == '\'') { int v;
--- a/lwasm/lwasm.h Mon Jul 13 20:59:02 2015 -0600 +++ b/lwasm/lwasm.h Mon Jul 13 21:04:39 2015 -0600 @@ -262,6 +262,7 @@ int cycle_base; // base instruction cycle count int cycle_adj; // cycle adjustment int cycle_flags; // cycle flags + int genmode; // generation mode (insn_parse_gen0/8/16) lwasm_error_t *err; // list of errors lwasm_error_t *warn; // list of errors lwasm_errorcode_t err_testmode; // error code in testmode