From 7286e0085578014588a51d479f055f6ea6fd0d29 Mon Sep 17 00:00:00 2001 From: marcobaye Date: Fri, 1 May 2020 21:01:23 +0000 Subject: [PATCH] typedef'd boolean to make source more readable. added "--test" option (unused atm). no change in functionality. git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@130 4df02467-bbd4-4a76-a152-e7ce94205b78 --- src/acme.c | 4 ++++ src/alu.c | 2 +- src/alu.h | 4 ++-- src/config.h | 13 ++++++++----- src/flow.c | 2 +- src/flow.h | 6 +++--- src/global.c | 1 + src/global.h | 15 ++++++++------- src/output.c | 2 +- src/pseudoopcodes.c | 6 +++--- src/version.h | 2 +- 11 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/acme.c b/src/acme.c index cf0a045..fcac721 100644 --- a/src/acme.c +++ b/src/acme.c @@ -65,6 +65,7 @@ static const char arg_vicelabels[] = "VICE labels filename"; #define OPTION_FULLSTOP "fullstop" #define OPTION_IGNORE_ZEROES "ignore-zeroes" #define OPTION_STRICT_SEGMENTS "strict-segments" +#define OPTION_TEST "test" // options for "-W" #define OPTIONWNO_LABEL_INDENT "no-label-indent" #define OPTIONWNO_OLD_FOR "no-old-for" @@ -146,6 +147,7 @@ static void show_help_and_exit(void) " --" OPTION_MSVC " output errors in MS VS format\n" " --" OPTION_COLOR " uses ANSI color codes for error output\n" " --" OPTION_FULLSTOP " use '.' as pseudo opcode prefix\n" +" --" OPTION_TEST " enable experimental features\n" PLATFORM_OPTION_HELP " -V, --" OPTION_VERSION " show version and exit\n"); exit(EXIT_SUCCESS); @@ -480,6 +482,8 @@ static const char *long_option(const char *string) config.honor_leading_zeroes = FALSE; else if (strcmp(string, OPTION_STRICT_SEGMENTS) == 0) config.segment_warning_is_error = TRUE; + else if (strcmp(string, OPTION_TEST) == 0) + config.test_new_features = TRUE; PLATFORM_LONGOPTION_CODE else if (strcmp(string, OPTION_COLOR) == 0) config.format_color = TRUE; diff --git a/src/alu.c b/src/alu.c index af03a52..a1cb79e 100644 --- a/src/alu.c +++ b/src/alu.c @@ -609,7 +609,7 @@ static int expect_operand_or_monadic_operator(void) { struct operator *operator; int ugly_length_kluge; - int perform_negation; // actually bool + boolean perform_negation; SKIPSPACE(); switch (GotByte) { diff --git a/src/alu.h b/src/alu.h index 5af1f25..71a2204 100644 --- a/src/alu.h +++ b/src/alu.h @@ -23,9 +23,9 @@ enum expression_type { struct expression { //enum expression_type type; struct number number; - int is_empty; // actually bool: nothing parsed (first character was a delimiter) FIXME - make into its own result type! + boolean is_empty; // nothing parsed (first character was a delimiter) FIXME - make into its own result type! int open_parentheses; // number of parentheses still open - int is_parenthesized; // actually bool: whole expression was in parentheses (indicating indirect addressing) + boolean is_parenthesized; // whole expression was in parentheses (indicating indirect addressing) }; diff --git a/src/config.h b/src/config.h index 359133a..7e75545 100644 --- a/src/config.h +++ b/src/config.h @@ -7,7 +7,15 @@ #define config_H +// make sure the enum below works with strange compilers, too: +#ifdef FALSE +#undef FALSE +#endif +#ifdef TRUE +#undef TRUE +#endif // types +typedef enum { FALSE = 0, TRUE } boolean; // yes, I could include , but this source should work with ancient compilers as well... typedef unsigned int scope_t; typedef signed long intval_t; // at least 32 bits typedef unsigned long uintval_t; // just for logical shift right @@ -37,11 +45,6 @@ struct number { // either int or float #ifndef NULL #define NULL ((void *) 0) #endif -// Boolean values -#ifndef FALSE -#define FALSE 0 -#define TRUE (!FALSE) -#endif #endif diff --git a/src/flow.c b/src/flow.c index 653c8dc..df0796a 100644 --- a/src/flow.c +++ b/src/flow.c @@ -59,7 +59,7 @@ void flow_forloop(struct for_loop *loop) loop_counter.val.intval = loop->counter.first; loop_counter.addr_refs = loop->counter.addr_refs; symbol_set_value(loop->symbol, &loop_counter, TRUE); - if (loop->old_algo) { + if (loop->use_old_algo) { // old algo for old syntax: // if count == 0, skip loop if (loop->counter.last) { diff --git a/src/flow.h b/src/flow.h index cf30b2e..1fd21e7 100644 --- a/src/flow.h +++ b/src/flow.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 // // flow control stuff (loops, conditional assembly etc.) @@ -19,7 +19,7 @@ struct block { // struct to pass "!for" loop stuff from pseudoopcodes.c to flow.c struct for_loop { struct symbol *symbol; - int old_algo; // actually bool + boolean use_old_algo; struct { intval_t first, last, @@ -32,7 +32,7 @@ struct for_loop { // structs to pass "!do" loop stuff from pseudoopcodes.c to flow.c struct loop_condition { int line; // original line number - int is_until; // actually bool (0 for WHILE, 1 for UNTIL) + boolean is_until; // so FALSE means WHILE, TRUE means UNTIL) char *body; // pointer to actual expression }; struct do_loop { diff --git a/src/global.c b/src/global.c index 1eefa15..7bf0e18 100644 --- a/src/global.c +++ b/src/global.c @@ -133,6 +133,7 @@ void config_default(struct config *conf) conf->msg_stream = stderr; // set to stdout by --use-stdout conf->honor_leading_zeroes = TRUE; // disabled by --ignore-zeroes conf->segment_warning_is_error = FALSE; // enabled by --strict-segments TODO - toggle default? + conf->test_new_features = FALSE; // enabled by --test } // memory allocation stuff diff --git a/src/global.h b/src/global.h index 8e51be4..5736c8c 100644 --- a/src/global.h +++ b/src/global.h @@ -67,15 +67,16 @@ extern int pass_real_errors; // Errors yet struct config { char pseudoop_prefix; // '!' or '.' int process_verbosity; // level of additional output - int warn_on_indented_labels; // actually bool: warn if indented label is encountered - int warn_on_old_for; // actually bool: warn if "!for" with old syntax is found - int warn_on_type_mismatch; // actually bool: use type-checking system + boolean warn_on_indented_labels; // warn if indented label is encountered + boolean warn_on_old_for; // warn if "!for" with old syntax is found + boolean warn_on_type_mismatch; // use type-checking system signed long max_errors; // errors before giving up - int format_msvc; // actually bool, enabled by --msvc - int format_color; // actually bool, enabled by --color + boolean format_msvc; // enabled by --msvc + boolean format_color; // enabled by --color FILE *msg_stream; // defaults to stderr, changed to stdout by --use-stdout - int honor_leading_zeroes; // actually bool, TRUE, disabled by --ignore-zeroes - int segment_warning_is_error; // actually bool, FALSE, enabled by --strict-segments + boolean honor_leading_zeroes; // TRUE, disabled by --ignore-zeroes + boolean segment_warning_is_error; // FALSE, enabled by --strict-segments + boolean test_new_features; // FALSE, enabled by --test }; extern struct config config; diff --git a/src/output.c b/src/output.c index 0c034f6..7d7bd0a 100644 --- a/src/output.c +++ b/src/output.c @@ -43,7 +43,7 @@ struct output { intval_t write_idx; // index of next write intval_t lowest_written; // smallest address used intval_t highest_written; // largest address used - int initvalue_set; // actually bool + boolean initvalue_set; struct { intval_t start; // start of current segment (or NO_SEGMENT_START) intval_t max; // highest address segment may use diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index 0f91aa1..4b2b476 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -66,7 +66,7 @@ void notreallypo_setpc(void) read memory limit } else if (strcmp(GlobalDynaBuf->buffer, "name") == 0) { skip '=' - read segment name */ + read segment name (quoted string!) */ } else { Throw_error("Unknown \"* =\" segment modifier."); return; @@ -893,7 +893,7 @@ static enum eos po_for(void) // now GotByte = illegal char ALU_defined_int(&intresult); // read first argument loop.counter.addr_refs = intresult.addr_refs; if (Input_accept_comma()) { - loop.old_algo = FALSE; // new format - yay! + loop.use_old_algo = FALSE; // new format - yay! if (!config.warn_on_old_for) Throw_first_pass_warning("Found new \"!for\" syntax."); loop.counter.first = intresult.val.intval; // use first argument @@ -906,7 +906,7 @@ static enum eos po_for(void) // now GotByte = illegal char } loop.counter.increment = (loop.counter.last < loop.counter.first) ? -1 : 1; } else { - loop.old_algo = TRUE; // old format - booo! + loop.use_old_algo = TRUE; // old format - booo! if (config.warn_on_old_for) Throw_first_pass_warning("Found old \"!for\" syntax."); if (intresult.val.intval < 0) diff --git a/src/version.h b/src/version.h index 694fc62..13a5431 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 Apr" // update before release FIXME +#define CHANGE_DATE "1 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