From 76ba56a36b6fe1d79e69e1025ad15d6659e91bd4 Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Fri, 19 Feb 2021 18:18:47 -0600 Subject: [PATCH] Allow 2-byte RELEXPR records to be used for branches of + or - 64KB. Previously, the linker gave an error if the relative displacement was more than + or - 32 KB. But 2-byte RELEXPR records are typically used for the operand of the BRL instruction, and since its address calculation wraps around within the program bank, it can effectively address + or - 64KB (i.e. any location within the program bank). Similar reasoning applies to PER, the other instruction using long relative addressing. This would give an error in code like the following: bigbrl start brl later ds 33000 ; realistic examples would have actual code here later rtl end (This currently also gives an assembler error due to similar logic in ORCA/M, but the output file can be linked anyway.) This issue can affect very large functions compiled with ORCA/C or ORCA/Pascal, which may sometimes have branches that go more than 32 KB forward or back. --- pass2.asm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pass2.asm b/pass2.asm index 9581a9c..aac0e28 100644 --- a/pass2.asm +++ b/pass2.asm @@ -1385,7 +1385,7 @@ lb2 lda t1,X blt lb2 lda t1-1,Y bpl lb6 - bra lb5 + bra lb4a lb3 lda #$FF lb4 cmp t1,X bne lb5 @@ -1394,6 +1394,9 @@ lb4 cmp t1,X blt lb4 lda t1-1,Y bmi lb6 +lb4a lda expLength let BRL wrap around within program bank + cmp #2 + bge lb6 lb5 long I,M ph4 #0 ph2 #11