mirror of
https://github.com/uffejakobsen/acme.git
synced 2024-11-23 09:30:48 +00:00
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:
parent
67b338e667
commit
134ba39638
15
src/alu.c
15
src/alu.c
@ -313,18 +313,16 @@ static intval_t my_asr(intval_t left, intval_t right)
|
|||||||
// if wanted, throw "Value not defined" error
|
// if wanted, throw "Value not defined" error
|
||||||
// This function is not allowed to change DynaBuf because the symbol's name
|
// This function is not allowed to change DynaBuf because the symbol's name
|
||||||
// might be stored there!
|
// 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)
|
if (!pass.flags.complain_about_undefined)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// only complain once per symbol
|
// only complain once per symbol
|
||||||
if (optional_symbol) {
|
if (symbol->has_been_reported)
|
||||||
if (optional_symbol->has_been_reported)
|
return;
|
||||||
return;
|
|
||||||
|
|
||||||
optional_symbol->has_been_reported = TRUE;
|
symbol->has_been_reported = TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
dynabuf_clear(errormsg_dyna_buf);
|
dynabuf_clear(errormsg_dyna_buf);
|
||||||
dynabuf_add_string(errormsg_dyna_buf, "Symbol not defined (");
|
dynabuf_add_string(errormsg_dyna_buf, "Symbol not defined (");
|
||||||
@ -397,10 +395,7 @@ static void parse_program_counter(void) // now GotByte = "*"
|
|||||||
struct object *arg;
|
struct object *arg;
|
||||||
|
|
||||||
GetByte();
|
GetByte();
|
||||||
programcounter_read(&pc);
|
programcounter_read_asterisk(&pc);
|
||||||
// if needed, output "value not defined" error
|
|
||||||
if (pc.ntype == NUMTYPE_UNDEFINED)
|
|
||||||
is_not_defined(NULL, "*", 1);
|
|
||||||
// push to arg stack
|
// push to arg stack
|
||||||
arg = &arg_stack[arg_sp++];
|
arg = &arg_stack[arg_sp++];
|
||||||
arg->type = &type_number;
|
arg->type = &type_number;
|
||||||
|
@ -220,7 +220,7 @@ static void set_label(scope_t scope, bits force_bit, bits powers)
|
|||||||
}
|
}
|
||||||
symbol = symbol_find(scope);
|
symbol = symbol_find(scope);
|
||||||
result.type = &type_number;
|
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);
|
symbol_set_object(symbol, &result, powers);
|
||||||
if (force_bit)
|
if (force_bit)
|
||||||
symbol_set_force_bit(symbol, force_bit);
|
symbol_set_force_bit(symbol, force_bit);
|
||||||
|
@ -812,7 +812,7 @@ static void near_branch(int preoffset)
|
|||||||
struct number target;
|
struct number target;
|
||||||
intval_t offset = 0; // dummy value, to not throw more errors than necessary
|
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);
|
get_int_arg(&target, TRUE);
|
||||||
typesystem_want_addr(&target);
|
typesystem_want_addr(&target);
|
||||||
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {
|
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {
|
||||||
@ -847,7 +847,7 @@ static void far_branch(int preoffset)
|
|||||||
struct number target;
|
struct number target;
|
||||||
intval_t offset = 0; // dummy value, to not throw more errors than necessary
|
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);
|
get_int_arg(&target, TRUE);
|
||||||
typesystem_want_addr(&target);
|
typesystem_want_addr(&target);
|
||||||
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {
|
if ((pc.ntype == NUMTYPE_INT) && (target.ntype == NUMTYPE_INT)) {
|
||||||
|
23
src/output.c
23
src/output.c
@ -454,8 +454,8 @@ void programcounter_set(intval_t new_pc, bits segment_flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// read program counter
|
// get program counter value
|
||||||
void programcounter_read(struct number *target)
|
void programcounter_read_pc(struct number *target)
|
||||||
{
|
{
|
||||||
// check whether ptr undefined
|
// check whether ptr undefined
|
||||||
if (PC_NOT_SET) {
|
if (PC_NOT_SET) {
|
||||||
@ -467,6 +467,25 @@ void programcounter_read(struct number *target)
|
|||||||
target->val.intval = program_counter;
|
target->val.intval = program_counter;
|
||||||
target->addr_refs = 1; // program counter is an address
|
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
|
// get size of current statement (until now) - needed for "!bin" verbose output
|
||||||
|
@ -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.
|
// 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);
|
extern void programcounter_set(intval_t new_pc, bits segment_flags);
|
||||||
|
|
||||||
// get program counter
|
// get program counter value
|
||||||
extern void programcounter_read(struct number *target);
|
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
|
// get size of current statement (until now) - needed for "!bin" verbose output
|
||||||
extern int output_get_statement_size(void);
|
extern int output_get_statement_size(void);
|
||||||
|
@ -651,7 +651,7 @@ static enum eos po_align(void)
|
|||||||
fill = cpu_current_type->default_align_value;
|
fill = cpu_current_type->default_align_value;
|
||||||
|
|
||||||
// make sure PC is defined
|
// make sure PC is defined
|
||||||
programcounter_read(&pc);
|
programcounter_read_pc(&pc);
|
||||||
if (pc.ntype == NUMTYPE_UNDEFINED) {
|
if (pc.ntype == NUMTYPE_UNDEFINED) {
|
||||||
throw_error(exception_pc_undefined);
|
throw_error(exception_pc_undefined);
|
||||||
return SKIP_REMAINDER;
|
return SKIP_REMAINDER;
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#define RELEASE "0.97" // update before release FIXME
|
#define RELEASE "0.97" // update before release FIXME
|
||||||
#define CODENAME "Zem" // update before release
|
#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 CHANGE_YEAR "2024" // update before release
|
||||||
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
//#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/"
|
||||||
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME
|
#define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME
|
||||||
|
2
testing/errors/valuenotdefined7.a
Normal file
2
testing/errors/valuenotdefined7.a
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
undef=* ; -> "Symbol not defined(*)."
|
||||||
|
*=$1000
|
2
testing/errors/valuenotdefined8.a
Normal file
2
testing/errors/valuenotdefined8.a
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
undef ; -> "Symbol not defined (*)."
|
||||||
|
*=$1000
|
Loading…
Reference in New Issue
Block a user