diff --git a/src/_riscos.h b/src/_riscos.h index 6ccf248..73ec959 100644 --- a/src/_riscos.h +++ b/src/_riscos.h @@ -15,7 +15,7 @@ #define PLATFORM_INIT RISCOS_entry() // convert UNIX-style pathname to RISC OS-style pathname -#define PLATFORM_CONVERTPATH(p) RISCOS_convert_path(p) +#define PLATFORM_CONVERTPATH(path) RISCOS_convert_path(path) // directory separator for include paths #define DIRECTORY_SEPARATOR '\0' // actually '.', but paths ending on ':' are ok, so auto-adding '.' is bad) @@ -66,7 +66,7 @@ extern int RISCOS_flags; // Holds platform-specific flags // used as PLATFORM_INIT: registers exit handler extern void RISCOS_entry(void); // convert UNIX-style pathname to RISC OS-style pathname -extern void RISCOS_convert_path(char *p); +extern void RISCOS_convert_path(char *path); // setting the created files' types extern void RISCOS_set_filetype(const char *, int); // use DDEUtils module's "Throwback" protocol diff --git a/src/alu.c b/src/alu.c index d9d169c..834e7bf 100644 --- a/src/alu.c +++ b/src/alu.c @@ -354,7 +354,7 @@ static void get_symbol_value(scope_t scope, char optional_prefix_char, size_t na symbol = symbol_find(scope, NUMBER_EVER_UNDEFINED); // first push on arg stack, so we have a local copy we can "unpseudopc" arg = &arg_stack[arg_sp++]; - *arg = symbol->result; + *arg = symbol->object; if (unpseudo_count) { if (arg->type == &type_int) { pseudopc_unpseudo(&arg->u.number, symbol->pseudopc, unpseudo_count); @@ -1158,7 +1158,7 @@ static void int_handle_monadic_operator(struct object *self, struct op *op) case OPID_ARCTAN: // convert int to fp and ask fp handler to do the work int_to_float(self); - type_float.handle_monadic_operator(self, op); // TODO - put recursion check around this? + type_float.monadic_op(self, op); // TODO - put recursion check around this? return; // float handler has done everything case OPID_NOT: @@ -1253,7 +1253,7 @@ static void float_handle_monadic_operator(struct object *self, struct op *op) case OPID_BANKBYTEOF: // convert fp to int and ask int handler to do the work float_to_int(self); - type_int.handle_monadic_operator(self, op); // TODO - put recursion check around this? + type_int.monadic_op(self, op); // TODO - put recursion check around this? return; // int handler has done everything // add new monadic operators here @@ -1341,7 +1341,7 @@ static void int_handle_dyadic_operator(struct object *self, struct op *op, struc case OPID_NOTEQUAL: // become float, delegate to float handler int_to_float(self); - type_float.handle_dyadic_operator(self, op, other); // TODO - put recursion check around this? + type_float.dyadic_op(self, op, other); // TODO - put recursion check around this? return; // float handler has done everything case OPID_MODULO: @@ -1560,7 +1560,7 @@ static void float_handle_dyadic_operator(struct object *self, struct op *op, str case OPID_MODULO: float_to_int(self); // int handler will check other and, if needed, convert to int - type_int.handle_dyadic_operator(self, op, other); // TODO - put recursion check around this? + type_int.dyadic_op(self, op, other); // TODO - put recursion check around this? return; // int handler has done everything case OPID_ADD: @@ -2001,14 +2001,14 @@ static void try_to_reduce_stacks(struct expression *expression) case OPGROUP_MONADIC: // monadic operators if (arg_sp < 1) Bug_found("ArgStackEmpty", arg_sp); - ARG_NOW.type->handle_monadic_operator(&ARG_NOW, previous_op); + ARG_NOW.type->monadic_op(&ARG_NOW, previous_op); // operation was something other than parentheses expression->is_parenthesized = FALSE; break; case OPGROUP_DYADIC: // dyadic operators if (arg_sp < 2) Bug_found("NotEnoughArgs", arg_sp); - ARG_PREV.type->handle_dyadic_operator(&ARG_PREV, previous_op, &ARG_NOW); + ARG_PREV.type->dyadic_op(&ARG_PREV, previous_op, &ARG_NOW); // decrement argument stack pointer because dyadic operator merged two arguments into one --arg_sp; // operation was something other than parentheses diff --git a/src/alu.h b/src/alu.h index 9545221..bb9661d 100644 --- a/src/alu.h +++ b/src/alu.h @@ -15,8 +15,8 @@ struct dynabuf; struct type { const char *name; boolean (*is_defined)(struct object *self); - void (*handle_monadic_operator)(struct object *self, struct op *op); - void (*handle_dyadic_operator)(struct object *self, struct op *op, struct object *other); + void (*monadic_op)(struct object *self, struct op *op); + void (*dyadic_op)(struct object *self, struct op *op, struct object *other); void (*fix_result)(struct object *self); void (*print)(struct object *self, struct dynabuf *db); }; diff --git a/src/config.h b/src/config.h index c820adc..e8d9c3f 100644 --- a/src/config.h +++ b/src/config.h @@ -29,17 +29,17 @@ struct number { } val; int addr_refs; // address reference count (only look at this if value is DEFINED) }; -// structure for ints/floats/lists/strings (TODO) + struct type; struct string; struct listitem; +// structure for ints/floats/lists/strings (anything that can be assigned to symbol) struct object { struct type *type; union { struct number number; struct string *string; struct listitem *listhead; - // TODO - add string struct } u; }; struct string { diff --git a/src/global.h b/src/global.h index 0f3e03b..e656312 100644 --- a/src/global.h +++ b/src/global.h @@ -125,7 +125,7 @@ do { \ // set configuration to default values extern void config_default(struct config *conf); // allocate memory and die if not available -extern void *safe_malloc(size_t); +extern void *safe_malloc(size_t amount); // Parse block, beginning with next byte. // End reason (either CHAR_EOB or CHAR_EOF) can be found in GotByte afterwards // Has to be re-entrant. @@ -140,22 +140,22 @@ extern int Throw_get_counter(void); // This means the produced code looks as expected. But there has been a // situation that should be reported to the user, for example ACME may have // assembled a 16-bit parameter with an 8-bit value. -extern void Throw_warning(const char *); +extern void Throw_warning(const char *msg); // Output a warning if in first pass. See above. -extern void Throw_first_pass_warning(const char *); +extern void Throw_first_pass_warning(const char *msg); // Output an error. // This means something went wrong in a way that implies that the output // almost for sure won't look like expected, for example when there was a // syntax error. The assembler will try to go on with the assembly though, so // the user gets to know about more than one of his typos at a time. -extern void Throw_error(const char *); +extern void Throw_error(const char *msg); // Output a serious error, stopping assembly. // Serious errors are those that make it impossible to go on with the // assembly. Example: "!fill" without a parameter - the program counter cannot // be set correctly in this case, so proceeding would be of no use at all. -extern void Throw_serious_error(const char *); +extern void Throw_serious_error(const char *msg); // handle bugs -extern void Bug_found(const char *, int); +extern void Bug_found(const char *msg, int code); #endif diff --git a/src/macro.c b/src/macro.c index 26ec013..f92e319 100644 --- a/src/macro.c +++ b/src/macro.c @@ -330,7 +330,7 @@ void Macro_parse_call(void) // Now GotByte = dot or first char of macro name // FIXME - add a possibility to symbol_find to make it possible to find out // whether symbol was just created. Then check for the same error message here // as above ("Macro parameter twice."). - symbol->result = arg_table[arg_count].result; + symbol->object = arg_table[arg_count].result; } ++arg_count; } while (Input_accept_comma()); diff --git a/src/output.h b/src/output.h index 845a6f0..0ed83b0 100644 --- a/src/output.h +++ b/src/output.h @@ -57,19 +57,19 @@ extern int output_initmem(char content); // move elsewhere: // Output 8-bit value with range check -extern void output_8(intval_t); +extern void output_8(intval_t value); // Output 16-bit value with range check big-endian -extern void output_be16(intval_t); +extern void output_be16(intval_t value); // Output 16-bit value with range check little-endian -extern void output_le16(intval_t); +extern void output_le16(intval_t value); // Output 24-bit value with range check big-endian -extern void output_be24(intval_t); +extern void output_be24(intval_t value); // Output 24-bit value with range check little-endian -extern void output_le24(intval_t); +extern void output_le24(intval_t value); // Output 32-bit value (without range check) big-endian -extern void output_be32(intval_t); +extern void output_be32(intval_t value); // Output 32-bit value (without range check) little-endian -extern void output_le32(intval_t); +extern void output_le32(intval_t value); // outfile stuff: diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index 41cd6c4..7cdc3f4 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -735,11 +735,11 @@ static enum eos po_set(void) // now GotByte = illegal char ALU_any_result(&result); // clear symbol's force bits and set new ones // (but only do this for numbers!) - if (((symbol->result.type == &type_int) || (symbol->result.type == &type_float)) + if (((symbol->object.type == &type_int) || (symbol->object.type == &type_float)) && ((result.type == &type_int) || (result.type == &type_float))) { - symbol->result.u.number.flags &= ~(NUMBER_FORCEBITS | NUMBER_FITS_BYTE); + symbol->object.u.number.flags &= ~(NUMBER_FORCEBITS | NUMBER_FITS_BYTE); if (force_bit) { - symbol->result.u.number.flags |= force_bit; + symbol->object.u.number.flags |= force_bit; result.u.number.flags &= ~(NUMBER_FORCEBITS | NUMBER_FITS_BYTE); } } @@ -843,6 +843,7 @@ static enum eos po_source(void) // now GotByte = illegal char // if file could be opened, parse it. otherwise, complain stream = includepaths_open_ro(uses_lib); if (stream) { +// FIXME - just use safe_malloc and never free! this also saves us making a copy if defining macros down the road... #ifdef __GNUC__ char filename[GlobalDynaBuf->size]; // GCC can do this #else @@ -885,7 +886,7 @@ static boolean check_ifdef_condition(void) // in first pass, count usage if (FIRST_PASS) symbol->usage++; - return symbol->result.type->is_defined(&symbol->result); + return symbol->object.type->is_defined(&symbol->object); } // new if/ifdef/ifndef/else function, to be able to do ELSE IF enum ifmode { diff --git a/src/pseudoopcodes.h b/src/pseudoopcodes.h index 7b6047e..f18580f 100644 --- a/src/pseudoopcodes.h +++ b/src/pseudoopcodes.h @@ -1,5 +1,5 @@ // ACME - a crossassembler for producing 6502/65c02/65816/65ce02 code. -// Copyright (C) 1998-2016 Marco Baye +// Copyright (C) 1998-2020 Marco Baye // Have a look at "acme.c" for further info // // pseudo opcode stuff @@ -7,7 +7,7 @@ #define pseudoopcodes_H -// call when "* = EXPRESSION" is parsed +// call when "*= EXPRESSION" is parsed extern void notreallypo_setpc(void); // register pseudo opcodes extern void pseudoopcodes_init(void); diff --git a/src/symbol.c b/src/symbol.c index c4a4f1d..9535d02 100644 --- a/src/symbol.c +++ b/src/symbol.c @@ -31,16 +31,16 @@ static void dump_one_symbol(struct rwnode *node, FILE *fd) struct symbol *symbol = node->body; // if symbol is neither int nor float, skip - if ((symbol->result.type != &type_int) - && (symbol->result.type != &type_float)) + if ((symbol->object.type != &type_int) + && (symbol->object.type != &type_float)) return; // output name if (config.warn_on_type_mismatch - && symbol->result.u.number.addr_refs == 1) + && symbol->object.u.number.addr_refs == 1) fprintf(fd, "!addr"); fprintf(fd, "\t%s", node->id_string); - switch (symbol->result.u.number.flags & NUMBER_FORCEBITS) { + switch (symbol->object.u.number.flags & NUMBER_FORCEBITS) { case NUMBER_FORCES_16: fprintf(fd, "+2\t= "); break; @@ -52,17 +52,17 @@ static void dump_one_symbol(struct rwnode *node, FILE *fd) default: fprintf(fd, "\t= "); } - if (symbol->result.u.number.flags & NUMBER_IS_DEFINED) { - if (symbol->result.type == &type_int) - fprintf(fd, "$%x", (unsigned) symbol->result.u.number.val.intval); - else if (symbol->result.type == &type_float) - fprintf(fd, "%.30f", symbol->result.u.number.val.fpval); //FIXME %g + if (symbol->object.u.number.flags & NUMBER_IS_DEFINED) { + if (symbol->object.type == &type_int) + fprintf(fd, "$%x", (unsigned) symbol->object.u.number.val.intval); + else if (symbol->object.type == &type_float) + fprintf(fd, "%.30f", symbol->object.u.number.val.fpval); //FIXME %g else Bug_found("BogusType", 0); // FIXME - put in docs! } else { fprintf(fd, " ?"); // TODO - maybe write "UNDEFINED" instead? then the file could at least be parsed without errors } - if (symbol->result.u.number.flags & NUMBER_EVER_UNDEFINED) + if (symbol->object.u.number.flags & NUMBER_EVER_UNDEFINED) fprintf(fd, "\t; ?"); // TODO - write "forward" instead? if (symbol->usage == 0) fprintf(fd, "\t; unused"); @@ -76,10 +76,10 @@ static void dump_vice_address(struct rwnode *node, FILE *fd) struct symbol *symbol = node->body; // dump address symbols even if they are not used - if ((symbol->result.type == &type_int) - && (symbol->result.u.number.flags & NUMBER_IS_DEFINED) - && (symbol->result.u.number.addr_refs == 1)) - fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->result.u.number.val.intval, node->id_string); + if ((symbol->object.type == &type_int) + && (symbol->object.u.number.flags & NUMBER_IS_DEFINED) + && (symbol->object.u.number.addr_refs == 1)) + fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->object.u.number.val.intval, node->id_string); } static void dump_vice_usednonaddress(struct rwnode *node, FILE *fd) { @@ -87,10 +87,10 @@ static void dump_vice_usednonaddress(struct rwnode *node, FILE *fd) // dump non-addresses that are used if (symbol->usage - && (symbol->result.type == &type_int) - && (symbol->result.u.number.flags & NUMBER_IS_DEFINED) - && (symbol->result.u.number.addr_refs != 1)) - fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->result.u.number.val.intval, node->id_string); + && (symbol->object.type == &type_int) + && (symbol->object.u.number.flags & NUMBER_IS_DEFINED) + && (symbol->object.u.number.addr_refs != 1)) + fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->object.u.number.val.intval, node->id_string); } static void dump_vice_unusednonaddress(struct rwnode *node, FILE *fd) { @@ -98,10 +98,10 @@ static void dump_vice_unusednonaddress(struct rwnode *node, FILE *fd) // dump non-addresses that are unused if (!symbol->usage - && (symbol->result.type == &type_int) - && (symbol->result.u.number.flags & NUMBER_IS_DEFINED) - && (symbol->result.u.number.addr_refs != 1)) - fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->result.u.number.val.intval, node->id_string); + && (symbol->object.type == &type_int) + && (symbol->object.u.number.flags & NUMBER_IS_DEFINED) + && (symbol->object.u.number.addr_refs != 1)) + fprintf(fd, "al C:%04x .%s\n", (unsigned) symbol->object.u.number.val.intval, node->id_string); } @@ -120,10 +120,10 @@ struct symbol *symbol_find(scope_t scope, int flags) // create new symbol structure symbol = safe_malloc(sizeof(*symbol)); // finish empty symbol item - symbol->result.type = &type_int; - symbol->result.u.number.flags = flags; - symbol->result.u.number.addr_refs = 0; - symbol->result.u.number.val.intval = 0; + symbol->object.type = &type_int; + symbol->object.u.number.flags = flags; + symbol->object.u.number.addr_refs = 0; + symbol->object.u.number.val.intval = 0; symbol->usage = 0; // usage count symbol->pass = pass.number; symbol->has_been_reported = FALSE; @@ -132,11 +132,11 @@ struct symbol *symbol_find(scope_t scope, int flags) } else { symbol = node->body; // make sure the force bits don't clash - if ((symbol->result.type == &type_int) - || (symbol->result.type == &type_float)) { + if ((symbol->object.type == &type_int) + || (symbol->object.type == &type_float)) { new_force_bits = flags & NUMBER_FORCEBITS; if (new_force_bits) - if ((symbol->result.u.number.flags & NUMBER_FORCEBITS) != new_force_bits) + if ((symbol->object.u.number.flags & NUMBER_FORCEBITS) != new_force_bits) Throw_error("Too late for postfix."); } } @@ -151,11 +151,11 @@ void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean int flags; // for int/float re-definitions // any new type? - if (((symbol->result.type != &type_int) && (symbol->result.type != &type_float)) + if (((symbol->object.type != &type_int) && (symbol->object.type != &type_float)) || ((new_value->type != &type_int) && (new_value->type != &type_float))) { // changing value is ok, changing type needs extra flag: - if (change_allowed || (symbol->result.type == new_value->type)) - symbol->result = *new_value; + if (change_allowed || (symbol->object.type == new_value->type)) + symbol->object = *new_value; else Throw_error("Symbol already defined."); return; @@ -164,15 +164,15 @@ void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean // both old and new are either int or float, so keep old algo: // value stuff - flags = symbol->result.u.number.flags; + flags = symbol->object.u.number.flags; if (change_allowed || !(flags & NUMBER_IS_DEFINED)) { // symbol is not defined yet OR redefinitions are allowed - symbol->result = *new_value; + symbol->object = *new_value; } else { // symbol is already defined, so compare new and old values // if different type OR same type but different value, complain - if ((symbol->result.type != new_value->type) - || ((symbol->result.type == &type_float) ? (symbol->result.u.number.val.fpval != new_value->u.number.val.fpval) : (symbol->result.u.number.val.intval != new_value->u.number.val.intval))) + if ((symbol->object.type != new_value->type) + || ((symbol->object.type == &type_float) ? (symbol->object.u.number.val.fpval != new_value->u.number.val.fpval) : (symbol->object.u.number.val.intval != new_value->u.number.val.intval))) Throw_error("Symbol already defined."); } // flags stuff @@ -189,7 +189,7 @@ void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean flags |= new_value->u.number.flags & NUMBER_FORCEBITS; flags |= new_value->u.number.flags & ~NUMBER_FORCEBITS; } - symbol->result.u.number.flags = flags; + symbol->object.u.number.flags = flags; } @@ -302,14 +302,14 @@ void symbol_fix_forward_anon_name(boolean increment) DynaBuf_append(GlobalDynaBuf, '\0'); counter_symbol = symbol_find(section_now->local_scope, 0); // sanity check: it must be an int! - if (counter_symbol->result.type != &type_int) + if (counter_symbol->object.type != &type_int) Bug_found("ForwardAnonCounterNotInt", 0); // make sure it gets reset to zero in each new pass if (counter_symbol->pass != pass.number) { counter_symbol->pass = pass.number; - counter_symbol->result.u.number.val.intval = 0; + counter_symbol->object.u.number.val.intval = 0; } - number = (unsigned long) counter_symbol->result.u.number.val.intval; + number = (unsigned long) counter_symbol->object.u.number.val.intval; // now append to the name to make it unique GlobalDynaBuf->size--; // forget terminator, we want to append do { @@ -318,5 +318,5 @@ void symbol_fix_forward_anon_name(boolean increment) } while (number); DynaBuf_append(GlobalDynaBuf, '\0'); if (increment) - counter_symbol->result.u.number.val.intval++; + counter_symbol->object.u.number.val.intval++; } diff --git a/src/symbol.h b/src/symbol.h index db62570..bc5d506 100644 --- a/src/symbol.h +++ b/src/symbol.h @@ -12,11 +12,11 @@ struct symbol { - struct object result; // flags, value, address refs + struct object object; // number/list/string int usage; // usage count int pass; // pass of creation (for anon counters) boolean has_been_reported; // indicates "has been reported as undefined" - struct pseudopc *pseudopc; + struct pseudopc *pseudopc; // NULL when defined outside of !pseudopc block // add file ref + line num of last definition }; @@ -30,7 +30,7 @@ extern struct rwnode *symbols_forest[]; // trees (because of 8-bit hash) // function acts upon the symbol's flag bits and produces an error if needed. -extern void symbol_set_object(struct symbol *symbol, struct object *new_value, boolean change_allowed); +extern void symbol_set_object(struct symbol *symbol, struct object *new_obj, boolean change_allowed); // parse label definition (can be either global or local). // name must be held in GlobalDynaBuf. extern void symbol_set_label(scope_t scope, int stat_flags, int force_bit, boolean change_allowed); diff --git a/src/version.h b/src/version.h index 0b14963..ccd4163 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ #define RELEASE "0.96.5" // update before release FIXME #define CODENAME "Fenchurch" // update before release -#define CHANGE_DATE "28 May" // update before release FIXME +#define CHANGE_DATE "29 May" // update before release FIXME #define CHANGE_YEAR "2020" // update before release //#define HOME_PAGE "http://home.pages.de/~mac_bacon/smorbrod/acme/" #define HOME_PAGE "http://sourceforge.net/p/acme-crossass/" // FIXME