From c2978f7e15d6c02958ce9e1f2340a2c2d47848b4 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Tue, 16 Jun 2020 23:12:44 +0000 Subject: [PATCH] "unpseudopc" operator & now also works with program counter * git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@236 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/acme.c | 2 +- src/alu.c | 12 ++++++++---- src/global.h | 2 +- src/output.c | 6 +++--- testing/errors/nopseudopccontext1.a | 2 ++ testing/errors/nopseudopccontext2.a | 2 ++ 6 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 testing/errors/nopseudopccontext1.a create mode 100644 testing/errors/nopseudopccontext2.a diff --git a/src/acme.c b/src/acme.c index 745154d..976ec1b 100644 --- a/src/acme.c +++ b/src/acme.c @@ -469,7 +469,7 @@ struct dialect dialects[] = { {VER_NEWFORSYNTAX, "0.94.12", "new \"!for\" syntax"}, // {VER_, "0.95.2", "changed ANC#8 from 0x2b to 0x0b"}, // {VER_CURRENT, "default", "default"}, -// {VER_BACKSLASHESCAPING, "", "backslash escaping and strings"}, +// {VER_BACKSLASHESCAPING, "0.97", "backslash escaping and strings"}, {VER_FUTURE, "future", "enable all experimental features"}, {0, NULL, NULL} // NULLs terminate }; diff --git a/src/alu.c b/src/alu.c index 54a3eea..25e51fb 100644 --- a/src/alu.c +++ b/src/alu.c @@ -361,7 +361,7 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na symbol->object.u.number.ntype = NUMTYPE_UNDEFINED; symbol->object.u.number.flags = NUMBER_EVER_UNDEFINED; // reading undefined taints it symbol->object.u.number.addr_refs = 0; - symbol->object.u.number.val.intval = 0; + symbol->object.u.number.val.intval = 0; // FIXME - should not be needed! } else { // FIXME - add sanity check for UNDEFINED where EVER_UNDEFINED is false -> Bug_found()! // (because the only way to have UNDEFINED is the block above, and EVER_UNDEFINED taints everything it touches) @@ -387,7 +387,7 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na // Parse program counter ('*') -static void parse_program_counter(void) // Now GotByte = "*" +static void parse_program_counter(unsigned int unpseudo_count) // Now GotByte = "*" { struct number pc; @@ -396,6 +396,8 @@ static void parse_program_counter(void) // Now GotByte = "*" // if needed, output "value not defined" error if (pc.ntype == NUMTYPE_UNDEFINED) is_not_defined(NULL, 0, "*", 1); + if (unpseudo_count) + pseudopc_unpseudo(&pc, pseudopc_get_context(), unpseudo_count); PUSH_INT_ARG(pc.val.intval, pc.flags, pc.addr_refs); // FIXME - when undefined pc is allowed, this must be changed for numtype! } @@ -712,7 +714,9 @@ static int parse_octal_or_unpseudo(void) // now GotByte = '&' } // TODO - support anonymous labels as well? - if (GotByte == '.') { + if (GotByte == '*') { + parse_program_counter(unpseudo_count); + } else if (GotByte == '.') { GetByte(); if (Input_read_keyword() == 0) // now GotByte = illegal char return 1; // error (no string given) @@ -838,7 +842,7 @@ static boolean expect_argument_or_monadic_operator(void) goto now_expect_dyadic_op; case '*': // Program counter - parse_program_counter(); + parse_program_counter(0); // Now GotByte = char after closing quote goto now_expect_dyadic_op; diff --git a/src/global.h b/src/global.h index 0db504f..dee8a78 100644 --- a/src/global.h +++ b/src/global.h @@ -69,7 +69,7 @@ enum version { VER_NEWFORSYNTAX, // v0.94.12 introduced the new "!for" syntax // v0.95.2 changed ANC#8 from 0x2b to 0x0b VER_CURRENT, // "RELEASE" - VER_BACKSLASHESCAPING, // backslash escaping (and therefore strings) + VER_BACKSLASHESCAPING, // v0.97 added backslash escaping (and therefore strings) // possible changes in future versions: // paths should be relative to file, not start dir // ignore leading zeroes? diff --git a/src/output.c b/src/output.c index 03202a0..1413cc2 100644 --- a/src/output.c +++ b/src/output.c @@ -703,14 +703,14 @@ void pseudopc_end_all(void) int pseudopc_unpseudo(struct number *target, struct pseudopc *context, unsigned int levels) { while (levels--) { - if (target->ntype == NUMTYPE_UNDEFINED) - return 0; // ok (no sense in trying to unpseudo this, and it might be an unresolved forward ref anway) + //if (target->ntype == NUMTYPE_UNDEFINED) + // return 0; // ok (no sense in trying to unpseudo this, and it might be an unresolved forward ref anyway) if (context == NULL) { Throw_error("Un-pseudopc operator '&' has no !pseudopc context."); return 1; // error } - // FIXME - in future, check DEFINED flag of context! + // FIXME - in future, check both target and context for NUMTYPE_UNDEFINED! target->val.intval = (target->val.intval - context->offset) & 0xffff; // FIXME - is masking really needed? context = context->outer; } diff --git a/testing/errors/nopseudopccontext1.a b/testing/errors/nopseudopccontext1.a new file mode 100644 index 0000000..170e44b --- /dev/null +++ b/testing/errors/nopseudopccontext1.a @@ -0,0 +1,2 @@ +;ACME 0.96.5 + a = &c diff --git a/testing/errors/nopseudopccontext2.a b/testing/errors/nopseudopccontext2.a new file mode 100644 index 0000000..a3b5dcc --- /dev/null +++ b/testing/errors/nopseudopccontext2.a @@ -0,0 +1,2 @@ +;ACME 0.96.5 + b = &*