From c03d1145f6fceea13b12a7211bf25d9f6bf61bda Mon Sep 17 00:00:00 2001 From: marcobaye Date: Sun, 31 May 2020 13:07:40 +0000 Subject: [PATCH] made warning about "pointer at $ff" depend on cpu flag git-svn-id: https://svn.code.sf.net/p/acme-crossass/code-0/trunk@205 4df02467-bbd4-4a76-a152-e7ce94205b78 --- docs/Errors.txt | 2 +- src/cpu.c | 13 +++++++------ src/cpu.h | 2 +- src/mnemo.c | 5 +++-- src/output.c | 6 +++--- src/pseudoopcodes.c | 4 ++-- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/Errors.txt b/docs/Errors.txt index 0605fe9..013df7f 100644 --- a/docs/Errors.txt +++ b/docs/Errors.txt @@ -373,7 +373,7 @@ Unknown processor. Unknown pseudo opcode. You have mistyped a "!" command. -Unknown "* =" segment modifier. +Unknown "*=" segment modifier. You used a modifier keyword ACME does not know. Unterminated index spec. diff --git a/src/cpu.c b/src/cpu.c index 2a4c795..19fcd57 100644 --- a/src/cpu.c +++ b/src/cpu.c @@ -17,36 +17,37 @@ // constants static struct cpu_type cpu_type_6502 = { keyword_is_6502_mnemo, - CPUFLAG_INDIRECTJMPBUGGY, // JMP ($xxFF) is buggy + CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY, // warn about "XYZ ($ff),y" and "jmp ($XYff)" 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_nmos6502 = { keyword_is_nmos6502_mnemo, - CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, // JMP ($xxFF) is buggy, ANE/LXA #$xx are unstable unless arg is $00 + CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, // ANE/LXA #$xx are unstable unless arg is $00 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_c64dtv2 = { keyword_is_c64dtv2_mnemo, - CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, // JMP ($xxFF) is buggy, ANE/LXA #$xx are unstable unless arg is $00 + CPUFLAG_WARN_ABOUT_FF_PTR | CPUFLAG_INDIRECTJMPBUGGY | CPUFLAG_8B_AND_AB_NEED_0_ARG, 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_65c02 = { keyword_is_65c02_mnemo, - 0, // no flags + CPUFLAG_WARN_ABOUT_FF_PTR, // TODO - remove this? check datasheets/realhw! 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_r65c02 = { keyword_is_r65c02_mnemo, - 0, // no flags + CPUFLAG_WARN_ABOUT_FF_PTR, // TODO - remove this? check datasheets/realhw! 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_w65c02 = { keyword_is_w65c02_mnemo, - 0, // no flags + CPUFLAG_WARN_ABOUT_FF_PTR, // TODO - remove this? check datasheets/realhw! 234 // !align fills with "NOP" }; static struct cpu_type cpu_type_65816 = { keyword_is_65816_mnemo, + // TODO - what about CPUFLAG_WARN_ABOUT_FF_PTR? does this depend on native/emulation mode? CPUFLAG_SUPPORTSLONGREGS, // allows A and XY to be 16bits wide 234 // !align fills with "NOP" }; diff --git a/src/cpu.h b/src/cpu.h index cb4b28d..396eaea 100644 --- a/src/cpu.h +++ b/src/cpu.h @@ -23,7 +23,7 @@ struct cpu_type { #define CPUFLAG_8B_AND_AB_NEED_0_ARG (1u << 2) // warn if "ane/lxa #$xx" uses non-zero arg #define CPUFLAG_ISBIGENDIAN (1u << 3) // for 16/24/32-bit values, output msb first #define CPUFLAG_DECIMALSUBTRACTBUGGY (1u << 4) // warn if "sed" is assembled - +#define CPUFLAG_WARN_ABOUT_FF_PTR (1u << 5) // warn if MNEMO($ff) is assembled // if cpu type and value match, set register length variable to value. // if cpu type and value don't match, complain instead. diff --git a/src/mnemo.c b/src/mnemo.c index 4267866..135a84d 100644 --- a/src/mnemo.c +++ b/src/mnemo.c @@ -899,8 +899,9 @@ static unsigned int imm_ops(int *force_bit, unsigned char opcode, int immediate_ // helper function to warn if zp pointer wraps around static void check_zp_wraparound(struct number *result) { - if ((result->val.intval == 0xff) - && (result->flags & NUMBER_IS_DEFINED)) + if ((result->flags & NUMBER_IS_DEFINED) + && (result->val.intval == 0xff) + && (CPU_state.type->flags & CPUFLAG_WARN_ABOUT_FF_PTR)) Throw_warning("Zeropage pointer wraps around from $ff to $00"); } diff --git a/src/output.c b/src/output.c index e78e580..e48598f 100644 --- a/src/output.c +++ b/src/output.c @@ -572,7 +572,7 @@ void output_set_xor(char xor) // set program counter to defined value (FIXME - allow for undefined!) // if start address was given on command line, main loop will call this before each pass. -// in addition to that, it will be called on each "* = VALUE". +// in addition to that, it will be called on each "*= VALUE". void vcpu_set_pc(intval_t new_pc, int segment_flags) { intval_t new_offset; @@ -599,7 +599,7 @@ when encountering "!pseudopc VALUE { BLOCK }": remember difference between current and new value set PC to new value after BLOCK, use remembered difference to change PC back -when encountering "* = VALUE": +when encountering "*= VALUE": parse new value (NEW: might be undefined!) calculate difference between current PC and new value set PC to new value @@ -608,7 +608,7 @@ when encountering "* = VALUE": Problem: always check for "undefined"; there are some problematic combinations. I need a way to return the size of a generated code block even if PC undefined. Maybe like this: - * = new_address [, invisible] [, overlay] [, &size_symbol_ref {] + *= new_address [, invisible] [, overlay] [, &size_symbol_ref {] ...code... [} ; at end of block, size is written to size symbol given above!] */ diff --git a/src/pseudoopcodes.c b/src/pseudoopcodes.c index 72548b6..cc6b785 100644 --- a/src/pseudoopcodes.c +++ b/src/pseudoopcodes.c @@ -44,7 +44,7 @@ static struct ronode *pseudo_opcode_tree = NULL; // tree to hold pseudo opcodes // this is not really a pseudo opcode, but similar enough to be put here: -// called when "* = EXPRESSION" is parsed, to set the program counter +// called when "*= EXPRESSION" is parsed, to set the program counter void notreallypo_setpc(void) // GotByte is '*' { int segment_flags = 0; @@ -76,7 +76,7 @@ void notreallypo_setpc(void) // GotByte is '*' skip '=' read segment name (quoted string!) */ } else { - Throw_error("Unknown \"* =\" segment modifier."); + Throw_error("Unknown \"*=\" segment modifier."); goto fail; } }