diff --git a/src/acme.c b/src/acme.c index c63466e..5437157 100644 --- a/src/acme.c +++ b/src/acme.c @@ -251,7 +251,7 @@ static void save_output_file(void) break; case OUTFILE_FORMAT_CBM: if (loadaddr > 0xffff) { - fprintf(stderr, "Error: Load address 0x%04lx too large for cbm file format.\n", loadaddr); + fprintf(stderr, "Error: Load address 0x%04x too large for cbm file format.\n", loadaddr); exit(ACME_finalize(EXIT_FAILURE)); } header[0] = loadaddr & 255; @@ -260,11 +260,11 @@ static void save_output_file(void) break; case OUTFILE_FORMAT_APPLE: if (loadaddr > 0xffff) { - fprintf(stderr, "Error: Load address 0x%04lx too large for apple file format.\n", loadaddr); + fprintf(stderr, "Error: Load address 0x%04x too large for apple file format.\n", loadaddr); exit(ACME_finalize(EXIT_FAILURE)); } if (amount > 0xffff) { - fprintf(stderr, "Error: File size 0x%04lx too large for apple file format.\n", loadaddr); + fprintf(stderr, "Error: File size 0x%04x too large for apple file format.\n", loadaddr); exit(ACME_finalize(EXIT_FAILURE)); } header[0] = loadaddr & 255; @@ -285,7 +285,7 @@ static void save_output_file(void) } if (config.process_verbosity >= 1) { - printf("Saving %ld (0x%04lx) bytes (0x%04lx - 0x%04lx exclusive).\n", + printf("Saving %d (0x%04x) bytes (0x%04x - 0x%04x exclusive).\n", amount, amount, loadaddr, loadaddr + amount); } @@ -746,6 +746,13 @@ done: // guess what int main(int argc, const char *argv[]) { + // make sure that if someone compiles this for ancient platforms + // they edit config.h accordingly: + // (on modern compilers this block will be optimized away anyway) + if ((sizeof(intval_t) < 4) || (sizeof(uintval_t) < 4)) { + fprintf(stderr, "Error: typedefs for intval_t and uintval_t must use types with at least 32 bits.\nPlease edit config.h and recompile.\n"); + exit(EXIT_FAILURE); + } config_default(&config); // if called without any arguments, show usage info (not full help) if (argc == 1) diff --git a/src/config.h b/src/config.h index f4838f3..a3ba3f0 100644 --- a/src/config.h +++ b/src/config.h @@ -18,13 +18,12 @@ typedef enum { FALSE = 0, TRUE } boolean; // yes, I could include , but this source should work with ancient compilers as well... typedef unsigned int bits; typedef unsigned int scope_t; -typedef signed long intval_t; // at least 32 bits -typedef unsigned long uintval_t; // just for logical shift right +typedef signed int intval_t; // at least 32 bits +typedef unsigned int uintval_t; // at least 32 bits (only used for logical shift right) // struct to remember where macros were defined (FIXME - use for symbols as well!) struct location { const char *plat_filename; // filename in platform style - // FIXME - add another field for filename in UNIX style? might be needed when fixing directory search order! int line_number; }; diff --git a/src/global.c b/src/global.c index f277752..bbeb04a 100644 --- a/src/global.c +++ b/src/global.c @@ -131,7 +131,7 @@ void config_default(struct config *conf) conf->output_filename = NULL; conf->outfile_format = OUTFILE_FORMAT_UNSPECIFIED; conf->report_filename = NULL; - conf->mem_init_value = MEMINIT_USE_DEFAULT; // set by --initmem + conf->mem_init_value = NO_VALUE_GIVEN; // set by --initmem conf->initial_pc = NO_VALUE_GIVEN; // set by --setpc conf->outfile_start = NO_VALUE_GIVEN; // set by --from-to conf->outfile_limit = NO_VALUE_GIVEN; // end+1, set by --from-to diff --git a/src/global.h b/src/global.h index a1e1103..17c98af 100644 --- a/src/global.h +++ b/src/global.h @@ -91,20 +91,19 @@ struct config { boolean all_warnings_are_errors; // FALSE, enabled by --strict boolean test_new_features; // FALSE, enabled by --test enum dialect dialect; // set by --dialect (and --test --test) - signed long debuglevel; // set by --debuglevel, used by "!debug" - signed long outbuf_size; // 64K, "--test" changes to 16M + int debuglevel; // set by --debuglevel, used by "!debug" + intval_t outbuf_size; // 64K, "--test" changes to 16M const struct cpu_type *initial_cpu_type; const char *symbollist_filename; const char *vicelabels_filename; const char *output_filename; // TODO - put in "part" struct enum outfile_format outfile_format; const char *report_filename; // TODO - put in "part" struct -#define MEMINIT_USE_DEFAULT 256 // default value for next field if cli switch not used: - signed long mem_init_value; // set by --initmem #define NO_VALUE_GIVEN (-1) // default value for these fields if cli switch not used: - signed long initial_pc; // set by --setpc - signed long outfile_start; // set by --from-to - signed long outfile_limit; // end+1, set by --from-to + int mem_init_value; // set by --initmem + intval_t initial_pc; // set by --setpc + intval_t outfile_start; // set by --from-to + intval_t outfile_limit; // end+1, set by --from-to }; extern struct config config; diff --git a/src/mnemo.c b/src/mnemo.c index 7730d28..3934d5f 100644 --- a/src/mnemo.c +++ b/src/mnemo.c @@ -84,7 +84,7 @@ enum mnemogroup { // save some space #define SCB static const unsigned char #define SCS static const unsigned short -#define SCL static const unsigned long +#define SCL static const intval_t // if we ever need 32 bits instead of 24, change to uintval_t! // Code tables for group GROUP_ACCU: // These tables are used for the main accumulator-related mnemonics. By reading diff --git a/src/output.c b/src/output.c index fe1ba76..de03d80 100644 --- a/src/output.c +++ b/src/output.c @@ -241,7 +241,7 @@ void output_createbuffer(void) char fill_value = 0; // default value for output buffer out->buffer = safe_malloc(config.outbuf_size); - if (config.mem_init_value == MEMINIT_USE_DEFAULT) { + if (config.mem_init_value == NO_VALUE_GIVEN) { out->initvalue_set = FALSE; // "!initmem" can be used } else { out->initvalue_set = TRUE; // "!initmem" generates a warning @@ -381,7 +381,7 @@ static void end_segment(void) if (config.process_verbosity >= 2) // TODO - change output to start, limit, size, name: // TODO - output hex numbers as %04x? What about limit 0x10000? - printf("Segment size is %ld (0x%lx) bytes (0x%lx - 0x%lx exclusive).\n", + printf("Segment size is %d (0x%x) bytes (0x%x - 0x%x exclusive).\n", amount, amount, out->segment.start, out->write_idx); } diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index bd97c5b..5d913de 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -607,7 +607,7 @@ static enum eos po_binary(void) if ((pass.number == 1) && (config.process_verbosity >= 2)) { int amount = output_get_statement_size(); - printf("Loaded %d (0x%04x) bytes from file offset %ld (0x%04lx).\n", + printf("Loaded %d (0x%04x) bytes from file offset %d (0x%04x).\n", amount, amount, skip.val.intval, skip.val.intval); } return ENSURE_EOS; diff --git a/src/version.h b/src/version.h index d25da19..5617e85 100644 --- a/src/version.h +++ b/src/version.h @@ -9,7 +9,7 @@ #define RELEASE "0.97" // update before release FIXME #define CODENAME "Zem" // update before release -#define CHANGE_DATE "10 Mar" // update before release FIXME +#define CHANGE_DATE "11 Mar" // 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