diff --git a/src/main/fragment/cache/fragment-cache-csg65ce02.asm b/src/main/fragment/cache/fragment-cache-csg65ce02.asm index 5bdf9ece4..1b5fe6283 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 132c9fe4d5 132c9ffe57 +//KICKC FRAGMENT CACHE 12beec37ea 12beec5182 //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 66deb076a..6d3f30609 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 132c9fe4d5 132c9ffe57 +//KICKC FRAGMENT CACHE 12beec37ea 12beec5182 //FRAGMENT _deref_pbuc1=vbuc2 lda #{c2} sta {c1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502.asm b/src/main/fragment/cache/fragment-cache-mos6502.asm index 16818e497..bf917b621 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 132c9fe4d5 132c9ffe57 +//KICKC FRAGMENT CACHE 12beec37ea 12beec5182 //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 339640eed..c90d7b74e 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -1,614 +1,12 @@ -//KICKC FRAGMENT CACHE 132c9fe4d5 132c9ffe57 -//FRAGMENT vbsz1=vbsc1 -lda #{c1} -sta {z1} +//KICKC FRAGMENT CACHE 12beec37ea 12beec5182 //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} -//FRAGMENT vbuz1_lt_vbuc1_then_la1 -lda {z1} -cmp #{c1} -bcc {la1} -//FRAGMENT _deref_pbuc1_neq_vbuc2_then_la1 -lda #{c2} -cmp {c1} -bne {la1} -//FRAGMENT _deref_pbuc1=vbuc2 -lda #{c2} -sta {c1} //FRAGMENT pbuz1=pbuc1 lda #<{c1} sta {z1} lda #>{c1} sta {z1}+1 -//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_(pbsc1_derefidx_vbuz2)=vbuc2 -lda #{c2} -ldx {z2} -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbsc1_derefidx_vbuz1=pbsc1_derefidx_vbuz1_plus_pbsc2_derefidx_vbuz1 -ldy {z1} -clc -lda {c1},y -adc {c2},y -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuz1_lt_0_then_la1 -ldy {z1} -lda {c1},y -cmp #0 -bmi {la1} -//FRAGMENT pbsc1_derefidx_vbuz1_lt_vbsc2_then_la1 -ldy {z1} -lda {c1},y -sec -sbc #{c2} -bvc !+ -eor #$80 -!: -bmi {la1} -//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuz2 -ldy {z2} -lda {c1},y -eor #$ff -clc -adc #$01 -sta {z1} -//FRAGMENT pbsc1_derefidx_vbuz1=vbsz2 -lda {z2} -ldy {z1} -sta {c1},y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=pbuc2_derefidx_vbuz2 -ldx {z2} -lda {c2},x -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbuz1=pbuz1_plus_vbuc1 -lda #{c1} -clc -adc {z1} -sta {z1} -bcc !+ -inc {z1}+1 -!: -//FRAGMENT vbuz1=_inc_vbuz1 -inc {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 -lda {z2} -ldy {z1} -sta {c1},y -//FRAGMENT vbsz1=_neg_vbsz1 -lda {z1} -eor #$ff -clc -adc #$01 -sta {z1} -//FRAGMENT vbuaa_lt_vbuc1_then_la1 -cmp #{c1} -bcc {la1} -//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=vbuz1_rol_1 -lda {z1} -asl -//FRAGMENT vbuaa=vbuaa_rol_1 -asl -//FRAGMENT vbuaa=vbuxx_rol_1 -txa -asl -//FRAGMENT vbuaa=vbuyy_rol_1 -tya -asl -//FRAGMENT vbuxx=vbuz1_rol_1 -lda {z1} -asl -tax -//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=vbuz1_rol_1 -lda {z1} -asl -tay -//FRAGMENT vbuyy=vbuaa_rol_1 -asl -tay -//FRAGMENT vbuyy=vbuxx_rol_1 -txa -asl -tay -//FRAGMENT vbuyy=vbuyy_rol_1 -tya -asl -tay -//FRAGMENT vbuz1=vbuz2_plus_vbuxx -txa -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuz2_plus_vbuyy -tya -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuaa_plus_vbuz2 -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuaa_plus_vbuxx -stx $ff -clc -adc $ff -sta {z1} -//FRAGMENT vbuz1=vbuaa_plus_vbuyy -sty $ff -clc -adc $ff -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_vbuz2 -txa -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_vbuxx -txa -asl -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_vbuyy -txa -sty $ff -clc -adc $ff -sta {z1} -//FRAGMENT vbuz1=vbuyy_plus_vbuz2 -tya -clc -adc {z2} -sta {z1} -//FRAGMENT vbuz1=vbuyy_plus_vbuxx -txa -sty $ff -clc -adc $ff -sta {z1} -//FRAGMENT vbuz1=vbuyy_plus_vbuyy -tya -asl -sta {z1} -//FRAGMENT vbuaa=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -//FRAGMENT vbuaa=vbuz1_plus_vbuxx -txa -clc -adc {z1} -//FRAGMENT vbuaa=vbuz1_plus_vbuyy -tya -clc -adc {z1} -//FRAGMENT vbuaa=vbuaa_plus_vbuz1 -clc -adc {z1} -//FRAGMENT vbuaa=vbuaa_plus_vbuxx -stx $ff -clc -adc $ff -//FRAGMENT vbuaa=vbuaa_plus_vbuyy -sty $ff -clc -adc $ff -//FRAGMENT vbuaa=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -//FRAGMENT vbuaa=vbuxx_plus_vbuxx -txa -asl -//FRAGMENT vbuaa=vbuxx_plus_vbuyy -txa -sty $ff -clc -adc $ff -//FRAGMENT vbuaa=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -//FRAGMENT vbuaa=vbuyy_plus_vbuxx -txa -sty $ff -clc -adc $ff -//FRAGMENT vbuaa=vbuyy_plus_vbuyy -tya -asl -//FRAGMENT vbuxx=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -tax -//FRAGMENT vbuxx=vbuz1_plus_vbuxx -txa -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuz1_plus_vbuyy -tya -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuaa_plus_vbuz1 -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuaa_plus_vbuxx -stx $ff -clc -adc $ff -tax -//FRAGMENT vbuxx=vbuaa_plus_vbuyy -sty $ff -clc -adc $ff -tax -//FRAGMENT vbuxx=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuxx_plus_vbuxx -txa -asl -tax -//FRAGMENT vbuxx=vbuxx_plus_vbuyy -txa -sty $ff -clc -adc $ff -tax -//FRAGMENT vbuxx=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -tax -//FRAGMENT vbuxx=vbuyy_plus_vbuxx -txa -sty $ff -clc -adc $ff -tax -//FRAGMENT vbuxx=vbuyy_plus_vbuyy -tya -asl -tax -//FRAGMENT vbuyy=vbuz1_plus_vbuz2 -lda {z1} -clc -adc {z2} -tay -//FRAGMENT vbuyy=vbuz1_plus_vbuxx -txa -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuz1_plus_vbuyy -tya -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuaa_plus_vbuz1 -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuaa_plus_vbuxx -stx $ff -clc -adc $ff -tay -//FRAGMENT vbuyy=vbuaa_plus_vbuyy -sty $ff -clc -adc $ff -tay -//FRAGMENT vbuyy=vbuxx_plus_vbuz1 -txa -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuxx_plus_vbuxx -txa -asl -tay -//FRAGMENT vbuyy=vbuxx_plus_vbuyy -txa -sty $ff -clc -adc $ff -tay -//FRAGMENT vbuyy=vbuyy_plus_vbuz1 -tya -clc -adc {z1} -tay -//FRAGMENT vbuyy=vbuyy_plus_vbuxx -txa -sty $ff -clc -adc $ff -tay -//FRAGMENT vbuyy=vbuyy_plus_vbuyy -tya -asl -tay -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=vbuc2 -tax -lda #{c2} -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=vbuc2 -lda #{c2} -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuyy)=vbuc2 -tya -tax -lda #{c2} -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx -clc -lda {c1},x -adc {c2},x -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuxx_lt_0_then_la1 -lda {c1},x -cmp #0 -bmi {la1} -//FRAGMENT pbsc1_derefidx_vbuxx_lt_vbsc2_then_la1 -lda {c1},x -sec -sbc #{c2} -bvc !+ -eor #$80 -!: -bmi {la1} -//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuaa -tay -lda {c1},y -eor #$ff -clc -adc #$01 -sta {z1} -//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuxx -lda {c1},x -eor #$ff -clc -adc #$01 -sta {z1} -//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuyy -lda {c1},y -eor #$ff -clc -adc #$01 -sta {z1} -//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -eor #$ff -clc -adc #$01 -//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuaa -tay -lda {c1},y -eor #$ff -clc -adc #$01 -//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuxx -lda {c1},x -eor #$ff -clc -adc #$01 -//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuyy -lda {c1},y -eor #$ff -clc -adc #$01 -//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuz1 -ldx {z1} -lda {c1},x -eor #$ff -clc -adc #$01 -tax -//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuaa -tax -lda {c1},x -eor #$ff -clc -adc #$01 -tax -//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuxx -lda {c1},x -eor #$ff -clc -adc #$01 -tax -//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuyy -lda {c1},y -eor #$ff -clc -adc #$01 -tax -//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -eor #$ff -clc -adc #$01 -tay -//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuaa -tay -lda {c1},y -eor #$ff -clc -adc #$01 -tay -//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuxx -lda {c1},x -eor #$ff -clc -adc #$01 -tay -//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuyy -lda {c1},y -eor #$ff -clc -adc #$01 -tay -//FRAGMENT pbsc1_derefidx_vbuxx=vbsz1 -lda {z1} -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuyy=vbsz1 -lda {z1} -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuz1=vbsaa -ldy {z1} -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuyy=pbsc1_derefidx_vbuyy_plus_pbsc2_derefidx_vbuyy -clc -lda {c1},y -adc {c2},y -sta {c1},y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=pbuc2_derefidx_vbuaa -tax -lda {c2},x -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=pbuc2_derefidx_vbuxx -lda {c2},x -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuyy)=pbuc2_derefidx_vbuyy -tya -tax -lda {c2},x -ldy {c1},x -sta ({z1}),y -//FRAGMENT pbsc1_derefidx_vbuz1=vbsxx -ldy {z1} -txa -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuz1=vbsyy -tya -ldy {z1} -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuaa=vbsz1 -tay -lda {z1} -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuaa=vbsxx -tay -txa -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuaa=vbsyy -tax -tya -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuxx=vbsxx -txa -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuxx=vbsyy -tya -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuyy=vbsxx -txa -sta {c1},y -//FRAGMENT pbsc1_derefidx_vbuyy=vbsyy -tya -sta {c1},y -//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_vbuxx=vbuz1 -lda {z1} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuxx=vbuxx -txa -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuxx=vbuyy -tya -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuz1 -lda {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuyy=vbuxx -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuyy=vbuyy -tya -sta {c1},y -//FRAGMENT vbsxx=_neg_vbsxx -txa -eor #$ff -clc -adc #$01 -tax -//FRAGMENT vbsyy=_neg_vbsyy -tya -eor #$ff -clc -adc #$01 -tay -//FRAGMENT vbuxx_lt_vbuc1_then_la1 -cpx #{c1} -bcc {la1} -//FRAGMENT vbuxx=vbuc1 -ldx #{c1} -//FRAGMENT vbuxx=_inc_vbuxx -inx -//FRAGMENT pbsc1_derefidx_vbuxx=vbsaa -sta {c1},x -//FRAGMENT pbsc1_derefidx_vbuyy=vbsaa -sta {c1},y -//FRAGMENT vbuyy=vbuc1 -ldy #{c1} -//FRAGMENT vbuyy_lt_vbuc1_then_la1 -cpy #{c1} -bcc {la1} -//FRAGMENT vbuyy=_inc_vbuyy -iny -//FRAGMENT vbsyy=vbsc1 -ldy #{c1} //FRAGMENT vwuz1=vwuc1 lda #<{c1} sta {z1} @@ -645,6 +43,8 @@ lda {z2} sta {z1} lda {z2}+1 sta {z1}+1 +//FRAGMENT vbuz1=_inc_vbuz1 +inc {z1} //FRAGMENT vbuz1_neq_vbuc1_then_la1 lda #{c1} cmp {z1} @@ -680,6 +80,14 @@ sta {z1} //FRAGMENT vbuz1=_lo_vwuz2 lda {z2} sta {z1} +//FRAGMENT pbuz1=pbuz1_plus_vbuc1 +lda #{c1} +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: //FRAGMENT pbuz1_lt_pbuz2_then_la1 lda {z1}+1 cmp {z2}+1 @@ -847,19 +255,33 @@ and #{c1} tay //FRAGMENT vbuaa=vbuc1 lda #{c1} +//FRAGMENT vbuxx=vbuc1 +ldx #{c1} +//FRAGMENT vbuyy=vbuc1 +ldy #{c1} //FRAGMENT vbuaa=pbuc1_derefidx_vbuxx lda {c1},x //FRAGMENT vbuaa=pbuc1_derefidx_vbuyy lda {c1},y +//FRAGMENT vbuz1_lt_vbuc1_then_la1 +lda {z1} +cmp #{c1} +bcc {la1} //FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 lda #{c2} ldy {z1} sta {c1},y +//FRAGMENT _deref_pbuc1=vbuc2 +lda #{c2} +sta {c1} //FRAGMENT vbuz1=vbuz1_plus_2 lda {z1} clc adc #2 sta {z1} +//FRAGMENT vbuaa_lt_vbuc1_then_la1 +cmp #{c1} +bcc {la1} //FRAGMENT pbuc1_derefidx_vbuaa=vbuc2 tay lda #{c2} @@ -873,6 +295,12 @@ sta {c1},y //FRAGMENT vbuxx=vbuxx_plus_2 inx inx +//FRAGMENT vbuxx_lt_vbuc1_then_la1 +cpx #{c1} +bcc {la1} +//FRAGMENT vbuyy_lt_vbuc1_then_la1 +cpy #{c1} +bcc {la1} //FRAGMENT vbuyy=vbuyy_plus_2 iny iny @@ -963,6 +391,11 @@ lda {z2} sec sbc {z3} sta {z1} +//FRAGMENT vbuz1=vbuz2_plus_vbuz3 +lda {z2} +clc +adc {z3} +sta {z1} //FRAGMENT vbuz1=_dec_vbuz1 dec {z1} //FRAGMENT vbuz1_eq_0_then_la1 @@ -989,6 +422,12 @@ sta {z1}+1 //FRAGMENT vbsz1_lt_0_then_la1 lda {z1} bmi {la1} +//FRAGMENT vbsz1=_neg_vbsz1 +lda {z1} +eor #$ff +clc +adc #$01 +sta {z1} //FRAGMENT vwuz1=vbuc1 lda #<{c1} sta {z1} @@ -1416,6 +855,20 @@ tay //FRAGMENT vbuyy=vbuyy_minus_vbuyy lda #0 tay +//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_vbuaa clc adc {z2} @@ -1431,6 +884,63 @@ tax clc adc {z1} tay +//FRAGMENT vbuz1=vbuz2_plus_vbuxx +txa +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuz1_plus_vbuxx +txa +clc +adc {z1} +//FRAGMENT vbuxx=vbuz1_plus_vbuxx +txa +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuz1_plus_vbuxx +txa +clc +adc {z1} +tay +//FRAGMENT vbuz1=vbuz2_plus_vbuyy +tya +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuz1_plus_vbuyy +tya +clc +adc {z1} +//FRAGMENT vbuxx=vbuz1_plus_vbuyy +tya +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuz1_plus_vbuyy +tya +clc +adc {z1} +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_vbuaa stx $ff clc @@ -1450,6 +960,63 @@ stx $ff clc adc $ff tay +//FRAGMENT vbuz1=vbuxx_plus_vbuxx +txa +asl +sta {z1} +//FRAGMENT vbuaa=vbuxx_plus_vbuxx +txa +asl +//FRAGMENT vbuxx=vbuxx_plus_vbuxx +txa +asl +tax +//FRAGMENT vbuyy=vbuxx_plus_vbuxx +txa +asl +tay +//FRAGMENT vbuz1=vbuxx_plus_vbuyy +txa +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbuaa=vbuxx_plus_vbuyy +txa +sty $ff +clc +adc $ff +//FRAGMENT vbuxx=vbuxx_plus_vbuyy +txa +sty $ff +clc +adc $ff +tax +//FRAGMENT vbuyy=vbuxx_plus_vbuyy +txa +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_vbuaa sty $ff clc @@ -1469,6 +1036,44 @@ sty $ff clc adc $ff tay +//FRAGMENT vbuz1=vbuyy_plus_vbuxx +txa +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbuaa=vbuyy_plus_vbuxx +txa +sty $ff +clc +adc $ff +//FRAGMENT vbuxx=vbuyy_plus_vbuxx +txa +sty $ff +clc +adc $ff +tax +//FRAGMENT vbuyy=vbuyy_plus_vbuxx +txa +sty $ff +clc +adc $ff +tay +//FRAGMENT vbuz1=vbuyy_plus_vbuyy +tya +asl +sta {z1} +//FRAGMENT vbuaa=vbuyy_plus_vbuyy +tya +asl +//FRAGMENT vbuxx=vbuyy_plus_vbuyy +tya +asl +tax +//FRAGMENT vbuyy=vbuyy_plus_vbuyy +tya +asl +tay //FRAGMENT vbuxx_eq_0_then_la1 cpx #0 beq {la1} @@ -1519,6 +1124,12 @@ txa eor #$ff clc adc #$01 +//FRAGMENT vbsxx=_neg_vbsxx +txa +eor #$ff +clc +adc #$01 +tax //FRAGMENT vbsyy=_neg_vbsxx txa eor #$ff @@ -1542,6 +1153,12 @@ eor #$ff clc adc #$01 tax +//FRAGMENT vbsyy=_neg_vbsyy +tya +eor #$ff +clc +adc #$01 +tay //FRAGMENT vbsxx_ge_0_then_la1 cpx #0 bpl {la1} @@ -1661,6 +1278,10 @@ ldy {z1}+1 //FRAGMENT vbuyy=vbuaa_band_vbuc1 and #{c1} tay +//FRAGMENT vbuxx=_inc_vbuxx +inx +//FRAGMENT vbuyy=_inc_vbuyy +iny //FRAGMENT vbuyy_neq_vbuc1_then_la1 cpy #{c1} bne {la1} @@ -1774,9 +1395,39 @@ bne !- lda {z1} cmp {z2} beq {la1} +//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 +lda {z2} +ldy {z1} +sta {c1},y //FRAGMENT vbuz1_eq_vbuaa_then_la1 cmp {z1} beq {la1} +//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_vbuxx=vbuz1 +lda {z1} +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuxx=vbuxx +txa +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuxx=vbuyy +tya +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=vbuz1 +lda {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=vbuxx +txa +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=vbuyy +tya +sta {c1},y //FRAGMENT vbuz1_eq_vbuyy_then_la1 tya cmp {z1} @@ -1948,6 +1599,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 @@ -1966,6 +1621,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 @@ -2033,6 +1740,9 @@ lda #<{c1} sta {z1} lda #>{c1} sta {z1}+1 +//FRAGMENT vbsz1=vbsc1 +lda #{c1} +sta {z1} //FRAGMENT vbsz1=pbsc1_derefidx_vbuz2 ldy {z2} lda {c1},y @@ -4199,6 +3909,296 @@ sta {c1},x lda ({z2}),y ldx {z1} sta {c1},x +//FRAGMENT _deref_pbuc1_neq_vbuc2_then_la1 +lda #{c2} +cmp {c1} +bne {la1} +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=vbuc2 +lda #{c2} +ldx {z2} +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbsc1_derefidx_vbuz1=pbsc1_derefidx_vbuz1_plus_pbsc2_derefidx_vbuz1 +ldy {z1} +clc +lda {c1},y +adc {c2},y +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuz1_lt_0_then_la1 +ldy {z1} +lda {c1},y +cmp #0 +bmi {la1} +//FRAGMENT pbsc1_derefidx_vbuz1_lt_vbsc2_then_la1 +ldy {z1} +lda {c1},y +sec +sbc #{c2} +bvc !+ +eor #$80 +!: +bmi {la1} +//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +eor #$ff +clc +adc #$01 +sta {z1} +//FRAGMENT pbsc1_derefidx_vbuz1=vbsz2 +lda {z2} +ldy {z1} +sta {c1},y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=pbuc2_derefidx_vbuz2 +ldx {z2} +lda {c2},x +ldy {c1},x +sta ({z1}),y +//FRAGMENT vbuz1=vbuaa_plus_vbuz2 +clc +adc {z2} +sta {z1} +//FRAGMENT vbuz1=vbuaa_plus_vbuxx +stx $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbuz1=vbuaa_plus_vbuyy +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbuaa=vbuaa_plus_vbuz1 +clc +adc {z1} +//FRAGMENT vbuaa=vbuaa_plus_vbuxx +stx $ff +clc +adc $ff +//FRAGMENT vbuaa=vbuaa_plus_vbuyy +sty $ff +clc +adc $ff +//FRAGMENT vbuxx=vbuaa_plus_vbuz1 +clc +adc {z1} +tax +//FRAGMENT vbuxx=vbuaa_plus_vbuxx +stx $ff +clc +adc $ff +tax +//FRAGMENT vbuxx=vbuaa_plus_vbuyy +sty $ff +clc +adc $ff +tax +//FRAGMENT vbuyy=vbuaa_plus_vbuz1 +clc +adc {z1} +tay +//FRAGMENT vbuyy=vbuaa_plus_vbuxx +stx $ff +clc +adc $ff +tay +//FRAGMENT vbuyy=vbuaa_plus_vbuyy +sty $ff +clc +adc $ff +tay +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=vbuc2 +tax +lda #{c2} +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=vbuc2 +lda #{c2} +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuyy)=vbuc2 +tya +tax +lda #{c2} +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbsc1_derefidx_vbuxx=pbsc1_derefidx_vbuxx_plus_pbsc2_derefidx_vbuxx +clc +lda {c1},x +adc {c2},x +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuxx_lt_0_then_la1 +lda {c1},x +cmp #0 +bmi {la1} +//FRAGMENT pbsc1_derefidx_vbuxx_lt_vbsc2_then_la1 +lda {c1},x +sec +sbc #{c2} +bvc !+ +eor #$80 +!: +bmi {la1} +//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuaa +tay +lda {c1},y +eor #$ff +clc +adc #$01 +sta {z1} +//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuxx +lda {c1},x +eor #$ff +clc +adc #$01 +sta {z1} +//FRAGMENT vbsz1=_neg_pbsc1_derefidx_vbuyy +lda {c1},y +eor #$ff +clc +adc #$01 +sta {z1} +//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +eor #$ff +clc +adc #$01 +//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuaa +tay +lda {c1},y +eor #$ff +clc +adc #$01 +//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuxx +lda {c1},x +eor #$ff +clc +adc #$01 +//FRAGMENT vbsaa=_neg_pbsc1_derefidx_vbuyy +lda {c1},y +eor #$ff +clc +adc #$01 +//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuz1 +ldx {z1} +lda {c1},x +eor #$ff +clc +adc #$01 +tax +//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuaa +tax +lda {c1},x +eor #$ff +clc +adc #$01 +tax +//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuxx +lda {c1},x +eor #$ff +clc +adc #$01 +tax +//FRAGMENT vbsxx=_neg_pbsc1_derefidx_vbuyy +lda {c1},y +eor #$ff +clc +adc #$01 +tax +//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +eor #$ff +clc +adc #$01 +tay +//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuaa +tay +lda {c1},y +eor #$ff +clc +adc #$01 +tay +//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuxx +lda {c1},x +eor #$ff +clc +adc #$01 +tay +//FRAGMENT vbsyy=_neg_pbsc1_derefidx_vbuyy +lda {c1},y +eor #$ff +clc +adc #$01 +tay +//FRAGMENT pbsc1_derefidx_vbuxx=vbsz1 +lda {z1} +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuyy=vbsz1 +lda {z1} +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuz1=vbsaa +ldy {z1} +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuyy=pbsc1_derefidx_vbuyy_plus_pbsc2_derefidx_vbuyy +clc +lda {c1},y +adc {c2},y +sta {c1},y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuaa)=pbuc2_derefidx_vbuaa +tax +lda {c2},x +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuxx)=pbuc2_derefidx_vbuxx +lda {c2},x +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuyy)=pbuc2_derefidx_vbuyy +tya +tax +lda {c2},x +ldy {c1},x +sta ({z1}),y +//FRAGMENT pbsc1_derefidx_vbuz1=vbsxx +ldy {z1} +txa +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuz1=vbsyy +tya +ldy {z1} +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuaa=vbsz1 +tay +lda {z1} +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuaa=vbsxx +tay +txa +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuaa=vbsyy +tax +tya +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuxx=vbsxx +txa +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuxx=vbsyy +tya +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuyy=vbsxx +txa +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuyy=vbsyy +tya +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuxx=vbsaa +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuyy=vbsaa +sta {c1},y +//FRAGMENT vbsyy=vbsc1 +ldy #{c1} //FRAGMENT vbuz1=vbuz2_plus_vbuc1 lax {z2} axs #-[{c1}] @@ -6053,6 +6053,155 @@ tay //FRAGMENT vboz1=vboyy tya sta {z1} +//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sta {z1} +//FRAGMENT pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_plus_1 +ldx {z1} +inc {c1},x +bne !+ +inc {c1}+1,x +!: +//FRAGMENT pwuc1_derefidx_vbuz1_lt_vbuc2_then_la1 +ldy {z1} +lda {c1}+1,y +bne !+ +lda {c1},y +cmp #{c2} +bcc {la1} +!: +//FRAGMENT pwuc1_derefidx_vbuz1=vbuc2 +lda {z1} +ldx #{c2} +tay +txa +sta {c1},y +//FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuz3 +ldy {z3} +clc +lda {z2} +adc {c1},y +sta {z1} +lda {z2}+1 +adc {c1}+1,y +sta {z1}+1 +//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuaa +tay +lda {c1},y +sta {z1} +//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuxx +lda {c1},x +sta {z1} +//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuyy +lda {c1},y +sta {z1} +//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuaa +tay +lda {c1},y +//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuxx +lda {c1},x +//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuyy +lda {c1},y +//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuz1 +ldx {z1} +lda {c1},x +tax +//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuaa +tax +lda {c1},x +tax +//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuxx +lda {c1},x +tax +//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuyy +lda {c1},y +tax +//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +tay +//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuaa +tay +lda {c1},y +tay +//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuxx +lda {c1},x +tay +//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuyy +lda {c1},y +tay +//FRAGMENT pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1 +inc {c1},x +bne !+ +inc {c1}+1,x +!: +//FRAGMENT pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1 +lda {c1}+1,x +bne !+ +lda {c1},x +cmp #{c2} +bcc {la1} +!: +//FRAGMENT pwuc1_derefidx_vbuyy_lt_vbuc2_then_la1 +lda {c1}+1,y +bne !+ +lda {c1},y +cmp #{c2} +bcc {la1} +!: +//FRAGMENT pwuc1_derefidx_vbuaa=vbuc2 +ldx #{c2} +tay +txa +sta {c1},y +//FRAGMENT pwuc1_derefidx_vbuxx=vbuc2 +lda #{c2} +sta {c1},x +lda #0 +sta {c1}+1,x +//FRAGMENT pwuc1_derefidx_vbuyy=vbuc2 +lda #{c2} +sta {c1},y +lda #0 +sta {c1}+1,y +//FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa +tay +clc +lda {z2} +adc {c1},y +sta {z1} +lda {z2}+1 +adc {c1}+1,y +sta {z1}+1 +//FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuxx +txa +tay +clc +lda {z2} +adc {c1},y +sta {z1} +lda {z2}+1 +adc {c1}+1,y +sta {z1}+1 +//FRAGMENT pbuz1=pbuz2_plus_pwuc1_derefidx_vbuyy +clc +lda {z2} +adc {c1},y +sta {z1} +lda {z2}+1 +adc {c1}+1,y +sta {z1}+1 +//FRAGMENT pwuc1_derefidx_vbuyy=pwuc1_derefidx_vbuyy_plus_1 +tya +tax +inc {c1},x +bne !+ +inc {c1}+1,x +!: //FRAGMENT vbuz1=vbuc1_bor_vbuz2 lda #{c1} ora {z2} @@ -8426,29 +8575,6 @@ sta {z1} lda {z1}+1 eor {z2}+1 sta {z1}+1 -//FRAGMENT vwuz1_lt_vbuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bcc {la1} -bne !+ -lda {z1} -cmp #<{c1} -bcc {la1} -!: -//FRAGMENT vwuz1=_word_vduz2 -lda {z2} -sta {z1} -lda {z2}+1 -sta {z1}+1 -//FRAGMENT vduz1=vwuz2_dword_vwuz3 -lda {z2} -sta {z1}+2 -lda {z2}+1 -sta {z1}+3 -lda {z3} -sta {z1} -lda {z3}+1 -sta {z1}+1 //FRAGMENT _deref_pbuz1_eq_vbuz2_then_la1 lda {z2} ldy #0 @@ -12361,6 +12487,15 @@ sta {z1} lda {z2}+1 adc #>{c1} sta {z1}+1 +//FRAGMENT vduz1=vwuz2_dword_vwuz3 +lda {z2} +sta {z1}+2 +lda {z2}+1 +sta {z1}+3 +lda {z3} +sta {z1} +lda {z3}+1 +sta {z1}+1 //FRAGMENT vduz1_lt_vduc1_then_la1 lda {z1}+3 cmp #>{c1}>>$10 @@ -12528,184 +12663,6 @@ rol {z1}+3 dex bne !- !e: -//FRAGMENT pssz1=pssc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT vwuz1=vwuz1_minus_1 -lda {z1} -sec -sbc #1 -sta {z1} -lda {z1}+1 -sbc #0 -sta {z1}+1 -//FRAGMENT vbuz1=vbuz1_minus_1 -dec {z1} -//FRAGMENT pbsz1_derefidx_vbuc1=pbsz1_derefidx_vbuc1_plus_pbsz1_derefidx_vbuc2 -ldy #{c2} -lda ({z1}),y -ldy #{c1} -tax -lda ({z1}),y -sty $ff - -stx $ff -clc -adc $ff -ldy $ff -sta ({z1}),y -//FRAGMENT pbsz1_derefidx_vbuc1_lt_vbsc2_then_la1 -ldy #{c1} -lda ({z1}),y - -sec -sbc #{c2} -bvc !+ -eor #$80 -!: -bmi {la1} -//FRAGMENT pbsz1_derefidx_vbuc1=vbsc2 -lda #{c1} -tay -lda #{c2} -sta ({z1}),y -//FRAGMENT pwsz1_derefidx_vbuc1_gt_vwsc2_then_la1 -ldy #{c1} -lda #<{c2} -cmp ({z1}),y -iny -lda #>{c2} -sbc ({z1}),y -bvc !+ -eor #$80 -!: -bmi {la1} -!e: -//FRAGMENT pwsz1_derefidx_vbuc1_ge_vwsc2_then_la1 -ldy #{c1} -lda ({z1}),y -cmp #<{c2} -iny -lda ({z1}),y -sbc #>{c2} -bvc !+ -eor #$80 -!: -bpl {la1} -//FRAGMENT pwsz1_derefidx_vbuc1=pwsz1_derefidx_vbuc1_plus_pbsz1_derefidx_vbuc2 -ldy #{c2} -lda ({z1}),y -sta $fe -ora #$7f -bmi !+ -lda #0 -!: -sta $ff -ldy #{c1} -clc -lda ({z1}),y -adc $fe -sta ({z1}),y -iny -lda ({z1}),y -adc $fe -sta ({z1}),y -//FRAGMENT pbuc1_derefidx_vbuz1_ge_vbuc2_then_la1 -ldy {z1} -lda {c1},y -cmp #{c2} -bcs {la1} -//FRAGMENT vwsz1=pwsz2_derefidx_vbuc1_ror_vbuc2 -ldx #{c2} -ldy #{c1} -lda ({z2}),y -sta {z1} -iny -lda ({z2}),y -sta {z1}+1 -cpx #0 -beq !e+ -!: -lda {z1}+1 -cmp #$80 -ror {z1}+1 -ror {z1} -dex -bne !- -!e: -//FRAGMENT pbuc1_derefidx_vbuz1=_byte_vwsz2 -ldy {z1} -lda {z2} -sta {c1},y -//FRAGMENT pssz1=pssz1_plus_vbuc1 -lda #{c1} -clc -adc {z1} -sta {z1} -bcc !+ -inc {z1}+1 -!: -//FRAGMENT pwsz1_derefidx_vbuc1=vwsc2 -ldy #{c1} -lda #<{c2} -sta ({z1}),y -iny -lda #>{c2} -sta ({z1}),y -//FRAGMENT pbsz1_derefidx_vbuc1=vbsz2 -lda #{c1} -tay -lda {z2} -sta ({z1}),y -//FRAGMENT pbuc1_derefidx_vbuz1_lt_vbuc2_then_la1 -ldy {z1} -lda {c1},y -cmp #{c2} -bcc {la1} -//FRAGMENT vbuc1_eq_pbuc2_derefidx_vbuz1_then_la1 -ldy {z1} -lda {c2},y -cmp #{c1} -beq {la1} -//FRAGMENT pbsz1_derefidx_vbuc1=vbsxx -lda #{c1} -tay -txa -sta ({z1}),y -//FRAGMENT pbuc1_derefidx_vbuaa_lt_vbuc2_then_la1 -tay -lda {c1},y -cmp #{c2} -bcc {la1} -//FRAGMENT pbuc1_derefidx_vbuxx_lt_vbuc2_then_la1 -lda {c1},x -cmp #{c2} -bcc {la1} -//FRAGMENT pbuc1_derefidx_vbuyy_lt_vbuc2_then_la1 -lda {c1},y -cmp #{c2} -bcc {la1} -//FRAGMENT vbuc1_eq_pbuc2_derefidx_vbuaa_then_la1 -tay -lda {c2},y -cmp #{c1} -beq {la1} -//FRAGMENT vbuc1_eq_pbuc2_derefidx_vbuxx_then_la1 -lda {c2},x -cmp #{c1} -beq {la1} -//FRAGMENT vbuc1_eq_pbuc2_derefidx_vbuyy_then_la1 -lda {c2},y -cmp #{c1} -beq {la1} -//FRAGMENT vbuxx=vbuxx_minus_1 -dex -//FRAGMENT vbuyy=vbuyy_minus_1 -tya -tay -dey //FRAGMENT vwsz1_neq_vwsc1_then_la1 lda {z1}+1 cmp #>{c1} @@ -13034,6 +12991,19 @@ ldy #{c2} tax lda ({z1}),y sta {c1},x +//FRAGMENT pssz1=pssc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +//FRAGMENT pssz1=pssz1_plus_vbuc1 +lda #{c1} +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: //FRAGMENT pbuc1_derefidx_vbuaa=pbuz1_derefidx_vbuc2 ldy #{c2} tax @@ -13408,23 +13378,6 @@ cmp {z2} beq {la1} !: bcc {la1} -//FRAGMENT vduz1=vwuz2_dword_vwuc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -lda {z2} -sta {z1}+2 -lda {z2}+1 -sta {z1}+3 -//FRAGMENT vwuz1=vwuz1_minus_vbuc1 -sec -lda {z1} -sbc #{c1} -sta {z1} -lda {z1}+1 -sbc #0 -sta {z1}+1 //FRAGMENT vbuz1=vbuz2_plus_pbuc1_derefidx_vbuz3 lda {z2} ldy {z3} @@ -17771,6 +17724,8 @@ lda ({z1}),y cmp #0 beq {la1} +//FRAGMENT vbuxx=vbuxx_minus_1 +dex //FRAGMENT pduc1_derefidx_vbuaa=pduc1_derefidx_vbuaa_plus_pduc2_derefidx_vbuaa tay clc @@ -18102,6 +18057,12 @@ tya clc adc {c1} tay +//FRAGMENT vbuz1=vbuz1_minus_1 +dec {z1} +//FRAGMENT vbuyy=vbuyy_minus_1 +tya +tay +dey //FRAGMENT vwsz1=pwsc1_derefidx_vbuz2_plus__deref_pwsz3 ldx {z2} clc @@ -18159,227 +18120,6 @@ adc ({z1}),y sta {z1}+1 pla sta {z1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_vbuc2 -lda #{c2} -ldy {z2} -clc -adc {c1},y -sta {z1} -//FRAGMENT pwuc1_derefidx_vbuz1=vbuc2 -lda {z1} -ldx #{c2} -tay -txa -sta {c1},y -//FRAGMENT vwuz1=pwuc1_derefidx_vbuz2_ror_8 -ldy {z2} -lda #0 -sta {z1}+1 -lda {c1}+1,y -sta {z1} -//FRAGMENT pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_bxor_vwuc2 -ldy {z1} -lda {c1},y -eor #<{c2} -sta {c1},y -lda {c1}+1,y -eor #>{c2} -sta {c1}+1,y -//FRAGMENT vwuz1_lt_vbuz2_then_la1 -lda {z1}+1 -bne !+ -lda {z1} -cmp {z2} -bcc {la1} -!: -//FRAGMENT vwuz1_ge_vbuz2_then_la1 -lda {z1}+1 -bne {la1} -lda {z1} -cmp {z2} -bcs {la1} -!: -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_vbuc2 -lda #{c2} -ldy {z1} -clc -adc {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_vbuc2 -ldx {z1} -lda {c1},x -tax -axs #-[{c2}] -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_vbuc2 -lda #{c2} -ldy {z1} -clc -adc {c1},y -tay -//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_vbuc2 -tay -lda #{c2} -clc -adc {c1},y -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_vbuc2 -tay -lda #{c2} -clc -adc {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_vbuc2 -tax -lda {c1},x -tax -axs #-[{c2}] -//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_vbuc2 -tay -lda #{c2} -clc -adc {c1},y -tay -//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_vbuc2 -lda #{c2} -clc -adc {c1},x -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_vbuc2 -lda #{c2} -clc -adc {c1},x -//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_vbuc2 -lda {c1},x -tax -axs #-[{c2}] -//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_vbuc2 -lda #{c2} -clc -adc {c1},x -tay -//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_vbuc2 -lda #{c2} -clc -adc {c1},y -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_vbuc2 -lda #{c2} -clc -adc {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_vbuc2 -lda {c1},y -tax -axs #-[{c2}] -//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_vbuc2 -lda #{c2} -clc -adc {c1},y -tay -//FRAGMENT pwuc1_derefidx_vbuaa=vbuc2 -ldx #{c2} -tay -txa -sta {c1},y -//FRAGMENT pwuc1_derefidx_vbuxx=vbuc2 -lda #{c2} -sta {c1},x -lda #0 -sta {c1}+1,x -//FRAGMENT pwuc1_derefidx_vbuyy=vbuc2 -lda #{c2} -sta {c1},y -lda #0 -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuaa=pwuc1_derefidx_vbuaa_plus_pwuc2_derefidx_vbuaa -tax -tay -clc -lda {c1},y -adc {c2},x -sta {c1},y -lda {c1}+1,y -adc {c2}+1,x -sta {c1}+1,y -//FRAGMENT vwuz1=pwuc1_derefidx_vbuxx_ror_8 -txa -tay -lda #0 -sta {z1}+1 -lda {c1}+1,y -sta {z1} -//FRAGMENT vwuz1=pwuc1_derefidx_vbuyy_ror_8 -lda #0 -sta {z1}+1 -lda {c1}+1,y -sta {z1} -//FRAGMENT pwuc1_derefidx_vbuaa=pwuc1_derefidx_vbuaa_bxor_vwuc2 -tay -lda {c1},y -eor #<{c2} -sta {c1},y -lda {c1}+1,y -eor #>{c2} -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_bxor_vwuc2 -txa -tay -lda {c1},y -eor #<{c2} -sta {c1},y -lda {c1}+1,y -eor #>{c2} -sta {c1}+1,y -//FRAGMENT pwuc1_derefidx_vbuyy=pwuc1_derefidx_vbuyy_bxor_vwuc2 -lda {c1},y -eor #<{c2} -sta {c1},y -lda {c1}+1,y -eor #>{c2} -sta {c1}+1,y -//FRAGMENT vwuz1=pwuc1_derefidx_vbuaa_ror_8 -tay -lda #0 -sta {z1}+1 -lda {c1}+1,y -sta {z1} -//FRAGMENT vwuz1_lt_vbuxx_then_la1 -lda {z1}+1 -bne !+ -stx $ff -lda {z1} -cmp $ff -bcc {la1} -!: -//FRAGMENT vwuz1_lt_vbuyy_then_la1 -lda {z1}+1 -bne !+ -sty $ff -lda {z1} -cmp $ff -bcc {la1} -!: -//FRAGMENT vwuz1_ge_vbuxx_then_la1 -lda {z1}+1 -bne {la1} -stx $ff -lda {z1} -cmp $ff -bcs {la1} -!: -//FRAGMENT vwuz1_ge_vbuyy_then_la1 -lda {z1}+1 -bne {la1} -sty $ff -lda {z1} -cmp $ff -bcs {la1} -!: -//FRAGMENT vbuz1=vbuxx_minus_2 -dex -dex -stx {z1} -//FRAGMENT vbuyy=vbuz1_minus_2 -ldy {z1} -dey -dey //FRAGMENT vwuz1=vwuz2_rol_5 lda {z2} asl @@ -18406,58 +18146,6 @@ asl {z1} rol {z1}+1 asl {z1} rol {z1}+1 -//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuz2 -ldy {z2} -lda {c1},y -sta {z1} -//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuz1 -ldx {z1} -lda {c1},x -tax -//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -tay -//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuaa -tay -lda {c1},y -sta {z1} -//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuaa -tay -lda {c1},y -//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuaa -tax -lda {c1},x -tax -//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuaa -tay -lda {c1},y -tay -//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuxx -lda {c1},x -sta {z1} -//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuxx -lda {c1},x -//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuxx -lda {c1},x -tax -//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuxx -lda {c1},x -tay -//FRAGMENT vbuz1=_byte_pwuc1_derefidx_vbuyy -lda {c1},y -sta {z1} -//FRAGMENT vbuaa=_byte_pwuc1_derefidx_vbuyy -lda {c1},y -//FRAGMENT vbuxx=_byte_pwuc1_derefidx_vbuyy -lda {c1},y -tax -//FRAGMENT vbuyy=_byte_pwuc1_derefidx_vbuyy -lda {c1},y -tay //FRAGMENT pprz1=_deref_qprc1 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 4eb4c82a9..c30c8f540 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 132c9fe4d5 132c9ffe57 +//KICKC FRAGMENT CACHE 12beec37ea 12beec5182 //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} diff --git a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1.asm b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1.asm new file mode 100644 index 000000000..f495c56a3 --- /dev/null +++ b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1.asm @@ -0,0 +1,4 @@ +inc {c1},x +bne !+ +inc {c1}+1,x +!: diff --git a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1.asm b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1.asm new file mode 100644 index 000000000..37efa4ca6 --- /dev/null +++ b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1.asm @@ -0,0 +1,6 @@ +lda {c1}+1,x +bne !+ +lda {c1},x +cmp #{c2} +bcc {la1} +!: diff --git a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy=pwuc1_derefidx_vbuyy_plus_1.asm b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy=pwuc1_derefidx_vbuyy_plus_1.asm new file mode 100644 index 000000000..2d3c2dc43 --- /dev/null +++ b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy=pwuc1_derefidx_vbuyy_plus_1.asm @@ -0,0 +1,9 @@ +clc +lda {c1},y +adc #1 +sta {c1},y +bne !+ +lda {c1}+1,y +adc #0 +sta {c1}+1,y +!: \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_lt_vbuc2_then_la1.asm b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_lt_vbuc2_then_la1.asm new file mode 100644 index 000000000..1c2ec4f5a --- /dev/null +++ b/src/main/fragment/mos6502-common/pwuc1_derefidx_vbuyy_lt_vbuc2_then_la1.asm @@ -0,0 +1,6 @@ +lda {c1}+1,y +bne !+ +lda {c1},y +cmp #{c2} +bcc {la1} +!: diff --git a/src/main/fragment/mos6502-common/vwum1_lt_vbuc1_then_la1.asm b/src/main/fragment/mos6502-common/vwum1_lt_vbuc1_then_la1.asm index f738ba0e1..57861a364 100644 --- a/src/main/fragment/mos6502-common/vwum1_lt_vbuc1_then_la1.asm +++ b/src/main/fragment/mos6502-common/vwum1_lt_vbuc1_then_la1.asm @@ -1,8 +1,6 @@ lda {m1}+1 -cmp #>{c1} -bcc {la1} bne !+ lda {m1} -cmp #<{c1} +cmp #{c1} bcc {la1} !: diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index ff6f14239..654ae6253 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -49,6 +49,11 @@ public class TestPrograms { compileAndCompare("index-sizeof-reuse.c"); } + @Test + public void testIndexSizeofReuse2() throws IOException, URISyntaxException { + compileAndCompare("index-sizeof-reuse-2.c"); + } + @Test public void testPragmaNoParenthesis() throws IOException, URISyntaxException { compileAndCompare("pragma-noparenthesis.c"); diff --git a/src/test/kc/index-sizeof-reuse-2.c b/src/test/kc/index-sizeof-reuse-2.c new file mode 100644 index 000000000..0079419da --- /dev/null +++ b/src/test/kc/index-sizeof-reuse-2.c @@ -0,0 +1,39 @@ +// Test that the multiplication of a idx*sizeof(element) is reused inside loops + +#define NUM_ENTITIES 25 + +unsigned int entities[NUM_ENTITIES]; + +char * const VIC_RASTER = 0xd012; +char * const VIC_BG_COLOR = 0xd020; +char * const SCREEN = 0x0400; + +void main() { + + asm { sei } + + while(1) { + // Wait for raster refresh + while(*VIC_RASTER!=0xff) ; + *VIC_BG_COLOR = 0; + // Move the entities + char * line = SCREEN; + for(char i=0;i39) { + entities[i] =0; + } + // Draw symbol + line[entities[i]] = '*'; + // Next line + line +=40; + } + *VIC_BG_COLOR = 15; + } + + +} \ No newline at end of file diff --git a/src/test/ref/complex/bubbles64/bubbles64.asm b/src/test/ref/complex/bubbles64/bubbles64.asm index ea5dcf4be..7efd8ff06 100644 --- a/src/test/ref/complex/bubbles64/bubbles64.asm +++ b/src/test/ref/complex/bubbles64/bubbles64.asm @@ -208,11 +208,9 @@ main: { !: // if (c>=14) lda.z c_2+1 - cmp #>$e - bcc __b36 bne !+ lda.z c_2 - cmp #<$e + cmp #$e bcc __b36 !: // if (0==stopIt && objects2 && objects>0) lda.z oCount+1 - cmp #>2+1 - bcc __b35 bne !+ lda.z oCount - cmp #<2+1 + cmp #2+1 bcc __b35 !: lda.z objects diff --git a/src/test/ref/complex/bubbles64/bubbles64.log b/src/test/ref/complex/bubbles64/bubbles64.log index 2c4557497..56113c201 100644 --- a/src/test/ref/complex/bubbles64/bubbles64.log +++ b/src/test/ref/complex/bubbles64/bubbles64.log @@ -3483,11 +3483,9 @@ main: { !: // [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1 lda.z c_2+1 - cmp #>$e - bcc __b33_from___b19 bne !+ lda.z c_2 - cmp #<$e + cmp #$e bcc __b33_from___b19 !: jmp __b30 @@ -3554,11 +3552,9 @@ main: { __b34: // [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1 lda.z oCount+1 - cmp #>2+1 - bcc __b35_from___b34 bne !+ lda.z oCount - cmp #<2+1 + cmp #2+1 bcc __b35_from___b34 !: jmp __b44 @@ -4522,31 +4518,31 @@ Uplift Scope [$4] Uplift Scope [$5] Uplift Scope [] -Uplifting [Print00] best 71507 combination reg byte x [ Print00::v#5 Print00::v#3 Print00::v0#0 Print00::v#1 Print00::v#2 ] reg byte y [ Print00::c#5 Print00::c#2 ] reg byte y [ Print00::c#10 Print00::c#4 ] -Uplifting [GetSprite] best 70211 combination reg byte x [ GetSprite::return#2 GetSprite::t0#3 GetSprite::t0#2 ] reg byte x [ GetSprite::return#4 ] -Uplifting [AddSprite] best 68968 combination reg byte y [ AddSprite::t0#3 AddSprite::t0#2 ] reg byte x [ AddSprite::sn#1 ] -Uplifting [main] best 68548 combination zp[1]:13 [ main::i#22 main::i#9 ] zp[2]:14 [ main::d#10 main::d#2 ] zp[2]:28 [ main::$27 ] zp[2]:30 [ main::$28 ] zp[2]:17 [ main::oCount#7 main::oCount#17 main::oCount#20 main::oCount#2 ] zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] reg byte x [ main::i#12 main::i#2 ] reg byte x [ main::i#14 main::i#4 ] zp[2]:6 [ main::c#11 main::c#4 ] zp[2]:4 [ main::c#10 main::c#2 ] reg byte x [ main::i#17 main::i#7 ] zp[1]:32 [ main::$132 ] reg byte a [ main::$52 ] zp[2]:38 [ main::$112 ] zp[2]:40 [ main::$109 ] zp[2]:42 [ main::$110 ] zp[2]:10 [ main::c#16 main::c#18 main::c#7 ] zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] zp[1]:26 [ main::i#11 ] zp[2]:36 [ main::$111 ] zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] zp[2]:34 [ main::d1#0 ] +Uplifting [Print00] best 71417 combination reg byte x [ Print00::v#5 Print00::v#3 Print00::v0#0 Print00::v#1 Print00::v#2 ] reg byte y [ Print00::c#5 Print00::c#2 ] reg byte y [ Print00::c#10 Print00::c#4 ] +Uplifting [GetSprite] best 70121 combination reg byte x [ GetSprite::return#2 GetSprite::t0#3 GetSprite::t0#2 ] reg byte x [ GetSprite::return#4 ] +Uplifting [AddSprite] best 68878 combination reg byte y [ AddSprite::t0#3 AddSprite::t0#2 ] reg byte x [ AddSprite::sn#1 ] +Uplifting [main] best 68458 combination zp[1]:13 [ main::i#22 main::i#9 ] zp[2]:14 [ main::d#10 main::d#2 ] zp[2]:28 [ main::$27 ] zp[2]:30 [ main::$28 ] zp[2]:17 [ main::oCount#7 main::oCount#17 main::oCount#20 main::oCount#2 ] zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] reg byte x [ main::i#12 main::i#2 ] reg byte x [ main::i#14 main::i#4 ] zp[2]:6 [ main::c#11 main::c#4 ] zp[2]:4 [ main::c#10 main::c#2 ] reg byte x [ main::i#17 main::i#7 ] zp[1]:32 [ main::$132 ] reg byte a [ main::$52 ] zp[2]:38 [ main::$112 ] zp[2]:40 [ main::$109 ] zp[2]:42 [ main::$110 ] zp[2]:10 [ main::c#16 main::c#18 main::c#7 ] zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] zp[1]:26 [ main::i#11 ] zp[2]:36 [ main::$111 ] zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] zp[2]:34 [ main::d1#0 ] Limited combination testing to 100 combinations of 1728 possible. -Uplifting [DelSprite] best 68512 combination reg byte x [ DelSprite::sn#0 ] -Uplifting [$0] best 68512 combination -Uplifting [$1] best 68512 combination -Uplifting [$2] best 68512 combination -Uplifting [$3] best 68512 combination -Uplifting [$4] best 68512 combination -Uplifting [$5] best 68512 combination -Uplifting [] best 68512 combination +Uplifting [DelSprite] best 68422 combination reg byte x [ DelSprite::sn#0 ] +Uplifting [$0] best 68422 combination +Uplifting [$1] best 68422 combination +Uplifting [$2] best 68422 combination +Uplifting [$3] best 68422 combination +Uplifting [$4] best 68422 combination +Uplifting [$5] best 68422 combination +Uplifting [] best 68422 combination Attempting to uplift remaining variables inzp[1]:13 [ main::i#22 main::i#9 ] -Uplifting [main] best 68512 combination zp[1]:13 [ main::i#22 main::i#9 ] +Uplifting [main] best 68422 combination zp[1]:13 [ main::i#22 main::i#9 ] Attempting to uplift remaining variables inzp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] -Uplifting [main] best 68512 combination zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] +Uplifting [main] best 68422 combination zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] Attempting to uplift remaining variables inzp[1]:32 [ main::$132 ] -Uplifting [main] best 68492 combination reg byte a [ main::$132 ] +Uplifting [main] best 68402 combination reg byte a [ main::$132 ] Attempting to uplift remaining variables inzp[1]:9 [ main::type#4 main::type#10 main::type#2 ] -Uplifting [main] best 68492 combination zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] +Uplifting [main] best 68402 combination zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] Attempting to uplift remaining variables inzp[1]:26 [ main::i#11 ] -Uplifting [main] best 68282 combination reg byte x [ main::i#11 ] +Uplifting [main] best 68192 combination reg byte x [ main::i#11 ] Attempting to uplift remaining variables inzp[1]:12 [ main::stopIt#5 main::stopIt#15 ] -Uplifting [main] best 68282 combination zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] +Uplifting [main] best 68192 combination zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] Allocated (was zp[2]:4) zp[2]:2 [ main::c#10 main::c#2 ] Allocated (was zp[2]:6) zp[2]:4 [ main::c#11 main::c#4 ] Allocated (was zp[1]:9) zp[1]:6 [ main::type#4 main::type#10 main::type#2 ] @@ -4829,11 +4825,9 @@ main: { !: // [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1 lda.z c_2+1 - cmp #>$e - bcc __b33_from___b19 bne !+ lda.z c_2 - cmp #<$e + cmp #$e bcc __b33_from___b19 !: jmp __b30 @@ -4900,11 +4894,9 @@ main: { __b34: // [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1 lda.z oCount+1 - cmp #>2+1 - bcc __b35_from___b34 bne !+ lda.z oCount - cmp #<2+1 + cmp #2+1 bcc __b35_from___b34 !: jmp __b44 @@ -5648,7 +5640,6 @@ Replacing label __b33 with __b36 Replacing label __b33 with __b36 Replacing label __b34_from___b36 with __b34 Replacing label __b35_from___b34 with __b35 -Replacing label __b35_from___b34 with __b35 Replacing label __b45_from___b13 with __b14 Removing instruction __b17_from___b16: Removing instruction __b33_from___b42: @@ -5715,7 +5706,6 @@ Removing instruction __b5: Removing instruction __b2_from___b4: Succesful ASM optimization Pass5UnusedLabelElimination Skipping double jump to __b36 in bcc __b33_from___b19 -Skipping double jump to __b36 in bcc __b33_from___b19 Skipping double jump to __b36 in jmp __b33_from___b43 Replacing jump to rts with rts in jmp __breturn Replacing jump to rts with rts in jmp __breturn @@ -5744,8 +5734,8 @@ Fixing long branch [101] bcc __b9 to bcs Fixing long branch [107] bcc __b9 to bcs Fixing long branch [145] bcc __b13 to bcs Fixing long branch [166] bcc __b18 to bcs -Fixing long branch [267] bmi __b20 to bpl -Fixing long branch [292] bmi __b22 to bpl +Fixing long branch [263] bmi __b20 to bpl +Fixing long branch [288] bmi __b22 to bpl FINAL SYMBOL TABLE (signed byte) $5::ax @@ -5950,7 +5940,7 @@ zp[2]:28 [ main::$110 ] FINAL ASSEMBLER -Score: 62702 +Score: 62612 // File Comments // bubbles64 - Q&D C64 port of the bubbles demo from vbcc6502's NES exmaples @@ -6232,11 +6222,9 @@ main: { // if (c>=14) // [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1 lda.z c_2+1 - cmp #>$e - bcc __b36 bne !+ lda.z c_2 - cmp #<$e + cmp #$e bcc __b36 !: // main::@30 @@ -6289,11 +6277,9 @@ main: { // if (oCount>2 && objects>0) // [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1 lda.z oCount+1 - cmp #>2+1 - bcc __b35 bne !+ lda.z oCount - cmp #<2+1 + cmp #2+1 bcc __b35 !: // main::@44 diff --git a/src/test/ref/complex/nes-balls/kickballs-2.asm b/src/test/ref/complex/nes-balls/kickballs-2.asm index 1e75229cc..3d80bdc52 100644 --- a/src/test/ref/complex/nes-balls/kickballs-2.asm +++ b/src/test/ref/complex/nes-balls/kickballs-2.asm @@ -544,11 +544,9 @@ ppuDataTransfer: { __b1: // for(unsigned int i=0;i$20*SIZEOF_BYTE - bcc __b2 bne !+ lda.z i - cmp #<$20*SIZEOF_BYTE + cmp #$20*SIZEOF_BYTE bcc __b2 !: // } diff --git a/src/test/ref/complex/nes-balls/kickballs-2.log b/src/test/ref/complex/nes-balls/kickballs-2.log index 347fee044..493d79d0e 100644 --- a/src/test/ref/complex/nes-balls/kickballs-2.log +++ b/src/test/ref/complex/nes-balls/kickballs-2.log @@ -3369,11 +3369,9 @@ ppuDataTransfer: { __b1: // [121] if((word) ppuDataTransfer::i#2<(byte) $20*(const byte) SIZEOF_BYTE) goto ppuDataTransfer::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>$20*SIZEOF_BYTE - bcc __b2 bne !+ lda.z i - cmp #<$20*SIZEOF_BYTE + cmp #$20*SIZEOF_BYTE bcc __b2 !: jmp __breturn @@ -3825,72 +3823,72 @@ Uplift Scope [$0] Uplift Scope [vblank] Uplift Scope [__start] -Uplifting [ppuDataTransfer] best 56865 combination zp[2]:13 [ ppuDataTransfer::i#2 ppuDataTransfer::i#1 ] reg byte a [ ppuDataTransfer::ppuDataPut1_val#0 ] zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$0 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$1 ] zp[2]:9 [ ppuDataTransfer::ppuDataPrepare1_ppuData#0 ] zp[2]:11 [ ppuDataTransfer::cpuData#2 ] -Uplifting [rand] best 56865 combination zp[2]:73 [ rand::$0 ] zp[2]:77 [ rand::$1 ] zp[2]:81 [ rand::$2 ] zp[2]:83 [ rand::return#0 ] zp[2]:55 [ rand::return#2 ] zp[2]:62 [ rand::return#3 ] -Uplifting [] best 56865 combination zp[2]:75 [ rand_state#0 ] zp[2]:79 [ rand_state#1 ] zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] zp[1]:25 [ scroll_y ] zp[1]:26 [ vblank_hit ] -Uplifting [ppuDataFill] best 56853 combination zp[2]:21 [ ppuDataFill::i#2 ppuDataFill::i#1 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$0 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$1 ] zp[2]:19 [ ppuDataFill::size#3 ] zp[2]:17 [ ppuDataFill::ppuDataPrepare1_ppuData#0 ] -Uplifting [RICOH_2C02] best 56853 combination -Uplifting [RICOH_2A03] best 56853 combination -Uplifting [SpriteData] best 56853 combination -Uplifting [RADIX] best 56853 combination -Uplifting [printf_format_number] best 56853 combination -Uplifting [printf_buffer_number] best 56853 combination -Uplifting [printf_format_string] best 56853 combination -Uplifting [$0] best 56853 combination -Uplifting [vblank] best 56853 combination -Uplifting [__start] best 56853 combination +Uplifting [ppuDataTransfer] best 56820 combination zp[2]:13 [ ppuDataTransfer::i#2 ppuDataTransfer::i#1 ] reg byte a [ ppuDataTransfer::ppuDataPut1_val#0 ] zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$0 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$1 ] zp[2]:9 [ ppuDataTransfer::ppuDataPrepare1_ppuData#0 ] zp[2]:11 [ ppuDataTransfer::cpuData#2 ] +Uplifting [rand] best 56820 combination zp[2]:73 [ rand::$0 ] zp[2]:77 [ rand::$1 ] zp[2]:81 [ rand::$2 ] zp[2]:83 [ rand::return#0 ] zp[2]:55 [ rand::return#2 ] zp[2]:62 [ rand::return#3 ] +Uplifting [] best 56820 combination zp[2]:75 [ rand_state#0 ] zp[2]:79 [ rand_state#1 ] zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] zp[1]:25 [ scroll_y ] zp[1]:26 [ vblank_hit ] +Uplifting [ppuDataFill] best 56808 combination zp[2]:21 [ ppuDataFill::i#2 ppuDataFill::i#1 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$0 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$1 ] zp[2]:19 [ ppuDataFill::size#3 ] zp[2]:17 [ ppuDataFill::ppuDataPrepare1_ppuData#0 ] +Uplifting [RICOH_2C02] best 56808 combination +Uplifting [RICOH_2A03] best 56808 combination +Uplifting [SpriteData] best 56808 combination +Uplifting [RADIX] best 56808 combination +Uplifting [printf_format_number] best 56808 combination +Uplifting [printf_buffer_number] best 56808 combination +Uplifting [printf_format_string] best 56808 combination +Uplifting [$0] best 56808 combination +Uplifting [vblank] best 56808 combination +Uplifting [__start] best 56808 combination Attempting to uplift remaining variables inzp[1]:36 [ main::$45 ] -Uplifting [main] best 56453 combination reg byte a [ main::$45 ] +Uplifting [main] best 56408 combination reg byte a [ main::$45 ] Attempting to uplift remaining variables inzp[1]:33 [ main::$40 ] -Uplifting [main] best 55153 combination reg byte y [ main::$40 ] +Uplifting [main] best 55108 combination reg byte y [ main::$40 ] Attempting to uplift remaining variables inzp[1]:7 [ main::i#10 main::i#4 ] -Uplifting [main] best 55153 combination zp[1]:7 [ main::i#10 main::i#4 ] +Uplifting [main] best 55108 combination zp[1]:7 [ main::i#10 main::i#4 ] Attempting to uplift remaining variables inzp[1]:37 [ main::$44 ] -Uplifting [main] best 54453 combination reg byte y [ main::$44 ] +Uplifting [main] best 54408 combination reg byte y [ main::$44 ] Attempting to uplift remaining variables inzp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ] -Uplifting [main] best 54453 combination zp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ] +Uplifting [main] best 54408 combination zp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ] Attempting to uplift remaining variables inzp[1]:42 [ main::$26 ] -Uplifting [main] best 54453 combination zp[1]:42 [ main::$26 ] +Uplifting [main] best 54408 combination zp[1]:42 [ main::$26 ] Attempting to uplift remaining variables inzp[1]:44 [ main::$30 ] -Uplifting [main] best 53853 combination reg byte a [ main::$30 ] +Uplifting [main] best 53808 combination reg byte a [ main::$30 ] Attempting to uplift remaining variables inzp[1]:52 [ main::$48 ] -Uplifting [main] best 52553 combination reg byte x [ main::$48 ] +Uplifting [main] best 52508 combination reg byte x [ main::$48 ] Attempting to uplift remaining variables inzp[1]:43 [ main::$53 ] -Uplifting [main] best 51853 combination reg byte y [ main::$53 ] +Uplifting [main] best 51808 combination reg byte y [ main::$53 ] Attempting to uplift remaining variables inzp[1]:49 [ main::$50 ] -Uplifting [main] best 51153 combination reg byte y [ main::$50 ] +Uplifting [main] best 51108 combination reg byte y [ main::$50 ] Attempting to uplift remaining variables inzp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ] -Uplifting [main] best 51153 combination zp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ] +Uplifting [main] best 51108 combination zp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ] Attempting to uplift remaining variables inzp[1]:2 [ main::initNES1_i#2 main::initNES1_i#1 ] -Uplifting [main] best 50823 combination reg byte x [ main::initNES1_i#2 main::initNES1_i#1 ] +Uplifting [main] best 50778 combination reg byte x [ main::initNES1_i#2 main::initNES1_i#1 ] Attempting to uplift remaining variables inzp[1]:3 [ main::i#14 main::i#2 ] -Uplifting [main] best 50823 combination zp[1]:3 [ main::i#14 main::i#2 ] +Uplifting [main] best 50778 combination zp[1]:3 [ main::i#14 main::i#2 ] Attempting to uplift remaining variables inzp[1]:4 [ main::timer_2#2 main::timer_2#1 ] -Uplifting [main] best 50823 combination zp[1]:4 [ main::timer_2#2 main::timer_2#1 ] +Uplifting [main] best 50778 combination zp[1]:4 [ main::timer_2#2 main::timer_2#1 ] Attempting to uplift remaining variables inzp[1]:27 [ main::initNES1_waitForVBlank1_$0 ] -Uplifting [main] best 50763 combination reg byte a [ main::initNES1_waitForVBlank1_$0 ] +Uplifting [main] best 50718 combination reg byte a [ main::initNES1_waitForVBlank1_$0 ] Attempting to uplift remaining variables inzp[1]:28 [ main::initNES1_waitForVBlank2_$0 ] -Uplifting [main] best 50703 combination reg byte a [ main::initNES1_waitForVBlank2_$0 ] +Uplifting [main] best 50658 combination reg byte a [ main::initNES1_waitForVBlank2_$0 ] Attempting to uplift remaining variables inzp[1]:30 [ main::$14 ] -Uplifting [main] best 50643 combination reg byte a [ main::$14 ] +Uplifting [main] best 50598 combination reg byte a [ main::$14 ] Attempting to uplift remaining variables inzp[1]:61 [ main::$35 ] -Uplifting [main] best 50603 combination reg byte a [ main::$35 ] +Uplifting [main] best 50558 combination reg byte a [ main::$35 ] Attempting to uplift remaining variables inzp[1]:67 [ main::$36 ] -Uplifting [main] best 50543 combination reg byte a [ main::$36 ] +Uplifting [main] best 50498 combination reg byte a [ main::$36 ] Attempting to uplift remaining variables inzp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ] -Uplifting [main] best 50543 combination zp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ] +Uplifting [main] best 50498 combination zp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ] Attempting to uplift remaining variables inzp[1]:32 [ main::$38 ] -Uplifting [main] best 50533 combination reg byte x [ main::$38 ] +Uplifting [main] best 50488 combination reg byte x [ main::$38 ] Attempting to uplift remaining variables inzp[1]:25 [ scroll_y ] -Uplifting [] best 50533 combination zp[1]:25 [ scroll_y ] +Uplifting [] best 50488 combination zp[1]:25 [ scroll_y ] Attempting to uplift remaining variables inzp[1]:31 [ main::timer#1 ] -Uplifting [main] best 50473 combination reg byte x [ main::timer#1 ] +Uplifting [main] best 50428 combination reg byte x [ main::timer#1 ] Attempting to uplift remaining variables inzp[1]:66 [ main::$12 ] -Uplifting [main] best 50433 combination reg byte x [ main::$12 ] +Uplifting [main] best 50388 combination reg byte x [ main::$12 ] Attempting to uplift remaining variables inzp[1]:29 [ main::h_bar#1 ] -Uplifting [main] best 50433 combination zp[1]:29 [ main::h_bar#1 ] +Uplifting [main] best 50388 combination zp[1]:29 [ main::h_bar#1 ] Attempting to uplift remaining variables inzp[1]:26 [ vblank_hit ] -Uplifting [] best 50433 combination zp[1]:26 [ vblank_hit ] +Uplifting [] best 50388 combination zp[1]:26 [ vblank_hit ] Coalescing zero page register [ zp[2]:11 [ ppuDataTransfer::cpuData#2 ] ] with [ zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] ] - score: 1 Coalescing zero page register [ zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] ] with [ zp[2]:75 [ rand_state#0 ] ] - score: 1 Coalescing zero page register [ zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 rand_state#0 ] ] with [ zp[2]:79 [ rand_state#1 ] ] - score: 1 @@ -4727,11 +4725,9 @@ ppuDataTransfer: { __b1: // [121] if((word) ppuDataTransfer::i#2<(byte) $20*(const byte) SIZEOF_BYTE) goto ppuDataTransfer::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>$20*SIZEOF_BYTE - bcc __b2 bne !+ lda.z i - cmp #<$20*SIZEOF_BYTE + cmp #$20*SIZEOF_BYTE bcc __b2 !: jmp __breturn @@ -5359,7 +5355,7 @@ zp[2]:32 [ rand::$2 ] FINAL ASSEMBLER -Score: 45588 +Score: 45543 // File Comments //#pragma emulator("java -jar /Applications/Nintaco_bin_2020-05-01/Nintaco.jar") @@ -6123,11 +6119,9 @@ ppuDataTransfer: { // for(unsigned int i=0;i$20*SIZEOF_BYTE - bcc __b2 bne !+ lda.z i - cmp #<$20*SIZEOF_BYTE + cmp #$20*SIZEOF_BYTE bcc __b2 !: // ppuDataTransfer::@return diff --git a/src/test/ref/index-sizeof-reuse-2.asm b/src/test/ref/index-sizeof-reuse-2.asm new file mode 100644 index 000000000..3c8c6873e --- /dev/null +++ b/src/test/ref/index-sizeof-reuse-2.asm @@ -0,0 +1,98 @@ +// Test that the multiplication of a idx*sizeof(element) is reused inside loops +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label VIC_RASTER = $d012 + .label VIC_BG_COLOR = $d020 + .label SCREEN = $400 +main: { + // Move the entities + .label line = 3 + .label i = 2 + .label __11 = 5 + // asm + sei + // Wait for raster refresh + __b1: + // while(*VIC_RASTER!=0xff) + lda #$ff + cmp VIC_RASTER + bne __b1 + // *VIC_BG_COLOR = 0 + lda #0 + sta VIC_BG_COLOR + lda #SCREEN + sta.z line+1 + lda #0 + sta.z i + __b3: + // for(char i=0;i39) + lda entities+1,x + bne !+ + lda entities,x + cmp #$27+1 + bcc __b6 + !: + // entities[i] =0 + lda.z i + asl + ldx #0 + tay + txa + sta entities,y + __b6: + // line[entities[i]] = '*' + lda.z i + asl + tay + clc + lda.z line + adc entities,y + sta.z __11 + lda.z line+1 + adc entities+1,y + sta.z __11+1 + // Draw symbol + lda #'*' + ldy #0 + sta (__11),y + // line +=40 + // Next line + lda #$28 + clc + adc.z line + sta.z line + bcc !+ + inc.z line+1 + !: + // for(char i=0;i (number) $27 + (bool~) main::$3 ← ! (bool~) main::$2 + if((bool~) main::$3) goto main::@7 + to:main::@8 +main::@6: scope:[main] from main::@4 + *((const nomodify byte*) VIC_BG_COLOR) ← (number) $f + to:main::@1 +main::@7: scope:[main] from main::@5 main::@8 + (byte*) main::line#3 ← phi( main::@5/(byte*) main::line#2 main::@8/(byte*) main::line#5 ) + (byte) main::i#4 ← phi( main::@5/(byte) main::i#3 main::@8/(byte) main::i#5 ) + (byte~) main::$7 ← (byte) main::i#4 * (const byte) SIZEOF_WORD + *((byte*) main::line#3 + *((const word*) entities + (byte~) main::$7)) ← (byte) '*' + (byte*) main::line#1 ← (byte*) main::line#3 + (number) $28 + (byte) main::i#1 ← ++ (byte) main::i#4 + to:main::@4 +main::@8: scope:[main] from main::@5 + (byte*) main::line#5 ← phi( main::@5/(byte*) main::line#2 ) + (byte) main::i#5 ← phi( main::@5/(byte) main::i#3 ) + (byte~) main::$8 ← (byte) main::i#5 * (const byte) SIZEOF_WORD + *((const word*) entities + (byte~) main::$8) ← (number) 0 + to:main::@7 +main::@return: scope:[main] from main::@1 + return + to:@return + +(void()) __start() +__start: scope:[__start] from + call main + to:__start::@1 +__start::@1: scope:[__start] from __start + to:__start::@return +__start::@return: scope:[__start] from __start::@1 + return + to:@return + +SYMBOL TABLE SSA +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(const byte) SIZEOF_WORD = (byte) 2 +(const nomodify byte*) VIC_BG_COLOR = (byte*)(number) $d020 +(const nomodify byte*) VIC_RASTER = (byte*)(number) $d012 +(void()) __start() +(label) __start::@1 +(label) __start::@return +(const word*) entities[(number) $19] = { fill( $19, 0) } +(void()) main() +(bool~) main::$0 +(bool~) main::$1 +(bool~) main::$10 +(bool~) main::$2 +(bool~) main::$3 +(byte~) main::$4 +(byte~) main::$5 +(byte~) main::$6 +(byte~) main::$7 +(byte~) main::$8 +(byte~) main::$9 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@8 +(label) main::@return +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte) main::i#3 +(byte) main::i#4 +(byte) main::i#5 +(byte*) main::line +(byte*) main::line#0 +(byte*) main::line#1 +(byte*) main::line#2 +(byte*) main::line#3 +(byte*) main::line#4 +(byte*) main::line#5 + +Adding number conversion cast (unumber) $ff in (bool~) main::$0 ← *((const nomodify byte*) VIC_RASTER) != (number) $ff +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) VIC_BG_COLOR) ← (number) 0 +Adding number conversion cast (unumber) $19 in (bool~) main::$1 ← (byte) main::i#2 < (number) $19 +Adding number conversion cast (unumber) 1 in *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (number) 1 +Adding number conversion cast (unumber) $27 in (bool~) main::$2 ← *((const word*) entities + (byte~) main::$6) > (number) $27 +Adding number conversion cast (unumber) $f in *((const nomodify byte*) VIC_BG_COLOR) ← (number) $f +Adding number conversion cast (unumber) $28 in (byte*) main::line#1 ← (byte*) main::line#3 + (number) $28 +Adding number conversion cast (unumber) 0 in *((const word*) entities + (byte~) main::$8) ← (number) 0 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) 0 +Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) $f +Inlining cast *((const word*) entities + (byte~) main::$8) ← (unumber)(number) 0 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 53266 +Simplifying constant pointer cast (byte*) 53280 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast $ff +Simplifying constant integer cast 0 +Simplifying constant integer cast $19 +Simplifying constant integer cast 1 +Simplifying constant integer cast $27 +Simplifying constant integer cast $f +Simplifying constant integer cast $28 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) $ff +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $19 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) $27 +Finalized unsigned number type (byte) $f +Finalized unsigned number type (byte) $28 +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inversing boolean not [19] (bool~) main::$3 ← *((const word*) entities + (byte~) main::$6) <= (byte) $27 from [18] (bool~) main::$2 ← *((const word*) entities + (byte~) main::$6) > (byte) $27 +Successful SSA optimization Pass2UnaryNotSimplification +Alias main::i#2 = main::i#3 main::i#5 +Alias main::line#2 = main::line#4 main::line#5 +Successful SSA optimization Pass2AliasElimination +Alias main::i#2 = main::i#4 +Alias main::line#2 = main::line#3 +Successful SSA optimization Pass2AliasElimination +Identified duplicate assignment right side [15] (byte~) main::$5 ← (byte) main::i#2 * (const byte) SIZEOF_WORD +Identified duplicate assignment right side [17] (byte~) main::$6 ← (byte) main::i#2 * (const byte) SIZEOF_WORD +Successful SSA optimization Pass2DuplicateRValueIdentification +Simple Condition (bool~) main::$10 [2] if((number) 0!=(number) 1) goto main::@2 +Simple Condition (bool~) main::$0 [4] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@2 +Simple Condition (bool~) main::$1 [10] if((byte) main::i#2<(byte) $19) goto main::@5 +Simple Condition (bool~) main::$3 [18] if(*((const word*) entities + (byte~) main::$6)<=(byte) $27) goto main::@7 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) main::line#0 = SCREEN +Constant (const byte) main::i#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +if() condition always true - replacing block destination [2] if((number) 0!=(number) 1) goto main::@2 +Successful SSA optimization Pass2ConstantIfs +Rewriting conditional comparison [18] if(*((const word*) entities + (byte~) main::$6)<=(byte) $27) goto main::@7 +De-inlining pointer[w] to *(pointer+w) [21] *((byte*) main::line#2 + *((const word*) entities + (byte~) main::$7)) ← (byte) '*' +Successful SSA optimization Pass2DeInlineWordDerefIdx +Removing unused block main::@return +Successful SSA optimization Pass2EliminateUnusedBlocks +Removing unused procedure __start +Removing unused procedure block __start +Removing unused procedure block __start::@1 +Removing unused procedure block __start::@return +Successful SSA optimization PassNEliminateEmptyStart +Adding number conversion cast (unumber) $27+1 in [11] if(*((const word*) entities + (byte~) main::$6)<(byte) $27+(number) 1) goto main::@7 +Adding number conversion cast (unumber) 1 in [11] if(*((const word*) entities + (byte~) main::$6)<(unumber)(byte) $27+(number) 1) goto main::@7 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast (byte) $27+(unumber)(number) 1 +Simplifying constant integer cast 1 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 1 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Alias main::$5 = main::$4 main::$6 +Successful SSA optimization Pass2AliasElimination +Rewriting multiplication to use shift [5] (byte~) main::$5 ← (byte) main::i#2 * (const byte) SIZEOF_WORD +Rewriting multiplication to use shift [11] (byte~) main::$7 ← (byte) main::i#2 * (const byte) SIZEOF_WORD +Rewriting multiplication to use shift [16] (byte~) main::$8 ← (byte) main::i#2 * (const byte) SIZEOF_WORD +Successful SSA optimization Pass2MultiplyToShiftRewriting +Inlining constant with var siblings (const byte*) main::line#0 +Inlining constant with var siblings (const byte) main::i#0 +Constant inlined main::line#0 = (const nomodify byte*) SCREEN +Constant inlined main::i#0 = (byte) 0 +Successful SSA optimization Pass2ConstantInlining +Eliminating unused constant (const byte) SIZEOF_WORD +Successful SSA optimization PassNEliminateUnusedVars +Adding NOP phi() at start of main::@1 +CALL GRAPH + +Created 2 initial phi equivalence classes +Coalesced [19] main::i#6 ← main::i#1 +Coalesced [20] main::line#6 ← main::line#1 +Coalesced down to 2 phi equivalence classes +Culled Empty Block (label) main::@1 +Renumbering block main::@2 to main::@1 +Renumbering block main::@3 to main::@2 +Renumbering block main::@4 to main::@3 +Renumbering block main::@5 to main::@4 +Renumbering block main::@6 to main::@5 +Renumbering block main::@7 to main::@6 +Renumbering block main::@8 to main::@7 + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + asm { sei } + to:main::@1 +main::@1: scope:[main] from main main::@1 main::@5 + [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 + to:main::@2 +main::@2: scope:[main] from main::@1 + [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 + to:main::@3 +main::@3: scope:[main] from main::@2 main::@6 + [3] (byte*) main::line#2 ← phi( main::@2/(const nomodify byte*) SCREEN main::@6/(byte*) main::line#1 ) + [3] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@6/(byte) main::i#1 ) + [4] if((byte) main::i#2<(byte) $19) goto main::@4 + to:main::@5 +main::@5: scope:[main] from main::@3 + [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f + to:main::@1 +main::@4: scope:[main] from main::@3 + [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 + [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) + [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' + [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 + [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 + to:main::@7 +main::@7: scope:[main] from main::@4 + [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 + [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 + to:main::@6 +main::@6: scope:[main] from main::@4 main::@7 + [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 + [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) + [15] *((byte*~) main::$11) ← (byte) '*' + [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 + [17] (byte) main::i#1 ← ++ (byte) main::i#2 + to:main::@3 + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte*~) main::$11 202.0 +(byte~) main::$5 101.0 +(byte~) main::$7 202.0 +(byte~) main::$8 202.0 +(byte~) main::$9 202.0 +(byte) main::i +(byte) main::i#1 202.0 +(byte) main::i#2 46.61538461538461 +(byte*) main::line +(byte*) main::line#1 101.0 +(byte*) main::line#2 33.666666666666664 + +Initial phi equivalence classes +[ main::i#2 main::i#1 ] +[ main::line#2 main::line#1 ] +Added variable main::$5 to live range equivalence class [ main::$5 ] +Added variable main::$9 to live range equivalence class [ main::$9 ] +Added variable main::$8 to live range equivalence class [ main::$8 ] +Added variable main::$7 to live range equivalence class [ main::$7 ] +Added variable main::$11 to live range equivalence class [ main::$11 ] +Complete equivalence classes +[ main::i#2 main::i#1 ] +[ main::line#2 main::line#1 ] +[ main::$5 ] +[ main::$9 ] +[ main::$8 ] +[ main::$7 ] +[ main::$11 ] +Allocated zp[1]:2 [ main::i#2 main::i#1 ] +Allocated zp[2]:3 [ main::line#2 main::line#1 ] +Allocated zp[1]:5 [ main::$5 ] +Allocated zp[1]:6 [ main::$9 ] +Allocated zp[1]:7 [ main::$8 ] +Allocated zp[1]:8 [ main::$7 ] +Allocated zp[2]:9 [ main::$11 ] + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test that the multiplication of a idx*sizeof(element) is reused inside loops + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label VIC_RASTER = $d012 + .label VIC_BG_COLOR = $d020 + .label SCREEN = $400 + // main +main: { + .label __5 = 5 + .label __7 = 8 + .label __8 = 7 + .label __9 = 6 + // Move the entities + .label line = 3 + .label i = 2 + .label __11 = 9 + // asm { sei } + sei + jmp __b1 + // Wait for raster refresh + // main::@1 + __b1: + // [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VIC_RASTER + bne __b1 + jmp __b2 + // main::@2 + __b2: + // [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2 + lda #0 + sta VIC_BG_COLOR + // [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + __b3_from___b2: + // [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1 + lda #SCREEN + sta.z line+1 + // [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1 + lda #0 + sta.z i + jmp __b3 + // main::@3 + __b3: + // [4] if((byte) main::i#2<(byte) $19) goto main::@4 -- vbuz1_lt_vbuc1_then_la1 + lda.z i + cmp #$19 + bcc __b4 + jmp __b5 + // main::@5 + __b5: + // [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2 + lda #$f + sta VIC_BG_COLOR + jmp __b1 + // main::@4 + __b4: + // [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda.z i + asl + sta.z __5 + // [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) -- vbuz1=_byte_pwuc1_derefidx_vbuz2 + ldy.z __5 + lda entities,y + sta.z __9 + // [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' -- pbuz1_derefidx_vbuz2=vbuc1 + // Delete old symbol + lda #' ' + ldy.z __9 + sta (line),y + // [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 -- pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_plus_1 + // Move by velocity + ldx.z __5 + inc entities,x + bne !+ + inc entities+1,x + !: + // [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuz1_lt_vbuc2_then_la1 + ldy.z __5 + lda entities+1,y + bne !+ + lda entities,y + cmp #$27+1 + bcc __b6 + !: + jmp __b7 + // main::@7 + __b7: + // [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda.z i + asl + sta.z __8 + // [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuz1=vbuc2 + lda.z __8 + ldx #0 + tay + txa + sta entities,y + jmp __b6 + // main::@6 + __b6: + // [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda.z i + asl + sta.z __7 + // [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuz3 + ldy.z __7 + clc + lda.z line + adc entities,y + sta.z __11 + lda.z line+1 + adc entities+1,y + sta.z __11+1 + // [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1 + // Draw symbol + lda #'*' + ldy #0 + sta (__11),y + // [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 + // Next line + lda #$28 + clc + adc.z line + sta.z line + bcc !+ + inc.z line+1 + !: + // [17] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc.z i + // [3] phi from main::@6 to main::@3 [phi:main::@6->main::@3] + __b3_from___b6: + // [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy + // [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy + jmp __b3 +} + // File Data + entities: .fill 2*$19, 0 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a +Statement [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ] +Statement [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) [ main::i#2 main::line#2 main::$5 main::$9 ] ( [ main::i#2 main::line#2 main::$5 main::$9 ] { } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::$5 ] +Statement [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a +Statement [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a +Statement [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$8 ] ( [ main::i#2 main::line#2 main::$8 ] { } ) always clobbers reg byte a +Statement [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a +Statement [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$7 ] ( [ main::i#2 main::line#2 main::$7 ] { } ) always clobbers reg byte a +Statement [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) [ main::i#2 main::line#2 main::$11 ] ( [ main::i#2 main::line#2 main::$11 ] { } ) always clobbers reg byte a +Statement [15] *((byte*~) main::$11) ← (byte) '*' [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ] +Statement [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i#2 main::line#1 ] ( [ main::i#2 main::line#1 ] { } ) always clobbers reg byte a +Statement [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a +Statement [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a +Statement [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) [ main::i#2 main::line#2 main::$5 main::$9 ] ( [ main::i#2 main::line#2 main::$5 main::$9 ] { } ) always clobbers reg byte a +Statement [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a +Statement [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a +Statement [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$8 ] ( [ main::i#2 main::line#2 main::$8 ] { } ) always clobbers reg byte a +Statement [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a +Statement [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$7 ] ( [ main::i#2 main::line#2 main::$7 ] { } ) always clobbers reg byte a +Statement [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) [ main::i#2 main::line#2 main::$11 ] ( [ main::i#2 main::line#2 main::$11 ] { } ) always clobbers reg byte a +Statement [15] *((byte*~) main::$11) ← (byte) '*' [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y +Statement [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i#2 main::line#1 ] ( [ main::i#2 main::line#1 ] { } ) always clobbers reg byte a +Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , +Potential registers zp[2]:3 [ main::line#2 main::line#1 ] : zp[2]:3 , +Potential registers zp[1]:5 [ main::$5 ] : zp[1]:5 , reg byte x , reg byte y , +Potential registers zp[1]:6 [ main::$9 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:7 [ main::$8 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:8 [ main::$7 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y , +Potential registers zp[2]:9 [ main::$11 ] : zp[2]:9 , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 248.62: zp[1]:2 [ main::i#2 main::i#1 ] 202: zp[1]:6 [ main::$9 ] 202: zp[1]:7 [ main::$8 ] 202: zp[1]:8 [ main::$7 ] 202: zp[2]:9 [ main::$11 ] 134.67: zp[2]:3 [ main::line#2 main::line#1 ] 101: zp[1]:5 [ main::$5 ] +Uplift Scope [] + +Uplifting [main] best 19305 combination zp[1]:2 [ main::i#2 main::i#1 ] reg byte a [ main::$9 ] reg byte a [ main::$8 ] reg byte a [ main::$7 ] zp[2]:9 [ main::$11 ] zp[2]:3 [ main::line#2 main::line#1 ] zp[1]:5 [ main::$5 ] +Limited combination testing to 100 combinations of 384 possible. +Uplifting [] best 19305 combination +Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ] +Uplifting [main] best 19305 combination zp[1]:2 [ main::i#2 main::i#1 ] +Attempting to uplift remaining variables inzp[1]:5 [ main::$5 ] +Uplifting [main] best 18305 combination reg byte x [ main::$5 ] +Allocated (was zp[2]:9) zp[2]:5 [ main::$11 ] + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test that the multiplication of a idx*sizeof(element) is reused inside loops + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label VIC_RASTER = $d012 + .label VIC_BG_COLOR = $d020 + .label SCREEN = $400 + // main +main: { + // Move the entities + .label line = 3 + .label i = 2 + .label __11 = 5 + // asm { sei } + sei + jmp __b1 + // Wait for raster refresh + // main::@1 + __b1: + // [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VIC_RASTER + bne __b1 + jmp __b2 + // main::@2 + __b2: + // [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2 + lda #0 + sta VIC_BG_COLOR + // [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + __b3_from___b2: + // [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1 + lda #SCREEN + sta.z line+1 + // [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1 + lda #0 + sta.z i + jmp __b3 + // main::@3 + __b3: + // [4] if((byte) main::i#2<(byte) $19) goto main::@4 -- vbuz1_lt_vbuc1_then_la1 + lda.z i + cmp #$19 + bcc __b4 + jmp __b5 + // main::@5 + __b5: + // [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2 + lda #$f + sta VIC_BG_COLOR + jmp __b1 + // main::@4 + __b4: + // [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuz1_rol_1 + lda.z i + asl + tax + // [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) -- vbuaa=_byte_pwuc1_derefidx_vbuxx + lda entities,x + // [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' -- pbuz1_derefidx_vbuaa=vbuc1 + // Delete old symbol + tay + lda #' ' + sta (line),y + // [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 -- pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1 + // Move by velocity + inc entities,x + bne !+ + inc entities+1,x + !: + // [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1 + lda entities+1,x + bne !+ + lda entities,x + cmp #$27+1 + bcc __b6 + !: + jmp __b7 + // main::@7 + __b7: + // [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda.z i + asl + // [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuaa=vbuc2 + ldx #0 + tay + txa + sta entities,y + jmp __b6 + // main::@6 + __b6: + // [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda.z i + asl + // [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa + tay + clc + lda.z line + adc entities,y + sta.z __11 + lda.z line+1 + adc entities+1,y + sta.z __11+1 + // [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1 + // Draw symbol + lda #'*' + ldy #0 + sta (__11),y + // [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 + // Next line + lda #$28 + clc + adc.z line + sta.z line + bcc !+ + inc.z line+1 + !: + // [17] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc.z i + // [3] phi from main::@6 to main::@3 [phi:main::@6->main::@3] + __b3_from___b6: + // [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy + // [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy + jmp __b3 +} + // File Data + entities: .fill 2*$19, 0 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __b2 +Removing instruction jmp __b3 +Removing instruction jmp __b5 +Removing instruction jmp __b7 +Removing instruction jmp __b6 +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b2: +Removing instruction __b3_from___b2: +Removing instruction __b5: +Removing instruction __b7: +Removing instruction __b3_from___b6: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const nomodify byte*) SCREEN = (byte*) 1024 +(const nomodify byte*) VIC_BG_COLOR = (byte*) 53280 +(const nomodify byte*) VIC_RASTER = (byte*) 53266 +(const word*) entities[(number) $19] = { fill( $19, 0) } +(void()) main() +(byte*~) main::$11 zp[2]:5 202.0 +(byte~) main::$5 reg byte x 101.0 +(byte~) main::$7 reg byte a 202.0 +(byte~) main::$8 reg byte a 202.0 +(byte~) main::$9 reg byte a 202.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(byte) main::i +(byte) main::i#1 i zp[1]:2 202.0 +(byte) main::i#2 i zp[1]:2 46.61538461538461 +(byte*) main::line +(byte*) main::line#1 line zp[2]:3 101.0 +(byte*) main::line#2 line zp[2]:3 33.666666666666664 + +zp[1]:2 [ main::i#2 main::i#1 ] +zp[2]:3 [ main::line#2 main::line#1 ] +reg byte x [ main::$5 ] +reg byte a [ main::$9 ] +reg byte a [ main::$8 ] +reg byte a [ main::$7 ] +zp[2]:5 [ main::$11 ] + + +FINAL ASSEMBLER +Score: 16802 + + // File Comments +// Test that the multiplication of a idx*sizeof(element) is reused inside loops + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label VIC_RASTER = $d012 + .label VIC_BG_COLOR = $d020 + .label SCREEN = $400 + // main +main: { + // Move the entities + .label line = 3 + .label i = 2 + .label __11 = 5 + // asm + // asm { sei } + sei + // Wait for raster refresh + // main::@1 + __b1: + // while(*VIC_RASTER!=0xff) + // [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1 + lda #$ff + cmp VIC_RASTER + bne __b1 + // main::@2 + // *VIC_BG_COLOR = 0 + // [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2 + lda #0 + sta VIC_BG_COLOR + // [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + // [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1 + lda #SCREEN + sta.z line+1 + // [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1 + lda #0 + sta.z i + // main::@3 + __b3: + // for(char i=0;i39) + // [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1 + lda entities+1,x + bne !+ + lda entities,x + cmp #$27+1 + bcc __b6 + !: + // main::@7 + // entities[i] =0 + // [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda.z i + asl + // [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuaa=vbuc2 + ldx #0 + tay + txa + sta entities,y + // main::@6 + __b6: + // line[entities[i]] = '*' + // [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda.z i + asl + // [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa + tay + clc + lda.z line + adc entities,y + sta.z __11 + lda.z line+1 + adc entities+1,y + sta.z __11+1 + // [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1 + // Draw symbol + lda #'*' + ldy #0 + sta (__11),y + // line +=40 + // [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 + // Next line + lda #$28 + clc + adc.z line + sta.z line + bcc !+ + inc.z line+1 + !: + // for(char i=0;imain::@3] + // [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy + // [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy + jmp __b3 +} + // File Data + entities: .fill 2*$19, 0 + diff --git a/src/test/ref/index-sizeof-reuse-2.sym b/src/test/ref/index-sizeof-reuse-2.sym new file mode 100644 index 000000000..b08d6344c --- /dev/null +++ b/src/test/ref/index-sizeof-reuse-2.sym @@ -0,0 +1,31 @@ +(const nomodify byte*) SCREEN = (byte*) 1024 +(const nomodify byte*) VIC_BG_COLOR = (byte*) 53280 +(const nomodify byte*) VIC_RASTER = (byte*) 53266 +(const word*) entities[(number) $19] = { fill( $19, 0) } +(void()) main() +(byte*~) main::$11 zp[2]:5 202.0 +(byte~) main::$5 reg byte x 101.0 +(byte~) main::$7 reg byte a 202.0 +(byte~) main::$8 reg byte a 202.0 +(byte~) main::$9 reg byte a 202.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(byte) main::i +(byte) main::i#1 i zp[1]:2 202.0 +(byte) main::i#2 i zp[1]:2 46.61538461538461 +(byte*) main::line +(byte*) main::line#1 line zp[2]:3 101.0 +(byte*) main::line#2 line zp[2]:3 33.666666666666664 + +zp[1]:2 [ main::i#2 main::i#1 ] +zp[2]:3 [ main::line#2 main::line#1 ] +reg byte x [ main::$5 ] +reg byte a [ main::$9 ] +reg byte a [ main::$8 ] +reg byte a [ main::$7 ] +zp[2]:5 [ main::$11 ] diff --git a/src/test/ref/linegen.asm b/src/test/ref/linegen.asm index 9034fbf1a..2ca60ce21 100644 --- a/src/test/ref/linegen.asm +++ b/src/test/ref/linegen.asm @@ -284,11 +284,9 @@ lin16u_gen: { __b1: // for(word i=0; i$14 - bcc __b2 bne !+ lda.z i - cmp #<$14 + cmp #$14 bcc __b2 !: // } @@ -463,11 +461,9 @@ divr16u: { rol.z quotient+1 // if(rem>=divisor) lda.z rem+1 - cmp #>$14-1 - bcc __b3 bne !+ lda.z rem - cmp #<$14-1 + cmp #$14-1 bcc __b3 !: // quotient++; diff --git a/src/test/ref/linegen.log b/src/test/ref/linegen.log index 43bddab02..113e796bd 100644 --- a/src/test/ref/linegen.log +++ b/src/test/ref/linegen.log @@ -2913,11 +2913,9 @@ lin16u_gen: { __b1: // [73] if((word) lin16u_gen::i#2<(byte) $14) goto lin16u_gen::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>$14 - bcc __b2 bne !+ lda.z i - cmp #<$14 + cmp #$14 bcc __b2 !: jmp __breturn @@ -3218,11 +3216,9 @@ divr16u: { rol.z quotient+1 // [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1 lda.z rem+1 - cmp #>$14-1 - bcc __b3_from___b2 bne !+ lda.z rem - cmp #<$14-1 + cmp #$14-1 bcc __b3_from___b2 !: jmp __b5 @@ -3461,21 +3457,21 @@ Uplift Scope [RADIX] Uplift Scope [print_ln] Uplift Scope [print_cls] -Uplifting [print_char] best 14122 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] -Uplifting [] best 14122 combination zp[2]:32 [ print_char_cursor#51 print_char_cursor#84 print_char_cursor#104 print_char_cursor#1 print_char_cursor#89 print_char_cursor#10 print_char_cursor#100 ] zp[2]:19 [ print_line_cursor#12 print_line_cursor#23 print_line_cursor#0 ] zp[2]:57 [ rem16u#0 ] -Uplifting [print_str] best 14122 combination zp[2]:15 [ print_str::str#10 print_str::str#13 print_str::str#0 ] -Uplifting [divr16u] best 13912 combination zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:24 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#0 ] zp[2]:39 [ divr16u::return#2 ] zp[2]:43 [ divr16u::return#3 ] -Uplifting [print_uchar] best 13864 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#3 print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] -Uplifting [memset] best 13864 combination zp[2]:29 [ memset::dst#2 memset::dst#1 ] -Uplifting [lin16u_gen] best 13864 combination zp[2]:7 [ lin16u_gen::i#2 lin16u_gen::i#1 ] zp[2]:51 [ lin16u_gen::$6 ] zp[4]:9 [ lin16u_gen::val#2 lin16u_gen::val#1 lin16u_gen::val#0 ] zp[2]:13 [ lin16u_gen::lintab#4 lin16u_gen::lintab#3 lin16u_gen::lintab#6 ] zp[2]:37 [ lin16u_gen::ampl#0 ] zp[2]:45 [ lin16u_gen::stepf#0 ] zp[4]:47 [ lin16u_gen::step#0 ] zp[2]:3 [ lin16u_gen::max#3 ] zp[2]:41 [ lin16u_gen::stepi#0 ] zp[2]:5 [ lin16u_gen::min#3 ] -Uplifting [print_uint] best 13864 combination zp[2]:17 [ print_uint::w#10 print_uint::w#3 print_uint::w#4 print_uint::w#5 ] -Uplifting [main] best 13744 combination zp[1]:2 [ main::i#10 main::i#1 ] reg byte a [ main::$27 ] reg byte a [ main::$28 ] reg byte a [ main::$29 ] +Uplifting [print_char] best 14032 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] +Uplifting [] best 14032 combination zp[2]:32 [ print_char_cursor#51 print_char_cursor#84 print_char_cursor#104 print_char_cursor#1 print_char_cursor#89 print_char_cursor#10 print_char_cursor#100 ] zp[2]:19 [ print_line_cursor#12 print_line_cursor#23 print_line_cursor#0 ] zp[2]:57 [ rem16u#0 ] +Uplifting [print_str] best 14032 combination zp[2]:15 [ print_str::str#10 print_str::str#13 print_str::str#0 ] +Uplifting [divr16u] best 13822 combination zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:24 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#0 ] zp[2]:39 [ divr16u::return#2 ] zp[2]:43 [ divr16u::return#3 ] +Uplifting [print_uchar] best 13774 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#3 print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] +Uplifting [memset] best 13774 combination zp[2]:29 [ memset::dst#2 memset::dst#1 ] +Uplifting [lin16u_gen] best 13774 combination zp[2]:7 [ lin16u_gen::i#2 lin16u_gen::i#1 ] zp[2]:51 [ lin16u_gen::$6 ] zp[4]:9 [ lin16u_gen::val#2 lin16u_gen::val#1 lin16u_gen::val#0 ] zp[2]:13 [ lin16u_gen::lintab#4 lin16u_gen::lintab#3 lin16u_gen::lintab#6 ] zp[2]:37 [ lin16u_gen::ampl#0 ] zp[2]:45 [ lin16u_gen::stepf#0 ] zp[4]:47 [ lin16u_gen::step#0 ] zp[2]:3 [ lin16u_gen::max#3 ] zp[2]:41 [ lin16u_gen::stepi#0 ] zp[2]:5 [ lin16u_gen::min#3 ] +Uplifting [print_uint] best 13774 combination zp[2]:17 [ print_uint::w#10 print_uint::w#3 print_uint::w#4 print_uint::w#5 ] +Uplifting [main] best 13654 combination zp[1]:2 [ main::i#10 main::i#1 ] reg byte a [ main::$27 ] reg byte a [ main::$28 ] reg byte a [ main::$29 ] Limited combination testing to 100 combinations of 128 possible. -Uplifting [RADIX] best 13744 combination -Uplifting [print_ln] best 13744 combination -Uplifting [print_cls] best 13744 combination +Uplifting [RADIX] best 13654 combination +Uplifting [print_ln] best 13654 combination +Uplifting [print_cls] best 13654 combination Attempting to uplift remaining variables inzp[1]:2 [ main::i#10 main::i#1 ] -Uplifting [main] best 13744 combination zp[1]:2 [ main::i#10 main::i#1 ] +Uplifting [main] best 13654 combination zp[1]:2 [ main::i#10 main::i#1 ] Coalescing zero page register [ zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] ] with [ zp[2]:57 [ rem16u#0 ] ] - score: 2 Coalescing zero page register [ zp[2]:3 [ lin16u_gen::max#3 ] ] with [ zp[2]:37 [ lin16u_gen::ampl#0 ] ] - score: 1 Coalescing zero page register [ zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] ] with [ zp[2]:39 [ divr16u::return#2 ] ] - score: 1 @@ -4047,11 +4043,9 @@ lin16u_gen: { __b1: // [73] if((word) lin16u_gen::i#2<(byte) $14) goto lin16u_gen::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>$14 - bcc __b2 bne !+ lda.z i - cmp #<$14 + cmp #$14 bcc __b2 !: jmp __breturn @@ -4331,11 +4325,9 @@ divr16u: { rol.z quotient+1 // [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1 lda.z rem+1 - cmp #>$14-1 - bcc __b3_from___b2 bne !+ lda.z rem - cmp #<$14-1 + cmp #$14-1 bcc __b3_from___b2 !: jmp __b5 @@ -4511,7 +4503,6 @@ Replacing label __b1_from___b1 with __b1 Replacing label __b1_from___b1 with __b1 Replacing label __b2_from___b1 with __b2 Replacing label __b3_from___b2 with __b3 -Replacing label __b3_from___b2 with __b3 Replacing label __b1_from___b3 with __b1 Removing instruction __b4_from_main: Removing instruction lin16u_gen_from___b4: @@ -4840,7 +4831,7 @@ reg byte a [ divr16u::$2 ] FINAL ASSEMBLER -Score: 11819 +Score: 11729 // File Comments // Linear table generator @@ -5315,11 +5306,9 @@ lin16u_gen: { // for(word i=0; i$14 - bcc __b2 bne !+ lda.z i - cmp #<$14 + cmp #$14 bcc __b2 !: // lin16u_gen::@return @@ -5589,11 +5578,9 @@ divr16u: { // if(rem>=divisor) // [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1 lda.z rem+1 - cmp #>$14-1 - bcc __b3 bne !+ lda.z rem - cmp #<$14-1 + cmp #$14-1 bcc __b3 !: // divr16u::@5 diff --git a/src/test/ref/millfork-benchmarks/romsum-kc.asm b/src/test/ref/millfork-benchmarks/romsum-kc.asm index 5799876c9..600a5cb85 100644 --- a/src/test/ref/millfork-benchmarks/romsum-kc.asm +++ b/src/test/ref/millfork-benchmarks/romsum-kc.asm @@ -36,11 +36,9 @@ main: { __b1: // for(i=0;i<6;i++) lda.z i+1 - cmp #>6 - bcc __b2 bne !+ lda.z i - cmp #<6 + cmp #6 bcc __b2 !: // end() diff --git a/src/test/ref/millfork-benchmarks/romsum-kc.log b/src/test/ref/millfork-benchmarks/romsum-kc.log index 67248680f..2fd9b95e4 100644 --- a/src/test/ref/millfork-benchmarks/romsum-kc.log +++ b/src/test/ref/millfork-benchmarks/romsum-kc.log @@ -2159,11 +2159,9 @@ main: { __b1: // [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>6 - bcc __b2_from___b1 bne !+ lda.z i - cmp #<6 + cmp #6 bcc __b2_from___b1 !: // [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3] @@ -2961,26 +2959,26 @@ Uplift Scope [start] Uplift Scope [end] Uplift Scope [__start] -Uplifting [utoa_append] best 145211 combination zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:48 [ utoa_append::sub#0 ] zp[2]:50 [ utoa_append::return#0 ] zp[2]:46 [ utoa_append::buffer#0 ] -Uplifting [utoa] best 143907 combination zp[2]:16 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:44 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:41 [ utoa::buffer#3 ] -Uplifting [print_char] best 143598 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] -Uplifting [] best 143598 combination zp[2]:25 [ print_char_cursor#36 print_char_cursor#52 print_char_cursor#49 print_char_cursor#12 print_char_cursor#1 print_char_cursor#54 print_char_cursor#73 ] zp[2]:10 [ print_line_cursor#10 print_line_cursor#22 print_line_cursor#0 ] zp[2]:35 [ Ticks#1 ] zp[2]:33 [ Ticks#0 ] zp[2]:27 [ last_time ] -Uplifting [sum] best 124698 combination reg byte y [ sum::i#3 sum::i#2 ] reg byte a [ sum::tmp#1 ] zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] zp[2]:5 [ sum::p#5 sum::p#2 ] reg byte x [ sum::page#3 sum::page#2 ] zp[2]:29 [ sum::return#2 ] -Uplifting [print_str] best 124698 combination zp[2]:18 [ print_str::str#2 print_str::str#0 ] -Uplifting [print_uchar] best 124680 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] -Uplifting [print_uint_decimal] best 124680 combination zp[2]:31 [ print_uint_decimal::w#0 ] -Uplifting [print_uint] best 124680 combination zp[2]:37 [ print_uint::w#0 ] -Uplifting [main] best 124680 combination zp[2]:2 [ main::i#3 main::i#2 ] -Uplifting [RADIX] best 124680 combination -Uplifting [print_ln] best 124680 combination -Uplifting [MOS6526_CIA] best 124680 combination -Uplifting [MOS6569_VICII] best 124680 combination -Uplifting [MOS6581_SID] best 124680 combination -Uplifting [start] best 124680 combination -Uplifting [end] best 124680 combination -Uplifting [__start] best 124680 combination +Uplifting [utoa_append] best 145166 combination zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:48 [ utoa_append::sub#0 ] zp[2]:50 [ utoa_append::return#0 ] zp[2]:46 [ utoa_append::buffer#0 ] +Uplifting [utoa] best 143862 combination zp[2]:16 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:44 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:41 [ utoa::buffer#3 ] +Uplifting [print_char] best 143553 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ] +Uplifting [] best 143553 combination zp[2]:25 [ print_char_cursor#36 print_char_cursor#52 print_char_cursor#49 print_char_cursor#12 print_char_cursor#1 print_char_cursor#54 print_char_cursor#73 ] zp[2]:10 [ print_line_cursor#10 print_line_cursor#22 print_line_cursor#0 ] zp[2]:35 [ Ticks#1 ] zp[2]:33 [ Ticks#0 ] zp[2]:27 [ last_time ] +Uplifting [sum] best 124653 combination reg byte y [ sum::i#3 sum::i#2 ] reg byte a [ sum::tmp#1 ] zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] zp[2]:5 [ sum::p#5 sum::p#2 ] reg byte x [ sum::page#3 sum::page#2 ] zp[2]:29 [ sum::return#2 ] +Uplifting [print_str] best 124653 combination zp[2]:18 [ print_str::str#2 print_str::str#0 ] +Uplifting [print_uchar] best 124635 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] +Uplifting [print_uint_decimal] best 124635 combination zp[2]:31 [ print_uint_decimal::w#0 ] +Uplifting [print_uint] best 124635 combination zp[2]:37 [ print_uint::w#0 ] +Uplifting [main] best 124635 combination zp[2]:2 [ main::i#3 main::i#2 ] +Uplifting [RADIX] best 124635 combination +Uplifting [print_ln] best 124635 combination +Uplifting [MOS6526_CIA] best 124635 combination +Uplifting [MOS6569_VICII] best 124635 combination +Uplifting [MOS6581_SID] best 124635 combination +Uplifting [start] best 124635 combination +Uplifting [end] best 124635 combination +Uplifting [__start] best 124635 combination Attempting to uplift remaining variables inzp[1]:12 [ utoa::digit#2 utoa::digit#1 ] -Uplifting [utoa] best 124680 combination zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] +Uplifting [utoa] best 124635 combination zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] Coalescing zero page register [ zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] ] with [ zp[2]:29 [ sum::return#2 ] ] - score: 1 Coalescing zero page register [ zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] ] with [ zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] ] - score: 1 Coalescing zero page register [ zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] ] with [ zp[2]:31 [ print_uint_decimal::w#0 ] ] - score: 1 @@ -3071,11 +3069,9 @@ main: { __b1: // [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>6 - bcc __b2_from___b1 bne !+ lda.z i - cmp #<6 + cmp #6 bcc __b2_from___b1 !: // [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3] @@ -3714,7 +3710,6 @@ Replacing instruction lda #0 with TXA Replacing instruction ldy #0 with TAY Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label __b2_from___b1 with __b2 -Replacing label __b2_from___b1 with __b2 Replacing label __b2_from___b2 with __b2 Replacing label __b1_from___b1 with __b1 Replacing label __b1_from___b1 with __b1 @@ -4057,7 +4052,7 @@ reg byte x [ print_uchar::$2 ] FINAL ASSEMBLER -Score: 99381 +Score: 99336 // File Comments // Print a number of zero-terminated strings, each followed by a newline. @@ -4117,11 +4112,9 @@ main: { // for(i=0;i<6;i++) // [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>6 - bcc __b2 bne !+ lda.z i - cmp #<6 + cmp #6 bcc __b2 !: // [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3] diff --git a/src/test/ref/sieve-min.asm b/src/test/ref/sieve-min.asm index ef59fe7f0..2c4a6c236 100644 --- a/src/test/ref/sieve-min.asm +++ b/src/test/ref/sieve-min.asm @@ -32,11 +32,9 @@ main: { __b1: // while (i < SQRT_COUNT) lda.z i+1 - cmp #>SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #main::@7] @@ -1532,16 +1530,16 @@ Uplift Scope [MOS6569_VICII] Uplift Scope [MOS6581_SID] Uplift Scope [RADIX] -Uplifting [print_char] best 10785 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 ] -Uplifting [] best 10785 combination zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ] -Uplifting [print_uchar] best 10767 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] -Uplifting [main] best 10767 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:18 [ main::$16 ] -Uplifting [memset] best 10767 combination zp[2]:12 [ memset::dst#2 memset::dst#1 ] -Uplifting [print_uint] best 10767 combination zp[2]:20 [ print_uint::w#0 ] -Uplifting [MOS6526_CIA] best 10767 combination -Uplifting [MOS6569_VICII] best 10767 combination -Uplifting [MOS6581_SID] best 10767 combination -Uplifting [RADIX] best 10767 combination +Uplifting [print_char] best 10740 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 ] +Uplifting [] best 10740 combination zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ] +Uplifting [print_uchar] best 10722 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] +Uplifting [main] best 10722 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:18 [ main::$16 ] +Uplifting [memset] best 10722 combination zp[2]:12 [ memset::dst#2 memset::dst#1 ] +Uplifting [print_uint] best 10722 combination zp[2]:20 [ print_uint::w#0 ] +Uplifting [MOS6526_CIA] best 10722 combination +Uplifting [MOS6569_VICII] best 10722 combination +Uplifting [MOS6581_SID] best 10722 combination +Uplifting [RADIX] best 10722 combination Coalescing zero page register [ zp[2]:6 [ main::i#10 main::i#3 ] ] with [ zp[2]:20 [ print_uint::w#0 ] ] - score: 1 Coalescing zero page register [ zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ] ] with [ zp[2]:2 [ main::i#12 main::i#2 ] ] Coalescing zero page register [ zp[2]:18 [ main::$16 ] ] with [ zp[2]:12 [ memset::dst#2 memset::dst#1 ] ] @@ -1599,11 +1597,9 @@ main: { __b1: // [3] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #main::@7] @@ -2137,7 +2133,7 @@ reg byte x [ print_uchar::$2 ] FINAL ASSEMBLER -Score: 9762 +Score: 9717 // File Comments // C standard library string.h @@ -2184,11 +2180,9 @@ main: { // while (i < SQRT_COUNT) // [3] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #main::@7] diff --git a/src/test/ref/sieve.asm b/src/test/ref/sieve.asm index 0e0eddb6e..b838ca254 100644 --- a/src/test/ref/sieve.asm +++ b/src/test/ref/sieve.asm @@ -113,13 +113,9 @@ main: { __b1: // while (i < SQRT_COUNT) lda.z i+1 - cmp #>SQRT_COUNT - bcs !__b2+ - jmp __b2 - !__b2: bne !+ lda.z i - cmp #SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #main::@3] @@ -5806,31 +5804,31 @@ Uplift Scope [RADIX] Uplift Scope [print_ln] Uplift Scope [print_cls] -Uplifting [utoa_append] best 102818 combination zp[2]:49 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:115 [ utoa_append::sub#0 ] zp[2]:117 [ utoa_append::return#0 ] zp[2]:113 [ utoa_append::buffer#0 ] -Uplifting [ultoa_append] best 102215 combination zp[4]:52 [ ultoa_append::value#2 ultoa_append::value#0 ultoa_append::value#1 ] reg byte x [ ultoa_append::digit#2 ultoa_append::digit#1 ] zp[4]:133 [ ultoa_append::sub#0 ] zp[4]:137 [ ultoa_append::return#0 ] zp[2]:131 [ ultoa_append::buffer#0 ] -Uplifting [utoa] best 100911 combination zp[2]:32 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:29 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:111 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:108 [ utoa::buffer#3 ] -Uplifting [print_char] best 100605 combination reg byte a [ print_char::ch#2 print_char::ch#0 ] -Uplifting [] best 100605 combination zp[2]:12 [ print_char_cursor#69 print_char_cursor#89 print_char_cursor#90 print_char_cursor#91 print_char_cursor#1 print_char_cursor#61 print_char_cursor#96 print_char_cursor#97 ] zp[2]:16 [ print_line_cursor#12 print_line_cursor#23 print_char_cursor#65 print_char_cursor#79 print_line_cursor#0 print_char_cursor#39 ] zp[2]:121 [ rem16u#0 ] -Uplifting [print_str] best 100605 combination zp[2]:14 [ print_str::str#10 print_str::str#11 print_str::str#0 ] -Uplifting [divr16u] best 100395 combination zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:38 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:36 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#2 divr16u::dividend#0 ] zp[2]:95 [ divr16u::return#2 ] zp[2]:99 [ divr16u::return#3 ] -Uplifting [ultoa] best 100261 combination zp[2]:47 [ ultoa::buffer#11 ultoa::buffer#14 ultoa::buffer#4 ] zp[4]:42 [ ultoa::value#2 ultoa::value#6 ultoa::value#1 ultoa::value#0 ] zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] reg byte a [ ultoa::$10 ] reg byte x [ ultoa::started#2 ultoa::started#4 ] zp[4]:127 [ ultoa::digit_value#0 ] reg byte a [ ultoa::$11 ] zp[2]:124 [ ultoa::buffer#3 ] -Uplifting [memset] best 100245 combination zp[2]:25 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:89 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:20 [ memset::num#2 ] zp[2]:22 [ memset::str#3 ] -Uplifting [main] best 100245 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:87 [ main::$33 ] zp[4]:61 [ main::$10 ] zp[4]:77 [ main::$12 ] zp[2]:81 [ main::sec100s#0 ] zp[4]:65 [ main::cyclecount#0 ] -Uplifting [print_uint_decimal] best 100245 combination zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ] -Uplifting [div32u16u] best 100245 combination zp[2]:101 [ div32u16u::quotient_lo#0 ] zp[4]:69 [ div32u16u::dividend#0 ] zp[4]:103 [ div32u16u::return#0 ] zp[4]:73 [ div32u16u::return#2 ] zp[2]:97 [ div32u16u::quotient_hi#0 ] -Uplifting [print_ulong_decimal] best 100245 combination zp[4]:83 [ print_ulong_decimal::w#0 ] -Uplifting [clock] best 100245 combination zp[4]:91 [ clock::return#0 ] zp[4]:57 [ clock::return#2 ] -Uplifting [MOS6526_CIA] best 100245 combination -Uplifting [MOS6569_VICII] best 100245 combination -Uplifting [MOS6581_SID] best 100245 combination -Uplifting [clock_start] best 100245 combination -Uplifting [RADIX] best 100245 combination -Uplifting [print_ln] best 100245 combination -Uplifting [print_cls] best 100245 combination +Uplifting [utoa_append] best 102773 combination zp[2]:49 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:115 [ utoa_append::sub#0 ] zp[2]:117 [ utoa_append::return#0 ] zp[2]:113 [ utoa_append::buffer#0 ] +Uplifting [ultoa_append] best 102170 combination zp[4]:52 [ ultoa_append::value#2 ultoa_append::value#0 ultoa_append::value#1 ] reg byte x [ ultoa_append::digit#2 ultoa_append::digit#1 ] zp[4]:133 [ ultoa_append::sub#0 ] zp[4]:137 [ ultoa_append::return#0 ] zp[2]:131 [ ultoa_append::buffer#0 ] +Uplifting [utoa] best 100866 combination zp[2]:32 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:29 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:111 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:108 [ utoa::buffer#3 ] +Uplifting [print_char] best 100560 combination reg byte a [ print_char::ch#2 print_char::ch#0 ] +Uplifting [] best 100560 combination zp[2]:12 [ print_char_cursor#69 print_char_cursor#89 print_char_cursor#90 print_char_cursor#91 print_char_cursor#1 print_char_cursor#61 print_char_cursor#96 print_char_cursor#97 ] zp[2]:16 [ print_line_cursor#12 print_line_cursor#23 print_char_cursor#65 print_char_cursor#79 print_line_cursor#0 print_char_cursor#39 ] zp[2]:121 [ rem16u#0 ] +Uplifting [print_str] best 100560 combination zp[2]:14 [ print_str::str#10 print_str::str#11 print_str::str#0 ] +Uplifting [divr16u] best 100350 combination zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:38 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:36 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#2 divr16u::dividend#0 ] zp[2]:95 [ divr16u::return#2 ] zp[2]:99 [ divr16u::return#3 ] +Uplifting [ultoa] best 100216 combination zp[2]:47 [ ultoa::buffer#11 ultoa::buffer#14 ultoa::buffer#4 ] zp[4]:42 [ ultoa::value#2 ultoa::value#6 ultoa::value#1 ultoa::value#0 ] zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] reg byte a [ ultoa::$10 ] reg byte x [ ultoa::started#2 ultoa::started#4 ] zp[4]:127 [ ultoa::digit_value#0 ] reg byte a [ ultoa::$11 ] zp[2]:124 [ ultoa::buffer#3 ] +Uplifting [memset] best 100200 combination zp[2]:25 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:89 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:20 [ memset::num#2 ] zp[2]:22 [ memset::str#3 ] +Uplifting [main] best 100200 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:87 [ main::$33 ] zp[4]:61 [ main::$10 ] zp[4]:77 [ main::$12 ] zp[2]:81 [ main::sec100s#0 ] zp[4]:65 [ main::cyclecount#0 ] +Uplifting [print_uint_decimal] best 100200 combination zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ] +Uplifting [div32u16u] best 100200 combination zp[2]:101 [ div32u16u::quotient_lo#0 ] zp[4]:69 [ div32u16u::dividend#0 ] zp[4]:103 [ div32u16u::return#0 ] zp[4]:73 [ div32u16u::return#2 ] zp[2]:97 [ div32u16u::quotient_hi#0 ] +Uplifting [print_ulong_decimal] best 100200 combination zp[4]:83 [ print_ulong_decimal::w#0 ] +Uplifting [clock] best 100200 combination zp[4]:91 [ clock::return#0 ] zp[4]:57 [ clock::return#2 ] +Uplifting [MOS6526_CIA] best 100200 combination +Uplifting [MOS6569_VICII] best 100200 combination +Uplifting [MOS6581_SID] best 100200 combination +Uplifting [clock_start] best 100200 combination +Uplifting [RADIX] best 100200 combination +Uplifting [print_ln] best 100200 combination +Uplifting [print_cls] best 100200 combination Attempting to uplift remaining variables inzp[1]:28 [ utoa::digit#2 utoa::digit#1 ] -Uplifting [utoa] best 100245 combination zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] +Uplifting [utoa] best 100200 combination zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] Attempting to uplift remaining variables inzp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] -Uplifting [ultoa] best 100245 combination zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] +Uplifting [ultoa] best 100200 combination zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] Coalescing zero page register [ zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] ] with [ zp[2]:121 [ rem16u#0 ] ] - score: 2 Coalescing zero page register [ zp[2]:6 [ main::i#10 main::i#3 ] ] with [ zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ] ] - score: 1 Coalescing zero page register [ zp[2]:20 [ memset::num#2 ] ] with [ zp[2]:89 [ memset::end#0 ] ] - score: 1 @@ -6075,11 +6073,9 @@ main: { __b1: // [19] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>SQRT_COUNT - bcc __b2 bne !+ lda.z i - cmp #main::@3] @@ -7490,8 +7486,7 @@ Removing instruction jmp __b1 Succesful ASM optimization Pass5NextJumpElimination Removing instruction lda.z digit_value+1 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Fixing long branch [106] bcc __b2 to bcs -Fixing long branch [112] bcc __b2 to bcs +Fixing long branch [108] bcc __b2 to bcs FINAL SYMBOL TABLE (const nomodify struct MOS6526_CIA*) CIA2 = (struct MOS6526_CIA*) 56576 @@ -7927,7 +7922,7 @@ zp[4]:31 [ ultoa::digit_value#0 ultoa_append::sub#0 ] FINAL ASSEMBLER -Score: 82397 +Score: 82322 // File Comments // C standard library string.h @@ -8097,13 +8092,9 @@ main: { // while (i < SQRT_COUNT) // [19] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1 lda.z i+1 - cmp #>SQRT_COUNT - bcs !__b2+ - jmp __b2 - !__b2: bne !+ lda.z i - cmp #