From 4d521217dda87d9480668d9f59090fdc4531b82d Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 9 Jan 2022 11:04:24 +0100 Subject: [PATCH] Postponed zeropage overflow to main memory until the final allocation (after uplift and optimization). Closes #753 --- .../cache/fragment-cache-csg65ce02.asm | 2 +- .../cache/fragment-cache-mega45gs02.asm | 2 +- .../fragment/cache/fragment-cache-mos6502.asm | 2 +- .../cache/fragment-cache-mos6502x.asm | 752 ++++++++---------- .../cache/fragment-cache-rom6502x.asm | 2 +- .../cache/fragment-cache-wdc65c02.asm | 2 +- .../mos6502-common/vwum1=vdum2_band_vwuc1.asm | 6 + .../java/dk/camelot64/kickc/Compiler.java | 4 +- .../kickc/passes/Pass2ConstantInlining.java | 8 +- .../Pass4RegisterUpliftCombinations.java | 2 +- ...gisterUpliftPotentialRegisterAnalysis.java | 2 +- .../kickc/passes/Pass4RegistersFinalize.java | 20 +- src/test/ref/struct-49.asm | 5 +- src/test/ref/struct-49.cfg | 4 +- src/test/ref/struct-49.log | 32 +- src/test/ref/struct-49.sym | 1 + src/test/ref/struct-with-huge-array.asm | 4 +- src/test/ref/struct-with-huge-array.cfg | 2 +- src/test/ref/struct-with-huge-array.log | 27 +- src/test/ref/zeropage-exhausted.log | 22 +- src/test/ref/zeropage-overflow.asm | 47 +- src/test/ref/zeropage-overflow.log | 201 +++-- src/test/ref/zeropage-overflow.sym | 17 +- 23 files changed, 532 insertions(+), 634 deletions(-) create mode 100644 src/main/fragment/mos6502-common/vwum1=vdum2_band_vwuc1.asm diff --git a/src/main/fragment/cache/fragment-cache-csg65ce02.asm b/src/main/fragment/cache/fragment-cache-csg65ce02.asm index 4579e6072..64eaae244 100644 --- a/src/main/fragment/cache/fragment-cache-csg65ce02.asm +++ b/src/main/fragment/cache/fragment-cache-csg65ce02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT vbuzz=vbuc1 ldz #{c1} //FRAGMENT vbuzz_lt_vbuc1_then_la1 diff --git a/src/main/fragment/cache/fragment-cache-mega45gs02.asm b/src/main/fragment/cache/fragment-cache-mega45gs02.asm index d5437595a..2987eb196 100644 --- a/src/main/fragment/cache/fragment-cache-mega45gs02.asm +++ b/src/main/fragment/cache/fragment-cache-mega45gs02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT vbuz1=vbuc1 ldz #{c1} stz {z1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502.asm b/src/main/fragment/cache/fragment-cache-mos6502.asm index 084a3df0a..8f5fd6f16 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502x.asm b/src/main/fragment/cache/fragment-cache-mos6502x.asm index b14e641f3..b76da673f 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -1,291 +1,7 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 -//FRAGMENT pbuz1=pbuc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT vbuz1=_stackidxbyte_vbuc1 -tsx -lda STACK_BASE+{c1},x -sta {z1} -//FRAGMENT _deref_pbuz1=vbuz2 -lda {z2} -ldy #0 -sta ({z1}),y -//FRAGMENT pbuz1=_inc_pbuz1 -inc {z1} -bne !+ -inc {z1}+1 -!: -//FRAGMENT vwuz1=vwuc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT _stackpushbyte_=vbuc1 -lda #{c1} -pha -//FRAGMENT call_vprc1 -jsr {c1} -//FRAGMENT _stackpullpadding_1 -pla -//FRAGMENT vbuz1=_deref_pbuc1_minus_vbuc2 -lax {c1} -axs #{c2} -stx {z1} +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} -//FRAGMENT vbuz1=vbuz2 -lda {z2} -sta {z1} -//FRAGMENT vbuz1=_byte_vwuz2 -lda {z2} -sta {z1} -//FRAGMENT _stackpushbyte_=vbuz1 -lda {z1} -pha -//FRAGMENT vbuz1_eq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -beq {la1} -//FRAGMENT vbuz1=vbuz2_rol_1 -lda {z2} -asl -sta {z1} -//FRAGMENT vbuz1=vbuz2_plus_vbuz3 -lda {z2} -clc -adc {z3} -sta {z1} -//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuz3 -ldy {z3} -lda {c1},y -ldy {z2} -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuz2=vbuc1 -lda #{c1} -ldy {z2} -sta ({z1}),y -//FRAGMENT vbuaa=_stackidxbyte_vbuc1 -tsx -lda STACK_BASE+{c1},x -//FRAGMENT vbuxx=_stackidxbyte_vbuc1 -tsx -lda STACK_BASE+{c1},x -tax -//FRAGMENT vbuyy=_stackidxbyte_vbuc1 -tsx -lda STACK_BASE+{c1},x -tay -//FRAGMENT _deref_pbuz1=vbuaa -ldy #0 -sta ({z1}),y -//FRAGMENT _deref_pbuz1=vbuxx -txa -ldy #0 -sta ({z1}),y -//FRAGMENT _deref_pbuz1=vbuyy -tya -ldy #0 -sta ({z1}),y -//FRAGMENT vbuaa=_byte_vwuz1 -lda {z1} -//FRAGMENT vbuxx=_byte_vwuz1 -ldx {z1} -//FRAGMENT _stackpushbyte_=vbuaa -pha -//FRAGMENT vbuaa=vbuz1_rol_1 -lda {z1} -asl -//FRAGMENT vbuxx=vbuz1_rol_1 -lda {z1} -asl -tax -//FRAGMENT vbuyy=vbuz1_rol_1 -lda {z1} -asl -tay -//FRAGMENT vbuz1=vbuaa_plus_vbuz2 -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_vbuz2 -txa -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuyy_plus_vbuz2 -tya -clc -adc {z2} -sta {z1} -//FRAGMENT vbuaa=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -//FRAGMENT vbuaa=vbuaa_plus_vbuz1 -clc -adc {z1} -//FRAGMENT vbuaa=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -//FRAGMENT vbuaa=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -//FRAGMENT vbuxx=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -tax -//FRAGMENT vbuxx=vbuaa_plus_vbuz1 -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -tax -//FRAGMENT vbuyy=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -tay -//FRAGMENT vbuyy=vbuaa_plus_vbuz1 -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -tay -//FRAGMENT vbuz1=vbuaa_rol_1 -asl -sta {z1} -//FRAGMENT vbuz1=vbuxx_rol_1 -txa -asl -sta {z1} -//FRAGMENT vbuz1=vbuyy_rol_1 -tya -asl -sta {z1} -//FRAGMENT vbuaa=vbuaa_rol_1 -asl -//FRAGMENT vbuaa=vbuxx_rol_1 -txa -asl -//FRAGMENT vbuaa=vbuyy_rol_1 -tya -asl -//FRAGMENT vbuxx=vbuaa_rol_1 -asl -tax -//FRAGMENT vbuxx=vbuxx_rol_1 -txa -asl -tax -//FRAGMENT vbuxx=vbuyy_rol_1 -tya -asl -tax -//FRAGMENT vbuyy=vbuaa_rol_1 -asl -tay -//FRAGMENT vbuyy=vbuxx_rol_1 -txa -asl -tay -//FRAGMENT vbuyy=vbuyy_rol_1 -tya -asl -tay -//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuaa -tay -lda {c1},y -ldy {z2} -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuxx -lda {c1},x -ldy {z2} -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuyy -lda {c1},y -ldy {z2} -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuz2 -txa -ldx {z2} -tay -lda {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuaa -stx $ff -tay -lda {c1},y -ldy $ff -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuxx -txa -tay -lda {c1},y -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuyy -lda {c1},y -stx $ff -ldy $ff -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuz2 -ldx {z2} -lda {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuaa -tax -lda {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx -lda {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuyy -lda {c1},y -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuxx=vbuc1 -txa -tay -lda #{c1} -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_vbuyy=vbuc1 -lda #{c1} -sta ({z1}),y -//FRAGMENT _stackpushbyte_=vbuxx -txa -pha -//FRAGMENT vbuyy=_byte_vwuz1 -ldy {z1} -//FRAGMENT _stackpushbyte_=vbuyy -tya -pha -//FRAGMENT vbuxx=vbuc1 -ldx #{c1} -//FRAGMENT vbuyy=vbuc1 -ldy #{c1} -//FRAGMENT vbuz1=_deref_pbuc1 -lda {c1} -sta {z1} //FRAGMENT vbuz1_lt_vbuc1_then_la1 lda {z1} cmp #{c1} @@ -321,6 +37,10 @@ inx //FRAGMENT vbuxx_lt_vbuc1_then_la1 cpx #{c1} bcc {la1} +//FRAGMENT vbuxx=vbuc1 +ldx #{c1} +//FRAGMENT vbuyy=vbuc1 +ldy #{c1} //FRAGMENT vbuyy_lt_vbuc1_then_la1 cpy #{c1} bcc {la1} @@ -510,10 +230,20 @@ ldy #0 lda ({z2}),y ldy {z1} sta {c1},y +//FRAGMENT pbuz1=_inc_pbuz1 +inc {z1} +bne !+ +inc {z1}+1 +!: //FRAGMENT pbuc1_derefidx_vbuxx=_deref_pbuz1 ldy #0 lda ({z1}),y sta {c1},x +//FRAGMENT pbuz1=pbuc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 //FRAGMENT 0_neq_pbuz1_derefidx_vbuz2_then_la1 ldy {z2} lda ({z1}),y @@ -525,6 +255,9 @@ lda {z2} sta {z1} lda {z2}+1 sta {z1}+1 +//FRAGMENT vbuz1=vbuz2 +lda {z2} +sta {z1} //FRAGMENT vbuz1=pbuz2_derefidx_vbuz3 ldy {z3} lda ({z2}),y @@ -806,6 +539,10 @@ bne {la1} //FRAGMENT vbuaa=_inc_vbuaa clc adc #1 +//FRAGMENT vbuz1=vbuz2_rol_1 +lda {z2} +asl +sta {z1} //FRAGMENT pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_plus_vbuc2 ldy {z1} clc @@ -824,6 +561,58 @@ sta {c1},y lda {c1}+1,y adc {c2}+1,y sta {c1}+1,y +//FRAGMENT vbuaa=vbuz1_rol_1 +lda {z1} +asl +//FRAGMENT vbuxx=vbuz1_rol_1 +lda {z1} +asl +tax +//FRAGMENT vbuyy=vbuz1_rol_1 +lda {z1} +asl +tay +//FRAGMENT vbuz1=vbuaa_rol_1 +asl +sta {z1} +//FRAGMENT vbuaa=vbuaa_rol_1 +asl +//FRAGMENT vbuxx=vbuaa_rol_1 +asl +tax +//FRAGMENT vbuyy=vbuaa_rol_1 +asl +tay +//FRAGMENT vbuz1=vbuxx_rol_1 +txa +asl +sta {z1} +//FRAGMENT vbuaa=vbuxx_rol_1 +txa +asl +//FRAGMENT vbuxx=vbuxx_rol_1 +txa +asl +tax +//FRAGMENT vbuyy=vbuxx_rol_1 +txa +asl +tay +//FRAGMENT vbuz1=vbuyy_rol_1 +tya +asl +sta {z1} +//FRAGMENT vbuaa=vbuyy_rol_1 +tya +asl +//FRAGMENT vbuxx=vbuyy_rol_1 +tya +asl +tax +//FRAGMENT vbuyy=vbuyy_rol_1 +tya +asl +tay //FRAGMENT pwuc1_derefidx_vbuaa=pwuc1_derefidx_vbuaa_plus_vbuc2 tay clc @@ -967,11 +756,19 @@ lda #<{c2} sta {c1} lda #>{c2} sta {c1}+1 +//FRAGMENT vwuz1=vwuc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 //FRAGMENT _deref_pwuc1=_deref_pwuc2 lda {c2} sta {c1} lda {c2}+1 sta {c1}+1 +//FRAGMENT vbuz1=_deref_pbuc1 +lda {c1} +sta {z1} //FRAGMENT vbuz1=_byte1_vwuz2 lda {z2}+1 sta {z1} @@ -1183,6 +980,10 @@ sta {z1} lda #0 sbc {z1}+1 sta {z1}+1 +//FRAGMENT _deref_pbuz1=vbuz2 +lda {z2} +ldy #0 +sta ({z1}),y //FRAGMENT pbuz1=pbuz1_plus_vbuc1 lda #{c1} clc @@ -1222,6 +1023,17 @@ sta {z1} ldy {z2} lda {c1},y sta {z1} +//FRAGMENT _deref_pbuz1=vbuaa +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=vbuxx +txa +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=vbuyy +tya +ldy #0 +sta ({z1}),y //FRAGMENT vbuaa=vbuz1_ror_4 lda {z1} lsr @@ -1321,6 +1133,57 @@ sta {z1} lda {c1},x //FRAGMENT vbuaa=pbuc1_derefidx_vbuyy lda {c1},y +//FRAGMENT vbuz1=_stackidxbyte_vbuc1 +tsx +lda STACK_BASE+{c1},x +sta {z1} +//FRAGMENT _stackpushbyte_=vbuc1 +lda #{c1} +pha +//FRAGMENT call_vprc1 +jsr {c1} +//FRAGMENT _stackpullpadding_1 +pla +//FRAGMENT vbuz1_eq_vbuc1_then_la1 +lda #{c1} +cmp {z1} +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuz2=vbuc1 +lda #{c1} +ldy {z2} +sta ({z1}),y +//FRAGMENT vbuaa=_stackidxbyte_vbuc1 +tsx +lda STACK_BASE+{c1},x +//FRAGMENT vbuxx=_stackidxbyte_vbuc1 +tsx +lda STACK_BASE+{c1},x +tax +//FRAGMENT vbuyy=_stackidxbyte_vbuc1 +tsx +lda STACK_BASE+{c1},x +tay +//FRAGMENT vbuaa_eq_vbuc1_then_la1 +cmp #{c1} +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuaa=vbuc1 +tay +lda #{c1} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=vbuc1 +txa +tay +lda #{c1} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=vbuc1 +lda #{c1} +sta ({z1}),y +//FRAGMENT vbuxx_eq_vbuc1_then_la1 +cpx #{c1} +beq {la1} +//FRAGMENT vbuyy_eq_vbuc1_then_la1 +cpy #{c1} +beq {la1} //FRAGMENT vwsz1=vwsz1_minus_vbsc1 lda {z1} sec @@ -2230,6 +2093,11 @@ sta {z1} lda #{c2} cmp {c1} bne {la1} +//FRAGMENT vbuz1=vbuz2_plus_vbuz3 +lda {z2} +clc +adc {z3} +sta {z1} //FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=vbuc2 lda #{c2} ldx {z2} @@ -2277,6 +2145,20 @@ eor #$ff clc adc #$01 sta {z1} +//FRAGMENT vbuaa=vbuz1_plus_vbuz2 +lda {z1} +clc +adc {z2} +//FRAGMENT vbuxx=vbuz1_plus_vbuz2 +lda {z1} +clc +adc {z2} +tax +//FRAGMENT vbuyy=vbuz1_plus_vbuz2 +lda {z1} +clc +adc {z2} +tay //FRAGMENT vbuz1=vbuz2_plus_vbuxx txa clc @@ -2315,6 +2197,21 @@ tya clc adc {z1} tay +//FRAGMENT vbuz1=vbuaa_plus_vbuz2 +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuaa_plus_vbuz1 +clc +adc {z1} +//FRAGMENT vbuxx=vbuaa_plus_vbuz1 +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuaa_plus_vbuz1 +clc +adc {z1} +tay //FRAGMENT vbuz1=vbuaa_plus_vbuxx stx $ff clc @@ -2353,6 +2250,25 @@ sty $ff clc adc $ff tay +//FRAGMENT vbuz1=vbuxx_plus_vbuz2 +txa +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuxx_plus_vbuz1 +txa +clc +adc {z1} +//FRAGMENT vbuxx=vbuxx_plus_vbuz1 +txa +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuxx_plus_vbuz1 +txa +clc +adc {z1} +tay //FRAGMENT vbuz1=vbuxx_plus_vbuxx txa asl @@ -2391,6 +2307,25 @@ sty $ff clc adc $ff tay +//FRAGMENT vbuz1=vbuyy_plus_vbuz2 +tya +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuyy_plus_vbuz1 +tya +clc +adc {z1} +//FRAGMENT vbuxx=vbuyy_plus_vbuz1 +tya +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuyy_plus_vbuz1 +tya +clc +adc {z1} +tay //FRAGMENT vbuz1=vbuyy_plus_vbuxx txa sty $ff @@ -2565,15 +2500,12 @@ tay sta {c1},x //FRAGMENT vbsyy=vbsc1 ldy #{c1} -//FRAGMENT vbuaa_eq_vbuc1_then_la1 -cmp #{c1} -beq {la1} -//FRAGMENT vbuxx_eq_vbuc1_then_la1 -cpx #{c1} -beq {la1} -//FRAGMENT vbuyy_eq_vbuc1_then_la1 -cpy #{c1} -beq {la1} +//FRAGMENT _stackpushbyte_=vbuz1 +lda {z1} +pha +//FRAGMENT _stackpushbyte_=vbuyy +tya +pha //FRAGMENT _deref_pbuz1=_deref_pbuz2 ldy #0 lda ({z2}),y @@ -4092,10 +4024,6 @@ ora {z2} sta {z1} //FRAGMENT vbuz1=vbuxx_bor_vbuxx stx {z1} -//FRAGMENT pbuz1_derefidx_vbuaa=vbuc1 -tay -lda #{c1} -sta ({z1}),y //FRAGMENT vwuz1=vwuz1_minus_pwuc1_derefidx_vbuaa tay lda {z1} @@ -4233,6 +4161,45 @@ beq {la1} sty $ff cpx $ff beq {la1} +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuz3 +ldy {z3} +lda {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuz2 +txa +ldx {z2} +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuz2 +ldx {z2} +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuxx +lda {c1},x +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuxx +txa +tay +lda {c1},y +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuyy +lda {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuyy +lda {c1},y +stx $ff +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuyy +lda {c1},y +sta ({z1}),y //FRAGMENT vwsz1=_sword_vbuz2 lda {z2} sta {z1} @@ -4868,6 +4835,9 @@ bne {la1} lda {z1} cmp #<{c1} bne {la1} +//FRAGMENT vbuz1=_byte_vwuz2 +lda {z2} +sta {z1} //FRAGMENT vwuz1_neq_vwuc1_then_la1 lda {z1}+1 cmp #>{c1} @@ -4927,6 +4897,12 @@ tay tya ora #{c1} tay +//FRAGMENT vbuaa=_byte_vwuz1 +lda {z1} +//FRAGMENT vbuxx=_byte_vwuz1 +ldx {z1} +//FRAGMENT vbuyy=_byte_vwuz1 +ldy {z1} //FRAGMENT vwuz1_gt_vbuc1_then_la1 lda {z1}+1 bne {la1} @@ -5369,9 +5345,14 @@ stx {z1} lda {z1} sec sbc #1 +//FRAGMENT _stackpushbyte_=vbuaa +pha //FRAGMENT vbuxx=vbuz1_minus_1 ldx {z1} dex +//FRAGMENT _stackpushbyte_=vbuxx +txa +pha //FRAGMENT vbuyy=vbuz1_minus_1 lda {z1} tay @@ -5669,6 +5650,11 @@ rol {z1}+1 clc adc #1 sta {z1} +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuaa +tay +lda {c1},y +ldy {z2} +sta ({z1}),y //FRAGMENT vbuxx=pbuc1_derefidx_vbuyy ldx {c1},y //FRAGMENT vbuyy=pbuc1_derefidx_vbuxx @@ -12018,6 +12004,10 @@ stx {z1} lax {c1} axs #-[{c2}] stx {z1} +//FRAGMENT vbuz1=_deref_pbuc1_minus_vbuc2 +lax {c1} +axs #{c2} +stx {z1} //FRAGMENT vbuz1=vbuz2_minus_vbuz3 lda {z2} sec @@ -13475,87 +13465,6 @@ lda ({z1}),y sta !+ +2 !: jsr $0000 -//FRAGMENT vwsm1=vwsc1 -lda #<{c1} -sta {m1} -lda #>{c1} -sta {m1}+1 -//FRAGMENT vwsm1_lt_vbsc1_then_la1 -NO_SYNTHESIS -//FRAGMENT vwsm1_lt_vwuc1_then_la1 -lda {m1}+1 -bmi {la1} -cmp #>{c1} -bcc {la1} -bne !+ -lda {m1} -cmp #<{c1} -bcc {la1} -!: -//FRAGMENT vbum1=_byte_vwsm2 -lda {m2} -sta {m1} -//FRAGMENT vbum1=vbum2_rol_1 -lda {m2} -asl -sta {m1} -//FRAGMENT pwsc1_derefidx_vbum1=vwsm2 -ldy {m1} -lda {m2} -sta {c1},y -lda {m2}+1 -sta {c1}+1,y -//FRAGMENT vwsm1=_inc_vwsm1 -inc {m1} -bne !+ -inc {m1}+1 -!: -//FRAGMENT vbuaa=_byte_vwsm1 -lda {m1} -//FRAGMENT vbuxx=_byte_vwsm1 -lda {m1} -tax -//FRAGMENT vbuyy=_byte_vwsm1 -lda {m1} -tay -//FRAGMENT vbuaa=vbum1_rol_1 -lda {m1} -asl -//FRAGMENT vbuxx=vbum1_rol_1 -lda {m1} -asl -tax -//FRAGMENT vbuyy=vbum1_rol_1 -lda {m1} -asl -tay -//FRAGMENT vbum1=vbuaa_rol_1 -asl -sta {m1} -//FRAGMENT vbum1=vbuxx_rol_1 -txa -asl -sta {m1} -//FRAGMENT vbum1=vbuyy_rol_1 -tya -asl -sta {m1} -//FRAGMENT pwsc1_derefidx_vbuaa=vwsm1 -tay -lda {m1} -sta {c1},y -lda {m1}+1 -sta {c1}+1,y -//FRAGMENT pwsc1_derefidx_vbuxx=vwsm1 -lda {m1} -sta {c1},x -lda {m1}+1 -sta {c1}+1,x -//FRAGMENT pwsc1_derefidx_vbuyy=vwsm1 -lda {m1} -sta {c1},y -lda {m1}+1 -sta {c1}+1,y //FRAGMENT vbuz1=vbuz2_band_pbuz3_derefidx_vbuc1 lda {z2} ldy #{c1} @@ -15803,48 +15712,6 @@ cmp {z1} beq !+ bcs {la1} !: -//FRAGMENT vbum1=vbuz2_rol_1 -lda {z2} -asl -sta {m1} -//FRAGMENT pwsc1_derefidx_vbum1=vwsz2 -ldy {m1} -lda {z2} -sta {c1},y -lda {z2}+1 -sta {c1}+1,y -//FRAGMENT vwsm1=_inc_vwsz2 -clc -lda {z2} -adc #1 -sta {m1} -lda {z2}+1 -adc #0 -sta {m1}+1 -//FRAGMENT vwsm1=_inc_vwsm2 -clc -lda {m2} -adc #1 -sta {m1} -lda {m2}+1 -adc #0 -sta {m1}+1 -//FRAGMENT vwsz1=_inc_vwsm2 -clc -lda {m2} -adc #1 -sta {z1} -lda {m2}+1 -adc #0 -sta {z1}+1 -//FRAGMENT vwsz1=_inc_vwsz2 -clc -lda {z2} -adc #1 -sta {z1} -lda {z2}+1 -adc #0 -sta {z1}+1 //FRAGMENT pbuz1=_dec_pbuz2 lda {z2} sec @@ -16310,3 +16177,46 @@ sta {c1},x lda #{c2} ora {c1},y sta {c1},y +//FRAGMENT vwsm1=vwsc1 +lda #<{c1} +sta {m1} +lda #>{c1} +sta {m1}+1 +//FRAGMENT vwsm1_lt_vbsc1_then_la1 +NO_SYNTHESIS +//FRAGMENT vwsm1_lt_vwuc1_then_la1 +lda {m1}+1 +bmi {la1} +cmp #>{c1} +bcc {la1} +bne !+ +lda {m1} +cmp #<{c1} +bcc {la1} +!: +//FRAGMENT vbuaa=_byte_vwsm1 +lda {m1} +//FRAGMENT pwsc1_derefidx_vbuaa=vwsm1 +tay +lda {m1} +sta {c1},y +lda {m1}+1 +sta {c1}+1,y +//FRAGMENT vwsm1=_inc_vwsm1 +inc {m1} +bne !+ +inc {m1}+1 +!: +//FRAGMENT vwsz1=_inc_vwsz2 +clc +lda {z2} +adc #1 +sta {z1} +lda {z2}+1 +adc #0 +sta {z1}+1 +//FRAGMENT pwsc1_derefidx_vbuxx=vwsm1 +lda {m1} +sta {c1},x +lda {m1}+1 +sta {c1}+1,x diff --git a/src/main/fragment/cache/fragment-cache-rom6502x.asm b/src/main/fragment/cache/fragment-cache-rom6502x.asm index ba341602c..20f382977 100644 --- a/src/main/fragment/cache/fragment-cache-rom6502x.asm +++ b/src/main/fragment/cache/fragment-cache-rom6502x.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT _deref_pbuc1=_inc__deref_pbuc1 inc {c1} //FRAGMENT isr_hardware_all_entry diff --git a/src/main/fragment/cache/fragment-cache-wdc65c02.asm b/src/main/fragment/cache/fragment-cache-wdc65c02.asm index 54466eef4..dd63d30f2 100644 --- a/src/main/fragment/cache/fragment-cache-wdc65c02.asm +++ b/src/main/fragment/cache/fragment-cache-wdc65c02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075 +//KICKC FRAGMENT CACHE 1472899f88 147289c4f1 //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} diff --git a/src/main/fragment/mos6502-common/vwum1=vdum2_band_vwuc1.asm b/src/main/fragment/mos6502-common/vwum1=vdum2_band_vwuc1.asm new file mode 100644 index 000000000..db51308ee --- /dev/null +++ b/src/main/fragment/mos6502-common/vwum1=vdum2_band_vwuc1.asm @@ -0,0 +1,6 @@ +lda {m2} +and #<{c1} +sta {m1} +lda {m2}+1 +and #>{c1} +sta {m1}+1 \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/Compiler.java b/src/main/java/dk/camelot64/kickc/Compiler.java index 5ffff9415..cc8b197cd 100644 --- a/src/main/java/dk/camelot64/kickc/Compiler.java +++ b/src/main/java/dk/camelot64/kickc/Compiler.java @@ -668,7 +668,7 @@ public class Compiler { getLog().append(program.getScope().toStringVars(program, true)); new Pass4LiveRangeEquivalenceClassesFinalize(program).allocate(); - new Pass4RegistersFinalize(program).allocate(true); + new Pass4RegistersFinalize(program).allocate(true, false); // Initial Code generation new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate(); @@ -719,7 +719,7 @@ public class Compiler { // Register coalesce using exhaustive search (saving even more ZP - but slow) new Pass4MemoryCoalesceExhaustive(program).coalesce(); } - new Pass4RegistersFinalize(program).allocate(true); + new Pass4RegistersFinalize(program).allocate(true, true); new Pass4AssertZeropageAllocation(program).check(); // Final ASM code generation before optimization diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantInlining.java b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantInlining.java index a9632cd8c..df78a6bb4 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantInlining.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2ConstantInlining.java @@ -44,8 +44,14 @@ public class Pass2ConstantInlining extends Pass2SsaOptimization { inline.remove(constantRef); } } + // Remove all SIZEOF_ constants + for(ConstantRef constantRef : (List) new ArrayList(inline.keySet())) { + if(constantRef.getLocalName().startsWith("SIZEOF_")) { + inline.remove(constantRef); + } + } - // Perform alias replacement within the constant values inside the aliases + // Perform alias replacement within the constant values inside the aliases replaceInValues(inline); // Replace all usages of the constants in the control flow graph or symbol table replaceVariables(inline); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java index 38d0dbbe9..2f4f84476 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftCombinations.java @@ -91,7 +91,7 @@ public class Pass4RegisterUpliftCombinations extends Pass2Base { Set unknownFragments, ScopeRef scope) { // Reset register allocation to original zero page allocation - new Pass4RegistersFinalize(program).allocate(false); + new Pass4RegistersFinalize(program).allocate(false, false); // Apply the uplift combination combination.allocate(program); // Check the register allocation for whether any register is being allocated to two variables with overlapping live ranges diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java index f58bcf85d..ce3225dba 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegisterUpliftPotentialRegisterAnalysis.java @@ -159,7 +159,7 @@ public class Pass4RegisterUpliftPotentialRegisterAnalysis extends Pass2Base { while(combinations.hasNext()) { RegisterCombination combination = combinations.next(); // Reset register allocation to original zero page allocation - new Pass4RegistersFinalize(getProgram()).allocate(false); + new Pass4RegistersFinalize(getProgram()).allocate(false, false); // Apply the combination combination.allocate(getProgram()); // Generate ASM diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java b/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java index a29b859f2..545eb23e9 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4RegistersFinalize.java @@ -48,7 +48,7 @@ public class Pass4RegistersFinalize extends Pass2Base { } } - public void allocate(boolean reallocateZp) { + public void allocate(boolean reallocateZp, boolean overflowToMainMem) { LiveRangeEquivalenceClassSet liveRangeEquivalenceClassSet = getProgram().getLiveRangeEquivalenceClassSet(); for(LiveRangeEquivalenceClass equivalenceClass : liveRangeEquivalenceClassSet.getEquivalenceClasses()) { for(VariableRef variableRef : equivalenceClass.getVariables()) { @@ -79,7 +79,7 @@ public class Pass4RegistersFinalize extends Pass2Base { if(reallocateZp) { - reallocateMemRegisters(liveRangeEquivalenceClassSet); + reallocateMemRegisters(liveRangeEquivalenceClassSet, overflowToMainMem); } liveRangeEquivalenceClassSet.storeRegisterAllocation(); if(reallocateZp) { @@ -152,11 +152,11 @@ public class Pass4RegistersFinalize extends Pass2Base { /** * Reallocate all memory registers. Minimizes zeropage usage. * - * @param liveRangeEquivalenceClassSet The + * @param equivalenceClassSet The live range equivalence classes + * @param overflowToMainMem If true zeropage variables overflow into main memory if they do not fit on zeropage. */ - private void reallocateMemRegisters(LiveRangeEquivalenceClassSet liveRangeEquivalenceClassSet) { + private void reallocateMemRegisters(LiveRangeEquivalenceClassSet equivalenceClassSet, boolean overflowToMainMem) { - LiveRangeEquivalenceClassSet equivalenceClassSet = getProgram().getLiveRangeEquivalenceClassSet(); List equivalenceClasses = new ArrayList<>(equivalenceClassSet.getEquivalenceClasses()); final VariableRegisterWeights registerWeights = getProgram().getVariableRegisterWeights(); Collections.sort(equivalenceClasses, (o1, o2) -> Double.compare(registerWeights.getTotalWeight(o2), registerWeights.getTotalWeight(o1))); @@ -183,10 +183,12 @@ public class Pass4RegistersFinalize extends Pass2Base { register = allocateNewRegisterZp(variable); int zp = ((Registers.RegisterZpMem) register).getZp(); int sizeBytes = variable.getType().getSizeBytes(); - if(zp + sizeBytes > 0x100) { - // Zero-page exhausted - move to main memory instead (TODO: prioritize!) - register = new Registers.RegisterMainMem(variableRef, variable.getType().getSizeBytes(), null, false); - getLog().append("Zero-page exhausted. Moving allocation to main memory "+variable.toString()); + if(overflowToMainMem) { + if (zp + sizeBytes > 0x100) { + // Zero-page exhausted - move to main memory instead (TODO: prioritize!) + register = new Registers.RegisterMainMem(variableRef, variable.getType().getSizeBytes(), null, false); + getLog().append("Zero-page exhausted. Moving allocation to main memory " + variable.toString()); + } } } equivalenceClass.setRegister(register); diff --git a/src/test/ref/struct-49.asm b/src/test/ref/struct-49.asm index c66f5d2ba..9da22ccf3 100644 --- a/src/test/ref/struct-49.asm +++ b/src/test/ref/struct-49.asm @@ -8,6 +8,7 @@ .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) + .const SIZEOF_STRUCT___0 = 3 .segment Code main: { .label msg = 2 @@ -24,7 +25,7 @@ main: { ldx #0 __b1: // for(char i=0;i$11a + cpx #>SIZEOF_STRUCT___0 bne !n- lda #<0 sta.z i diff --git a/src/test/ref/struct-with-huge-array.cfg b/src/test/ref/struct-with-huge-array.cfg index 94220019b..53ad83543 100644 --- a/src/test/ref/struct-with-huge-array.cfg +++ b/src/test/ref/struct-with-huge-array.cfg @@ -1,7 +1,7 @@ void main() main: scope:[main] from - [0] *(&main::b) = memset(struct $0, $11a) + [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) to:main::@1 main::@1: scope:[main] from main main::@2 [1] main::i#2 = phi( main/0, main::@2/main::i#1 ) diff --git a/src/test/ref/struct-with-huge-array.log b/src/test/ref/struct-with-huge-array.log index abe44d6be..e168dfda3 100644 --- a/src/test/ref/struct-with-huge-array.log +++ b/src/test/ref/struct-with-huge-array.log @@ -81,7 +81,6 @@ Removing unused procedure block __start::@2 Removing unused procedure block __start::@return Successful SSA optimization PassNEliminateEmptyStart Inlining constant with var siblings main::i#0 -Constant inlined SIZEOF_STRUCT_$0 = $11a Constant inlined main::i#0 = 0 Constant inlined main::$0 = $11a Successful SSA optimization Pass2ConstantInlining @@ -98,7 +97,7 @@ FINAL CONTROL FLOW GRAPH void main() main: scope:[main] from - [0] *(&main::b) = memset(struct $0, $11a) + [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) to:main::@1 main::@1: scope:[main] from main main::@2 [1] main::i#2 = phi( main/0, main::@2/main::i#1 ) @@ -137,10 +136,9 @@ Complete equivalence classes Allocated zp[2]:2 [ main::i#2 main::i#1 ] Allocated zp[2]:4 [ main::$3 ] Allocated zp[2]:6 [ main::$2 ] -Zero-page exhausted. Moving allocation to main memory main::b -Allocated mem[282] [ main::b ] +Allocated zp[282]:256 [ main::b ] REGISTER UPLIFT POTENTIAL REGISTERS -Statement [0] *(&main::b) = memset(struct $0, $11a) [ main::b ] ( [ main::b ] { } ) always clobbers reg byte a reg byte x reg byte y +Statement [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) [ main::b ] ( [ main::b ] { } ) always clobbers reg byte a reg byte x reg byte y Statement [2] if(main::i#2<$11a) goto main::@2 [ main::i#2 main::b ] ( [ main::i#2 main::b ] { } ) always clobbers reg byte a Statement [4] main::$2 = (char *)&main::b + main::i#2 [ main::i#2 main::$2 main::b ] ( [ main::i#2 main::$2 main::b ] { } ) always clobbers reg byte a Statement [5] main::$3 = SCREEN + main::i#2 [ main::i#2 main::$2 main::b main::$3 ] ( [ main::i#2 main::$2 main::b main::$3 ] { } ) always clobbers reg byte a @@ -148,17 +146,18 @@ Statement [6] *main::$3 = *main::$2 [ main::i#2 main::b ] ( [ main::i#2 main::b Potential registers zp[2]:2 [ main::i#2 main::i#1 ] : zp[2]:2 , Potential registers zp[2]:6 [ main::$2 ] : zp[2]:6 , Potential registers zp[2]:4 [ main::$3 ] : zp[2]:4 , -Potential registers mem[282] [ main::b ] : mem[282] , +Potential registers zp[282]:256 [ main::b ] : zp[282]:256 , REGISTER UPLIFT SCOPES -Uplift Scope [main] 33: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[2]:4 [ main::$3 ] 11: zp[2]:6 [ main::$2 ] 0: mem[282] [ main::b ] +Uplift Scope [main] 33: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[2]:4 [ main::$3 ] 11: zp[2]:6 [ main::$2 ] 0: zp[282]:256 [ main::b ] Uplift Scope [$0] Uplift Scope [] -Uplifting [main] best 1055 combination zp[2]:2 [ main::i#2 main::i#1 ] zp[2]:4 [ main::$3 ] zp[2]:6 [ main::$2 ] mem[282] [ main::b ] +Uplifting [main] best 1055 combination zp[2]:2 [ main::i#2 main::i#1 ] zp[2]:4 [ main::$3 ] zp[2]:6 [ main::$2 ] zp[282]:256 [ main::b ] Uplifting [$0] best 1055 combination Uplifting [] best 1055 combination Zero-page exhausted. Moving allocation to main memory main::b +Allocated (was zp[282]:256) mem[282] [ main::b ] ASSEMBLER BEFORE OPTIMIZATION // File Comments @@ -180,7 +179,7 @@ main: { .label i = 2 .label __2 = 6 .label __3 = 4 - // [0] *(&main::b) = memset(struct $0, $11a) -- _deref_pssc1=_memset_vwuc2 + // [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) -- _deref_pssc1=_memset_vwuc2 lda #b @@ -196,9 +195,9 @@ main: { inc.z $ff inx !: - cpy #<$11a + cpy #$11a + cpx #>SIZEOF_STRUCT___0 bne !n- // [1] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: @@ -313,7 +312,7 @@ main: { .label __2 = 6 .label __3 = 4 // bug b - // [0] *(&main::b) = memset(struct $0, $11a) -- _deref_pssc1=_memset_vwuc2 + // [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) -- _deref_pssc1=_memset_vwuc2 lda #b @@ -329,9 +328,9 @@ main: { inc.z $ff inx !: - cpy #<$11a + cpy #$11a + cpx #>SIZEOF_STRUCT___0 bne !n- // [1] phi from main to main::@1 [phi:main->main::@1] // [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vwuz1=vwuc1 diff --git a/src/test/ref/zeropage-exhausted.log b/src/test/ref/zeropage-exhausted.log index c113a4378..1991dbe88 100644 --- a/src/test/ref/zeropage-exhausted.log +++ b/src/test/ref/zeropage-exhausted.log @@ -115,28 +115,26 @@ Complete equivalence classes [ main::i#2 main::i#1 ] [ main::$2 ] [ main::$1 ] -Zero-page exhausted. Moving allocation to main memory main::i#2 -Allocated mem[2] [ main::i#2 main::i#1 ] -Zero-page exhausted. Moving allocation to main memory main::$2 -Allocated mem[1] [ main::$2 ] -Zero-page exhausted. Moving allocation to main memory main::$1 -Allocated mem[1] [ main::$1 ] +Allocated zp[2]:256 [ main::i#2 main::i#1 ] +Allocated zp[1]:258 [ main::$2 ] +Allocated zp[1]:259 [ main::$1 ] REGISTER UPLIFT POTENTIAL REGISTERS Statement [2] if(main::i#2<$a) goto main::@2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a Statement [4] main::$2 = (char)main::i#2 [ main::i#2 main::$2 ] ( [ main::i#2 main::$2 ] { } ) always clobbers reg byte a Statement [5] main::$1 = main::$2 << 1 [ main::i#2 main::$1 ] ( [ main::i#2 main::$1 ] { } ) always clobbers reg byte a Statement [6] main::SCREEN[main::$1] = main::i#2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a -Potential registers mem[2] [ main::i#2 main::i#1 ] : mem[2] , -Potential registers mem[1] [ main::$2 ] : mem[1] , reg byte a , reg byte x , reg byte y , -Potential registers mem[1] [ main::$1 ] : mem[1] , reg byte a , reg byte x , reg byte y , +Potential registers zp[2]:256 [ main::i#2 main::i#1 ] : zp[2]:256 , +Potential registers zp[1]:258 [ main::$2 ] : zp[1]:258 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:259 [ main::$1 ] : zp[1]:259 , reg byte a , reg byte x , reg byte y , REGISTER UPLIFT SCOPES -Uplift Scope [main] 30.8: mem[2] [ main::i#2 main::i#1 ] 22: mem[1] [ main::$2 ] 22: mem[1] [ main::$1 ] +Uplift Scope [main] 30.8: zp[2]:256 [ main::i#2 main::i#1 ] 22: zp[1]:258 [ main::$2 ] 22: zp[1]:259 [ main::$1 ] Uplift Scope [] -Uplifting [main] best 841 combination mem[2] [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$1 ] -Uplifting [] best 841 combination +Uplifting [main] best 751 combination zp[2]:256 [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$1 ] +Uplifting [] best 751 combination Zero-page exhausted. Moving allocation to main memory main::i#2 +Allocated (was zp[2]:256) mem[2] [ main::i#2 main::i#1 ] ASSEMBLER BEFORE OPTIMIZATION // File Comments diff --git a/src/test/ref/zeropage-overflow.asm b/src/test/ref/zeropage-overflow.asm index 9d001766d..6d2549ea9 100644 --- a/src/test/ref/zeropage-overflow.asm +++ b/src/test/ref/zeropage-overflow.asm @@ -11,11 +11,11 @@ // And then allocate a bunch of variables main: { .label SCREEN = $400 - .label a = $f9 - .label a_1 = $f7 + .label a = $f7 + .label h = $f9 lda #<0 - sta h - sta h+1 + sta.z h + sta.z h+1 sta g sta g+1 sta f @@ -28,8 +28,8 @@ main: { sta c+1 sta b sta b+1 - sta.z a_1 - sta.z a_1+1 + sta.z a + sta.z a+1 tay __b1: // for(char i=0;i<10;i++) @@ -42,18 +42,15 @@ main: { tya asl tax - lda.z a_1 + lda.z a sta SCREEN,x - lda.z a_1+1 + lda.z a+1 sta SCREEN+1,x // SCREEN[i] = a++; - clc - lda.z a_1 - adc #1 - sta.z a - lda.z a_1+1 - adc #0 - sta.z a+1 + inc.z a + bne !+ + inc.z a+1 + !: // SCREEN[i] = b++ lda b sta SCREEN,x @@ -125,14 +122,14 @@ main: { inc g+1 !: // SCREEN[i] = h++ - lda h + lda.z h sta SCREEN,x - lda h+1 + lda.z h+1 sta SCREEN+1,x // SCREEN[i] = h++; - inc h + inc.z h bne !+ - inc h+1 + inc.z h+1 !: // SCREEN[i] = a++ lda.z a @@ -140,13 +137,10 @@ main: { lda.z a+1 sta SCREEN+1,x // SCREEN[i] = a++; - clc - lda.z a - adc #1 - sta.z a_1 - lda.z a+1 - adc #0 - sta.z a_1+1 + inc.z a + bne !+ + inc.z a+1 + !: // for(char i=0;i<10;i++) iny jmp __b1 @@ -157,5 +151,4 @@ main: { e: .word 0 f: .word 0 g: .word 0 - h: .word 0 } diff --git a/src/test/ref/zeropage-overflow.log b/src/test/ref/zeropage-overflow.log index aad2a4609..1c088266c 100644 --- a/src/test/ref/zeropage-overflow.log +++ b/src/test/ref/zeropage-overflow.log @@ -340,29 +340,20 @@ Complete equivalence classes Allocated zp[1]:247 [ main::i#2 main::i#1 ] Allocated zp[2]:248 [ main::a#4 main::a#3 ] Allocated zp[2]:250 [ main::h#2 main::h#1 ] -Zero-page exhausted. Moving allocation to main memory main::b#2 -Allocated mem[2] [ main::b#2 main::b#1 ] -Zero-page exhausted. Moving allocation to main memory main::$2 -Allocated mem[1] [ main::$2 ] -Zero-page exhausted. Moving allocation to main memory main::c#2 -Allocated mem[2] [ main::c#2 main::c#1 ] -Zero-page exhausted. Moving allocation to main memory main::g#2 -Allocated mem[2] [ main::g#2 main::g#1 ] -Zero-page exhausted. Moving allocation to main memory main::d#2 -Allocated mem[2] [ main::d#2 main::d#1 ] -Zero-page exhausted. Moving allocation to main memory main::f#2 -Allocated mem[2] [ main::f#2 main::f#1 ] -Zero-page exhausted. Moving allocation to main memory main::e#2 -Allocated mem[2] [ main::e#2 main::e#1 ] -Zero-page exhausted. Moving allocation to main memory main::a#1 -Allocated mem[2] [ main::a#1 ] -Zero-page exhausted. Moving allocation to main memory main::a#2 -Allocated mem[2] [ main::a#2 ] +Allocated zp[2]:256 [ main::b#2 main::b#1 ] +Allocated zp[1]:258 [ main::$2 ] +Allocated zp[2]:259 [ main::c#2 main::c#1 ] +Allocated zp[2]:261 [ main::g#2 main::g#1 ] +Allocated zp[2]:263 [ main::d#2 main::d#1 ] +Allocated zp[2]:265 [ main::f#2 main::f#1 ] +Allocated zp[2]:267 [ main::e#2 main::e#1 ] +Allocated zp[2]:269 [ main::a#1 ] +Allocated zp[2]:271 [ main::a#2 ] REGISTER UPLIFT POTENTIAL REGISTERS Statement [4] main::$2 = main::i#2 << 1 [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] ( [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] { } ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp[1]:247 [ main::i#2 main::i#1 ] Statement [5] main::SCREEN[main::$2] = main::a#4 [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] ( [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] { } ) always clobbers reg byte a -Removing always clobbered register reg byte a as potential for mem[1] [ main::$2 ] +Removing always clobbered register reg byte a as potential for zp[1]:258 [ main::$2 ] Statement [6] main::a#1 = ++ main::a#4 [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] ( [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] { } ) always clobbers reg byte a Statement [7] main::SCREEN[main::$2] = main::b#2 [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] ( [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] { } ) always clobbers reg byte a Statement [9] main::SCREEN[main::$2] = main::c#2 [ main::i#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::b#1 main::$2 main::a#1 ] ( [ main::i#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::b#1 main::$2 main::a#1 ] { } ) always clobbers reg byte a @@ -391,34 +382,39 @@ Statement [23] main::SCREEN[main::$2] = main::a#2 [ main::i#2 main::b#1 main::c# Statement [24] main::a#3 = ++ main::a#2 [ main::i#2 main::a#3 main::b#1 main::c#1 main::d#1 main::e#1 main::f#1 main::g#1 main::h#1 ] ( [ main::i#2 main::a#3 main::b#1 main::c#1 main::d#1 main::e#1 main::f#1 main::g#1 main::h#1 ] { } ) always clobbers reg byte a Potential registers zp[1]:247 [ main::i#2 main::i#1 ] : zp[1]:247 , reg byte x , reg byte y , Potential registers zp[2]:248 [ main::a#4 main::a#3 ] : zp[2]:248 , -Potential registers mem[2] [ main::b#2 main::b#1 ] : mem[2] , -Potential registers mem[2] [ main::c#2 main::c#1 ] : mem[2] , -Potential registers mem[2] [ main::d#2 main::d#1 ] : mem[2] , -Potential registers mem[2] [ main::e#2 main::e#1 ] : mem[2] , -Potential registers mem[2] [ main::f#2 main::f#1 ] : mem[2] , -Potential registers mem[2] [ main::g#2 main::g#1 ] : mem[2] , +Potential registers zp[2]:256 [ main::b#2 main::b#1 ] : zp[2]:256 , +Potential registers zp[2]:259 [ main::c#2 main::c#1 ] : zp[2]:259 , +Potential registers zp[2]:263 [ main::d#2 main::d#1 ] : zp[2]:263 , +Potential registers zp[2]:267 [ main::e#2 main::e#1 ] : zp[2]:267 , +Potential registers zp[2]:265 [ main::f#2 main::f#1 ] : zp[2]:265 , +Potential registers zp[2]:261 [ main::g#2 main::g#1 ] : zp[2]:261 , Potential registers zp[2]:250 [ main::h#2 main::h#1 ] : zp[2]:250 , -Potential registers mem[1] [ main::$2 ] : mem[1] , reg byte x , reg byte y , -Potential registers mem[2] [ main::a#1 ] : mem[2] , -Potential registers mem[2] [ main::a#2 ] : mem[2] , +Potential registers zp[1]:258 [ main::$2 ] : zp[1]:258 , reg byte x , reg byte y , +Potential registers zp[2]:269 [ main::a#1 ] : zp[2]:269 , +Potential registers zp[2]:271 [ main::a#2 ] : zp[2]:271 , REGISTER UPLIFT SCOPES -Uplift Scope [main] 23.91: zp[1]:247 [ main::i#2 main::i#1 ] 19.25: zp[2]:248 [ main::a#4 main::a#3 ] 7.15: zp[2]:250 [ main::h#2 main::h#1 ] 6.72: mem[2] [ main::b#2 main::b#1 ] 6.37: mem[1] [ main::$2 ] 5.5: mem[2] [ main::c#2 main::c#1 ] 5.5: mem[2] [ main::g#2 main::g#1 ] 4.87: mem[2] [ main::d#2 main::d#1 ] 4.81: mem[2] [ main::f#2 main::f#1 ] 4.56: mem[2] [ main::e#2 main::e#1 ] 4.12: mem[2] [ main::a#1 ] 3.3: mem[2] [ main::a#2 ] +Uplift Scope [main] 23.91: zp[1]:247 [ main::i#2 main::i#1 ] 19.25: zp[2]:248 [ main::a#4 main::a#3 ] 7.15: zp[2]:250 [ main::h#2 main::h#1 ] 6.72: zp[2]:256 [ main::b#2 main::b#1 ] 6.37: zp[1]:258 [ main::$2 ] 5.5: zp[2]:259 [ main::c#2 main::c#1 ] 5.5: zp[2]:261 [ main::g#2 main::g#1 ] 4.87: zp[2]:263 [ main::d#2 main::d#1 ] 4.81: zp[2]:265 [ main::f#2 main::f#1 ] 4.56: zp[2]:267 [ main::e#2 main::e#1 ] 4.12: zp[2]:269 [ main::a#1 ] 3.3: zp[2]:271 [ main::a#2 ] Uplift Scope [] -Uplifting [main] best 4536 combination reg byte y [ main::i#2 main::i#1 ] zp[2]:248 [ main::a#4 main::a#3 ] zp[2]:250 [ main::h#2 main::h#1 ] mem[2] [ main::b#2 main::b#1 ] reg byte x [ main::$2 ] mem[2] [ main::c#2 main::c#1 ] mem[2] [ main::g#2 main::g#1 ] mem[2] [ main::d#2 main::d#1 ] mem[2] [ main::f#2 main::f#1 ] mem[2] [ main::e#2 main::e#1 ] mem[2] [ main::a#1 ] mem[2] [ main::a#2 ] -Uplifting [] best 4536 combination -Coalescing zero page register [ mem[2] [ main::a#1 ] ] with [ mem[2] [ main::a#2 ] ] - score: 1 -Allocated (was zp[2]:248) zp[2]:247 [ main::a#4 main::a#3 ] -Allocated (was mem[2]) zp[2]:249 [ main::a#1 main::a#2 ] -Zero-page exhausted. Moving allocation to main memory main::h#2 -Allocated (was zp[2]:250) mem[2] [ main::h#2 main::h#1 ] +Uplifting [main] best 4056 combination reg byte y [ main::i#2 main::i#1 ] zp[2]:248 [ main::a#4 main::a#3 ] zp[2]:250 [ main::h#2 main::h#1 ] zp[2]:256 [ main::b#2 main::b#1 ] reg byte x [ main::$2 ] zp[2]:259 [ main::c#2 main::c#1 ] zp[2]:261 [ main::g#2 main::g#1 ] zp[2]:263 [ main::d#2 main::d#1 ] zp[2]:265 [ main::f#2 main::f#1 ] zp[2]:267 [ main::e#2 main::e#1 ] zp[2]:269 [ main::a#1 ] zp[2]:271 [ main::a#2 ] +Uplifting [] best 4056 combination +Coalescing zero page register [ zp[2]:248 [ main::a#4 main::a#3 ] ] with [ zp[2]:269 [ main::a#1 ] ] - score: 1 +Coalescing zero page register [ zp[2]:248 [ main::a#4 main::a#3 main::a#1 ] ] with [ zp[2]:271 [ main::a#2 ] ] - score: 1 +Allocated (was zp[2]:248) zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ] +Allocated (was zp[2]:250) zp[2]:249 [ main::h#2 main::h#1 ] Zero-page exhausted. Moving allocation to main memory main::b#2 +Allocated (was zp[2]:256) mem[2] [ main::b#2 main::b#1 ] Zero-page exhausted. Moving allocation to main memory main::c#2 +Allocated (was zp[2]:259) mem[2] [ main::c#2 main::c#1 ] Zero-page exhausted. Moving allocation to main memory main::g#2 +Allocated (was zp[2]:261) mem[2] [ main::g#2 main::g#1 ] Zero-page exhausted. Moving allocation to main memory main::d#2 +Allocated (was zp[2]:263) mem[2] [ main::d#2 main::d#1 ] Zero-page exhausted. Moving allocation to main memory main::f#2 +Allocated (was zp[2]:265) mem[2] [ main::f#2 main::f#1 ] Zero-page exhausted. Moving allocation to main memory main::e#2 +Allocated (was zp[2]:267) mem[2] [ main::e#2 main::e#1 ] ASSEMBLER BEFORE OPTIMIZATION // File Comments @@ -438,15 +434,15 @@ ASSEMBLER BEFORE OPTIMIZATION // And then allocate a bunch of variables main: { .label SCREEN = $400 - .label a = $f9 - .label a_1 = $f7 + .label a = $f7 + .label h = $f9 // [1] phi from main to main::@1 [phi:main->main::@1] __b1_from_main: - // [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsm1=vwsc1 + // [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsz1=vwsc1 lda #<0 - sta h + sta.z h lda #>0 - sta h+1 + sta.z h+1 // [1] phi main::g#2 = 0 [phi:main->main::@1#1] -- vwsm1=vwsc1 lda #<0 sta g @@ -479,9 +475,9 @@ main: { sta b+1 // [1] phi main::a#4 = 0 [phi:main->main::@1#7] -- vwsz1=vwsc1 lda #<0 - sta.z a_1 + sta.z a lda #>0 - sta.z a_1+1 + sta.z a+1 // [1] phi main::i#2 = 0 [phi:main->main::@1#8] -- vbuyy=vbuc1 ldy #0 jmp __b1 @@ -502,18 +498,15 @@ main: { asl tax // [5] main::SCREEN[main::$2] = main::a#4 -- pwsc1_derefidx_vbuxx=vwsz1 - lda.z a_1 + lda.z a sta SCREEN,x - lda.z a_1+1 + lda.z a+1 sta SCREEN+1,x - // [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz2 - clc - lda.z a_1 - adc #1 - sta.z a - lda.z a_1+1 - adc #0 - sta.z a+1 + // [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz1 + inc.z a + bne !+ + inc.z a+1 + !: // [7] main::SCREEN[main::$2] = main::b#2 -- pwsc1_derefidx_vbuxx=vwsm1 lda b sta SCREEN,x @@ -584,29 +577,26 @@ main: { bne !+ inc g+1 !: - // [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsm1 - lda h + // [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsz1 + lda.z h sta SCREEN,x - lda h+1 + lda.z h+1 sta SCREEN+1,x - // [22] main::h#1 = ++ main::h#2 -- vwsm1=_inc_vwsm1 - inc h + // [22] main::h#1 = ++ main::h#2 -- vwsz1=_inc_vwsz1 + inc.z h bne !+ - inc h+1 + inc.z h+1 !: // [23] main::SCREEN[main::$2] = main::a#2 -- pwsc1_derefidx_vbuxx=vwsz1 lda.z a sta SCREEN,x lda.z a+1 sta SCREEN+1,x - // [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz2 - clc - lda.z a - adc #1 - sta.z a_1 - lda.z a+1 - adc #0 - sta.z a_1+1 + // [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz1 + inc.z a + bne !+ + inc.z a+1 + !: // [25] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy iny // [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1] @@ -628,7 +618,6 @@ main: { e: .word 0 f: .word 0 g: .word 0 - h: .word 0 } // File Data @@ -663,10 +652,10 @@ void main() char main::$2 // reg byte x 6.3684210526315805 __constant int * const main::SCREEN = (int *) 1024 int main::a -int main::a#1 // a zp[2]:249 4.125 -int main::a#2 // a zp[2]:249 3.3000000000000003 -int main::a#3 // a_1 zp[2]:247 11.0 -int main::a#4 // a_1 zp[2]:247 8.25 +int main::a#1 // a zp[2]:247 4.125 +int main::a#2 // a zp[2]:247 3.3000000000000003 +int main::a#3 // a zp[2]:247 11.0 +int main::a#4 // a zp[2]:247 8.25 int main::b int main::b#1 // b mem[2] 1.2222222222222223 int main::b#2 // b mem[2] 5.5 @@ -686,27 +675,26 @@ int main::g int main::g#1 // g mem[2] 3.6666666666666665 int main::g#2 // g mem[2] 1.8333333333333335 int main::h -int main::h#1 // h mem[2] 5.5 -int main::h#2 // h mem[2] 1.6500000000000001 +int main::h#1 // h zp[2]:249 5.5 +int main::h#2 // h zp[2]:249 1.6500000000000001 char main::i char main::i#1 // reg byte y 22.0 char main::i#2 // reg byte y 1.9130434782608696 reg byte y [ main::i#2 main::i#1 ] -zp[2]:247 [ main::a#4 main::a#3 ] +zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ] mem[2] [ main::b#2 main::b#1 ] mem[2] [ main::c#2 main::c#1 ] mem[2] [ main::d#2 main::d#1 ] mem[2] [ main::e#2 main::e#1 ] mem[2] [ main::f#2 main::f#1 ] mem[2] [ main::g#2 main::g#1 ] -mem[2] [ main::h#2 main::h#1 ] +zp[2]:249 [ main::h#2 main::h#1 ] reg byte x [ main::$2 ] -zp[2]:249 [ main::a#1 main::a#2 ] FINAL ASSEMBLER -Score: 4061 +Score: 3891 // File Comments // Tests that variables overflow to main memory when zeropage is exhausted @@ -725,13 +713,13 @@ Score: 4061 // And then allocate a bunch of variables main: { .label SCREEN = $400 - .label a = $f9 - .label a_1 = $f7 + .label a = $f7 + .label h = $f9 // [1] phi from main to main::@1 [phi:main->main::@1] - // [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsm1=vwsc1 + // [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsz1=vwsc1 lda #<0 - sta h - sta h+1 + sta.z h + sta.z h+1 // [1] phi main::g#2 = 0 [phi:main->main::@1#1] -- vwsm1=vwsc1 sta g sta g+1 @@ -751,8 +739,8 @@ main: { sta b sta b+1 // [1] phi main::a#4 = 0 [phi:main->main::@1#7] -- vwsz1=vwsc1 - sta.z a_1 - sta.z a_1+1 + sta.z a + sta.z a+1 // [1] phi main::i#2 = 0 [phi:main->main::@1#8] -- vbuyy=vbuc1 tay // main::@1 @@ -773,19 +761,16 @@ main: { asl tax // [5] main::SCREEN[main::$2] = main::a#4 -- pwsc1_derefidx_vbuxx=vwsz1 - lda.z a_1 + lda.z a sta SCREEN,x - lda.z a_1+1 + lda.z a+1 sta SCREEN+1,x // SCREEN[i] = a++; - // [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz2 - clc - lda.z a_1 - adc #1 - sta.z a - lda.z a_1+1 - adc #0 - sta.z a+1 + // [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz1 + inc.z a + bne !+ + inc.z a+1 + !: // SCREEN[i] = b++ // [7] main::SCREEN[main::$2] = main::b#2 -- pwsc1_derefidx_vbuxx=vwsm1 lda b @@ -871,16 +856,16 @@ main: { inc g+1 !: // SCREEN[i] = h++ - // [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsm1 - lda h + // [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsz1 + lda.z h sta SCREEN,x - lda h+1 + lda.z h+1 sta SCREEN+1,x // SCREEN[i] = h++; - // [22] main::h#1 = ++ main::h#2 -- vwsm1=_inc_vwsm1 - inc h + // [22] main::h#1 = ++ main::h#2 -- vwsz1=_inc_vwsz1 + inc.z h bne !+ - inc h+1 + inc.z h+1 !: // SCREEN[i] = a++ // [23] main::SCREEN[main::$2] = main::a#2 -- pwsc1_derefidx_vbuxx=vwsz1 @@ -889,14 +874,11 @@ main: { lda.z a+1 sta SCREEN+1,x // SCREEN[i] = a++; - // [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz2 - clc - lda.z a - adc #1 - sta.z a_1 - lda.z a+1 - adc #0 - sta.z a_1+1 + // [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz1 + inc.z a + bne !+ + inc.z a+1 + !: // for(char i=0;i<10;i++) // [25] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy iny @@ -918,7 +900,6 @@ main: { e: .word 0 f: .word 0 g: .word 0 - h: .word 0 } // File Data diff --git a/src/test/ref/zeropage-overflow.sym b/src/test/ref/zeropage-overflow.sym index 497c1c806..55516a22d 100644 --- a/src/test/ref/zeropage-overflow.sym +++ b/src/test/ref/zeropage-overflow.sym @@ -2,10 +2,10 @@ void main() char main::$2 // reg byte x 6.3684210526315805 __constant int * const main::SCREEN = (int *) 1024 int main::a -int main::a#1 // a zp[2]:249 4.125 -int main::a#2 // a zp[2]:249 3.3000000000000003 -int main::a#3 // a_1 zp[2]:247 11.0 -int main::a#4 // a_1 zp[2]:247 8.25 +int main::a#1 // a zp[2]:247 4.125 +int main::a#2 // a zp[2]:247 3.3000000000000003 +int main::a#3 // a zp[2]:247 11.0 +int main::a#4 // a zp[2]:247 8.25 int main::b int main::b#1 // b mem[2] 1.2222222222222223 int main::b#2 // b mem[2] 5.5 @@ -25,20 +25,19 @@ int main::g int main::g#1 // g mem[2] 3.6666666666666665 int main::g#2 // g mem[2] 1.8333333333333335 int main::h -int main::h#1 // h mem[2] 5.5 -int main::h#2 // h mem[2] 1.6500000000000001 +int main::h#1 // h zp[2]:249 5.5 +int main::h#2 // h zp[2]:249 1.6500000000000001 char main::i char main::i#1 // reg byte y 22.0 char main::i#2 // reg byte y 1.9130434782608696 reg byte y [ main::i#2 main::i#1 ] -zp[2]:247 [ main::a#4 main::a#3 ] +zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ] mem[2] [ main::b#2 main::b#1 ] mem[2] [ main::c#2 main::c#1 ] mem[2] [ main::d#2 main::d#1 ] mem[2] [ main::e#2 main::e#1 ] mem[2] [ main::f#2 main::f#1 ] mem[2] [ main::g#2 main::g#1 ] -mem[2] [ main::h#2 main::h#1 ] +zp[2]:249 [ main::h#2 main::h#1 ] reg byte x [ main::$2 ] -zp[2]:249 [ main::a#1 main::a#2 ]