# HG changeset patch # User William Astle # Date 1436843079 21600 # Node ID 17fcd0c3ee452220ae4489b4054c089fbd62775b # Parent d791d47afc48572f522ceed308dbf3bd5154b9ef 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 for the patch. diff -r d791d47afc48 -r 17fcd0c3ee45 lwasm/insn_gen.c --- 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; diff -r d791d47afc48 -r 17fcd0c3ee45 lwasm/lwasm.c --- 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; diff -r d791d47afc48 -r 17fcd0c3ee45 lwasm/lwasm.h --- 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