From c45e992aef6d7713307e3344199a35add0843d49 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 15 Sep 2020 20:13:46 +0200 Subject: [PATCH] Optimized fragment. Thanks @IcePic. #513 --- .../cache/fragment-cache-csg65ce02.asm | 2 +- .../cache/fragment-cache-mega45gs02.asm | 1315 +++++++++++++---- .../fragment/cache/fragment-cache-mos6502.asm | 2 +- .../cache/fragment-cache-mos6502x.asm | 2 +- .../cache/fragment-cache-wdc65c02.asm | 2 +- .../pwuc1_derefidx_vbuyy_eq_0_then_la1.asm | 7 +- src/test/kc/examples/mega65/raster65.c | 1 + src/test/ref/examples/mega65/raster65.asm | 1 + src/test/ref/examples/mega65/raster65.log | 5 +- 9 files changed, 1003 insertions(+), 334 deletions(-) diff --git a/src/main/fragment/cache/fragment-cache-csg65ce02.asm b/src/main/fragment/cache/fragment-cache-csg65ce02.asm index bd3cc9030..b38989b40 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 17a386c46b 17a386dcb0 +//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-mega45gs02.asm b/src/main/fragment/cache/fragment-cache-mega45gs02.asm index f757b82ca..b307e0258 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 17a386c46b 17a386dcb0 +//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c //FRAGMENT _deref_pbuc1=vbuc2 lda #{c2} sta {c1} @@ -59,329 +59,6 @@ ldz {z1} //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} -//FRAGMENT vbuz1=_inc_vbuz1 -inc {z1} -//FRAGMENT vbuz1=vbuz2 -lda {z2} -sta {z1} -//FRAGMENT vbuz1_neq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -bne {la1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 -lda #{c2} -ldy {z1} -sta {c1},y -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2 -ldy {z2} -lda {c1},y -sta {z1} -//FRAGMENT _deref_pbuc1=vbuz1 -lda {z1} -sta {c1} -//FRAGMENT vbuz1_lt_vbuc1_then_la1 -lda {z1} -cmp #{c1} -bcc {la1} -//FRAGMENT vbuz1_eq_vbuc1_then_la1 -lda #{c1} -cmp {z1} -beq {la1} -//FRAGMENT vbuz1=vbuz2_plus_1 -lda {z2} -inc -sta {z1} -//FRAGMENT vbuz1_neq_0_then_la1 -lda {z1} -cmp #0 -bne {la1} -//FRAGMENT vbuz1=_deref_pbuc1 -lda {c1} -sta {z1} -//FRAGMENT vbuz1_eq__deref_pbuc1_then_la1 -lda {c1} -cmp {z1} -beq {la1} -//FRAGMENT vbuz1=vbuc1_plus_pbuc2_derefidx_vbuz2 -lda #{c1} -ldy {z2} -clc -adc {c2},y -sta {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 -ldy {z1} -lda {c2},y -sta {c1},y -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuc2 -lda #{c2} -and {c1} -sta {c1} -//FRAGMENT _deref_qprc1=pprc2 -lda #<{c2} -sta {c1} -lda #>{c2} -sta {c1}+1 -//FRAGMENT pbuz1_neq_pbuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bne {la1} -lda {z1} -cmp #<{c1} -bne {la1} -//FRAGMENT vbuaa=vbuz1 -lda {z1} -//FRAGMENT vbuxx=vbuz1 -ldx {z1} -//FRAGMENT vbuaa_neq_vbuc1_then_la1 -cmp #{c1} -bne {la1} -//FRAGMENT pbuc1_derefidx_vbuaa=vbuc2 -tay -lda #{c2} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuc2 -lda #{c2} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuc2 -lda #{c2} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuc2 -tza -tay -lda #{c2} -sta {c1},y -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1 -ldy {z1} -ldx {c1},y -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1 -ldx {z1} -ldy {c1},x -//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1 -ldx {z1} -ldz {c1},x -//FRAGMENT _deref_pbuc1=vbuaa -sta {c1} -//FRAGMENT vbuaa_lt_vbuc1_then_la1 -cmp #{c1} -bcc {la1} -//FRAGMENT vbuaa_eq_vbuc1_then_la1 -cmp #{c1} -beq {la1} -//FRAGMENT vbuz1=vbuaa_plus_1 -inc -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_1 -inx -stx {z1} -//FRAGMENT vbuaa=_deref_pbuc1 -lda {c1} -//FRAGMENT vbuxx=_deref_pbuc1 -ldx {c1} -//FRAGMENT vbuaa_eq__deref_pbuc1_then_la1 -cmp {c1} -beq {la1} -//FRAGMENT vbuz1=vbuc1_plus_pbuc2_derefidx_vbuxx -lda #{c1} -clc -adc {c2},x -sta {z1} -//FRAGMENT vbuz1=vbuc1_plus_pbuc2_derefidx_vbuyy -lda #{c1} -clc -adc {c2},y -sta {z1} -//FRAGMENT vbuz1=vbuc1_plus_pbuc2_derefidx_vbuzz -tza -tay -lda #{c1} -clc -adc {c2},y -sta {z1} -//FRAGMENT vbuaa=vbuc1_plus_pbuc2_derefidx_vbuz1 -lda #{c1} -ldy {z1} -clc -adc {c2},y -//FRAGMENT vbuaa=vbuc1_plus_pbuc2_derefidx_vbuxx -lda #{c1} -clc -adc {c2},x -//FRAGMENT vbuaa=vbuc1_plus_pbuc2_derefidx_vbuyy -lda #{c1} -clc -adc {c2},y -//FRAGMENT vbuaa=vbuc1_plus_pbuc2_derefidx_vbuzz -tza -tay -lda #{c1} -clc -adc {c2},y -//FRAGMENT vbuxx=vbuc1_plus_pbuc2_derefidx_vbuz1 -lda #{c1} -ldx {z1} -clc -adc {c2},x -tax -//FRAGMENT vbuxx=vbuc1_plus_pbuc2_derefidx_vbuxx -lda #{c1} -clc -adc {c2},x -tax -//FRAGMENT vbuxx=vbuc1_plus_pbuc2_derefidx_vbuyy -lda #{c1} -clc -adc {c2},y -tax -//FRAGMENT vbuxx=vbuc1_plus_pbuc2_derefidx_vbuzz -tza -tax -lda #{c1} -clc -adc {c2},x -tax -//FRAGMENT vbuyy=vbuc1_plus_pbuc2_derefidx_vbuz1 -lda #{c1} -ldy {z1} -clc -adc {c2},y -tay -//FRAGMENT vbuyy=vbuc1_plus_pbuc2_derefidx_vbuxx -lda #{c1} -clc -adc {c2},x -tay -//FRAGMENT vbuyy=vbuc1_plus_pbuc2_derefidx_vbuyy -lda #{c1} -clc -adc {c2},y -tay -//FRAGMENT vbuyy=vbuc1_plus_pbuc2_derefidx_vbuzz -tza -tay -lda #{c1} -clc -adc {c2},y -tay -//FRAGMENT vbuzz=vbuc1_plus_pbuc2_derefidx_vbuz1 -lda #{c1} -ldy {z1} -clc -adc {c2},y -taz -//FRAGMENT vbuzz=vbuc1_plus_pbuc2_derefidx_vbuxx -lda #{c1} -clc -adc {c2},x -taz -//FRAGMENT vbuzz=vbuc1_plus_pbuc2_derefidx_vbuyy -lda #{c1} -clc -adc {c2},y -taz -//FRAGMENT vbuzz=vbuc1_plus_pbuc2_derefidx_vbuzz -tza -tay -lda #{c1} -clc -adc {c2},y -taz -//FRAGMENT pbuc1_derefidx_vbuaa=pbuc2_derefidx_vbuaa -tay -lda {c2},y -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx -lda {c2},x -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy -lda {c2},y -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuzz -tza -tay -lda {c2},y -sta {c1},y -//FRAGMENT vbuxx_neq_0_then_la1 -cpx #0 -bne {la1} -//FRAGMENT vbuxx_neq_vbuc1_then_la1 -cpx #{c1} -bne {la1} -//FRAGMENT vbuxx_lt_vbuc1_then_la1 -cpx #{c1} -bcc {la1} -//FRAGMENT vbuxx_eq_vbuc1_then_la1 -cpx #{c1} -beq {la1} -//FRAGMENT vbuxx=vbuc1 -ldx #{c1} -//FRAGMENT vbuxx=_inc_vbuxx -inx -//FRAGMENT vbuyy=vbuc1 -ldy #{c1} -//FRAGMENT vbuyy_lt_vbuc1_then_la1 -cpy #{c1} -bcc {la1} -//FRAGMENT vbuyy=_inc_vbuyy -iny -//FRAGMENT vbuzz=vbuc1 -ldz #{c1} -//FRAGMENT vbuzz_lt_vbuc1_then_la1 -cpz #{c1} -bcc {la1} -//FRAGMENT vbuzz=_inc_vbuzz -inz -//FRAGMENT vbuyy_neq_0_then_la1 -cpy #0 -bne {la1} -//FRAGMENT vbuzz_neq_0_then_la1 -cpz #0 -bne {la1} -//FRAGMENT vbuxx_eq__deref_pbuc1_then_la1 -cpx {c1} -beq {la1} -//FRAGMENT vbuyy=_deref_pbuc1 -ldy {c1} -//FRAGMENT vbuyy_eq__deref_pbuc1_then_la1 -cpy {c1} -beq {la1} -//FRAGMENT vbuzz=_deref_pbuc1 -ldz {c1} -//FRAGMENT vbuzz_eq__deref_pbuc1_then_la1 -cpz {c1} -beq {la1} -//FRAGMENT vbuyy=vbuz1 -ldy {z1} -//FRAGMENT vbuzz=vbuz1 -ldz {z1} -//FRAGMENT vbuyy_neq_vbuc1_then_la1 -cpy #{c1} -bne {la1} -//FRAGMENT vbuzz_neq_vbuc1_then_la1 -cpz #{c1} -bne {la1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx -lda {c1},x -sta {z1} -//FRAGMENT vbuaa=vbuz1_plus_1 -lda {z1} -inc -//FRAGMENT vbuyy=vbuz1_plus_1 -ldy {z1} -iny -//FRAGMENT _deref_pbuc1=vbuyy -sty {c1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx -lda {c1},x -//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx -ldy {c1},x -//FRAGMENT vbuaa=vbuaa_plus_1 -inc -//FRAGMENT vbuaa=vbuyy_plus_1 -tya -inc //FRAGMENT vbuz1=_deref_pbuz2 ldy #0 lda ({z2}),y @@ -390,6 +67,13 @@ sta {z1} lda #{c1} cmp {z1} bne {la1} +//FRAGMENT vbuz1=vbuz2 +lda {z2} +sta {z1} +//FRAGMENT vbuz1_eq_vbuc1_then_la1 +lda #{c1} +cmp {z1} +beq {la1} //FRAGMENT pbuz1_derefidx_vbuz2=vbuz3 lda {z3} ldy {z2} @@ -398,6 +82,12 @@ sta ({z1}),y lda #{c1} ldy {z2} sta ({z1}),y +//FRAGMENT vbuz1=_inc_vbuz1 +inc {z1} +//FRAGMENT vbuz1_neq_vbuc1_then_la1 +lda #{c1} +cmp {z1} +bne {la1} //FRAGMENT pbuz1=pbuz1_plus_vbuc1 lda #{c1} clc @@ -474,6 +164,9 @@ cmp #{c1} bne {la1} //FRAGMENT vbuz1=vbuaa sta {z1} +//FRAGMENT vbuaa_eq_vbuc1_then_la1 +cmp #{c1} +beq {la1} //FRAGMENT pbuz1_derefidx_vbuz2=vbuaa ldy {z2} sta ({z1}),y @@ -481,6 +174,19 @@ sta ({z1}),y txa ldz {z2} sta ({z1}),z +//FRAGMENT vbuxx=vbuc1 +ldx #{c1} +//FRAGMENT vbuzz=vbuc1 +ldz #{c1} +//FRAGMENT vbuaa=vbuz1 +lda {z1} +//FRAGMENT vbuxx=vbuz1 +ldx {z1} +//FRAGMENT vbuxx_eq_vbuc1_then_la1 +cpx #{c1} +beq {la1} +//FRAGMENT vbuyy=vbuz1 +ldy {z1} //FRAGMENT vbuyy_eq_vbuc1_then_la1 cpy #{c1} beq {la1} @@ -488,6 +194,8 @@ beq {la1} tya ldy {z2} sta ({z1}),y +//FRAGMENT vbuzz=vbuz1 +ldz {z1} //FRAGMENT vbuzz_eq_vbuc1_then_la1 cpz #{c1} beq {la1} @@ -515,6 +223,10 @@ lda #{c1} ldy {z1} cmp {c2},y bne {la1} +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 +ldy {z1} +lda {c2},y +sta {c1},y //FRAGMENT pbuc1_derefidx_vbuz1=vbuz1 ldy {z1} tya @@ -538,6 +250,17 @@ tay lda #{c1} cmp {c2},y bne {la1} +//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx +lda {c2},x +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy +lda {c2},y +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuzz +tza +tay +lda {c2},y +sta {c1},y //FRAGMENT pbuc1_derefidx_vbuxx=vbuxx txa sta {c1},x @@ -548,6 +271,14 @@ sta {c1},y tza tax sta {c1},x +//FRAGMENT vbuxx=_inc_vbuxx +inx +//FRAGMENT vbuyy=vbuc1 +ldy #{c1} +//FRAGMENT vbuyy=_inc_vbuyy +iny +//FRAGMENT vbuzz=_inc_vbuzz +inz //FRAGMENT vduz1=vduc1 lda #<{c1} sta {z1} @@ -557,6 +288,10 @@ lda #<{c1}>>$10 sta {z1}+2 lda #>{c1}>>$10 sta {z1}+3 +//FRAGMENT vbuz1_lt_vbuc1_then_la1 +lda {z1} +cmp #{c1} +bcc {la1} //FRAGMENT _deref_pduc1=vduz1 ldq {z1} stq {c1} @@ -579,7 +314,939 @@ sta {z1}+2 lda {z1}+3 adc #0 sta {z1}+3 +//FRAGMENT vbuaa_lt_vbuc1_then_la1 +cmp #{c1} +bcc {la1} //FRAGMENT vduz1=vwuc1 NO_SYNTHESIS //FRAGMENT vduz1=vwsc1 NO_SYNTHESIS +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_ror_1 +ldy {z2} +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbuz1=vbuz2_band_vbuc1 +lda #{c1} +and {z2} +sta {z1} +//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 +lda {z2} +ldy {z1} +sta {c1},y +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sta {z1} +//FRAGMENT vbuz1=vbuz2_rol_4 +lda {z2} +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuz1=vbuz1_plus_vbuc1 +lda #{c1} +clc +adc {z1} +sta {z1} +//FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 +lda #{c2} +ldy {z1} +sta {c1},y +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_ror_2 +ldy {z2} +lda {c1},y +lsr +lsr +sta {z1} +//FRAGMENT vbuz1=vbuz2_ror_1 +lda {z2} +lsr +sta {z1} +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 +ldy {z2} +lda {c2},y +ldy {z1} +sta {c1},y +//FRAGMENT _deref_pbuc1=vbuz1 +lda {z1} +sta {c1} +//FRAGMENT vbuz1=vbuz2_plus_1 +lda {z2} +inc +sta {z1} +//FRAGMENT vbuz1_neq_0_then_la1 +lda {z1} +cmp #0 +bne {la1} +//FRAGMENT vbuz1=_deref_pbuc1 +lda {c1} +sta {z1} +//FRAGMENT vbuz1_eq__deref_pbuc1_then_la1 +lda {c1} +cmp {z1} +beq {la1} +//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuz1 +ldy {z1} +lda {c2},y +sta {c1} +//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuc2 +lda #{c2} +and {c1} +sta {c1} +//FRAGMENT _deref_qprc1=pprc2 +lda #<{c2} +sta {c1} +lda #>{c2} +sta {c1}+1 +//FRAGMENT pbuz1_neq_pbuc1_then_la1 +lda {z1}+1 +cmp #>{c1} +bne {la1} +lda {z1} +cmp #<{c1} +bne {la1} +//FRAGMENT vbuaa_neq_vbuc1_then_la1 +cmp #{c1} +bne {la1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_ror_1 +tay +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz_ror_1 +tza +tay +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_ror_1 +ldy {z1} +lda {c1},y +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_ror_1 +tay +lda {c1},y +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz_ror_1 +tza +tay +lda {c1},y +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_ror_1 +ldx {z1} +lda {c1},x +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_ror_1 +tax +lda {c1},x +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuzz_ror_1 +tza +tax +lda {c1},x +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_ror_1 +ldy {z1} +lda {c1},y +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_ror_1 +tay +lda {c1},y +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz_ror_1 +tza +tay +lda {c1},y +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1_ror_1 +ldy {z1} +lda {c1},y +lsr +taz +//FRAGMENT vbuzz=pbuc1_derefidx_vbuaa_ror_1 +tay +lda {c1},y +lsr +taz +//FRAGMENT vbuzz=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +taz +//FRAGMENT vbuzz=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +taz +//FRAGMENT vbuzz=pbuc1_derefidx_vbuzz_ror_1 +tza +tay +lda {c1},y +lsr +taz +//FRAGMENT vbuaa=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +//FRAGMENT vbuxx=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +tax +//FRAGMENT vbuyy=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +tay +//FRAGMENT vbuzz=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +taz +//FRAGMENT vbuz1=vbuaa_band_vbuc1 +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuaa_band_vbuc1 +and #{c1} +//FRAGMENT vbuxx=vbuaa_band_vbuc1 +and #{c1} +tax +//FRAGMENT vbuyy=vbuaa_band_vbuc1 +and #{c1} +tay +//FRAGMENT vbuzz=vbuaa_band_vbuc1 +and #{c1} +taz +//FRAGMENT vbuz1=vbuxx_band_vbuc1 +txa +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuxx_band_vbuc1 +txa +and #{c1} +//FRAGMENT vbuxx=vbuxx_band_vbuc1 +txa +and #{c1} +tax +//FRAGMENT vbuyy=vbuxx_band_vbuc1 +txa +and #{c1} +tay +//FRAGMENT vbuzz=vbuxx_band_vbuc1 +txa +and #{c1} +taz +//FRAGMENT vbuz1=vbuyy_band_vbuc1 +tya +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuyy_band_vbuc1 +tya +and #{c1} +//FRAGMENT vbuxx=vbuyy_band_vbuc1 +tya +and #{c1} +tax +//FRAGMENT vbuyy=vbuyy_band_vbuc1 +tya +and #{c1} +tay +//FRAGMENT vbuzz=vbuyy_band_vbuc1 +tya +and #{c1} +taz +//FRAGMENT vbuz1=vbuzz_band_vbuc1 +tza +and #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuzz_band_vbuc1 +tza +and #{c1} +//FRAGMENT vbuxx=vbuzz_band_vbuc1 +tza +and #{c1} +tax +//FRAGMENT vbuyy=vbuzz_band_vbuc1 +tza +and #{c1} +tay +//FRAGMENT vbuzz=vbuzz_band_vbuc1 +tza +and #{c1} +taz +//FRAGMENT pbuc1_derefidx_vbuxx=vbuz1 +lda {z1} +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=vbuz1 +lda {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuz1 +tza +tay +lda {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=vbuaa +ldy {z1} +sta {c1},y +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1 +ldy {z1} +ldx {c1},y +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1 +ldx {z1} +ldy {c1},x +//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1 +ldx {z1} +ldz {c1},x +//FRAGMENT vbuaa=vbuz1_rol_4 +lda {z1} +asl +asl +asl +asl +//FRAGMENT vbuxx=vbuz1_rol_4 +lda {z1} +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=vbuz1_rol_4 +lda {z1} +asl +asl +asl +asl +tay +//FRAGMENT vbuzz=vbuz1_rol_4 +lda {z1} +asl +asl +asl +asl +taz +//FRAGMENT vbuz1=vbuaa_rol_4 +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuaa=vbuaa_rol_4 +asl +asl +asl +asl +//FRAGMENT vbuxx=vbuaa_rol_4 +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=vbuaa_rol_4 +asl +asl +asl +asl +tay +//FRAGMENT vbuzz=vbuaa_rol_4 +asl +asl +asl +asl +taz +//FRAGMENT vbuz1=vbuxx_rol_4 +txa +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuaa=vbuxx_rol_4 +txa +asl +asl +asl +asl +//FRAGMENT vbuxx=vbuxx_rol_4 +txa +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=vbuxx_rol_4 +txa +asl +asl +asl +asl +tay +//FRAGMENT vbuzz=vbuxx_rol_4 +txa +asl +asl +asl +asl +taz +//FRAGMENT vbuz1=vbuyy_rol_4 +tya +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuaa=vbuyy_rol_4 +tya +asl +asl +asl +asl +//FRAGMENT vbuxx=vbuyy_rol_4 +tya +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=vbuyy_rol_4 +tya +asl +asl +asl +asl +tay +//FRAGMENT vbuzz=vbuyy_rol_4 +tya +asl +asl +asl +asl +taz +//FRAGMENT vbuz1=vbuzz_rol_4 +tza +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuaa=vbuzz_rol_4 +tza +asl +asl +asl +asl +//FRAGMENT vbuxx=vbuzz_rol_4 +tza +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=vbuzz_rol_4 +tza +asl +asl +asl +asl +tay +//FRAGMENT vbuzz=vbuzz_rol_4 +tza +asl +asl +asl +asl +taz +//FRAGMENT vbuxx=vbuxx_plus_vbuc1 +txa +clc +adc #{c1} +tax +//FRAGMENT vbuyy=vbuyy_plus_vbuc1 +tya +clc +adc #{c1} +tay +//FRAGMENT vbuzz=vbuzz_plus_vbuc1 +tza +clc +adc #{c1} +taz +//FRAGMENT pbuc1_derefidx_vbuz1=vbuxx +ldy {z1} +txa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=vbuyy +tya +ldy {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=vbuzz +ldy {z1} +tza +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuaa=vbuc2 +tay +lda #{c2} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuxx=vbuc2 +lda #{c2} +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=vbuc2 +lda #{c2} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuc2 +tza +tay +lda #{c2} +sta {c1},y +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_ror_2 +ldy {z1} +lda {c1},y +lsr +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_ror_2 +ldx {z1} +lda {c1},x +lsr +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_ror_2 +ldy {z1} +lda {c1},y +lsr +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1_ror_2 +ldy {z1} +lda {c1},y +lsr +lsr +taz +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_ror_2 +tay +lda {c1},y +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_ror_2 +tay +lda {c1},y +lsr +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_ror_2 +tax +lda {c1},x +lsr +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_ror_2 +tay +lda {c1},y +lsr +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuaa_ror_2 +tay +lda {c1},y +lsr +lsr +taz +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_ror_2 +lda {c1},x +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_ror_2 +lda {c1},x +lsr +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_ror_2 +lda {c1},x +lsr +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_ror_2 +lda {c1},x +lsr +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuxx_ror_2 +lda {c1},x +lsr +lsr +taz +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_ror_2 +lda {c1},y +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_ror_2 +lda {c1},y +lsr +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_ror_2 +lda {c1},y +lsr +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_ror_2 +lda {c1},y +lsr +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuyy_ror_2 +lda {c1},y +lsr +lsr +taz +//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz_ror_2 +tza +tay +lda {c1},y +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz_ror_2 +tza +tay +lda {c1},y +lsr +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuzz_ror_2 +tza +tax +lda {c1},x +lsr +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz_ror_2 +tza +tay +lda {c1},y +lsr +lsr +tay +//FRAGMENT vbuzz=pbuc1_derefidx_vbuzz_ror_2 +tza +tay +lda {c1},y +lsr +lsr +taz +//FRAGMENT vbuz1=vbuaa_ror_1 +lsr +sta {z1} +//FRAGMENT vbuz1=vbuxx_ror_1 +txa +lsr +sta {z1} +//FRAGMENT vbuz1=vbuyy_ror_1 +tya +lsr +sta {z1} +//FRAGMENT vbuz1=vbuzz_ror_1 +tza +lsr +sta {z1} +//FRAGMENT vbuaa=vbuz1_ror_1 +lda {z1} +lsr +//FRAGMENT vbuaa=vbuaa_ror_1 +lsr +//FRAGMENT vbuaa=vbuxx_ror_1 +txa +lsr +//FRAGMENT vbuaa=vbuyy_ror_1 +tya +lsr +//FRAGMENT vbuaa=vbuzz_ror_1 +tza +lsr +//FRAGMENT vbuxx=vbuz1_ror_1 +lda {z1} +lsr +tax +//FRAGMENT vbuxx=vbuaa_ror_1 +lsr +tax +//FRAGMENT vbuxx=vbuxx_ror_1 +txa +lsr +tax +//FRAGMENT vbuxx=vbuyy_ror_1 +tya +lsr +tax +//FRAGMENT vbuxx=vbuzz_ror_1 +tza +lsr +tax +//FRAGMENT vbuyy=vbuz1_ror_1 +lda {z1} +lsr +tay +//FRAGMENT vbuyy=vbuaa_ror_1 +lsr +tay +//FRAGMENT vbuyy=vbuxx_ror_1 +txa +lsr +tay +//FRAGMENT vbuyy=vbuyy_ror_1 +tya +lsr +tay +//FRAGMENT vbuyy=vbuzz_ror_1 +tza +lsr +tay +//FRAGMENT vbuzz=vbuz1_ror_1 +lda {z1} +lsr +taz +//FRAGMENT vbuzz=vbuaa_ror_1 +lsr +taz +//FRAGMENT vbuzz=vbuxx_ror_1 +txa +lsr +taz +//FRAGMENT vbuzz=vbuyy_ror_1 +tya +lsr +taz +//FRAGMENT vbuzz=vbuzz_ror_1 +tza +lsr +taz +//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuz1 +ldy {z1} +lda {c2},y +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuz1 +ldx {z1} +lda {c2},x +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuz1 +ldx {z1} +tza +tay +lda {c2},x +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuxx +lda {c2},x +ldy {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx +lda {c2},x +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuxx +tza +tay +lda {c2},x +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuyy +lda {c2},y +ldy {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuyy +lda {c2},y +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuyy +tza +tax +lda {c2},y +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuzz +tza +tay +lda {c2},y +ldy {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuzz +tza +tay +lda {c2},y +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuzz +tza +tax +lda {c2},x +sta {c1},y +//FRAGMENT _deref_pbuc1=vbuaa +sta {c1} +//FRAGMENT vbuz1=vbuaa_plus_1 +inc +sta {z1} +//FRAGMENT vbuz1=vbuxx_plus_1 +inx +stx {z1} +//FRAGMENT vbuaa=_deref_pbuc1 +lda {c1} +//FRAGMENT vbuxx=_deref_pbuc1 +ldx {c1} +//FRAGMENT vbuaa_eq__deref_pbuc1_then_la1 +cmp {c1} +beq {la1} +//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuxx +lda {c2},x +sta {c1} +//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuyy +lda {c2},y +sta {c1} +//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuzz +tza +tay +lda {c2},y +sta {c1} +//FRAGMENT pbuc1_derefidx_vbuaa=pbuc2_derefidx_vbuaa +tay +lda {c2},y +sta {c1},y +//FRAGMENT vbuxx_neq_0_then_la1 +cpx #0 +bne {la1} +//FRAGMENT vbuxx_neq_vbuc1_then_la1 +cpx #{c1} +bne {la1} +//FRAGMENT vbuxx_lt_vbuc1_then_la1 +cpx #{c1} +bcc {la1} +//FRAGMENT vbuaa=_dec_vbuaa +sec +sbc #1 +//FRAGMENT vbuaa=_inc_vbuaa +inc +//FRAGMENT vbuxx=_dec_vbuxx +dex +//FRAGMENT vbuyy=_dec_vbuyy +dey +//FRAGMENT vbuzz=_dec_vbuzz +dez +//FRAGMENT pbuc1_derefidx_vbuxx=vbuaa +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuxx=vbuyy +tya +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuxx=vbuzz +tza +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=vbuaa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=vbuxx +txa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=vbuzz +tza +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuaa +tax +tza +tay +txa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuxx +tza +tay +txa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuyy +tza +tax +tya +sta {c1},x +//FRAGMENT vbuaa=vbuc1 +lda #{c1} +//FRAGMENT vbuyy_lt_vbuc1_then_la1 +cpy #{c1} +bcc {la1} +//FRAGMENT vbuzz_lt_vbuc1_then_la1 +cpz #{c1} +bcc {la1} +//FRAGMENT vbuyy_neq_0_then_la1 +cpy #0 +bne {la1} +//FRAGMENT vbuzz_neq_0_then_la1 +cpz #0 +bne {la1} +//FRAGMENT vbuxx_eq__deref_pbuc1_then_la1 +cpx {c1} +beq {la1} +//FRAGMENT vbuyy=_deref_pbuc1 +ldy {c1} +//FRAGMENT vbuyy_eq__deref_pbuc1_then_la1 +cpy {c1} +beq {la1} +//FRAGMENT vbuzz=_deref_pbuc1 +ldz {c1} +//FRAGMENT vbuzz_eq__deref_pbuc1_then_la1 +cpz {c1} +beq {la1} +//FRAGMENT vbuyy_neq_vbuc1_then_la1 +cpy #{c1} +bne {la1} +//FRAGMENT vbuzz_neq_vbuc1_then_la1 +cpz #{c1} +bne {la1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy +lda {c1},y +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz +tza +tay +lda {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuz1_plus_1 +lda {z1} +inc +//FRAGMENT vbuyy=vbuz1_plus_1 +ldy {z1} +iny +//FRAGMENT _deref_pbuc1=vbuyy +sty {c1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz +tza +tay +lda {c1},y +//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz +tza +tax +ldy {c1},x +//FRAGMENT vbuaa=vbuaa_plus_1 +inc +//FRAGMENT vbuaa=vbuyy_plus_1 +tya +inc diff --git a/src/main/fragment/cache/fragment-cache-mos6502.asm b/src/main/fragment/cache/fragment-cache-mos6502.asm index e2872981d..cb8dbef44 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 17a386c46b 17a386dcb0 +//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c //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 325985c0f..2ba889d19 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 17a386c46b 17a386dcb0 +//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-wdc65c02.asm b/src/main/fragment/cache/fragment-cache-wdc65c02.asm index dc301b95d..650149bb9 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 17a386c46b 17a386dcb0 +//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} diff --git a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_eq_0_then_la1.asm b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_eq_0_then_la1.asm index 8cef7e26e..b9f37752e 100644 --- a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_eq_0_then_la1.asm +++ b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_eq_0_then_la1.asm @@ -1,7 +1,4 @@ lda {c1},y +ora {c1}+1,y cmp #0 -bne !+ -lda {c1}+1,y -cmp #0 -beq {la1} -!: \ No newline at end of file +beq {la1} \ No newline at end of file diff --git a/src/test/kc/examples/mega65/raster65.c b/src/test/kc/examples/mega65/raster65.c index dbfa6bb5a..b20defafc 100644 --- a/src/test/kc/examples/mega65/raster65.c +++ b/src/test/kc/examples/mega65/raster65.c @@ -8,6 +8,7 @@ #include #include +// The screen address char * const SCREEN = 0x0400; // Logo y-position (char row on screen) diff --git a/src/test/ref/examples/mega65/raster65.asm b/src/test/ref/examples/mega65/raster65.asm index 9cb07d162..84189c2fe 100644 --- a/src/test/ref/examples/mega65/raster65.asm +++ b/src/test/ref/examples/mega65/raster65.asm @@ -72,6 +72,7 @@ .label CIA1 = $dc00 // The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe + // The screen address .label SCREEN = $400 // Pointer to the song init routine .label songInit = SONG diff --git a/src/test/ref/examples/mega65/raster65.log b/src/test/ref/examples/mega65/raster65.log index 5af71f835..d3667b25a 100644 --- a/src/test/ref/examples/mega65/raster65.log +++ b/src/test/ref/examples/mega65/raster65.log @@ -2236,6 +2236,7 @@ Target platform is mega65_c64 / MEGA45GS02 .label CIA1 = $dc00 // The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe + // The screen address .label SCREEN = $400 // Pointer to the song init routine .label songInit = SONG @@ -3289,6 +3290,7 @@ ASSEMBLER BEFORE OPTIMIZATION .label CIA1 = $dc00 // The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe + // The screen address .label SCREEN = $400 // Pointer to the song init routine .label songInit = SONG @@ -4054,7 +4056,7 @@ Removing instruction __b1_from___b2: Succesful ASM optimization Pass5UnusedLabelElimination Removing instruction jmp __b5 Succesful ASM optimization Pass5NextJumpElimination -Fixing long branch [128] bne __b2 to beq +Fixing long branch [129] bne __b2 to beq FINAL SYMBOL TABLE (const nomodify struct MOS6526_CIA*) CIA1 = (struct MOS6526_CIA*) 56320 @@ -4635,6 +4637,7 @@ Score: 9456 .label CIA1 = $dc00 // The vector used when the HARDWARE serves IRQ interrupts .label HARDWARE_IRQ = $fffe + // The screen address .label SCREEN = $400 // Pointer to the song init routine .label songInit = SONG