mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-24 16:31:14 +00:00
"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
This commit is contained in:
parent
f9a2f5f698
commit
c2978f7e15
@ -469,7 +469,7 @@ struct dialect dialects[] = {
|
|||||||
{VER_NEWFORSYNTAX, "0.94.12", "new \"!for\" syntax"},
|
{VER_NEWFORSYNTAX, "0.94.12", "new \"!for\" syntax"},
|
||||||
// {VER_, "0.95.2", "changed ANC#8 from 0x2b to 0x0b"},
|
// {VER_, "0.95.2", "changed ANC#8 from 0x2b to 0x0b"},
|
||||||
// {VER_CURRENT, "default", "default"},
|
// {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"},
|
{VER_FUTURE, "future", "enable all experimental features"},
|
||||||
{0, NULL, NULL} // NULLs terminate
|
{0, NULL, NULL} // NULLs terminate
|
||||||
};
|
};
|
||||||
|
12
src/alu.c
12
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.ntype = NUMTYPE_UNDEFINED;
|
||||||
symbol->object.u.number.flags = NUMBER_EVER_UNDEFINED; // reading undefined taints it
|
symbol->object.u.number.flags = NUMBER_EVER_UNDEFINED; // reading undefined taints it
|
||||||
symbol->object.u.number.addr_refs = 0;
|
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 {
|
} else {
|
||||||
// FIXME - add sanity check for UNDEFINED where EVER_UNDEFINED is false -> Bug_found()!
|
// 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)
|
// (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 ('*')
|
// 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;
|
struct number pc;
|
||||||
|
|
||||||
@ -396,6 +396,8 @@ static void parse_program_counter(void) // Now GotByte = "*"
|
|||||||
// if needed, output "value not defined" error
|
// if needed, output "value not defined" error
|
||||||
if (pc.ntype == NUMTYPE_UNDEFINED)
|
if (pc.ntype == NUMTYPE_UNDEFINED)
|
||||||
is_not_defined(NULL, 0, "*", 1);
|
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!
|
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?
|
// TODO - support anonymous labels as well?
|
||||||
if (GotByte == '.') {
|
if (GotByte == '*') {
|
||||||
|
parse_program_counter(unpseudo_count);
|
||||||
|
} else if (GotByte == '.') {
|
||||||
GetByte();
|
GetByte();
|
||||||
if (Input_read_keyword() == 0) // now GotByte = illegal char
|
if (Input_read_keyword() == 0) // now GotByte = illegal char
|
||||||
return 1; // error (no string given)
|
return 1; // error (no string given)
|
||||||
@ -838,7 +842,7 @@ static boolean expect_argument_or_monadic_operator(void)
|
|||||||
goto now_expect_dyadic_op;
|
goto now_expect_dyadic_op;
|
||||||
|
|
||||||
case '*': // Program counter
|
case '*': // Program counter
|
||||||
parse_program_counter();
|
parse_program_counter(0);
|
||||||
// Now GotByte = char after closing quote
|
// Now GotByte = char after closing quote
|
||||||
goto now_expect_dyadic_op;
|
goto now_expect_dyadic_op;
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ enum version {
|
|||||||
VER_NEWFORSYNTAX, // v0.94.12 introduced the new "!for" syntax
|
VER_NEWFORSYNTAX, // v0.94.12 introduced the new "!for" syntax
|
||||||
// v0.95.2 changed ANC#8 from 0x2b to 0x0b
|
// v0.95.2 changed ANC#8 from 0x2b to 0x0b
|
||||||
VER_CURRENT, // "RELEASE"
|
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:
|
// possible changes in future versions:
|
||||||
// paths should be relative to file, not start dir
|
// paths should be relative to file, not start dir
|
||||||
// ignore leading zeroes?
|
// ignore leading zeroes?
|
||||||
|
@ -703,14 +703,14 @@ void pseudopc_end_all(void)
|
|||||||
int pseudopc_unpseudo(struct number *target, struct pseudopc *context, unsigned int levels)
|
int pseudopc_unpseudo(struct number *target, struct pseudopc *context, unsigned int levels)
|
||||||
{
|
{
|
||||||
while (levels--) {
|
while (levels--) {
|
||||||
if (target->ntype == NUMTYPE_UNDEFINED)
|
//if (target->ntype == NUMTYPE_UNDEFINED)
|
||||||
return 0; // ok (no sense in trying to unpseudo this, and it might be an unresolved forward ref anway)
|
// return 0; // ok (no sense in trying to unpseudo this, and it might be an unresolved forward ref anyway)
|
||||||
|
|
||||||
if (context == NULL) {
|
if (context == NULL) {
|
||||||
Throw_error("Un-pseudopc operator '&' has no !pseudopc context.");
|
Throw_error("Un-pseudopc operator '&' has no !pseudopc context.");
|
||||||
return 1; // error
|
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?
|
target->val.intval = (target->val.intval - context->offset) & 0xffff; // FIXME - is masking really needed?
|
||||||
context = context->outer;
|
context = context->outer;
|
||||||
}
|
}
|
||||||
|
2
testing/errors/nopseudopccontext1.a
Normal file
2
testing/errors/nopseudopccontext1.a
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
;ACME 0.96.5
|
||||||
|
a = &c
|
2
testing/errors/nopseudopccontext2.a
Normal file
2
testing/errors/nopseudopccontext2.a
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
;ACME 0.96.5
|
||||||
|
b = &*
|
Loading…
Reference in New Issue
Block a user