changed some longs to ints because using 64 bits is overkill

git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@368 4df02467-bbd4-4a76-a152-e7ce94205b78
This commit is contained in:
marcobaye 2024-03-19 15:30:57 +00:00
parent 242cdad5be
commit 5179714785
8 changed files with 25 additions and 20 deletions

View File

@ -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)

View File

@ -18,13 +18,12 @@
typedef enum { FALSE = 0, TRUE } boolean; // yes, I could include <stdbool.h>, 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;
};

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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);
}

View File

@ -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;

View File

@ -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