Skip to content

Commit f7b4eac

Browse files
committed
hirom optimize mirrors fix (closes #376)
1 parent 34a1c27 commit f7b4eac

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/asar/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,8 @@ int getlenforlabel(int labelpos, int label_fs_id, bool exists)
377377
else cur_effective_bank = relaxed_bank = target_bank;
378378
}
379379
}
380+
// hirom has non-mirrored sram in 6000-7fff, so optimize mirrors shouldn't cover it
381+
int mirror_bound = (mapper == hirom || mapper == exhirom) ? 0x6000 : 0x8000;
380382

381383
if(lbl_is_freespace) {
382384
bank = freespaces[label_fs_id].bank;
@@ -410,7 +412,7 @@ int getlenforlabel(int labelpos, int label_fs_id, bool exists)
410412
// we're in a bank with ram mirrors...
411413
&& !(relaxed_bank & 0x40)
412414
// and the label is in a mirrored section
413-
&& !(bank & 0x40) && word < 0x8000 && !lbl_is_freespace)
415+
&& !(bank & 0x40) && word < mirror_bound && !lbl_is_freespace)
414416
{
415417
return 2;
416418
}

tests/hirom_mirrors.asm

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
l = $006000
2+
l2 = $016000
3+
4+
hirom
5+
org $008000
6+
optimize address mirrors
7+
;`08000
8+
;`ad 00 60
9+
lda l
10+
;`af 00 60 01
11+
lda l2

0 commit comments

Comments
 (0)