1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-25 11:32:07 +00:00

Postponed zeropage overflow to main memory until the final allocation (after uplift and optimization). Closes #753

This commit is contained in:
jespergravgaard 2022-01-09 11:04:24 +01:00
parent b446d4d64b
commit 4d521217dd
23 changed files with 532 additions and 634 deletions

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT vbuzz=vbuc1
ldz #{c1}
//FRAGMENT vbuzz_lt_vbuc1_then_la1

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT vbuz1=vbuc1
ldz #{c1}
stz {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

View File

@ -1,291 +1,7 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//FRAGMENT pbuz1=pbuc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
sta {z1}
//FRAGMENT _deref_pbuz1=vbuz2
lda {z2}
ldy #0
sta ({z1}),y
//FRAGMENT pbuz1=_inc_pbuz1
inc {z1}
bne !+
inc {z1}+1
!:
//FRAGMENT vwuz1=vwuc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT _stackpushbyte_=vbuc1
lda #{c1}
pha
//FRAGMENT call_vprc1
jsr {c1}
//FRAGMENT _stackpullpadding_1
pla
//FRAGMENT vbuz1=_deref_pbuc1_minus_vbuc2
lax {c1}
axs #{c2}
stx {z1}
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}
//FRAGMENT vbuz1=vbuz2
lda {z2}
sta {z1}
//FRAGMENT vbuz1=_byte_vwuz2
lda {z2}
sta {z1}
//FRAGMENT _stackpushbyte_=vbuz1
lda {z1}
pha
//FRAGMENT vbuz1_eq_vbuc1_then_la1
lda #{c1}
cmp {z1}
beq {la1}
//FRAGMENT vbuz1=vbuz2_rol_1
lda {z2}
asl
sta {z1}
//FRAGMENT vbuz1=vbuz2_plus_vbuz3
lda {z2}
clc
adc {z3}
sta {z1}
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuz3
ldy {z3}
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuz2=vbuc1
lda #{c1}
ldy {z2}
sta ({z1}),y
//FRAGMENT vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
//FRAGMENT vbuxx=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tax
//FRAGMENT vbuyy=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tay
//FRAGMENT _deref_pbuz1=vbuaa
ldy #0
sta ({z1}),y
//FRAGMENT _deref_pbuz1=vbuxx
txa
ldy #0
sta ({z1}),y
//FRAGMENT _deref_pbuz1=vbuyy
tya
ldy #0
sta ({z1}),y
//FRAGMENT vbuaa=_byte_vwuz1
lda {z1}
//FRAGMENT vbuxx=_byte_vwuz1
ldx {z1}
//FRAGMENT _stackpushbyte_=vbuaa
pha
//FRAGMENT vbuaa=vbuz1_rol_1
lda {z1}
asl
//FRAGMENT vbuxx=vbuz1_rol_1
lda {z1}
asl
tax
//FRAGMENT vbuyy=vbuz1_rol_1
lda {z1}
asl
tay
//FRAGMENT vbuz1=vbuaa_plus_vbuz2
clc
adc {z2}
sta {z1}
//FRAGMENT vbuz1=vbuxx_plus_vbuz2
txa
clc
adc {z2}
sta {z1}
//FRAGMENT vbuz1=vbuyy_plus_vbuz2
tya
clc
adc {z2}
sta {z1}
//FRAGMENT vbuaa=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
//FRAGMENT vbuaa=vbuaa_plus_vbuz1
clc
adc {z1}
//FRAGMENT vbuaa=vbuxx_plus_vbuz1
txa
clc
adc {z1}
//FRAGMENT vbuaa=vbuyy_plus_vbuz1
tya
clc
adc {z1}
//FRAGMENT vbuxx=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
tax
//FRAGMENT vbuxx=vbuaa_plus_vbuz1
clc
adc {z1}
tax
//FRAGMENT vbuxx=vbuxx_plus_vbuz1
txa
clc
adc {z1}
tax
//FRAGMENT vbuxx=vbuyy_plus_vbuz1
tya
clc
adc {z1}
tax
//FRAGMENT vbuyy=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
tay
//FRAGMENT vbuyy=vbuaa_plus_vbuz1
clc
adc {z1}
tay
//FRAGMENT vbuyy=vbuxx_plus_vbuz1
txa
clc
adc {z1}
tay
//FRAGMENT vbuyy=vbuyy_plus_vbuz1
tya
clc
adc {z1}
tay
//FRAGMENT vbuz1=vbuaa_rol_1
asl
sta {z1}
//FRAGMENT vbuz1=vbuxx_rol_1
txa
asl
sta {z1}
//FRAGMENT vbuz1=vbuyy_rol_1
tya
asl
sta {z1}
//FRAGMENT vbuaa=vbuaa_rol_1
asl
//FRAGMENT vbuaa=vbuxx_rol_1
txa
asl
//FRAGMENT vbuaa=vbuyy_rol_1
tya
asl
//FRAGMENT vbuxx=vbuaa_rol_1
asl
tax
//FRAGMENT vbuxx=vbuxx_rol_1
txa
asl
tax
//FRAGMENT vbuxx=vbuyy_rol_1
tya
asl
tax
//FRAGMENT vbuyy=vbuaa_rol_1
asl
tay
//FRAGMENT vbuyy=vbuxx_rol_1
txa
asl
tay
//FRAGMENT vbuyy=vbuyy_rol_1
tya
asl
tay
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuaa
tay
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuxx
lda {c1},x
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuyy
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuz2
txa
ldx {z2}
tay
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuaa
stx $ff
tay
lda {c1},y
ldy $ff
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuxx
txa
tay
lda {c1},y
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuyy
lda {c1},y
stx $ff
ldy $ff
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuz2
ldx {z2}
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuaa
tax
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuyy
lda {c1},y
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=vbuc1
txa
tay
lda #{c1}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=vbuc1
lda #{c1}
sta ({z1}),y
//FRAGMENT _stackpushbyte_=vbuxx
txa
pha
//FRAGMENT vbuyy=_byte_vwuz1
ldy {z1}
//FRAGMENT _stackpushbyte_=vbuyy
tya
pha
//FRAGMENT vbuxx=vbuc1
ldx #{c1}
//FRAGMENT vbuyy=vbuc1
ldy #{c1}
//FRAGMENT vbuz1=_deref_pbuc1
lda {c1}
sta {z1}
//FRAGMENT vbuz1_lt_vbuc1_then_la1
lda {z1}
cmp #{c1}
@ -321,6 +37,10 @@ inx
//FRAGMENT vbuxx_lt_vbuc1_then_la1
cpx #{c1}
bcc {la1}
//FRAGMENT vbuxx=vbuc1
ldx #{c1}
//FRAGMENT vbuyy=vbuc1
ldy #{c1}
//FRAGMENT vbuyy_lt_vbuc1_then_la1
cpy #{c1}
bcc {la1}
@ -510,10 +230,20 @@ ldy #0
lda ({z2}),y
ldy {z1}
sta {c1},y
//FRAGMENT pbuz1=_inc_pbuz1
inc {z1}
bne !+
inc {z1}+1
!:
//FRAGMENT pbuc1_derefidx_vbuxx=_deref_pbuz1
ldy #0
lda ({z1}),y
sta {c1},x
//FRAGMENT pbuz1=pbuc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT 0_neq_pbuz1_derefidx_vbuz2_then_la1
ldy {z2}
lda ({z1}),y
@ -525,6 +255,9 @@ lda {z2}
sta {z1}
lda {z2}+1
sta {z1}+1
//FRAGMENT vbuz1=vbuz2
lda {z2}
sta {z1}
//FRAGMENT vbuz1=pbuz2_derefidx_vbuz3
ldy {z3}
lda ({z2}),y
@ -806,6 +539,10 @@ bne {la1}
//FRAGMENT vbuaa=_inc_vbuaa
clc
adc #1
//FRAGMENT vbuz1=vbuz2_rol_1
lda {z2}
asl
sta {z1}
//FRAGMENT pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_plus_vbuc2
ldy {z1}
clc
@ -824,6 +561,58 @@ sta {c1},y
lda {c1}+1,y
adc {c2}+1,y
sta {c1}+1,y
//FRAGMENT vbuaa=vbuz1_rol_1
lda {z1}
asl
//FRAGMENT vbuxx=vbuz1_rol_1
lda {z1}
asl
tax
//FRAGMENT vbuyy=vbuz1_rol_1
lda {z1}
asl
tay
//FRAGMENT vbuz1=vbuaa_rol_1
asl
sta {z1}
//FRAGMENT vbuaa=vbuaa_rol_1
asl
//FRAGMENT vbuxx=vbuaa_rol_1
asl
tax
//FRAGMENT vbuyy=vbuaa_rol_1
asl
tay
//FRAGMENT vbuz1=vbuxx_rol_1
txa
asl
sta {z1}
//FRAGMENT vbuaa=vbuxx_rol_1
txa
asl
//FRAGMENT vbuxx=vbuxx_rol_1
txa
asl
tax
//FRAGMENT vbuyy=vbuxx_rol_1
txa
asl
tay
//FRAGMENT vbuz1=vbuyy_rol_1
tya
asl
sta {z1}
//FRAGMENT vbuaa=vbuyy_rol_1
tya
asl
//FRAGMENT vbuxx=vbuyy_rol_1
tya
asl
tax
//FRAGMENT vbuyy=vbuyy_rol_1
tya
asl
tay
//FRAGMENT pwuc1_derefidx_vbuaa=pwuc1_derefidx_vbuaa_plus_vbuc2
tay
clc
@ -967,11 +756,19 @@ lda #<{c2}
sta {c1}
lda #>{c2}
sta {c1}+1
//FRAGMENT vwuz1=vwuc1
lda #<{c1}
sta {z1}
lda #>{c1}
sta {z1}+1
//FRAGMENT _deref_pwuc1=_deref_pwuc2
lda {c2}
sta {c1}
lda {c2}+1
sta {c1}+1
//FRAGMENT vbuz1=_deref_pbuc1
lda {c1}
sta {z1}
//FRAGMENT vbuz1=_byte1_vwuz2
lda {z2}+1
sta {z1}
@ -1183,6 +980,10 @@ sta {z1}
lda #0
sbc {z1}+1
sta {z1}+1
//FRAGMENT _deref_pbuz1=vbuz2
lda {z2}
ldy #0
sta ({z1}),y
//FRAGMENT pbuz1=pbuz1_plus_vbuc1
lda #{c1}
clc
@ -1222,6 +1023,17 @@ sta {z1}
ldy {z2}
lda {c1},y
sta {z1}
//FRAGMENT _deref_pbuz1=vbuaa
ldy #0
sta ({z1}),y
//FRAGMENT _deref_pbuz1=vbuxx
txa
ldy #0
sta ({z1}),y
//FRAGMENT _deref_pbuz1=vbuyy
tya
ldy #0
sta ({z1}),y
//FRAGMENT vbuaa=vbuz1_ror_4
lda {z1}
lsr
@ -1321,6 +1133,57 @@ sta {z1}
lda {c1},x
//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy
lda {c1},y
//FRAGMENT vbuz1=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
sta {z1}
//FRAGMENT _stackpushbyte_=vbuc1
lda #{c1}
pha
//FRAGMENT call_vprc1
jsr {c1}
//FRAGMENT _stackpullpadding_1
pla
//FRAGMENT vbuz1_eq_vbuc1_then_la1
lda #{c1}
cmp {z1}
beq {la1}
//FRAGMENT pbuz1_derefidx_vbuz2=vbuc1
lda #{c1}
ldy {z2}
sta ({z1}),y
//FRAGMENT vbuaa=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
//FRAGMENT vbuxx=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tax
//FRAGMENT vbuyy=_stackidxbyte_vbuc1
tsx
lda STACK_BASE+{c1},x
tay
//FRAGMENT vbuaa_eq_vbuc1_then_la1
cmp #{c1}
beq {la1}
//FRAGMENT pbuz1_derefidx_vbuaa=vbuc1
tay
lda #{c1}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=vbuc1
txa
tay
lda #{c1}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=vbuc1
lda #{c1}
sta ({z1}),y
//FRAGMENT vbuxx_eq_vbuc1_then_la1
cpx #{c1}
beq {la1}
//FRAGMENT vbuyy_eq_vbuc1_then_la1
cpy #{c1}
beq {la1}
//FRAGMENT vwsz1=vwsz1_minus_vbsc1
lda {z1}
sec
@ -2230,6 +2093,11 @@ sta {z1}
lda #{c2}
cmp {c1}
bne {la1}
//FRAGMENT vbuz1=vbuz2_plus_vbuz3
lda {z2}
clc
adc {z3}
sta {z1}
//FRAGMENT pbuz1_derefidx_(pbsc1_derefidx_vbuz2)=vbuc2
lda #{c2}
ldx {z2}
@ -2277,6 +2145,20 @@ eor #$ff
clc
adc #$01
sta {z1}
//FRAGMENT vbuaa=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
//FRAGMENT vbuxx=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
tax
//FRAGMENT vbuyy=vbuz1_plus_vbuz2
lda {z1}
clc
adc {z2}
tay
//FRAGMENT vbuz1=vbuz2_plus_vbuxx
txa
clc
@ -2315,6 +2197,21 @@ tya
clc
adc {z1}
tay
//FRAGMENT vbuz1=vbuaa_plus_vbuz2
clc
adc {z2}
sta {z1}
//FRAGMENT vbuaa=vbuaa_plus_vbuz1
clc
adc {z1}
//FRAGMENT vbuxx=vbuaa_plus_vbuz1
clc
adc {z1}
tax
//FRAGMENT vbuyy=vbuaa_plus_vbuz1
clc
adc {z1}
tay
//FRAGMENT vbuz1=vbuaa_plus_vbuxx
stx $ff
clc
@ -2353,6 +2250,25 @@ sty $ff
clc
adc $ff
tay
//FRAGMENT vbuz1=vbuxx_plus_vbuz2
txa
clc
adc {z2}
sta {z1}
//FRAGMENT vbuaa=vbuxx_plus_vbuz1
txa
clc
adc {z1}
//FRAGMENT vbuxx=vbuxx_plus_vbuz1
txa
clc
adc {z1}
tax
//FRAGMENT vbuyy=vbuxx_plus_vbuz1
txa
clc
adc {z1}
tay
//FRAGMENT vbuz1=vbuxx_plus_vbuxx
txa
asl
@ -2391,6 +2307,25 @@ sty $ff
clc
adc $ff
tay
//FRAGMENT vbuz1=vbuyy_plus_vbuz2
tya
clc
adc {z2}
sta {z1}
//FRAGMENT vbuaa=vbuyy_plus_vbuz1
tya
clc
adc {z1}
//FRAGMENT vbuxx=vbuyy_plus_vbuz1
tya
clc
adc {z1}
tax
//FRAGMENT vbuyy=vbuyy_plus_vbuz1
tya
clc
adc {z1}
tay
//FRAGMENT vbuz1=vbuyy_plus_vbuxx
txa
sty $ff
@ -2565,15 +2500,12 @@ tay
sta {c1},x
//FRAGMENT vbsyy=vbsc1
ldy #{c1}
//FRAGMENT vbuaa_eq_vbuc1_then_la1
cmp #{c1}
beq {la1}
//FRAGMENT vbuxx_eq_vbuc1_then_la1
cpx #{c1}
beq {la1}
//FRAGMENT vbuyy_eq_vbuc1_then_la1
cpy #{c1}
beq {la1}
//FRAGMENT _stackpushbyte_=vbuz1
lda {z1}
pha
//FRAGMENT _stackpushbyte_=vbuyy
tya
pha
//FRAGMENT _deref_pbuz1=_deref_pbuz2
ldy #0
lda ({z2}),y
@ -4092,10 +4024,6 @@ ora {z2}
sta {z1}
//FRAGMENT vbuz1=vbuxx_bor_vbuxx
stx {z1}
//FRAGMENT pbuz1_derefidx_vbuaa=vbuc1
tay
lda #{c1}
sta ({z1}),y
//FRAGMENT vwuz1=vwuz1_minus_pwuc1_derefidx_vbuaa
tay
lda {z1}
@ -4233,6 +4161,45 @@ beq {la1}
sty $ff
cpx $ff
beq {la1}
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuz3
ldy {z3}
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuz2
txa
ldx {z2}
tay
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuz2
ldx {z2}
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuxx
lda {c1},x
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuxx
txa
tay
lda {c1},y
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuxx
lda {c1},x
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuyy
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_vbuyy
lda {c1},y
stx $ff
ldy $ff
sta ({z1}),y
//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_vbuyy
lda {c1},y
sta ({z1}),y
//FRAGMENT vwsz1=_sword_vbuz2
lda {z2}
sta {z1}
@ -4868,6 +4835,9 @@ bne {la1}
lda {z1}
cmp #<{c1}
bne {la1}
//FRAGMENT vbuz1=_byte_vwuz2
lda {z2}
sta {z1}
//FRAGMENT vwuz1_neq_vwuc1_then_la1
lda {z1}+1
cmp #>{c1}
@ -4927,6 +4897,12 @@ tay
tya
ora #{c1}
tay
//FRAGMENT vbuaa=_byte_vwuz1
lda {z1}
//FRAGMENT vbuxx=_byte_vwuz1
ldx {z1}
//FRAGMENT vbuyy=_byte_vwuz1
ldy {z1}
//FRAGMENT vwuz1_gt_vbuc1_then_la1
lda {z1}+1
bne {la1}
@ -5369,9 +5345,14 @@ stx {z1}
lda {z1}
sec
sbc #1
//FRAGMENT _stackpushbyte_=vbuaa
pha
//FRAGMENT vbuxx=vbuz1_minus_1
ldx {z1}
dex
//FRAGMENT _stackpushbyte_=vbuxx
txa
pha
//FRAGMENT vbuyy=vbuz1_minus_1
lda {z1}
tay
@ -5669,6 +5650,11 @@ rol {z1}+1
clc
adc #1
sta {z1}
//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_vbuaa
tay
lda {c1},y
ldy {z2}
sta ({z1}),y
//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy
ldx {c1},y
//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx
@ -12018,6 +12004,10 @@ stx {z1}
lax {c1}
axs #-[{c2}]
stx {z1}
//FRAGMENT vbuz1=_deref_pbuc1_minus_vbuc2
lax {c1}
axs #{c2}
stx {z1}
//FRAGMENT vbuz1=vbuz2_minus_vbuz3
lda {z2}
sec
@ -13475,87 +13465,6 @@ lda ({z1}),y
sta !+ +2
!:
jsr $0000
//FRAGMENT vwsm1=vwsc1
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1
//FRAGMENT vwsm1_lt_vbsc1_then_la1
NO_SYNTHESIS
//FRAGMENT vwsm1_lt_vwuc1_then_la1
lda {m1}+1
bmi {la1}
cmp #>{c1}
bcc {la1}
bne !+
lda {m1}
cmp #<{c1}
bcc {la1}
!:
//FRAGMENT vbum1=_byte_vwsm2
lda {m2}
sta {m1}
//FRAGMENT vbum1=vbum2_rol_1
lda {m2}
asl
sta {m1}
//FRAGMENT pwsc1_derefidx_vbum1=vwsm2
ldy {m1}
lda {m2}
sta {c1},y
lda {m2}+1
sta {c1}+1,y
//FRAGMENT vwsm1=_inc_vwsm1
inc {m1}
bne !+
inc {m1}+1
!:
//FRAGMENT vbuaa=_byte_vwsm1
lda {m1}
//FRAGMENT vbuxx=_byte_vwsm1
lda {m1}
tax
//FRAGMENT vbuyy=_byte_vwsm1
lda {m1}
tay
//FRAGMENT vbuaa=vbum1_rol_1
lda {m1}
asl
//FRAGMENT vbuxx=vbum1_rol_1
lda {m1}
asl
tax
//FRAGMENT vbuyy=vbum1_rol_1
lda {m1}
asl
tay
//FRAGMENT vbum1=vbuaa_rol_1
asl
sta {m1}
//FRAGMENT vbum1=vbuxx_rol_1
txa
asl
sta {m1}
//FRAGMENT vbum1=vbuyy_rol_1
tya
asl
sta {m1}
//FRAGMENT pwsc1_derefidx_vbuaa=vwsm1
tay
lda {m1}
sta {c1},y
lda {m1}+1
sta {c1}+1,y
//FRAGMENT pwsc1_derefidx_vbuxx=vwsm1
lda {m1}
sta {c1},x
lda {m1}+1
sta {c1}+1,x
//FRAGMENT pwsc1_derefidx_vbuyy=vwsm1
lda {m1}
sta {c1},y
lda {m1}+1
sta {c1}+1,y
//FRAGMENT vbuz1=vbuz2_band_pbuz3_derefidx_vbuc1
lda {z2}
ldy #{c1}
@ -15803,48 +15712,6 @@ cmp {z1}
beq !+
bcs {la1}
!:
//FRAGMENT vbum1=vbuz2_rol_1
lda {z2}
asl
sta {m1}
//FRAGMENT pwsc1_derefidx_vbum1=vwsz2
ldy {m1}
lda {z2}
sta {c1},y
lda {z2}+1
sta {c1}+1,y
//FRAGMENT vwsm1=_inc_vwsz2
clc
lda {z2}
adc #1
sta {m1}
lda {z2}+1
adc #0
sta {m1}+1
//FRAGMENT vwsm1=_inc_vwsm2
clc
lda {m2}
adc #1
sta {m1}
lda {m2}+1
adc #0
sta {m1}+1
//FRAGMENT vwsz1=_inc_vwsm2
clc
lda {m2}
adc #1
sta {z1}
lda {m2}+1
adc #0
sta {z1}+1
//FRAGMENT vwsz1=_inc_vwsz2
clc
lda {z2}
adc #1
sta {z1}
lda {z2}+1
adc #0
sta {z1}+1
//FRAGMENT pbuz1=_dec_pbuz2
lda {z2}
sec
@ -16310,3 +16177,46 @@ sta {c1},x
lda #{c2}
ora {c1},y
sta {c1},y
//FRAGMENT vwsm1=vwsc1
lda #<{c1}
sta {m1}
lda #>{c1}
sta {m1}+1
//FRAGMENT vwsm1_lt_vbsc1_then_la1
NO_SYNTHESIS
//FRAGMENT vwsm1_lt_vwuc1_then_la1
lda {m1}+1
bmi {la1}
cmp #>{c1}
bcc {la1}
bne !+
lda {m1}
cmp #<{c1}
bcc {la1}
!:
//FRAGMENT vbuaa=_byte_vwsm1
lda {m1}
//FRAGMENT pwsc1_derefidx_vbuaa=vwsm1
tay
lda {m1}
sta {c1},y
lda {m1}+1
sta {c1}+1,y
//FRAGMENT vwsm1=_inc_vwsm1
inc {m1}
bne !+
inc {m1}+1
!:
//FRAGMENT vwsz1=_inc_vwsz2
clc
lda {z2}
adc #1
sta {z1}
lda {z2}+1
adc #0
sta {z1}+1
//FRAGMENT pwsc1_derefidx_vbuxx=vwsm1
lda {m1}
sta {c1},x
lda {m1}+1
sta {c1}+1,x

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT _deref_pbuc1=_inc__deref_pbuc1
inc {c1}
//FRAGMENT isr_hardware_all_entry

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 1377b54b6c 1377b57075
//KICKC FRAGMENT CACHE 1472899f88 147289c4f1
//FRAGMENT vbuz1=_deref_pbuc1
lda {c1}
sta {z1}

