Merge pull request #2006 from bbbradsmith/ca65_jmp_abs_wrap_error

jmp (abs) wrap warning promoted to an error, suppressed on 65C02/etc
This commit is contained in:
Bob Andrews 2023-09-08 18:26:55 +02:00 committed by GitHub
commit 537aa665cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 7 deletions

View File

@ -120,7 +120,7 @@ Long options:
--list-bytes n Maximum number of bytes per listing line
--memory-model model Set the memory model
--pagelength n Set the page length for the listing
--relax-checks Relax some checks (see docs)
--relax-checks Disables some error checks
--smart Enable smart mode
--target sys Set the target system
--verbose Increase verbosity
@ -265,14 +265,17 @@ Here is a description of all the command line options:
<label id="option--relax-checks">
<tag><tt>--relax-checks</tt></tag>
Relax some checks done by the assembler. This will allow code that is an
Disables some error checks done by the assembler. This will allow code that is an
error in most cases and flagged as such by the assembler, but can be valid
in special situations.
Examples are:
Disabled checks are:
<itemize>
<item>Short branches between two different segments.
<item>Byte sized address loads where the address is not a zeropage address.
<item>Address vs. fragment size: a byte sized load from an non-zeropage
address is truncated instead of producing an error.
<item>Indirect jump on page boundary: <tt>jmp (label)</tt> on a label that
resides on a page boundary (<tt>$xxFF</tt>) fetches the second byte from the
wrong address on 6502 CPUs, now allowed instead of producing an error.
</itemize>

View File

@ -1618,7 +1618,7 @@ static void PutJMP (const InsDesc* Ins)
if (EvalEA (Ins, &A)) {
/* Check for indirect addressing */
if ((A.AddrModeBit & AM65_ABS_IND) && (CPU < CPU_65SC02)) {
if ((A.AddrModeBit & AM65_ABS_IND) && (CPU < CPU_65SC02) && (RelaxChecks == 0)) {
/* Compare the low byte of the expression to 0xFF to check for
** a page cross. Be sure to use a copy of the expression otherwise
@ -1631,7 +1631,7 @@ static void PutJMP (const InsDesc* Ins)
unsigned Msg = GetStringId ("\"jmp (abs)\" across page border");
/* Generate the assertion */
AddAssertion (E, ASSERT_ACT_WARN, Msg);
AddAssertion (E, ASSERT_ACT_ERROR, Msg);
}
/* No error, output code */

View File

@ -0,0 +1,4 @@
; test that jmp (indirect) on a page boundary will give an error for 6502 CPU
.p02
jmp ($10FF)

View File

@ -0,0 +1,18 @@
; test that jmp (indirect) on a page boundary will not give an error for non-6502 CPUs
.pc02
jmp ($10FF)
.psc02
jmp ($10FF)
.p816
jmp ($10FF)
; main always returns success (the tested issue is only whether the assembly errors)
.import _exit
.export _main
_main:
lda #0
tax
jmp _exit