diff --git a/src/global.c b/src/global.c index 11cbbd5..a62eeb6 100644 --- a/src/global.c +++ b/src/global.c @@ -262,7 +262,7 @@ static void parse_symbol_definition(scope_t scope) if (GotByte == '?') symbol_fix_dynamic_name(); - force_bit = input_get_force_bit(); // skips spaces after (yes, force bit is allowed for label definitions) + force_bit = parser_get_force_bit(); // skips spaces after (yes, force bit is allowed for label definitions) if (GotByte == '=') { // explicit symbol definition (symbol = ) GetByte(); // eat '=' @@ -457,6 +457,29 @@ void parse_and_close_platform_file(FILE *fd, const char *eternal_plat_filename) inputchange_back(&icb); } +// read optional info about parameter length +bits parser_get_force_bit(void) +{ + char byte; + bits force_bit = 0; + + if (GotByte == '+') { + byte = GetByte(); + if (byte == '1') + force_bit = NUMBER_FORCES_8; + else if (byte == '2') + force_bit = NUMBER_FORCES_16; + else if (byte == '3') + force_bit = NUMBER_FORCES_24; + if (force_bit) + GetByte(); + else + Throw_error("Illegal postfix."); + } + SKIPSPACE(); + return force_bit; +} + // Error handling diff --git a/src/global.h b/src/global.h index d2fad49..5c0e1e1 100644 --- a/src/global.h +++ b/src/global.h @@ -197,6 +197,9 @@ extern int parse_optional_block(void); // and the pointer must remain valid forever! extern void parse_and_close_platform_file(FILE *fd, const char *eternal_plat_filename); +// read optional info about parameter length +extern bits parser_get_force_bit(void); + // generate a debug/info/warning/error message extern void throw_message(enum debuglevel level, const char msg[]); diff --git a/src/input.c b/src/input.c index f9ec04f..cea24e5 100644 --- a/src/input.c +++ b/src/input.c @@ -732,30 +732,6 @@ int input_expect(int chr) return FALSE; } -// read optional info about parameter length -// FIXME - move to different file! -bits input_get_force_bit(void) -{ - char byte; - bits force_bit = 0; - - if (GotByte == '+') { - byte = GetByte(); - if (byte == '1') - force_bit = NUMBER_FORCES_8; - else if (byte == '2') - force_bit = NUMBER_FORCES_16; - else if (byte == '3') - force_bit = NUMBER_FORCES_24; - if (force_bit) - GetByte(); - else - Throw_error("Illegal postfix."); - } - SKIPSPACE(); - return force_bit; -} - // force input system to return "end of file" on next read // (back end function for "!eof" pseudo opcode) void input_force_eof(void) diff --git a/src/input.h b/src/input.h index 1af616a..3265fc1 100644 --- a/src/input.h +++ b/src/input.h @@ -141,10 +141,6 @@ extern int input_accept_comma(void); // If not found, throw syntax error and return FALSE. extern int input_expect(int chr); -// read optional info about parameter length -// FIXME - move to different file! -extern bits input_get_force_bit(void); - // force input system to return "end of file" on next read // (back end function for "!eof" pseudo opcode) extern void input_force_eof(void); diff --git a/src/mnemo.c b/src/mnemo.c index b9c4c60..1e10dc2 100644 --- a/src/mnemo.c +++ b/src/mnemo.c @@ -773,7 +773,7 @@ static bits calc_arg_size(bits force_bit, struct number *argument, bits addressi // Mnemonics using only implied addressing. static void group_only_implied_addressing(int opcode) { - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? // TODO - accept argument and complain about it? error message should tell more than "garbage data at end of line"! // for 65ce02 and 4502, warn about buggy decimal mode if ((opcode == 0xf8) && (cpu_current_type->flags & CPUFLAG_DECIMALSUBTRACTBUGGY)) { @@ -926,7 +926,7 @@ static void group_main(int index, bits flags) { unsigned long immediate_opcodes; struct number result; - bits force_bit = input_get_force_bit(); // skips spaces after + bits force_bit = parser_get_force_bit(); // skips spaces after switch (get_addr_mode(&result)) { case IMMEDIATE_ADDRESSING: // #$ff or #$ffff (depending on accu length) @@ -990,7 +990,7 @@ static void group_misc(int index, bits immediate_mode) { unsigned long immediate_opcodes; struct number result; - bits force_bit = input_get_force_bit(); // skips spaces after + bits force_bit = parser_get_force_bit(); // skips spaces after switch (get_addr_mode(&result)) { case IMPLIED_ADDRESSING: // implied addressing @@ -1031,7 +1031,7 @@ static void group_misc(int index, bits immediate_mode) // mnemonics using only 8bit relative addressing (short branch instructions). static void group_std_branches(int opcode) { - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? output_byte(opcode); near_branch(2); } @@ -1040,7 +1040,7 @@ static void group_std_branches(int opcode) static void group_bbr_bbs(int opcode) { struct number zpmem; - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? get_int_arg(&zpmem, TRUE); typesystem_want_addr(&zpmem); @@ -1054,7 +1054,7 @@ static void group_bbr_bbs(int opcode) // mnemonics using only 16bit relative addressing (BRL and PER of 65816, and the long branches of 65ce02) static void group_relative16(int opcode, int preoffset) { - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? output_byte(opcode); far_branch(preoffset); } @@ -1066,7 +1066,7 @@ static void group_mvn_mvp(int opcode) boolean unmatched_hash = FALSE; struct number source, target; - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? // assembler syntax: "mnemonic source, target" or "mnemonic #source, #target" // machine language order: "opcode target source" @@ -1103,7 +1103,7 @@ static void group_mvn_mvp(int opcode) // "rmb0..7" and "smb0..7" static void group_only_zp(int opcode) { - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? struct number target; get_int_arg(&target, TRUE); @@ -1116,7 +1116,7 @@ static void group_only_zp(int opcode) // NOP on m65 cpu (FIXME - "!align" outputs NOPs, what about that? what if user writes NEG:NEG?) static void group_prefix(int opcode) { - //bits force_bit = input_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? + //bits force_bit = parser_get_force_bit(); // skips spaces after // TODO - accept postfix and complain about it? char buffer[100]; // 640K should be enough for anybody sprintf(buffer, "The chosen CPU uses opcode 0x%02x as a prefix code, do not use this mnemonic!", opcode); @@ -1127,7 +1127,7 @@ static void group_prefix(int opcode) static void group_jump(int index) { struct number result; - bits force_bit = input_get_force_bit(); // skips spaces after + bits force_bit = parser_get_force_bit(); // skips spaces after switch (get_addr_mode(&result)) { case ABSOLUTE_ADDRESSING: // absolute16 or absolute24 diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index 6364dbf..7d76834 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -826,7 +826,7 @@ static enum eos po_set(void) // now GotByte = illegal char if (input_read_scope_and_symbol_name(&scope)) // skips spaces before return SKIP_REMAINDER; // zero length - force_bit = input_get_force_bit(); // skips spaces after + force_bit = parser_get_force_bit(); // skips spaces after if (!input_expect('=')) return SKIP_REMAINDER; @@ -1058,7 +1058,7 @@ static enum eos po_for(void) // now GotByte = illegal char return SKIP_REMAINDER; // zero length // now GotByte = illegal char - force_bit = input_get_force_bit(); // skips spaces after + force_bit = parser_get_force_bit(); // skips spaces after loop.symbol = symbol_find(scope); // if not number, error will be reported on first assignment if (input_accept_comma()) { // counter syntax (old or new) diff --git a/src/version.h b/src/version.h index d175ce1..eca39ac 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 "20 Jul" // update before release FIXME +#define CHANGE_DATE "21 Jul" // 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