View File

@ -0,0 +1,6 @@
lda {m2}
and #<{c1}
sta {m1}
lda {m2}+1
and #>{c1}
sta {m1}+1

View File

@ -668,7 +668,7 @@ public class Compiler {
getLog().append(program.getScope().toStringVars(program, true));
new Pass4LiveRangeEquivalenceClassesFinalize(program).allocate();
new Pass4RegistersFinalize(program).allocate(true);
new Pass4RegistersFinalize(program).allocate(true, false);
// Initial Code generation
new Pass4CodeGeneration(program, false, program.isWarnFragmentMissing()).generate();
@ -719,7 +719,7 @@ public class Compiler {
// Register coalesce using exhaustive search (saving even more ZP - but slow)
new Pass4MemoryCoalesceExhaustive(program).coalesce();
}
new Pass4RegistersFinalize(program).allocate(true);
new Pass4RegistersFinalize(program).allocate(true, true);
new Pass4AssertZeropageAllocation(program).check();
// Final ASM code generation before optimization

View File

@ -44,6 +44,12 @@ public class Pass2ConstantInlining extends Pass2SsaOptimization {
inline.remove(constantRef);
}
}
// Remove all SIZEOF_ constants
for(ConstantRef constantRef : (List<ConstantRef>) new ArrayList(inline.keySet())) {
if(constantRef.getLocalName().startsWith("SIZEOF_")) {
inline.remove(constantRef);
}
}
// Perform alias replacement within the constant values inside the aliases
replaceInValues(inline);

