small fix so "label" and "label=*" throw the same error if pc undefined

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@414 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-09-01 16:23:08 +00:00
parent 67b338e667
commit 134ba39638
9 changed files with 39 additions and 19 deletions

View File

@ -313,18 +313,16 @@ static intval_t my_asr(intval_t left, intval_t right)
// if wanted, throw "Value not defined" error
// This function is not allowed to change DynaBuf because the symbol's name
// might be stored there!
static void is_not_defined(struct symbol *optional_symbol, char *name, size_t length)
static void is_not_defined(struct symbol *symbol, char *name, size_t length)
{
if (!pass.flags.complain_about_undefined)
return;
// only complain once per symbol
if (optional_symbol) {
if (optional_symbol->has_been_reported)
if (symbol->has_been_reported)
return;
optional_symbol->has_been_reported = TRUE;
}
symbol->has_been_reported = TRUE;
dynabuf_clear(errormsg_dyna_buf);
dynabuf_add_string(errormsg_dyna_buf, "Symbol not defined (");
@ -397,10 +395,7 @@ static void parse_program_counter(void) // now GotByte = "*"
struct object *arg;
GetByte();
programcounter_read(&pc);
// if needed, output "value not defined" error
if (pc.ntype == NUMTYPE_UNDEFINED)
is_not_defined(NULL, "*", 1);
programcounter_read_asterisk(&pc);
// push to arg stack
arg = &arg_stack[arg_sp++];
arg->type = &type_number;

View File

@ -220,7 +220,7 @@ static void set_label(scope_t scope, bits force_bit, bits powers)
}
symbol = symbol_find(scope);
result.type = &type_number;
programcounter_read(&result.u.number); // FIXME - if undefined, check pass.flags.complain_about_undefined and maybe throw "value not defined"!
programcounter_read_asterisk(&result.u.number);
symbol_set_object(symbol, &result, powers);
if (force_bit)
symbol_set_force_bit(symbol, force_bit);

View File

@ -812,7 +812,7 @@ static void near_branch(int preoffset)
struct number target;
intval_t offset = 0; // dummy value, to not throw more errors than necessary
programcounter_read(&pc);
programcounter_read_pc(&pc);
get_int_arg(&target, TRUE);
typesystem_want_addr(&target);
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {
@ -847,7 +847,7 @@ static void far_branch(int preoffset)
struct number target;
intval_t offset = 0; // dummy value, to not throw more errors than necessary
programcounter_read(&pc);
programcounter_read_pc(&pc);
get_int_arg(&target, TRUE);
typesystem_want_addr(&target);
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {

View File

@ -454,8 +454,8 @@ void programcounter_set(intval_t new_pc, bits segment_flags)
}
// read program counter
void programcounter_read(struct number *target)
// get program counter value
void programcounter_read_pc(struct number *target)
{
// check whether ptr undefined
if (PC_NOT_SET) {
@ -467,6 +467,25 @@ void programcounter_read(struct number *target)
target->val.intval = program_counter;
target->addr_refs = 1; // program counter is an address
}
// get program counter and check if defined
void programcounter_read_asterisk(struct number *target)
{
programcounter_read_pc(target);
// defined?
if (target->ntype != NUMTYPE_UNDEFINED)
return;
// either complain or count
if (pass.flags.complain_about_undefined)
throw_error("Symbol not defined (*).");
else
++pass.counters.undefineds;
// counting is not needed when called by expression parser, because that
// will count undefined _results_ on its own.
// but if this was called by implicit label definition, we want to count
// undefined pc to make sure "label" throws the same error as "label=*"
}
// get size of current statement (until now) - needed for "!bin" verbose output

View File

@ -49,8 +49,10 @@ extern void output_set_xor(char xor);
// this will in turn set the outbuf index according to the current pseudopc offset.
extern void programcounter_set(intval_t new_pc, bits segment_flags);
// get program counter
extern void programcounter_read(struct number *target);
// get program counter value
extern void programcounter_read_pc(struct number *target);
// get program counter and check if defined
extern void programcounter_read_asterisk(struct number *target);
// get size of current statement (until now) - needed for "!bin" verbose output
extern int output_get_statement_size(void);

View File

@ -651,7 +651,7 @@ static enum eos po_align(void)
fill = cpu_current_type->default_align_value;
// make sure PC is defined
programcounter_read(&pc);
programcounter_read_pc(&pc);
if (pc.ntype == NUMTYPE_UNDEFINED) {
throw_error(exception_pc_undefined);
return SKIP_REMAINDER;

View File

@ -9,7 +9,7 @@
#define RELEASE "0.97" // update before release FIXME
#define CODENAME "Zem" // update before release
#define CHANGE_DATE "16 Aug" // update before release FIXME
#define CHANGE_DATE "17 Aug" // update before release FIXME
#define CHANGE_YEAR "2024" // update before release
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME

View File

@ -0,0 +1,2 @@
undef=* ; -> "Symbol not defined(*)."
*=$1000

View File

@ -0,0 +1,2 @@
undef ; -> "Symbol not defined (*)."
*=$1000