View File

@ -91,7 +91,7 @@ public class Pass4RegisterUpliftCombinations extends Pass2Base {
Set<String> unknownFragments,
ScopeRef scope) {
// Reset register allocation to original zero page allocation
new Pass4RegistersFinalize(program).allocate(false);
new Pass4RegistersFinalize(program).allocate(false, false);
// Apply the uplift combination
combination.allocate(program);
// Check the register allocation for whether any register is being allocated to two variables with overlapping live ranges

View File

@ -159,7 +159,7 @@ public class Pass4RegisterUpliftPotentialRegisterAnalysis extends Pass2Base {
while(combinations.hasNext()) {
RegisterCombination combination = combinations.next();
// Reset register allocation to original zero page allocation
new Pass4RegistersFinalize(getProgram()).allocate(false);
new Pass4RegistersFinalize(getProgram()).allocate(false, false);
// Apply the combination
combination.allocate(getProgram());
// Generate ASM

View File

@ -48,7 +48,7 @@ public class Pass4RegistersFinalize extends Pass2Base {
}
}
public void allocate(boolean reallocateZp) {
public void allocate(boolean reallocateZp, boolean overflowToMainMem) {
LiveRangeEquivalenceClassSet liveRangeEquivalenceClassSet = getProgram().getLiveRangeEquivalenceClassSet();
for(LiveRangeEquivalenceClass equivalenceClass : liveRangeEquivalenceClassSet.getEquivalenceClasses()) {
for(VariableRef variableRef : equivalenceClass.getVariables()) {
@ -79,7 +79,7 @@ public class Pass4RegistersFinalize extends Pass2Base {
if(reallocateZp) {
reallocateMemRegisters(liveRangeEquivalenceClassSet);
reallocateMemRegisters(liveRangeEquivalenceClassSet, overflowToMainMem);
}
liveRangeEquivalenceClassSet.storeRegisterAllocation();
if(reallocateZp) {
@ -152,11 +152,11 @@ public class Pass4RegistersFinalize extends Pass2Base {
/**
* Reallocate all memory registers. Minimizes zeropage usage.
*
* @param liveRangeEquivalenceClassSet The
* @param equivalenceClassSet The live range equivalence classes
* @param overflowToMainMem If true zeropage variables overflow into main memory if they do not fit on zeropage.
*/
private void reallocateMemRegisters(LiveRangeEquivalenceClassSet liveRangeEquivalenceClassSet) {
private void reallocateMemRegisters(LiveRangeEquivalenceClassSet equivalenceClassSet, boolean overflowToMainMem) {
LiveRangeEquivalenceClassSet equivalenceClassSet = getProgram().getLiveRangeEquivalenceClassSet();
List<LiveRangeEquivalenceClass> equivalenceClasses = new ArrayList<>(equivalenceClassSet.getEquivalenceClasses());
final VariableRegisterWeights registerWeights = getProgram().getVariableRegisterWeights();
Collections.sort(equivalenceClasses, (o1, o2) -> Double.compare(registerWeights.getTotalWeight(o2), registerWeights.getTotalWeight(o1)));
@ -183,12 +183,14 @@ public class Pass4RegistersFinalize extends Pass2Base {
register = allocateNewRegisterZp(variable);
int zp = ((Registers.RegisterZpMem) register).getZp();
int sizeBytes = variable.getType().getSizeBytes();
if(overflowToMainMem) {
if (zp + sizeBytes > 0x100) {
// Zero-page exhausted - move to main memory instead (TODO: prioritize!)
register = new Registers.RegisterMainMem(variableRef, variable.getType().getSizeBytes(), null, false);
getLog().append("Zero-page exhausted. Moving allocation to main memory " + variable.toString());
}
}
}
equivalenceClass.setRegister(register);
if(before == null || !before.equals(register.toString())) {
getLog().append("Allocated " + (before == null ? "" : ("(was " + before + ") ")) + equivalenceClass.toString());

View File

@ -8,6 +8,7 @@
.segmentdef Data [startAfter="Code"]
.segment Basic
:BasicUpstart(main)
.const SIZEOF_STRUCT___0 = 3
.segment Code
main: {
.label msg = 2
@ -24,7 +25,7 @@ main: {
ldx #0
__b1:
// for(char i=0;i<sizeof(Text)/sizeof(TextDesc); i++, txt++)
cpx #$c*3/3
cpx #$c*SIZEOF_STRUCT___0/SIZEOF_STRUCT___0
bcc __b2
// }
rts
@ -52,7 +53,7 @@ main: {
!:
// for(char i=0;i<sizeof(Text)/sizeof(TextDesc); i++, txt++)
inx
lda #3
lda #SIZEOF_STRUCT___0
clc
adc.z txt
sta.z txt

View File

@ -7,7 +7,7 @@ main::@1: scope:[main] from main main::@5
[1] main::screen#6 = phi( main/(char *) 1024, main::@5/main::screen#2 )
[1] main::txt#2 = phi( main/Text, main::@5/main::txt#1 )
[1] main::i#2 = phi( main/0, main::@5/main::i#1 )
[2] if(main::i#2<$c*3/3) goto main::@2
[2] if(main::i#2<$c*SIZEOF_STRUCT_$0/SIZEOF_STRUCT_$0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[3] return
@ -24,7 +24,7 @@ main::@5: scope:[main] from main::@3
[7] *main::screen#3 = ' '
[8] main::screen#2 = ++ main::screen#3
[9] main::i#1 = ++ main::i#2
[10] main::txt#1 = main::txt#2 + 3
[10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0
to:main::@1
main::@4: scope:[main] from main::@3
[11] *main::screen#3 = *main::msg#2

View File

@ -177,9 +177,8 @@ Inlining constant with var siblings main::txt#0
Inlining constant with var siblings main::i#0
Constant inlined main::txt#0 = Text
Constant inlined main::screen#0 = (char *) 1024
Constant inlined main::$1 = $c*3/3
Constant inlined main::$0 = $c*3
Constant inlined SIZEOF_STRUCT_$0 = 3
Constant inlined main::$1 = $c*SIZEOF_STRUCT_$0/SIZEOF_STRUCT_$0
Constant inlined main::$0 = $c*SIZEOF_STRUCT_$0
Constant inlined main::i#0 = 0
Constant inlined OFFSET_STRUCT_$0_MSG = 1
Constant inlined $0_msg7 = $0_msg10
@ -208,7 +207,7 @@ main::@1: scope:[main] from main main::@5
[1] main::screen#6 = phi( main/(char *) 1024, main::@5/main::screen#2 )
[1] main::txt#2 = phi( main/Text, main::@5/main::txt#1 )
[1] main::i#2 = phi( main/0, main::@5/main::i#1 )
[2] if(main::i#2<$c*3/3) goto main::@2
[2] if(main::i#2<$c*SIZEOF_STRUCT_$0/SIZEOF_STRUCT_$0) goto main::@2
to:main::@return
main::@return: scope:[main] from main::@1
[3] return
@ -225,7 +224,7 @@ main::@5: scope:[main] from main::@3
[7] *main::screen#3 = ' '
[8] main::screen#2 = ++ main::screen#3
[9] main::i#1 = ++ main::i#2
[10] main::txt#1 = main::txt#2 + 3
[10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0
to:main::@1
main::@4: scope:[main] from main::@3
[11] *main::screen#3 = *main::msg#2
@ -272,12 +271,12 @@ Removing always clobbered register reg byte a as potential for zp[1]:8 [ main::i
Removing always clobbered register reg byte y as potential for zp[1]:8 [ main::i#2 main::i#1 ]
Statement [6] if(0!=*main::msg#2) goto main::@4 [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Statement [7] *main::screen#3 = ' ' [ main::i#2 main::txt#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Statement [10] main::txt#1 = main::txt#2 + 3 [ main::i#1 main::txt#1 main::screen#2 ] ( [ main::i#1 main::txt#1 main::screen#2 ] { } ) always clobbers reg byte a
Statement [10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0 [ main::i#1 main::txt#1 main::screen#2 ] ( [ main::i#1 main::txt#1 main::screen#2 ] { } ) always clobbers reg byte a
Statement [11] *main::screen#3 = *main::msg#2 [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Statement [4] main::msg#0 = ((char **)main::txt#2)[1] [ main::i#2 main::txt#2 main::screen#6 main::msg#0 ] ( [ main::i#2 main::txt#2 main::screen#6 main::msg#0 ] { } ) always clobbers reg byte a reg byte y
Statement [6] if(0!=*main::msg#2) goto main::@4 [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Statement [7] *main::screen#3 = ' ' [ main::i#2 main::txt#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Statement [10] main::txt#1 = main::txt#2 + 3 [ main::i#1 main::txt#1 main::screen#2 ] ( [ main::i#1 main::txt#1 main::screen#2 ] { } ) always clobbers reg byte a
Statement [10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0 [ main::i#1 main::txt#1 main::screen#2 ] ( [ main::i#1 main::txt#1 main::screen#2 ] { } ) always clobbers reg byte a
Statement [11] *main::screen#3 = *main::msg#2 [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] ( [ main::i#2 main::txt#2 main::msg#2 main::screen#3 ] { } ) always clobbers reg byte a reg byte y
Potential registers zp[1]:8 [ main::i#2 main::i#1 ] : zp[1]:8 , reg byte x ,
Potential registers zp[2]:6 [ main::txt#2 main::txt#1 ] : zp[2]:6 ,
@ -307,6 +306,7 @@ ASSEMBLER BEFORE OPTIMIZATION
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_STRUCT___0 = 3
.segment Code
// main
main: {
@ -330,8 +330,8 @@ main: {
jmp __b1
// main::@1
__b1:
// [2] if(main::i#2<$c*3/3) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$c*3/3
// [2] if(main::i#2<$c*SIZEOF_STRUCT_$0/SIZEOF_STRUCT_$0) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$c*SIZEOF_STRUCT___0/SIZEOF_STRUCT___0
bcc __b2
jmp __breturn
// main::@return
@ -374,8 +374,8 @@ main: {
!:
// [9] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] main::txt#1 = main::txt#2 + 3 -- pssz1=pssz1_plus_vbuc1
lda #3
// [10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0 -- pssz1=pssz1_plus_vbuc1
lda #SIZEOF_STRUCT___0
clc
adc.z txt
sta.z txt
@ -488,6 +488,7 @@ __constant char $0_msg5[$1b] = "(joachim@von-bassewitz.de)"
__constant char $0_msg6[4] = "and"
__constant char $0_msg8[$1b] = "(ullrich@von-bassewitz.de)"
__constant char $0_msg9[$14] = "C Implementation by"
__constant char SIZEOF_STRUCT_$0 = 3
__constant struct $0 Text[] = { { Y: 2, Msg: $0_msg }, { Y: 4, Msg: $0_msg1 }, { Y: 5, Msg: $0_msg2 }, { Y: 9, Msg: $0_msg3 }, { Y: $b, Msg: $0_msg4 }, { Y: $c, Msg: $0_msg5 }, { Y: $d, Msg: $0_msg6 }, { Y: $e, Msg: $0_msg10 }, { Y: $f, Msg: $0_msg8 }, { Y: $12, Msg: $0_msg9 }, { Y: $13, Msg: $0_msg10 }, { Y: $17, Msg: $0_msg11 } }
void main()
char main::i
@ -528,6 +529,7 @@ Score: 6261
.segment Basic
:BasicUpstart(main)
// Global Constants & labels
.const SIZEOF_STRUCT___0 = 3
.segment Code
// main
main: {
@ -550,8 +552,8 @@ main: {
// main::@1
__b1:
// for(char i=0;i<sizeof(Text)/sizeof(TextDesc); i++, txt++)
// [2] if(main::i#2<$c*3/3) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$c*3/3
// [2] if(main::i#2<$c*SIZEOF_STRUCT_$0/SIZEOF_STRUCT_$0) goto main::@2 -- vbuxx_lt_vbuc1_then_la1
cpx #$c*SIZEOF_STRUCT___0/SIZEOF_STRUCT___0
bcc __b2
// main::@return
// }
@ -592,8 +594,8 @@ main: {
// for(char i=0;i<sizeof(Text)/sizeof(TextDesc); i++, txt++)
// [9] main::i#1 = ++ main::i#2 -- vbuxx=_inc_vbuxx
inx
// [10] main::txt#1 = main::txt#2 + 3 -- pssz1=pssz1_plus_vbuc1
lda #3
// [10] main::txt#1 = main::txt#2 + SIZEOF_STRUCT_$0 -- pssz1=pssz1_plus_vbuc1
lda #SIZEOF_STRUCT___0
clc
adc.z txt
sta.z txt

View File

@ -9,6 +9,7 @@ __constant char $0_msg5[$1b] = "(joachim@von-bassewitz.de)"
__constant char $0_msg6[4] = "and"
__constant char $0_msg8[$1b] = "(ullrich@von-bassewitz.de)"
__constant char $0_msg9[$14] = "C Implementation by"
__constant char SIZEOF_STRUCT_$0 = 3
__constant struct $0 Text[] = { { Y: 2, Msg: $0_msg }, { Y: 4, Msg: $0_msg1 }, { Y: 5, Msg: $0_msg2 }, { Y: 9, Msg: $0_msg3 }, { Y: $b, Msg: $0_msg4 }, { Y: $c, Msg: $0_msg5 }, { Y: $d, Msg: $0_msg6 }, { Y: $e, Msg: $0_msg10 }, { Y: $f, Msg: $0_msg8 }, { Y: $12, Msg: $0_msg9 }, { Y: $13, Msg: $0_msg10 }, { Y: $17, Msg: $0_msg11 } }
void main()
char main::i

View File

@ -29,9 +29,9 @@ main: {
inc.z $ff
inx
!:
cpy #<$11a
cpy #<SIZEOF_STRUCT___0
bne !n-
cpx #>$11a
cpx #>SIZEOF_STRUCT___0
bne !n-
lda #<0
sta.z i

View File

@ -1,7 +1,7 @@
void main()
main: scope:[main] from
[0] *(&main::b) = memset(struct $0, $11a)
[0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0)
to:main::@1
main::@1: scope:[main] from main main::@2
[1] main::i#2 = phi( main/0, main::@2/main::i#1 )

View File

@ -81,7 +81,6 @@ Removing unused procedure block __start::@2
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Inlining constant with var siblings main::i#0
Constant inlined SIZEOF_STRUCT_$0 = $11a
Constant inlined main::i#0 = 0
Constant inlined main::$0 = $11a
Successful SSA optimization Pass2ConstantInlining
@ -98,7 +97,7 @@ FINAL CONTROL FLOW GRAPH
void main()
main: scope:[main] from
[0] *(&main::b) = memset(struct $0, $11a)
[0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0)
to:main::@1
main::@1: scope:[main] from main main::@2
[1] main::i#2 = phi( main/0, main::@2/main::i#1 )
@ -137,10 +136,9 @@ Complete equivalence classes
Allocated zp[2]:2 [ main::i#2 main::i#1 ]
Allocated zp[2]:4 [ main::$3 ]
Allocated zp[2]:6 [ main::$2 ]
Zero-page exhausted. Moving allocation to main memory main::b
Allocated mem[282] [ main::b ]
Allocated zp[282]:256 [ main::b ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [0] *(&main::b) = memset(struct $0, $11a) [ main::b ] ( [ main::b ] { } ) always clobbers reg byte a reg byte x reg byte y
Statement [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) [ main::b ] ( [ main::b ] { } ) always clobbers reg byte a reg byte x reg byte y
Statement [2] if(main::i#2<$11a) goto main::@2 [ main::i#2 main::b ] ( [ main::i#2 main::b ] { } ) always clobbers reg byte a
Statement [4] main::$2 = (char *)&main::b + main::i#2 [ main::i#2 main::$2 main::b ] ( [ main::i#2 main::$2 main::b ] { } ) always clobbers reg byte a
Statement [5] main::$3 = SCREEN + main::i#2 [ main::i#2 main::$2 main::b main::$3 ] ( [ main::i#2 main::$2 main::b main::$3 ] { } ) always clobbers reg byte a
@ -148,17 +146,18 @@ Statement [6] *main::$3 = *main::$2 [ main::i#2 main::b ] ( [ main::i#2 main::b
Potential registers zp[2]:2 [ main::i#2 main::i#1 ] : zp[2]:2 ,
Potential registers zp[2]:6 [ main::$2 ] : zp[2]:6 ,
Potential registers zp[2]:4 [ main::$3 ] : zp[2]:4 ,
Potential registers mem[282] [ main::b ] : mem[282] ,
Potential registers zp[282]:256 [ main::b ] : zp[282]:256 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 33: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[2]:4 [ main::$3 ] 11: zp[2]:6 [ main::$2 ] 0: mem[282] [ main::b ]
Uplift Scope [main] 33: zp[2]:2 [ main::i#2 main::i#1 ] 22: zp[2]:4 [ main::$3 ] 11: zp[2]:6 [ main::$2 ] 0: zp[282]:256 [ main::b ]
Uplift Scope [$0]
Uplift Scope []
Uplifting [main] best 1055 combination zp[2]:2 [ main::i#2 main::i#1 ] zp[2]:4 [ main::$3 ] zp[2]:6 [ main::$2 ] mem[282] [ main::b ]
Uplifting [main] best 1055 combination zp[2]:2 [ main::i#2 main::i#1 ] zp[2]:4 [ main::$3 ] zp[2]:6 [ main::$2 ] zp[282]:256 [ main::b ]
Uplifting [$0] best 1055 combination
Uplifting [] best 1055 combination
Zero-page exhausted. Moving allocation to main memory main::b
Allocated (was zp[282]:256) mem[282] [ main::b ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -180,7 +179,7 @@ main: {
.label i = 2
.label __2 = 6
.label __3 = 4
// [0] *(&main::b) = memset(struct $0, $11a) -- _deref_pssc1=_memset_vwuc2
// [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) -- _deref_pssc1=_memset_vwuc2
lda #<b
sta.z $fe
lda #>b
@ -196,9 +195,9 @@ main: {
inc.z $ff
inx
!:
cpy #<$11a
cpy #<SIZEOF_STRUCT___0
bne !n-
cpx #>$11a
cpx #>SIZEOF_STRUCT___0
bne !n-
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
@ -313,7 +312,7 @@ main: {
.label __2 = 6
.label __3 = 4
// bug b
// [0] *(&main::b) = memset(struct $0, $11a) -- _deref_pssc1=_memset_vwuc2
// [0] *(&main::b) = memset(struct $0, SIZEOF_STRUCT_$0) -- _deref_pssc1=_memset_vwuc2
lda #<b
sta.z $fe
lda #>b
@ -329,9 +328,9 @@ main: {
inc.z $ff
inx
!:
cpy #<$11a
cpy #<SIZEOF_STRUCT___0
bne !n-
cpx #>$11a
cpx #>SIZEOF_STRUCT___0
bne !n-
// [1] phi from main to main::@1 [phi:main->main::@1]
// [1] phi main::i#2 = 0 [phi:main->main::@1#0] -- vwuz1=vwuc1

View File

@ -115,28 +115,26 @@ Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::$2 ]
[ main::$1 ]
Zero-page exhausted. Moving allocation to main memory main::i#2
Allocated mem[2] [ main::i#2 main::i#1 ]
Zero-page exhausted. Moving allocation to main memory main::$2
Allocated mem[1] [ main::$2 ]
Zero-page exhausted. Moving allocation to main memory main::$1
Allocated mem[1] [ main::$1 ]
Allocated zp[2]:256 [ main::i#2 main::i#1 ]
Allocated zp[1]:258 [ main::$2 ]
Allocated zp[1]:259 [ main::$1 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [2] if(main::i#2<$a) goto main::@2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Statement [4] main::$2 = (char)main::i#2 [ main::i#2 main::$2 ] ( [ main::i#2 main::$2 ] { } ) always clobbers reg byte a
Statement [5] main::$1 = main::$2 << 1 [ main::i#2 main::$1 ] ( [ main::i#2 main::$1 ] { } ) always clobbers reg byte a
Statement [6] main::SCREEN[main::$1] = main::i#2 [ main::i#2 ] ( [ main::i#2 ] { } ) always clobbers reg byte a
Potential registers mem[2] [ main::i#2 main::i#1 ] : mem[2] ,
Potential registers mem[1] [ main::$2 ] : mem[1] , reg byte a , reg byte x , reg byte y ,
Potential registers mem[1] [ main::$1 ] : mem[1] , reg byte a , reg byte x , reg byte y ,
Potential registers zp[2]:256 [ main::i#2 main::i#1 ] : zp[2]:256 ,
Potential registers zp[1]:258 [ main::$2 ] : zp[1]:258 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:259 [ main::$1 ] : zp[1]:259 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 30.8: mem[2] [ main::i#2 main::i#1 ] 22: mem[1] [ main::$2 ] 22: mem[1] [ main::$1 ]
Uplift Scope [main] 30.8: zp[2]:256 [ main::i#2 main::i#1 ] 22: zp[1]:258 [ main::$2 ] 22: zp[1]:259 [ main::$1 ]
Uplift Scope []
Uplifting [main] best 841 combination mem[2] [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$1 ]
Uplifting [] best 841 combination
Uplifting [main] best 751 combination zp[2]:256 [ main::i#2 main::i#1 ] reg byte a [ main::$2 ] reg byte a [ main::$1 ]
Uplifting [] best 751 combination
Zero-page exhausted. Moving allocation to main memory main::i#2
Allocated (was zp[2]:256) mem[2] [ main::i#2 main::i#1 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments

View File

@ -11,11 +11,11 @@
// And then allocate a bunch of variables
main: {
.label SCREEN = $400
.label a = $f9
.label a_1 = $f7
.label a = $f7
.label h = $f9
lda #<0
sta h
sta h+1
sta.z h
sta.z h+1
sta g
sta g+1
sta f
@ -28,8 +28,8 @@ main: {
sta c+1
sta b
sta b+1
sta.z a_1
sta.z a_1+1
sta.z a
sta.z a+1
tay
__b1:
// for(char i=0;i<10;i++)
@ -42,18 +42,15 @@ main: {
tya
asl
tax
lda.z a_1
lda.z a
sta SCREEN,x
lda.z a_1+1
lda.z a+1
sta SCREEN+1,x
// SCREEN[i] = a++;
clc
lda.z a_1
adc #1
sta.z a
lda.z a_1+1
adc #0
sta.z a+1
inc.z a
bne !+
inc.z a+1
!:
// SCREEN[i] = b++
lda b
sta SCREEN,x
@ -125,14 +122,14 @@ main: {
inc g+1
!:
// SCREEN[i] = h++
lda h
lda.z h
sta SCREEN,x
lda h+1
lda.z h+1
sta SCREEN+1,x
// SCREEN[i] = h++;
inc h
inc.z h
bne !+
inc h+1
inc.z h+1
!:
// SCREEN[i] = a++
lda.z a
@ -140,13 +137,10 @@ main: {
lda.z a+1
sta SCREEN+1,x
// SCREEN[i] = a++;
clc
lda.z a
adc #1
sta.z a_1
lda.z a+1
adc #0
sta.z a_1+1
inc.z a
bne !+
inc.z a+1
!:
// for(char i=0;i<10;i++)
iny
jmp __b1
@ -157,5 +151,4 @@ main: {
e: .word 0
f: .word 0
g: .word 0
h: .word 0
}

View File

@ -340,29 +340,20 @@ Complete equivalence classes
Allocated zp[1]:247 [ main::i#2 main::i#1 ]
Allocated zp[2]:248 [ main::a#4 main::a#3 ]
Allocated zp[2]:250 [ main::h#2 main::h#1 ]
Zero-page exhausted. Moving allocation to main memory main::b#2
Allocated mem[2] [ main::b#2 main::b#1 ]
Zero-page exhausted. Moving allocation to main memory main::$2
Allocated mem[1] [ main::$2 ]
Zero-page exhausted. Moving allocation to main memory main::c#2
Allocated mem[2] [ main::c#2 main::c#1 ]
Zero-page exhausted. Moving allocation to main memory main::g#2
Allocated mem[2] [ main::g#2 main::g#1 ]
Zero-page exhausted. Moving allocation to main memory main::d#2
Allocated mem[2] [ main::d#2 main::d#1 ]
Zero-page exhausted. Moving allocation to main memory main::f#2
Allocated mem[2] [ main::f#2 main::f#1 ]
Zero-page exhausted. Moving allocation to main memory main::e#2
Allocated mem[2] [ main::e#2 main::e#1 ]
Zero-page exhausted. Moving allocation to main memory main::a#1
Allocated mem[2] [ main::a#1 ]
Zero-page exhausted. Moving allocation to main memory main::a#2
Allocated mem[2] [ main::a#2 ]
Allocated zp[2]:256 [ main::b#2 main::b#1 ]
Allocated zp[1]:258 [ main::$2 ]
Allocated zp[2]:259 [ main::c#2 main::c#1 ]
Allocated zp[2]:261 [ main::g#2 main::g#1 ]
Allocated zp[2]:263 [ main::d#2 main::d#1 ]
Allocated zp[2]:265 [ main::f#2 main::f#1 ]
Allocated zp[2]:267 [ main::e#2 main::e#1 ]
Allocated zp[2]:269 [ main::a#1 ]
Allocated zp[2]:271 [ main::a#2 ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [4] main::$2 = main::i#2 << 1 [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] ( [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:247 [ main::i#2 main::i#1 ]
Statement [5] main::SCREEN[main::$2] = main::a#4 [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] ( [ main::i#2 main::a#4 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for mem[1] [ main::$2 ]
Removing always clobbered register reg byte a as potential for zp[1]:258 [ main::$2 ]
Statement [6] main::a#1 = ++ main::a#4 [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] ( [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] { } ) always clobbers reg byte a
Statement [7] main::SCREEN[main::$2] = main::b#2 [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] ( [ main::i#2 main::b#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::$2 main::a#1 ] { } ) always clobbers reg byte a
Statement [9] main::SCREEN[main::$2] = main::c#2 [ main::i#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::b#1 main::$2 main::a#1 ] ( [ main::i#2 main::c#2 main::d#2 main::e#2 main::f#2 main::g#2 main::h#2 main::b#1 main::$2 main::a#1 ] { } ) always clobbers reg byte a
@ -391,34 +382,39 @@ Statement [23] main::SCREEN[main::$2] = main::a#2 [ main::i#2 main::b#1 main::c#
Statement [24] main::a#3 = ++ main::a#2 [ main::i#2 main::a#3 main::b#1 main::c#1 main::d#1 main::e#1 main::f#1 main::g#1 main::h#1 ] ( [ main::i#2 main::a#3 main::b#1 main::c#1 main::d#1 main::e#1 main::f#1 main::g#1 main::h#1 ] { } ) always clobbers reg byte a
Potential registers zp[1]:247 [ main::i#2 main::i#1 ] : zp[1]:247 , reg byte x , reg byte y ,
Potential registers zp[2]:248 [ main::a#4 main::a#3 ] : zp[2]:248 ,
Potential registers mem[2] [ main::b#2 main::b#1 ] : mem[2] ,
Potential registers mem[2] [ main::c#2 main::c#1 ] : mem[2] ,
Potential registers mem[2] [ main::d#2 main::d#1 ] : mem[2] ,
Potential registers mem[2] [ main::e#2 main::e#1 ] : mem[2] ,
Potential registers mem[2] [ main::f#2 main::f#1 ] : mem[2] ,
Potential registers mem[2] [ main::g#2 main::g#1 ] : mem[2] ,
Potential registers zp[2]:256 [ main::b#2 main::b#1 ] : zp[2]:256 ,
Potential registers zp[2]:259 [ main::c#2 main::c#1 ] : zp[2]:259 ,
Potential registers zp[2]:263 [ main::d#2 main::d#1 ] : zp[2]:263 ,
Potential registers zp[2]:267 [ main::e#2 main::e#1 ] : zp[2]:267 ,
Potential registers zp[2]:265 [ main::f#2 main::f#1 ] : zp[2]:265 ,
Potential registers zp[2]:261 [ main::g#2 main::g#1 ] : zp[2]:261 ,
Potential registers zp[2]:250 [ main::h#2 main::h#1 ] : zp[2]:250 ,
Potential registers mem[1] [ main::$2 ] : mem[1] , reg byte x , reg byte y ,
Potential registers mem[2] [ main::a#1 ] : mem[2] ,
Potential registers mem[2] [ main::a#2 ] : mem[2] ,
Potential registers zp[1]:258 [ main::$2 ] : zp[1]:258 , reg byte x , reg byte y ,
Potential registers zp[2]:269 [ main::a#1 ] : zp[2]:269 ,
Potential registers zp[2]:271 [ main::a#2 ] : zp[2]:271 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 23.91: zp[1]:247 [ main::i#2 main::i#1 ] 19.25: zp[2]:248 [ main::a#4 main::a#3 ] 7.15: zp[2]:250 [ main::h#2 main::h#1 ] 6.72: mem[2] [ main::b#2 main::b#1 ] 6.37: mem[1] [ main::$2 ] 5.5: mem[2] [ main::c#2 main::c#1 ] 5.5: mem[2] [ main::g#2 main::g#1 ] 4.87: mem[2] [ main::d#2 main::d#1 ] 4.81: mem[2] [ main::f#2 main::f#1 ] 4.56: mem[2] [ main::e#2 main::e#1 ] 4.12: mem[2] [ main::a#1 ] 3.3: mem[2] [ main::a#2 ]
Uplift Scope [main] 23.91: zp[1]:247 [ main::i#2 main::i#1 ] 19.25: zp[2]:248 [ main::a#4 main::a#3 ] 7.15: zp[2]:250 [ main::h#2 main::h#1 ] 6.72: zp[2]:256 [ main::b#2 main::b#1 ] 6.37: zp[1]:258 [ main::$2 ] 5.5: zp[2]:259 [ main::c#2 main::c#1 ] 5.5: zp[2]:261 [ main::g#2 main::g#1 ] 4.87: zp[2]:263 [ main::d#2 main::d#1 ] 4.81: zp[2]:265 [ main::f#2 main::f#1 ] 4.56: zp[2]:267 [ main::e#2 main::e#1 ] 4.12: zp[2]:269 [ main::a#1 ] 3.3: zp[2]:271 [ main::a#2 ]
Uplift Scope []
Uplifting [main] best 4536 combination reg byte y [ main::i#2 main::i#1 ] zp[2]:248 [ main::a#4 main::a#3 ] zp[2]:250 [ main::h#2 main::h#1 ] mem[2] [ main::b#2 main::b#1 ] reg byte x [ main::$2 ] mem[2] [ main::c#2 main::c#1 ] mem[2] [ main::g#2 main::g#1 ] mem[2] [ main::d#2 main::d#1 ] mem[2] [ main::f#2 main::f#1 ] mem[2] [ main::e#2 main::e#1 ] mem[2] [ main::a#1 ] mem[2] [ main::a#2 ]
Uplifting [] best 4536 combination
Coalescing zero page register [ mem[2] [ main::a#1 ] ] with [ mem[2] [ main::a#2 ] ] - score: 1
Allocated (was zp[2]:248) zp[2]:247 [ main::a#4 main::a#3 ]
Allocated (was mem[2]) zp[2]:249 [ main::a#1 main::a#2 ]
Zero-page exhausted. Moving allocation to main memory main::h#2
Allocated (was zp[2]:250) mem[2] [ main::h#2 main::h#1 ]
Uplifting [main] best 4056 combination reg byte y [ main::i#2 main::i#1 ] zp[2]:248 [ main::a#4 main::a#3 ] zp[2]:250 [ main::h#2 main::h#1 ] zp[2]:256 [ main::b#2 main::b#1 ] reg byte x [ main::$2 ] zp[2]:259 [ main::c#2 main::c#1 ] zp[2]:261 [ main::g#2 main::g#1 ] zp[2]:263 [ main::d#2 main::d#1 ] zp[2]:265 [ main::f#2 main::f#1 ] zp[2]:267 [ main::e#2 main::e#1 ] zp[2]:269 [ main::a#1 ] zp[2]:271 [ main::a#2 ]
Uplifting [] best 4056 combination
Coalescing zero page register [ zp[2]:248 [ main::a#4 main::a#3 ] ] with [ zp[2]:269 [ main::a#1 ] ] - score: 1
Coalescing zero page register [ zp[2]:248 [ main::a#4 main::a#3 main::a#1 ] ] with [ zp[2]:271 [ main::a#2 ] ] - score: 1
Allocated (was zp[2]:248) zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ]
Allocated (was zp[2]:250) zp[2]:249 [ main::h#2 main::h#1 ]
Zero-page exhausted. Moving allocation to main memory main::b#2
Allocated (was zp[2]:256) mem[2] [ main::b#2 main::b#1 ]
Zero-page exhausted. Moving allocation to main memory main::c#2
Allocated (was zp[2]:259) mem[2] [ main::c#2 main::c#1 ]
Zero-page exhausted. Moving allocation to main memory main::g#2
Allocated (was zp[2]:261) mem[2] [ main::g#2 main::g#1 ]
Zero-page exhausted. Moving allocation to main memory main::d#2
Allocated (was zp[2]:263) mem[2] [ main::d#2 main::d#1 ]
Zero-page exhausted. Moving allocation to main memory main::f#2
Allocated (was zp[2]:265) mem[2] [ main::f#2 main::f#1 ]
Zero-page exhausted. Moving allocation to main memory main::e#2
Allocated (was zp[2]:267) mem[2] [ main::e#2 main::e#1 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
@ -438,15 +434,15 @@ ASSEMBLER BEFORE OPTIMIZATION
// And then allocate a bunch of variables
main: {
.label SCREEN = $400
.label a = $f9
.label a_1 = $f7
.label a = $f7
.label h = $f9
// [1] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsm1=vwsc1
// [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsz1=vwsc1
lda #<0
sta h
sta.z h
lda #>0
sta h+1
sta.z h+1
// [1] phi main::g#2 = 0 [phi:main->main::@1#1] -- vwsm1=vwsc1
lda #<0
sta g
@ -479,9 +475,9 @@ main: {
sta b+1
// [1] phi main::a#4 = 0 [phi:main->main::@1#7] -- vwsz1=vwsc1
lda #<0
sta.z a_1
sta.z a
lda #>0
sta.z a_1+1
sta.z a+1
// [1] phi main::i#2 = 0 [phi:main->main::@1#8] -- vbuyy=vbuc1
ldy #0
jmp __b1
@ -502,18 +498,15 @@ main: {
asl
tax
// [5] main::SCREEN[main::$2] = main::a#4 -- pwsc1_derefidx_vbuxx=vwsz1
lda.z a_1
lda.z a
sta SCREEN,x
lda.z a_1+1
lda.z a+1
sta SCREEN+1,x
// [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz2
clc
lda.z a_1
adc #1
sta.z a
lda.z a_1+1
adc #0
sta.z a+1
// [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz1
inc.z a
bne !+
inc.z a+1
!:
// [7] main::SCREEN[main::$2] = main::b#2 -- pwsc1_derefidx_vbuxx=vwsm1
lda b
sta SCREEN,x
@ -584,29 +577,26 @@ main: {
bne !+
inc g+1
!:
// [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsm1
lda h
// [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsz1
lda.z h
sta SCREEN,x
lda h+1
lda.z h+1
sta SCREEN+1,x
// [22] main::h#1 = ++ main::h#2 -- vwsm1=_inc_vwsm1
inc h
// [22] main::h#1 = ++ main::h#2 -- vwsz1=_inc_vwsz1
inc.z h
bne !+
inc h+1
inc.z h+1
!:
// [23] main::SCREEN[main::$2] = main::a#2 -- pwsc1_derefidx_vbuxx=vwsz1
lda.z a
sta SCREEN,x
lda.z a+1
sta SCREEN+1,x
// [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz2
clc
lda.z a
adc #1
sta.z a_1
lda.z a+1
adc #0
sta.z a_1+1
// [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz1
inc.z a
bne !+
inc.z a+1
!:
// [25] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy
iny
// [1] phi from main::@2 to main::@1 [phi:main::@2->main::@1]
@ -628,7 +618,6 @@ main: {
e: .word 0
f: .word 0
g: .word 0
h: .word 0
}
// File Data
@ -663,10 +652,10 @@ void main()
char main::$2 // reg byte x 6.3684210526315805
__constant int * const main::SCREEN = (int *) 1024
int main::a
int main::a#1 // a zp[2]:249 4.125
int main::a#2 // a zp[2]:249 3.3000000000000003
int main::a#3 // a_1 zp[2]:247 11.0
int main::a#4 // a_1 zp[2]:247 8.25
int main::a#1 // a zp[2]:247 4.125
int main::a#2 // a zp[2]:247 3.3000000000000003
int main::a#3 // a zp[2]:247 11.0
int main::a#4 // a zp[2]:247 8.25
int main::b
int main::b#1 // b mem[2] 1.2222222222222223
int main::b#2 // b mem[2] 5.5
@ -686,27 +675,26 @@ int main::g
int main::g#1 // g mem[2] 3.6666666666666665
int main::g#2 // g mem[2] 1.8333333333333335
int main::h
int main::h#1 // h mem[2] 5.5
int main::h#2 // h mem[2] 1.6500000000000001
int main::h#1 // h zp[2]:249 5.5
int main::h#2 // h zp[2]:249 1.6500000000000001
char main::i
char main::i#1 // reg byte y 22.0
char main::i#2 // reg byte y 1.9130434782608696
reg byte y [ main::i#2 main::i#1 ]
zp[2]:247 [ main::a#4 main::a#3 ]
zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ]
mem[2] [ main::b#2 main::b#1 ]
mem[2] [ main::c#2 main::c#1 ]
mem[2] [ main::d#2 main::d#1 ]
mem[2] [ main::e#2 main::e#1 ]
mem[2] [ main::f#2 main::f#1 ]
mem[2] [ main::g#2 main::g#1 ]
mem[2] [ main::h#2 main::h#1 ]
zp[2]:249 [ main::h#2 main::h#1 ]
reg byte x [ main::$2 ]
zp[2]:249 [ main::a#1 main::a#2 ]
FINAL ASSEMBLER
Score: 4061
Score: 3891
// File Comments
// Tests that variables overflow to main memory when zeropage is exhausted
@ -725,13 +713,13 @@ Score: 4061
// And then allocate a bunch of variables
main: {
.label SCREEN = $400
.label a = $f9
.label a_1 = $f7
.label a = $f7
.label h = $f9
// [1] phi from main to main::@1 [phi:main->main::@1]
// [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsm1=vwsc1
// [1] phi main::h#2 = 0 [phi:main->main::@1#0] -- vwsz1=vwsc1
lda #<0
sta h
sta h+1
sta.z h
sta.z h+1
// [1] phi main::g#2 = 0 [phi:main->main::@1#1] -- vwsm1=vwsc1
sta g
sta g+1
@ -751,8 +739,8 @@ main: {
sta b
sta b+1
// [1] phi main::a#4 = 0 [phi:main->main::@1#7] -- vwsz1=vwsc1
sta.z a_1
sta.z a_1+1
sta.z a
sta.z a+1
// [1] phi main::i#2 = 0 [phi:main->main::@1#8] -- vbuyy=vbuc1
tay
// main::@1
@ -773,19 +761,16 @@ main: {
asl
tax
// [5] main::SCREEN[main::$2] = main::a#4 -- pwsc1_derefidx_vbuxx=vwsz1
lda.z a_1
lda.z a
sta SCREEN,x
lda.z a_1+1
lda.z a+1
sta SCREEN+1,x
// SCREEN[i] = a++;
// [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz2
clc
lda.z a_1
adc #1
sta.z a
lda.z a_1+1
adc #0
sta.z a+1
// [6] main::a#1 = ++ main::a#4 -- vwsz1=_inc_vwsz1
inc.z a
bne !+
inc.z a+1
!:
// SCREEN[i] = b++
// [7] main::SCREEN[main::$2] = main::b#2 -- pwsc1_derefidx_vbuxx=vwsm1
lda b
@ -871,16 +856,16 @@ main: {
inc g+1
!:
// SCREEN[i] = h++
// [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsm1
lda h
// [21] main::SCREEN[main::$2] = main::h#2 -- pwsc1_derefidx_vbuxx=vwsz1
lda.z h
sta SCREEN,x
lda h+1
lda.z h+1
sta SCREEN+1,x
// SCREEN[i] = h++;
// [22] main::h#1 = ++ main::h#2 -- vwsm1=_inc_vwsm1
inc h
// [22] main::h#1 = ++ main::h#2 -- vwsz1=_inc_vwsz1
inc.z h
bne !+
inc h+1
inc.z h+1
!:
// SCREEN[i] = a++
// [23] main::SCREEN[main::$2] = main::a#2 -- pwsc1_derefidx_vbuxx=vwsz1
@ -889,14 +874,11 @@ main: {
lda.z a+1
sta SCREEN+1,x
// SCREEN[i] = a++;
// [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz2
clc
lda.z a
adc #1
sta.z a_1
lda.z a+1
adc #0
sta.z a_1+1
// [24] main::a#3 = ++ main::a#2 -- vwsz1=_inc_vwsz1
inc.z a
bne !+
inc.z a+1
!:
// for(char i=0;i<10;i++)
// [25] main::i#1 = ++ main::i#2 -- vbuyy=_inc_vbuyy
iny
@ -918,7 +900,6 @@ main: {
e: .word 0
f: .word 0
g: .word 0
h: .word 0
}
// File Data

View File

@ -2,10 +2,10 @@ void main()
char main::$2 // reg byte x 6.3684210526315805
__constant int * const main::SCREEN = (int *) 1024
int main::a
int main::a#1 // a zp[2]:249 4.125
int main::a#2 // a zp[2]:249 3.3000000000000003
int main::a#3 // a_1 zp[2]:247 11.0
int main::a#4 // a_1 zp[2]:247 8.25
int main::a#1 // a zp[2]:247 4.125
int main::a#2 // a zp[2]:247 3.3000000000000003
int main::a#3 // a zp[2]:247 11.0
int main::a#4 // a zp[2]:247 8.25
int main::b
int main::b#1 // b mem[2] 1.2222222222222223
int main::b#2 // b mem[2] 5.5
@ -25,20 +25,19 @@ int main::g
int main::g#1 // g mem[2] 3.6666666666666665
int main::g#2 // g mem[2] 1.8333333333333335
int main::h
int main::h#1 // h mem[2] 5.5
int main::h#2 // h mem[2] 1.6500000000000001
int main::h#1 // h zp[2]:249 5.5
int main::h#2 // h zp[2]:249 1.6500000000000001
char main::i
char main::i#1 // reg byte y 22.0
char main::i#2 // reg byte y 1.9130434782608696
reg byte y [ main::i#2 main::i#1 ]
zp[2]:247 [ main::a#4 main::a#3 ]
zp[2]:247 [ main::a#4 main::a#3 main::a#1 main::a#2 ]
mem[2] [ main::b#2 main::b#1 ]
mem[2] [ main::c#2 main::c#1 ]
mem[2] [ main::d#2 main::d#1 ]
mem[2] [ main::e#2 main::e#1 ]
mem[2] [ main::f#2 main::f#1 ]
mem[2] [ main::g#2 main::g#1 ]
mem[2] [ main::h#2 main::h#1 ]
zp[2]:249 [ main::h#2 main::h#1 ]
reg byte x [ main::$2 ]
zp[2]:249 [ main::a#1 main::a#2 ]