diff --git a/src/main/fragment/cache/fragment-cache-mos6502x.asm b/src/main/fragment/cache/fragment-cache-mos6502x.asm index 6ba73f180..6e0a97519 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -11196,3 +11196,6535 @@ sta {c1},x lda #{c2} ora {c1},y sta {c1},y +//FRAGMENT pbuz1_lt_pbuz2_then_la1 +lda {z1}+1 +cmp {z2}+1 +bcc {la1} +bne !+ +lda {z1} +cmp {z2} +bcc {la1} +!: +//FRAGMENT vwuz1=vwuz2_rol_vbuz3 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +ldy {z3} +beq !e+ +!: +asl {z1} +rol {z1}+1 +dey +bne !- +!e: +//FRAGMENT vbsaa_lt_0_then_la1 +cmp #0 +bmi {la1} +//FRAGMENT vwuz1=vwuz2_rol_vbuxx +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +cpx #0 +beq !e+ +!: +asl {z1} +rol {z1}+1 +dex +bne !- +!e: +//FRAGMENT vwuz1=vwuz2_rol_vbuyy +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +cpy #0 +beq !e+ +!: +asl {z1} +rol {z1}+1 +dey +bne !- +!e: +//FRAGMENT vbsyy=vbsxx +txa +tay +//FRAGMENT vbuz1=vbuc1_plus__hi_vwsz2 +lda #{c1} +clc +adc {z2}+1 +sta {z1} +//FRAGMENT vwuz1=vwuz1_rol_vbuz2 +ldy {z2} +beq !e+ +!: +asl {z1} +rol {z1}+1 +dey +bne !- +!e: +//FRAGMENT pptz1=pptc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +//FRAGMENT vwsz1=vwsz2_plus_vwsc1 +lda {z2} +clc +adc #<{c1} +sta {z1} +lda {z2}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vbsz1=vbsz1_plus_vbsc1 +lax {z1} +axs #-[{c1}] +stx {z1} +//FRAGMENT _deref_pptz1=pbuz2 +ldy #0 +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pptz1=pptz1_plus_vbuc1 +lda #{c1} +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: +//FRAGMENT pbuz1=pptc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +//FRAGMENT pptc1_derefidx_vbuz1=pbuc2 +ldy {z1} +lda #<{c2} +sta {c1},y +lda #>{c2} +sta {c1}+1,y +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_ror_1 +ldy {z2} +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbsxx=vbsxx_plus_vbsc1 +txa +axs #-[{c1}] +//FRAGMENT vbsyy=vbsyy_plus_vbsc1 +tya +clc +adc #{c1} +tay +//FRAGMENT pbuz1=pptc1_derefidx_vbuaa +tay +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +//FRAGMENT pbuz1=pptc1_derefidx_vbuxx +lda {c1},x +sta {z1} +lda {c1}+1,x +sta {z1}+1 +//FRAGMENT pbuz1=pptc1_derefidx_vbuyy +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +//FRAGMENT pptc1_derefidx_vbuaa=pbuc2 +tay +lda #<{c2} +sta {c1},y +lda #>{c2} +sta {c1}+1,y +//FRAGMENT pptc1_derefidx_vbuxx=pbuc2 +lda #<{c2} +sta {c1},x +lda #>{c2} +sta {c1}+1,x +//FRAGMENT pptc1_derefidx_vbuyy=pbuc2 +lda #<{c2} +sta {c1},y +lda #>{c2} +sta {c1}+1,y +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_band_vbuc2 +tay +lda #{c2} +and {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_band_vbuc2 +tay +lda #{c2} +and {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_band_vbuc2 +tax +lda #{c2} +and {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_band_vbuc2 +tay +lda #{c2} +and {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_ror_1 +ldy {z1} +lda {c1},y +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_ror_1 +ldx {z1} +lda {c1},x +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +tax +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_ror_1 +ldy {z1} +lda {c1},y +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_ror_1 +lda {c1},x +lsr +tay +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_ror_1 +lda {c1},y +lsr +tay +//FRAGMENT vwsz1=vwsz1_plus_vwsc1 +clc +lda {z1} +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT pbuz1=pbuz1_plus_vbuxx +txa +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: +//FRAGMENT vwsz1=vbsc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +//FRAGMENT pwsz1=pwsc1_plus_vwsz2 +lda #<{c1} +clc +adc {z2} +sta {z1} +lda #>{c1} +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pwsz1=pwsc1_plus_vwsz1 +clc +lda {z1} +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT pbuc1_derefidx_vbuz1=pbuz2_derefidx_vbuaa +ldx {z1} +tay +lda ({z2}),y +sta {c1},x +//FRAGMENT vbuz1=vbuz2_minus__deref_pbuz3 +lda {z2} +sec +ldy #0 +sbc ({z3}),y +sta {z1} +//FRAGMENT vbuz1=vbuxx_minus__deref_pbuz2 +txa +sec +ldy #0 +sbc ({z2}),y +sta {z1} +//FRAGMENT vbuaa=vbuz1_minus__deref_pbuz2 +lda {z1} +sec +ldy #0 +sbc ({z2}),y +//FRAGMENT vbuaa=vbuxx_minus__deref_pbuz1 +txa +sec +ldy #0 +sbc ({z1}),y +//FRAGMENT vbuxx=vbuz1_minus__deref_pbuz2 +lda {z1} +sec +ldy #0 +sbc ({z2}),y +tax +//FRAGMENT vbuxx=vbuxx_minus__deref_pbuz1 +txa +sec +ldy #0 +sbc ({z1}),y +tax +//FRAGMENT vbuyy=vbuz1_minus__deref_pbuz2 +lda {z1} +sec +ldy #0 +sbc ({z2}),y +tay +//FRAGMENT vbuyy=vbuxx_minus__deref_pbuz1 +txa +sec +ldy #0 +sbc ({z1}),y +tay +//FRAGMENT pwuz1=pwuz2 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +//FRAGMENT vwuz1=pwuz2_minus_pwuc1 +lda {z2} +sec +sbc #<{c1} +sta {z1} +lda {z2}+1 +sbc #>{c1} +sta {z1}+1 +//FRAGMENT _deref_pwuz1_le_vwuz2_then_la1 +ldy #1 +lda ({z1}),y +cmp {z2}+1 +bne !+ +dey +lda ({z1}),y +cmp {z2} +beq {la1} +!: +bcc {la1} +//FRAGMENT pwuz1=pwuz1_minus_vbuc1 +sec +lda {z1} +sbc #{c1} +sta {z1} +lda {z1}+1 +sbc #0 +sta {z1}+1 +//FRAGMENT pwuz1=pwuz2_plus_vbuz3 +lda {z3} +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT vwsz1=vwsz2_minus__deref_pwsz3 +sec +lda {z2} +ldy #0 +sbc ({z3}),y +sta {z1} +lda {z2}+1 +iny +sbc ({z3}),y +sta {z1}+1 +//FRAGMENT vwsz1_le_0_then_la1 +lda {z1}+1 +bmi {la1} +bne !+ +lda {z1} +beq {la1} +!: +//FRAGMENT pwuz1=pwuz2_plus_vbuc1 +lda #{c1} +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pwuz1=pwuz2_plus_vbuaa +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pwuz1=pwuz2_plus_vbuxx +txa +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pwuz1=pwuz2_plus_vbuyy +tya +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT vbuxx=vbuaa_plus_1 +tax +inx +//FRAGMENT vbuyy=vbuaa_plus_1 +tay +iny +//FRAGMENT vwuz1=pwuz1_minus_pwuc1 +lda {z1} +sec +sbc #<{c1} +sta {z1} +lda {z1}+1 +sbc #>{c1} +sta {z1}+1 +//FRAGMENT _stackpushbyte_1 +pha +//FRAGMENT _stackpushbyte_3 +pha +pha +pha +//FRAGMENT _stackpullbyte_4 +tsx +txa +axs #-4 +txs +//FRAGMENT pbuz1=_stackidxptr_vbuc1 +tsx +lda STACK_BASE+{c1},x +sta {z1} +lda STACK_BASE+{c1}+1,x +sta {z1}+1 +//FRAGMENT _stackpushptr_=pbuc1 +lda #>{c1} +pha +lda #<{c1} +pha +//FRAGMENT _stackpullbyte_3 +tsx +txa +axs #-3 +txs +//FRAGMENT vbuc1_lt_vbuz1_then_la1 +lda #{c1} +cmp {z1} +bcc {la1} +//FRAGMENT vbuc1_lt_vbuaa_then_la1 +cmp #{c1} +beq !+ +bcs {la1} +!: +//FRAGMENT vbuc1_lt_vbuxx_then_la1 +cpx #{c1} +beq !+ +bcs {la1} +!: +//FRAGMENT vbuc1_lt_vbuyy_then_la1 +cpy #{c1} +beq !+ +bcs {la1} +!: +//FRAGMENT vwuz1=vwuz2_rol_6 +lda {z2}+1 +lsr +sta $ff +lda {z2} +ror +sta {z1}+1 +lda #0 +ror +sta {z1} +lsr $ff +ror {z1}+1 +ror {z1} +//FRAGMENT vwuz1=vbuc1_plus_vwuz2 +lda #{c1} +clc +adc {z2} +sta {z1} +lda #0 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pptc1_derefidx_vbuz1=pbuz2 +ldy {z1} +lda {z2} +sta {c1},y +lda {z2}+1 +sta {c1}+1,y +//FRAGMENT pbuz1=pbuz2_minus_vwuc1 +lda {z2} +sec +sbc #<{c1} +sta {z1} +lda {z2}+1 +sbc #>{c1} +sta {z1}+1 +//FRAGMENT vbuz1=vbuc1_rol_pbuz2_derefidx_vbuc2 +ldy #{c2} +lda ({z2}),y +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +sta {z1} +//FRAGMENT pbuz1_derefidx_vbuc1_eq_vbuc2_then_la1 +lda #{c2} +ldy #{c1} +cmp ({z1}),y +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuc1_neq_vbuc2_then_la1 +ldy #{c1} +lda ({z1}),y + +cmp #{c2} +bne {la1} +//FRAGMENT _deref_(pptz1_derefidx_vbuc1)=vbuc2 +ldx #{c2} +ldy #{c1} +lda ({z1}),y +sta !+ +1 +iny +lda ({z1}),y +sta !+ +2 +!: stx $ffff +//FRAGMENT pbuc1_derefidx_(pbuz1_derefidx_vbuc2)=pbuz1_derefidx_vbuc3 +ldy #{c3} +lda ({z1}),y +ldy #{c2} +pha +lda ({z1}),y +tay +pla +sta {c1},y +//FRAGMENT vwuz1=_deref_pwuz2_ror_4 +ldy #0 +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +//FRAGMENT vwuz1=pwuz2_derefidx_vbuc1_ror_4 +ldy #{c1} +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +//FRAGMENT _deref_pwuz1_lt_vwuc1_then_la1 +ldy #1 +lda ({z1}),y +cmp #>{c1} +bcc {la1} +bne !+ +dey +lda ({z1}),y +cmp #<{c1} +bcc {la1} +!: +//FRAGMENT _deref_pwuz1_gt_vwuc1_then_la1 +ldy #1 +lda #>{c1} +cmp ({z1}),y +bcc {la1} +bne !+ +dey +lda #<{c1} +cmp ({z1}),y +bcc {la1} +!: +//FRAGMENT pwuz1_derefidx_vbuc1_lt_vwuc2_then_la1 +ldy #{c1} +iny +lda ({z1}),y +cmp #>{c2} +bcc {la1} +bne !+ +dey +lda ({z1}),y +cmp #<{c2} +bcc {la1} +!: +//FRAGMENT pwuz1_derefidx_vbuc1_gt_vwuc2_then_la1 +ldy #{c1} +iny +lda #>{c2} +cmp ({z1}),y +bcc {la1} +bne !+ +dey +lda #<{c2} +cmp ({z1}),y +bcc {la1} +!: +//FRAGMENT vwuz1=vwuz2_ror_3 +lda {z2}+1 +lsr +sta {z1}+1 +lda {z2} +ror +sta {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +//FRAGMENT pwuz1_derefidx_vbuc1=pwuz1_derefidx_vbuc1_plus_pwuc2_derefidx_vbuz2 +ldx {z2} +ldy #{c1} +clc +lda ({z1}),y +adc {c2},x +sta ({z1}),y +iny +lda ({z1}),y +adc {c2}+1,x +sta ({z1}),y +//FRAGMENT _deref_pwuz1=_deref_pwuz1_plus_pwuz1_derefidx_vbuc1 +ldy #{c1} +sty $ff +clc +lda ({z1}),y +ldy #0 +adc ({z1}),y +sta ({z1}),y +ldy $ff +iny +lda ({z1}),y +ldy #1 +adc ({z1}),y +sta ({z1}),y +//FRAGMENT pwuz1_derefidx_vbuc1=pwuz1_derefidx_vbuc1_plus_pwuz1_derefidx_vbuc2 +ldy #{c2} +clc +lda ({z1}),y +ldy #{c1} +adc ({z1}),y +sta ({z1}),y +ldy #{c2}+1 +lda ({z1}),y +ldy #{c1}+1 +adc ({z1}),y +sta ({z1}),y +//FRAGMENT pptc1_derefidx_vbuxx=pbuz1 +lda {z1} +sta {c1},x +lda {z1}+1 +sta {c1}+1,x +//FRAGMENT pptc1_derefidx_vbuyy=pbuz1 +lda {z1} +sta {c1},y +lda {z1}+1 +sta {c1}+1,y +//FRAGMENT vbuaa=vbuc1_rol_pbuz1_derefidx_vbuc2 +ldy #{c2} +lda ({z1}),y +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_pbuz1_derefidx_vbuc2 +ldy #{c2} +lda ({z1}),y +tax +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: +tax +//FRAGMENT vbuyy=vbuc1_rol_pbuz1_derefidx_vbuc2 +ldy #{c2} +lda ({z1}),y +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +tay +//FRAGMENT pbuc1_derefidx_vbuaa=_byte_vwuz1 +tay +lda {z1} +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuyy=_byte_vwuz1 +lda {z1} +sta {c1},y +//FRAGMENT pwuz1_derefidx_vbuc1=pwuz1_derefidx_vbuc1_plus_pwuc2_derefidx_vbuaa +ldy #{c1} +tax +clc +lda ({z1}),y +adc {c2},x +sta ({z1}),y +iny +lda ({z1}),y +adc {c2}+1,x +sta ({z1}),y +//FRAGMENT pwuz1_derefidx_vbuc1=pwuz1_derefidx_vbuc1_plus_pwuc2_derefidx_vbuxx +ldy #{c1} +clc +lda ({z1}),y +adc {c2},x +sta ({z1}),y +iny +lda ({z1}),y +adc {c2}+1,x +sta ({z1}),y +//FRAGMENT pwuz1_derefidx_vbuc1=pwuz1_derefidx_vbuc1_plus_pwuc2_derefidx_vbuyy +tya +ldy #{c1} +tax +clc +lda ({z1}),y +adc {c2},x +sta ({z1}),y +iny +lda ({z1}),y +adc {c2}+1,x +sta ({z1}),y +//FRAGMENT vwuz1=vwuz1_ror_3 +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +lsr {z1}+1 +ror {z1} +//FRAGMENT vwuz1=vwuz1_rol_6 +lda {z1}+1 +lsr +sta $ff +lda {z1} +ror +sta {z1}+1 +lda #0 +ror +sta {z1} +lsr $ff +ror {z1}+1 +ror {z1} +//FRAGMENT vwuz1=vbuc1_plus_vwuz1 +lda #{c1} +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: +//FRAGMENT pwuz1=pptz2_derefidx_vbuz3 +ldy {z3} +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vbuz1_le_0_then_la1 +lda {z1} +cmp #0 +beq {la1} +//FRAGMENT vwuz1_eq_vwuc1_then_la1 +lda {z1} +cmp #<{c1} +bne !+ +lda {z1}+1 +cmp #>{c1} +beq {la1} +!: +//FRAGMENT vwuz1=pwuz2_derefidx_vbuz3 +ldy {z3} +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT _deref_pbuz1_gt_vbuz2_then_la1 +ldy #0 +lda ({z1}),y +cmp {z2} +beq !+ +bcs {la1} +!: +//FRAGMENT pbuz1_derefidx_(_deref_pbuz2)=_inc_pbuz1_derefidx_(_deref_pbuz2) +ldy #0 +lda ({z2}),y +tay +lda ({z1}),y +clc +adc #1 +sta ({z1}),y +//FRAGMENT vwuz1=_deref_pbuz2_rol_1 +ldy #0 +lda ({z2}),y +asl +sta {z1} +lda #0 +rol +sta {z1}+1 +//FRAGMENT pptz1=pptz2_plus_vwuz3 +lda {z2} +clc +adc {z3} +sta {z1} +lda {z2}+1 +adc {z3}+1 +sta {z1}+1 +//FRAGMENT _deref_pptz1=pwuz2 +ldy #0 +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pwuz1=_deref_pptz2 +ldy #0 +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vwuz1=pbuz2_minus_pbuz3 +lda {z2} +sec +sbc {z3} +sta {z1} +lda {z2}+1 +sbc {z3}+1 +sta {z1}+1 +//FRAGMENT pwuz1_derefidx_vbuz2=vwuz3 +ldy {z2} +lda {z3} +sta ({z1}),y +iny +lda {z3}+1 +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=_inc_pbuz1_derefidx_vbuz2 +ldy {z2} +lda ({z1}),y +clc +adc #1 +sta ({z1}),y +//FRAGMENT pbuz1=pbuz2_minus_vwuz3 +lda {z2} +sec +sbc {z3} +sta {z1} +lda {z2}+1 +sbc {z3}+1 +sta {z1}+1 +//FRAGMENT vwuz1=pwuz2_minus_pwuz3 +lda {z2} +sec +sbc {z3} +sta {z1} +lda {z2}+1 +sbc {z3}+1 +sta {z1}+1 +//FRAGMENT pwuz1=pptz2_derefidx_vbuaa +tay +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT pwuz1=pptz2_derefidx_vbuxx +txa +tay +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT pwuz1=pptz2_derefidx_vbuyy +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vbuaa_le_0_then_la1 +cmp #0 +beq {la1} +//FRAGMENT vwuz1=pwuz2_derefidx_vbuaa +tay +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vwuz1=pwuz2_derefidx_vbuxx +txa +tay +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vwuz1=pwuz2_derefidx_vbuyy +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT _deref_pbuz1_gt_vbuxx_then_la1 +ldy #0 +lda ({z1}),y +sta $ff +cpx $ff +bcc {la1} +//FRAGMENT pwuz1_derefidx_vbuaa=vwuz2 +tay +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pwuz1_derefidx_vbuxx=vwuz2 +txa +tay +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pwuz1_derefidx_vbuyy=vwuz2 +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=_inc_pbuz1_derefidx_vbuxx +txa +tay +lda ({z1}),y +clc +adc #1 +sta ({z1}),y +//FRAGMENT vbuxx_le_0_then_la1 +cpx #0 +beq {la1} +//FRAGMENT vwuz1=_deref_pbuz1_rol_1 +ldy #0 +lda ({z1}),y +asl +sta {z1} +lda #0 +rol +sta {z1}+1 +//FRAGMENT pbuz1=pbuz2_minus_vwuz1 +lda {z2} +sec +sbc {z1} +sta {z1} +lda {z2}+1 +sbc {z1}+1 +sta {z1}+1 +//FRAGMENT pptz1=pptz2_plus_vwuz1 +lda {z1} +clc +adc {z2} +sta {z1} +lda {z1}+1 +adc {z2}+1 +sta {z1}+1 +//FRAGMENT pwuz1=_deref_pptz1 +ldy #0 +lda ({z1}),y +pha +iny +lda ({z1}),y +sta {z1}+1 +pla +sta {z1} +//FRAGMENT vwuz1=pwuz1_minus_pwuz2 +lda {z1} +sec +sbc {z2} +sta {z1} +lda {z1}+1 +sbc {z2}+1 +sta {z1}+1 +//FRAGMENT vbsz1=_sbyte_vwuz2 +lda {z2} +sta {z1} +//FRAGMENT vbsz1=vbsz2_minus_vbsz3 +lda {z2} +sec +sbc {z3} +sta {z1} +//FRAGMENT vduz1=pduc1_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT vduz1_ge_vduz2_then_la1 +lda {z1}+3 +cmp {z2}+3 +bcc !+ +bne {la1} +lda {z1}+2 +cmp {z2}+2 +bcc !+ +bne {la1} +lda {z1}+1 +cmp {z2}+1 +bcc !+ +bne {la1} +lda {z1} +cmp {z2} +bcs {la1} +!: +//FRAGMENT vduz1=vduz1_minus_vduz2 +lda {z1} +sec +sbc {z2} +sta {z1} +lda {z1}+1 +sbc {z2}+1 +sta {z1}+1 +lda {z1}+2 +sbc {z2}+2 +sta {z1}+2 +lda {z1}+3 +sbc {z2}+3 +sta {z1}+3 +//FRAGMENT vbsaa=_sbyte_vwuz1 +lda {z1} +//FRAGMENT vbsxx=_sbyte_vwuz1 +lda {z1} +tax +//FRAGMENT vbsyy=_sbyte_vwuz1 +lda {z1} +tay +//FRAGMENT vbsz1=vbsz2_minus_vbsaa +eor #$ff +sec +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsz2_minus_vbsxx +txa +eor #$ff +sec +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsz2_minus_vbsyy +tya +eor #$ff +sec +adc {z2} +sta {z1} +//FRAGMENT vbsxx=vbsz1_minus_vbsz2 +lda {z1} +sec +sbc {z2} +tax +//FRAGMENT vbsxx=vbsz1_minus_vbsaa +eor #$ff +sec +adc {z1} +tax +//FRAGMENT vbsxx=vbsz1_minus_vbsxx +txa +eor #$ff +sec +adc {z1} +tax +//FRAGMENT vbsxx=vbsz1_minus_vbsyy +tya +eor #$ff +sec +adc {z1} +tax +//FRAGMENT vbsz1=vbsxx_minus_vbsz2 +txa +sec +sbc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_vbsaa +sta $ff +txa +sec +sbc $ff +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_vbsxx +lda #0 +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_vbsyy +txa +sty $ff +sec +sbc $ff +sta {z1} +//FRAGMENT vbsxx=vbsxx_minus_vbsaa +sta $ff +txa +sec +sbc $ff +tax +//FRAGMENT vbsz1=vbsyy_minus_vbsz2 +tya +sec +sbc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_vbsaa +sta $ff +tya +sec +sbc $ff +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_vbsxx +tya +stx $ff +sec +sbc $ff +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_vbsyy +lda #0 +sta {z1} +//FRAGMENT vbsxx=vbsyy_minus_vbsz1 +tya +sec +sbc {z1} +tax +//FRAGMENT vbsxx=vbsyy_minus_vbsaa +sta $ff +tya +sec +sbc $ff +tax +//FRAGMENT vbsxx=vbsyy_minus_vbsxx +tya +stx $ff +sec +sbc $ff +tax +//FRAGMENT vbsxx=vbsyy_minus_vbsyy +lda #0 +tax +//FRAGMENT vduz1=pduc1_derefidx_vbuaa +tay +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT vduz1=pduc1_derefidx_vbuxx +lda {c1},x +sta {z1} +lda {c1}+1,x +sta {z1}+1 +lda {c1}+2,x +sta {z1}+2 +lda {c1}+3,x +sta {z1}+3 +//FRAGMENT vduz1=pduc1_derefidx_vbuyy +lda {c1},y +sta {z1} +lda {c1}+1,y +sta {z1}+1 +lda {c1}+2,y +sta {z1}+2 +lda {c1}+3,y +sta {z1}+3 +//FRAGMENT pbuc1_derefidx_vbuaa_eq_vbuz1_then_la1 +tay +lda {c1},y +cmp {z1} +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuz1_eq_vbuaa_then_la1 +ldx {z1} +tay +lda {c1},x +tax +sty $ff +cpx $ff +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuaa_eq_vbuaa_then_la1 +tax +lda {c1},x +tay +sty $ff +cpx $ff +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuxx_eq_vbuaa_then_la1 +tay +lda {c1},x +tax +sty $ff +cpx $ff +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuyy_eq_vbuaa_then_la1 +tax +lda {c1},y +tay +sty $ff +cpx $ff +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuaa_eq_vbuxx_then_la1 +tay +lda {c1},y +tay +sty $ff +cpx $ff +beq {la1} +//FRAGMENT pbuc1_derefidx_vbuaa_eq_vbuyy_then_la1 +tax +lda {c1},x +tax +sty $ff +cpx $ff +beq {la1} +//FRAGMENT vbuz1=vbuxx_minus_1 +dex +stx {z1} +//FRAGMENT vbuz1=vbuyy_minus_1 +tya +sec +sbc #1 +sta {z1} +//FRAGMENT vbuaa_lt_vbuyy_then_la1 +tax +sty $ff +cpx $ff +bcc {la1} +//FRAGMENT vbuyy_lt_vbuaa_then_la1 +sta $ff +cpy $ff +bcc {la1} +//FRAGMENT vbuz1=vbuz2_minus_vbuz1 +lda {z2} +sec +sbc {z1} +sta {z1} +//FRAGMENT vbuz1=vbuc1_plus_vbuz1 +lax {z1} +axs #-[{c1}] +stx {z1} +//FRAGMENT vbuz1=vbuz1_band_vbuc1 +lda #{c1} +and {z1} +sta {z1} +//FRAGMENT vwuz1=vwuz2_rol_7 +lda {z2}+1 +lsr +lda {z2} +ror +sta {z1}+1 +lda #0 +ror +sta {z1} +//FRAGMENT vwuz1=vwuz2_bxor_vwuz3 +lda {z2} +eor {z3} +sta {z1} +lda {z2}+1 +eor {z3}+1 +sta {z1}+1 +//FRAGMENT vwuz1=vwuz2_ror_9 +lda {z2}+1 +lsr +sta {z1} +lda #0 +sta {z1}+1 +//FRAGMENT vbsaa=vbsz1_minus_vbsz2 +lda {z1} +sec +sbc {z2} +//FRAGMENT vbsaa=vbsz1_minus_vbsaa +eor #$ff +sec +adc {z1} +//FRAGMENT vbsaa=vbsz1_minus_vbsxx +txa +eor #$ff +sec +adc {z1} +//FRAGMENT vbsaa=vbsz1_minus_vbsyy +tya +eor #$ff +sec +adc {z1} +//FRAGMENT vbsaa=vbsxx_minus_vbsz1 +txa +sec +sbc {z1} +//FRAGMENT vbsaa=vbsxx_minus_vbsaa +sta $ff +txa +sec +sbc $ff +//FRAGMENT vbsaa=vbsxx_minus_vbsxx +lda #0 +//FRAGMENT vbsaa=vbsxx_minus_vbsyy +txa +sty $ff +sec +sbc $ff +//FRAGMENT vbsaa=vbsyy_minus_vbsz1 +tya +sec +sbc {z1} +//FRAGMENT vbsaa=vbsyy_minus_vbsaa +sta $ff +tya +sec +sbc $ff +//FRAGMENT vbsaa=vbsyy_minus_vbsxx +tya +stx $ff +sec +sbc $ff +//FRAGMENT vbsaa=vbsyy_minus_vbsyy +lda #0 +//FRAGMENT vbsyy=vbsz1_minus_vbsz2 +lda {z1} +sec +sbc {z2} +tay +//FRAGMENT vbsyy=vbsz1_minus_vbsaa +eor #$ff +sec +adc {z1} +tay +//FRAGMENT vbsyy=vbsz1_minus_vbsxx +txa +eor #$ff +sec +adc {z1} +tay +//FRAGMENT vbsyy=vbsz1_minus_vbsyy +tya +eor #$ff +sec +adc {z1} +tay +//FRAGMENT vbsyy=vbsxx_minus_vbsz1 +txa +sec +sbc {z1} +tay +//FRAGMENT vbsyy=vbsxx_minus_vbsaa +sta $ff +txa +sec +sbc $ff +tay +//FRAGMENT vbsyy=vbsxx_minus_vbsxx +lda #0 +tay +//FRAGMENT vbsyy=vbsxx_minus_vbsyy +txa +sty $ff +sec +sbc $ff +tay +//FRAGMENT vbsyy=vbsyy_minus_vbsaa +sta $ff +tya +sec +sbc $ff +tay +//FRAGMENT vbsaa_ge_0_then_la1 +cmp #0 +bpl {la1} +//FRAGMENT vwuz1=vwuz1_bxor_vwuz2 +lda {z1} +eor {z2} +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 vwsz1=vwsz2_plus_pbuz3_derefidx_vbuz4 +ldy {z4} +clc +lda {z2} +adc ({z3}),y +sta {z1} +bcc !+ +inc {z2}+1 +!: +//FRAGMENT vwsz1=vwsz2_minus_vbuc1 +sec +lda {z2} +sbc #{c1} +sta {z1} +lda {z2}+1 +sbc #0 +sta {z1}+1 +//FRAGMENT vwsz1=vwsz2_plus_pbuz3_derefidx_vbuxx +txa +tay +clc +lda {z2} +adc ({z3}),y +sta {z1} +bcc !+ +inc {z2}+1 +!: +//FRAGMENT vwsz1=vwsz2_plus_pbuz3_derefidx_vbuyy +clc +lda {z2} +adc ({z3}),y +sta {z1} +bcc !+ +inc {z2}+1 +!: +//FRAGMENT vwsz1=vwsz1_minus_vbuc1 +sec +lda {z1} +sbc #{c1} +sta {z1} +bcs !+ +dec {z1}+1 +!: +//FRAGMENT vwsz1=vwsz1_plus_pbuz2_derefidx_vbuyy +clc +lda {z1} +adc ({z2}),y +sta {z1} +bcc !+ +inc {z1}+1 +!: +//FRAGMENT vbuz1_ge_pbuc1_derefidx_vbuz2_then_la1 +lda {z1} +ldy {z2} +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_ge_vbuz1_then_la1 +lda {z1} +cmp {z1} +bcs {la1} +//FRAGMENT vbuz1_le_pbuc1_derefidx_vbuz2_then_la1 +ldy {z2} +lda {c1},y +cmp {z1} +bcs {la1} +//FRAGMENT vbuz1_le_vbuz1_then_la1 +lda {z1} +cmp {z1} +bcs {la1} +//FRAGMENT vbuz1_gt_pbuc1_derefidx_vbuz2_then_la1 +ldy {z2} +lda {c1},y +cmp {z1} +bcc {la1} +//FRAGMENT vbuz1_gt_vbuz1_then_la1 +lda {z1} +cmp {z1} +bcc {la1} +//FRAGMENT vbuz1_lt_pbuc1_derefidx_vbuz2_then_la1 +lda {z1} +ldy {z2} +cmp {c1},y +bcc {la1} +//FRAGMENT vbuz1_lt_vbuz1_then_la1 +lda {z1} +cmp {z1} +bcc {la1} +//FRAGMENT vbuz1_neq_pbuc1_derefidx_vbuz2_then_la1 +lda {z1} +ldy {z2} +cmp {c1},y +bne {la1} +//FRAGMENT vbuz1_neq_vbuz1_then_la1 +lda {z1} +cmp {z1} +bne {la1} +//FRAGMENT vbuz1_ge_pbuc1_derefidx_vbuxx_then_la1 +txa +tay +lda {z1} +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_ge_pbuc1_derefidx_vbuyy_then_la1 +lda {z1} +cmp {c1},y +bcs {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +txa +cmp {c1},y +bcs {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_vbuxx_then_la1 +txa +tay +cmp {c1},y +bcs {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_vbuyy_then_la1 +txa +cmp {c1},y +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_vbuz1_then_la1 +tya +ldy {z1} +cmp {c1},y +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +sta $ff +cpy $ff +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_vbuyy_then_la1 +tya +cmp {c1},y +bcs {la1} +//FRAGMENT vbuxx_ge_vbuxx_then_la1 +txa +stx $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuyy_ge_vbuyy_then_la1 +tya +sta $ff +cpy $ff +bcs {la1} +//FRAGMENT vbuz1_le_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +cmp {z1} +bcs {la1} +//FRAGMENT vbuz1_le_pbuc1_derefidx_vbuyy_then_la1 +lda {c1},y +cmp {z1} +bcs {la1} +//FRAGMENT vbuxx_le_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +txa +cmp {c1},y +bcc {la1} +beq {la1} +//FRAGMENT vbuxx_le_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +stx $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuxx_le_pbuc1_derefidx_vbuyy_then_la1 +txa +cmp {c1},y +bcc {la1} +beq {la1} +//FRAGMENT vbuyy_le_pbuc1_derefidx_vbuz1_then_la1 +tya +ldy {z1} +cmp {c1},y +bcc {la1} +beq {la1} +//FRAGMENT vbuyy_le_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +sty $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuyy_le_pbuc1_derefidx_vbuyy_then_la1 +tya +cmp {c1},y +bcc {la1} +beq {la1} +//FRAGMENT vbuxx_le_vbuxx_then_la1 +txa +stx $ff +cmp $ff +bcs {la1} +//FRAGMENT vbuyy_le_vbuyy_then_la1 +tya +sta $ff +cpy $ff +bcs {la1} +//FRAGMENT vbuz1_gt_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +cmp {z1} +bcc {la1} +//FRAGMENT vbuz1_gt_pbuc1_derefidx_vbuyy_then_la1 +lda {c1},y +cmp {z1} +bcc {la1} +//FRAGMENT vbuxx_gt_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +txa +cmp {c1},y +beq !+ +bcs {la1} +!: +//FRAGMENT vbuxx_gt_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +stx $ff +cmp $ff +bcc {la1} +//FRAGMENT vbuxx_gt_pbuc1_derefidx_vbuyy_then_la1 +txa +cmp {c1},y +beq !+ +bcs {la1} +!: +//FRAGMENT vbuyy_gt_pbuc1_derefidx_vbuz1_then_la1 +tya +ldy {z1} +cmp {c1},y +beq !+ +bcs {la1} +!: +//FRAGMENT vbuyy_gt_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +tax +sty $ff +cpx $ff +bcc {la1} +//FRAGMENT vbuyy_gt_pbuc1_derefidx_vbuyy_then_la1 +tya +cmp {c1},y +beq !+ +bcs {la1} +!: +//FRAGMENT vbuxx_gt_vbuxx_then_la1 +txa +sta $ff +cpx $ff +bcc {la1} +//FRAGMENT vbuyy_gt_vbuyy_then_la1 +tya +sta $ff +cpy $ff +bcc {la1} +//FRAGMENT vbuz1_lt_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +cmp {z1} +beq !+ +bcs {la1} +!: +//FRAGMENT vbuz1_lt_pbuc1_derefidx_vbuyy_then_la1 +lda {z1} +cmp {c1},y +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +txa +cmp {c1},y +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_vbuxx_then_la1 +txa +tay +cmp {c1},y +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_vbuyy_then_la1 +txa +cmp {c1},y +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_vbuz1_then_la1 +tya +ldy {z1} +cmp {c1},y +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +sta $ff +cpy $ff +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_vbuyy_then_la1 +tya +cmp {c1},y +bcc {la1} +//FRAGMENT vbuxx_lt_vbuxx_then_la1 +txa +sta $ff +cpx $ff +bcc {la1} +//FRAGMENT vbuyy_lt_vbuyy_then_la1 +tya +sta $ff +cpy $ff +bcc {la1} +//FRAGMENT vbuz1_neq_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +cmp {z1} +bne {la1} +//FRAGMENT vbuz1_neq_pbuc1_derefidx_vbuyy_then_la1 +lda {c1},y +cmp {z1} +bne {la1} +//FRAGMENT vbuxx_neq_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +txa +cmp {c1},y +bne {la1} +//FRAGMENT vbuxx_neq_pbuc1_derefidx_vbuxx_then_la1 +txa +tay +cmp {c1},y +bne {la1} +//FRAGMENT vbuxx_neq_pbuc1_derefidx_vbuyy_then_la1 +txa +cmp {c1},y +bne {la1} +//FRAGMENT vbuyy_neq_pbuc1_derefidx_vbuz1_then_la1 +tya +ldy {z1} +cmp {c1},y +bne {la1} +//FRAGMENT vbuyy_neq_pbuc1_derefidx_vbuxx_then_la1 +lda {c1},x +tax +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vbuyy_neq_pbuc1_derefidx_vbuyy_then_la1 +tya +cmp {c1},y +bne {la1} +//FRAGMENT vbuxx_neq_vbuxx_then_la1 +txa +tay +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vbuyy_neq_vbuyy_then_la1 +tya +tax +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vbuyy=vbuz1_plus_2 +ldy {z1} +iny +iny +//FRAGMENT vbuxx=vbuaa_plus_2 +tax +inx +inx +//FRAGMENT vwsz1=vwsz2_ror_7 +// ROL once instead of RORing 7 times +lda {z2} // {z2} low byte to tmp $ff +sta $ff +lda {z2}+1 // {z2} high byte to {z1} low byte +sta {z1} +lda #0 +bit {z2}+1 +bpl !+ // {z2} high byte positive? +lda #$ff +!: +sta {z1}+1 // sign extended {z2} into {z1} high byte +// ROL once +rol $ff +rol {z1} +rol {z1}+1 +//FRAGMENT vwsz1=vwsz2_ror_5 +lda {z2} +sta $ff +lda {z2}+1 +sta {z1} +lda #0 +bit {z2}+1 +bpl !+ +lda #$ff +!: +sta {z1}+1 +rol $ff +rol {z1} +rol {z1}+1 +rol $ff +rol {z1} +rol {z1}+1 +rol $ff +rol {z1} +rol {z1}+1 +//FRAGMENT _deref_pbuc1=_byte_vwsz1 +lda {z1} +sta {c1} +//FRAGMENT vwsz1=vwsc1_minus_vwsz1 +lda #<{c1} +sec +sbc {z1} +sta {z1} +lda #>{c1} +sbc {z1}+1 +sta {z1}+1 +//FRAGMENT vwuz1=pbuc1_minus_pbuz2 +sec +lda #<{c1} +sbc {z2} +sta {z1} +lda #>{c1} +sbc {z2}+1 +sta {z1}+1 +//FRAGMENT vwuz1=pbuc1_minus_pbuz1 +sec +lda #<{c1} +sbc {z1} +sta {z1} +lda #>{c1} +sbc {z1}+1 +sta {z1}+1 +//FRAGMENT pbsc1_derefidx_vbuz1=_deref_pbsc2 +lda {c2} +ldy {z1} +sta {c1},y +//FRAGMENT vbuz1=vbuc1_plus__deref_pbuc2 +lda #{c1} +clc +adc {c2} +sta {z1} +//FRAGMENT vbsz1=vbsz1_plus_2 +inc {z1} +inc {z1} +//FRAGMENT vbsz1=vbsz1_minus_vbsc1 +lax {z1} +axs #{c1} +stx {z1} +//FRAGMENT vbsz1=vbsz2_plus_vbsz3 +lda {z2} +clc +adc {z3} +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_plus_pbsc1_derefidx_vbsz3 +ldy {z2} +lda {c1},y +ldy {z3} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_minus_pbsc1_derefidx_vbsz3 +ldy {z2} +lda {c1},y +ldy {z3} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_plus_pbsc1_derefidx_vbsz2 +ldy {z2} +clc +lda {c1},y +adc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsz2_plus_pbsc1_derefidx_vbsz3 +lda {z2} +ldy {z3} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsz2_minus_pbsc1_derefidx_vbsz3 +lda {z2} +ldy {z3} +sec +sbc {c1},y +sta {z1} +//FRAGMENT pbsc1_derefidx_vbuaa=_deref_pbsc2 +tay +lda {c2} +sta {c1},y +//FRAGMENT pbsc1_derefidx_vbuxx=_deref_pbsc2 +lda {c2} +sta {c1},x +//FRAGMENT pbsc1_derefidx_vbuyy=_deref_pbsc2 +lda {c2} +sta {c1},y +//FRAGMENT vbuaa=vbuc1_plus__deref_pbuc2 +lda #{c1} +clc +adc {c2} +//FRAGMENT vbuxx=vbuc1_plus__deref_pbuc2 +lda {c2} +tax +axs #-[{c1}] +//FRAGMENT vbuyy=vbuc1_plus__deref_pbuc2 +lda #{c1} +clc +adc {c2} +tay +//FRAGMENT vbsxx=vbsxx_minus_vbsc1 +txa +axs #{c1} +//FRAGMENT vbsyy=vbsyy_minus_vbsc1 +tya +sec +sbc #{c1} +tay +//FRAGMENT vbsz1=vbsz2_plus_vbsaa +clc +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsz2_plus_vbsxx +txa +clc +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsz2_plus_vbsyy +tya +clc +adc {z2} +sta {z1} +//FRAGMENT vbsaa=vbsz1_plus_vbsz2 +lda {z1} +clc +adc {z2} +//FRAGMENT vbsaa=vbsz1_plus_vbsaa +clc +adc {z1} +//FRAGMENT vbsaa=vbsz1_plus_vbsxx +txa +clc +adc {z1} +//FRAGMENT vbsaa=vbsz1_plus_vbsyy +tya +clc +adc {z1} +//FRAGMENT vbsxx=vbsz1_plus_vbsz2 +lda {z1} +clc +adc {z2} +tax +//FRAGMENT vbsxx=vbsz1_plus_vbsaa +clc +adc {z1} +tax +//FRAGMENT vbsxx=vbsz1_plus_vbsxx +txa +clc +adc {z1} +tax +//FRAGMENT vbsxx=vbsz1_plus_vbsyy +tya +clc +adc {z1} +tax +//FRAGMENT vbsyy=vbsz1_plus_vbsz2 +lda {z1} +clc +adc {z2} +tay +//FRAGMENT vbsyy=vbsz1_plus_vbsaa +clc +adc {z1} +tay +//FRAGMENT vbsyy=vbsz1_plus_vbsxx +txa +clc +adc {z1} +tay +//FRAGMENT vbsyy=vbsz1_plus_vbsyy +tya +clc +adc {z1} +tay +//FRAGMENT vbsz1=vbsaa_plus_vbsz2 +clc +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsaa_plus_vbsaa +asl +sta {z1} +//FRAGMENT vbsz1=vbsaa_plus_vbsxx +stx $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsz1=vbsaa_plus_vbsyy +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsaa=vbsaa_plus_vbsz1 +clc +adc {z1} +//FRAGMENT vbsaa=vbsaa_plus_vbsaa +asl +//FRAGMENT vbsaa=vbsaa_plus_vbsxx +stx $ff +clc +adc $ff +//FRAGMENT vbsaa=vbsaa_plus_vbsyy +sty $ff +clc +adc $ff +//FRAGMENT vbsxx=vbsaa_plus_vbsz1 +clc +adc {z1} +tax +//FRAGMENT vbsxx=vbsaa_plus_vbsaa +asl +tax +//FRAGMENT vbsxx=vbsaa_plus_vbsxx +stx $ff +clc +adc $ff +tax +//FRAGMENT vbsxx=vbsaa_plus_vbsyy +sty $ff +clc +adc $ff +tax +//FRAGMENT vbsyy=vbsaa_plus_vbsz1 +clc +adc {z1} +tay +//FRAGMENT vbsyy=vbsaa_plus_vbsaa +asl +tay +//FRAGMENT vbsyy=vbsaa_plus_vbsxx +stx $ff +clc +adc $ff +tay +//FRAGMENT vbsyy=vbsaa_plus_vbsyy +sty $ff +clc +adc $ff +tay +//FRAGMENT vbsz1=vbsxx_plus_vbsz2 +txa +clc +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsxx_plus_vbsaa +stx $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsz1=vbsxx_plus_vbsxx +txa +asl +sta {z1} +//FRAGMENT vbsz1=vbsxx_plus_vbsyy +txa +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsaa=vbsxx_plus_vbsz1 +txa +clc +adc {z1} +//FRAGMENT vbsaa=vbsxx_plus_vbsaa +stx $ff +clc +adc $ff +//FRAGMENT vbsaa=vbsxx_plus_vbsxx +txa +asl +//FRAGMENT vbsaa=vbsxx_plus_vbsyy +txa +sty $ff +clc +adc $ff +//FRAGMENT vbsxx=vbsxx_plus_vbsaa +stx $ff +clc +adc $ff +tax +//FRAGMENT vbsyy=vbsxx_plus_vbsz1 +txa +clc +adc {z1} +tay +//FRAGMENT vbsyy=vbsxx_plus_vbsaa +stx $ff +clc +adc $ff +tay +//FRAGMENT vbsyy=vbsxx_plus_vbsxx +txa +asl +tay +//FRAGMENT vbsyy=vbsxx_plus_vbsyy +txa +sty $ff +clc +adc $ff +tay +//FRAGMENT vbsz1=vbsyy_plus_vbsz2 +tya +clc +adc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsyy_plus_vbsaa +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsz1=vbsyy_plus_vbsxx +txa +sty $ff +clc +adc $ff +sta {z1} +//FRAGMENT vbsz1=vbsyy_plus_vbsyy +tya +asl +sta {z1} +//FRAGMENT vbsaa=vbsyy_plus_vbsz1 +tya +clc +adc {z1} +//FRAGMENT vbsaa=vbsyy_plus_vbsaa +sty $ff +clc +adc $ff +//FRAGMENT vbsaa=vbsyy_plus_vbsxx +txa +sty $ff +clc +adc $ff +//FRAGMENT vbsaa=vbsyy_plus_vbsyy +tya +asl +//FRAGMENT vbsxx=vbsyy_plus_vbsz1 +tya +clc +adc {z1} +tax +//FRAGMENT vbsxx=vbsyy_plus_vbsaa +sty $ff +clc +adc $ff +tax +//FRAGMENT vbsxx=vbsyy_plus_vbsxx +txa +sty $ff +clc +adc $ff +tax +//FRAGMENT vbsxx=vbsyy_plus_vbsyy +tya +asl +tax +//FRAGMENT vbsyy=vbsyy_plus_vbsaa +sty $ff +clc +adc $ff +tay +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz2 +ldx {z1} +lda {c1},x +ldx {z2} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsz2 +lda {c1},x +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsz2 +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_plus_pbsc1_derefidx_vbsxx +lda {c1},x +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},x +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},x +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},x +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},y +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsxx +clc +lda {c1},x +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_plus_pbsc1_derefidx_vbsyy +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},x +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},x +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},x +adc {c1},y +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},x +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},y +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},y +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},y +adc {c1},y +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_plus_pbsc1_derefidx_vbsyy +clc +lda {c1},y +adc {c1},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsz2 +lda {c1},x +ldy {z2} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsz2 +lda {c1},y +ldy {z2} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_minus_pbsc1_derefidx_vbsxx +ldy {z2} +lda {c1},y +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsxx +lda {c1},x +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsxx +lda {c1},y +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsz2_minus_pbsc1_derefidx_vbsyy +ldx {z2} +lda {c1},x +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsyy +lda {c1},x +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsyy +lda {c1},y +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsz2 +ldy {z1} +lda {c1},y +ldy {z2} +sec +sbc {c1},y +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldy {z1} +sec +sbc {c1},y +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldy {z1} +sec +sbc {c1},y +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsxx +ldy {z1} +lda {c1},y +sec +sbc {c1},x +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsxx +lda {c1},x +sec +sbc {c1},x +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsxx +lda {c1},y +sec +sbc {c1},x +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsyy +ldx {z1} +lda {c1},x +sec +sbc {c1},y +//FRAGMENT vbsaa=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsyy +lda {c1},x +sec +sbc {c1},y +//FRAGMENT vbsaa=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsyy +lda {c1},y +sec +sbc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsz2 +ldx {z1} +lda {c1},x +ldx {z2} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldx {z1} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldx {z1} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsxx +ldy {z1} +lda {c1},y +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsxx +lda {c1},x +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsxx +lda {c1},y +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsyy +ldx {z1} +lda {c1},x +sec +sbc {c1},y +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsyy +lda {c1},x +sec +sbc {c1},y +tax +//FRAGMENT vbsxx=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsyy +lda {c1},y +sec +sbc {c1},y +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsz2 +ldy {z1} +lda {c1},y +ldy {z2} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsz1 +lda {c1},x +ldy {z1} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsz1 +lda {c1},y +ldy {z1} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsxx +ldy {z1} +lda {c1},y +sec +sbc {c1},x +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsxx +lda {c1},x +sec +sbc {c1},x +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsxx +lda {c1},y +sec +sbc {c1},x +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_minus_pbsc1_derefidx_vbsyy +ldx {z1} +lda {c1},x +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsxx_minus_pbsc1_derefidx_vbsyy +lda {c1},x +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=pbsc1_derefidx_vbsyy_minus_pbsc1_derefidx_vbsyy +lda {c1},y +sec +sbc {c1},y +tay +//FRAGMENT vbsaa=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +clc +lda {c1},y +adc {c1},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz1 +ldx {z1} +clc +lda {c1},x +adc {c1},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbsz1_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +clc +lda {c1},y +adc {c1},y +tay +//FRAGMENT vbsaa=vbsz1_plus_pbsc1_derefidx_vbsz2 +lda {z1} +ldy {z2} +clc +adc {c1},y +//FRAGMENT vbsxx=vbsz1_plus_pbsc1_derefidx_vbsz2 +lda {z1} +ldx {z2} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsz1_plus_pbsc1_derefidx_vbsz2 +lda {z1} +ldy {z2} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsaa_plus_pbsc1_derefidx_vbsz2 +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsaa_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=vbsaa_plus_pbsc1_derefidx_vbsz1 +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsaa_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsxx_plus_pbsc1_derefidx_vbsz2 +ldy {z2} +txa +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsxx_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +txa +clc +adc {c1},y +//FRAGMENT vbsxx=vbsxx_plus_pbsc1_derefidx_vbsz1 +txa +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsxx_plus_pbsc1_derefidx_vbsz1 +ldy {z1} +txa +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsyy_plus_pbsc1_derefidx_vbsz2 +tya +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsyy_plus_pbsc1_derefidx_vbsz1 +tya +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbsxx=vbsyy_plus_pbsc1_derefidx_vbsz1 +ldx {z1} +tya +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsyy_plus_pbsc1_derefidx_vbsz1 +tya +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsz2_plus_pbsc1_derefidx_vbsxx +lda {c1},x +clc +adc {z2} +sta {z1} +//FRAGMENT vbsaa=vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +clc +adc {z1} +//FRAGMENT vbsxx=vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +clc +adc {z1} +tax +//FRAGMENT vbsyy=vbsz1_plus_pbsc1_derefidx_vbsxx +lda {c1},x +clc +adc {z1} +tay +//FRAGMENT vbsz1=vbsaa_plus_pbsc1_derefidx_vbsxx +clc +adc {c1},x +sta {z1} +//FRAGMENT vbsaa=vbsaa_plus_pbsc1_derefidx_vbsxx +clc +adc {c1},x +//FRAGMENT vbsxx=vbsaa_plus_pbsc1_derefidx_vbsxx +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsaa_plus_pbsc1_derefidx_vbsxx +clc +adc {c1},x +tay +//FRAGMENT vbsz1=vbsxx_plus_pbsc1_derefidx_vbsxx +txa +clc +adc {c1},x +sta {z1} +//FRAGMENT vbsaa=vbsxx_plus_pbsc1_derefidx_vbsxx +txa +clc +adc {c1},x +//FRAGMENT vbsxx=vbsxx_plus_pbsc1_derefidx_vbsxx +txa +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsxx_plus_pbsc1_derefidx_vbsxx +txa +clc +adc {c1},x +tay +//FRAGMENT vbsz1=vbsyy_plus_pbsc1_derefidx_vbsxx +tya +clc +adc {c1},x +sta {z1} +//FRAGMENT vbsaa=vbsyy_plus_pbsc1_derefidx_vbsxx +tya +clc +adc {c1},x +//FRAGMENT vbsxx=vbsyy_plus_pbsc1_derefidx_vbsxx +tya +clc +adc {c1},x +tax +//FRAGMENT vbsyy=vbsyy_plus_pbsc1_derefidx_vbsxx +tya +clc +adc {c1},x +tay +//FRAGMENT vbsz1=vbsz2_plus_pbsc1_derefidx_vbsyy +lda {c1},y +clc +adc {z2} +sta {z1} +//FRAGMENT vbsaa=vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +clc +adc {z1} +//FRAGMENT vbsxx=vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +clc +adc {z1} +tax +//FRAGMENT vbsyy=vbsz1_plus_pbsc1_derefidx_vbsyy +lda {c1},y +clc +adc {z1} +tay +//FRAGMENT vbsz1=vbsaa_plus_pbsc1_derefidx_vbsyy +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsaa_plus_pbsc1_derefidx_vbsyy +clc +adc {c1},y +//FRAGMENT vbsxx=vbsaa_plus_pbsc1_derefidx_vbsyy +clc +adc {c1},y +tax +//FRAGMENT vbsyy=vbsaa_plus_pbsc1_derefidx_vbsyy +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsxx_plus_pbsc1_derefidx_vbsyy +txa +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsxx_plus_pbsc1_derefidx_vbsyy +txa +clc +adc {c1},y +//FRAGMENT vbsxx=vbsxx_plus_pbsc1_derefidx_vbsyy +txa +clc +adc {c1},y +tax +//FRAGMENT vbsyy=vbsxx_plus_pbsc1_derefidx_vbsyy +txa +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsyy_plus_pbsc1_derefidx_vbsyy +tya +clc +adc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsyy_plus_pbsc1_derefidx_vbsyy +tya +clc +adc {c1},y +//FRAGMENT vbsxx=vbsyy_plus_pbsc1_derefidx_vbsyy +tya +clc +adc {c1},y +tax +//FRAGMENT vbsyy=vbsyy_plus_pbsc1_derefidx_vbsyy +tya +clc +adc {c1},y +tay +//FRAGMENT vbsz1=vbsaa_minus_pbsc1_derefidx_vbsz2 +ldy {z2} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_pbsc1_derefidx_vbsz2 +ldy {z2} +txa +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_pbsc1_derefidx_vbsz2 +tya +ldy {z2} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsz1_minus_pbsc1_derefidx_vbsz2 +lda {z1} +ldy {z2} +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsaa_minus_pbsc1_derefidx_vbsz1 +ldy {z1} +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsxx_minus_pbsc1_derefidx_vbsz1 +ldy {z1} +txa +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsyy_minus_pbsc1_derefidx_vbsz1 +tya +ldy {z1} +sec +sbc {c1},y +//FRAGMENT vbsxx=vbsz1_minus_pbsc1_derefidx_vbsz2 +lda {z1} +ldx {z2} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsaa_minus_pbsc1_derefidx_vbsz1 +ldx {z1} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsxx_minus_pbsc1_derefidx_vbsz1 +txa +ldx {z1} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsyy_minus_pbsc1_derefidx_vbsz1 +ldx {z1} +tya +sec +sbc {c1},x +tax +//FRAGMENT vbsyy=vbsz1_minus_pbsc1_derefidx_vbsz2 +lda {z1} +ldy {z2} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsaa_minus_pbsc1_derefidx_vbsz1 +ldy {z1} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsxx_minus_pbsc1_derefidx_vbsz1 +ldy {z1} +txa +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsyy_minus_pbsc1_derefidx_vbsz1 +tya +ldy {z1} +sec +sbc {c1},y +tay +//FRAGMENT vbsz1=vbsz2_minus_pbsc1_derefidx_vbsxx +lda {z2} +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsz1=vbsaa_minus_pbsc1_derefidx_vbsxx +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_pbsc1_derefidx_vbsxx +txa +tay +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_pbsc1_derefidx_vbsxx +tya +sec +sbc {c1},x +sta {z1} +//FRAGMENT vbsaa=vbsz1_minus_pbsc1_derefidx_vbsxx +lda {z1} +sec +sbc {c1},x +//FRAGMENT vbsaa=vbsaa_minus_pbsc1_derefidx_vbsxx +sec +sbc {c1},x +//FRAGMENT vbsaa=vbsxx_minus_pbsc1_derefidx_vbsxx +txa +tay +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsyy_minus_pbsc1_derefidx_vbsxx +tya +sec +sbc {c1},x +//FRAGMENT vbsxx=vbsz1_minus_pbsc1_derefidx_vbsxx +lda {z1} +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsaa_minus_pbsc1_derefidx_vbsxx +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsxx_minus_pbsc1_derefidx_vbsxx +txa +tax +sec +sbc {c1},x +tax +//FRAGMENT vbsxx=vbsyy_minus_pbsc1_derefidx_vbsxx +tya +sec +sbc {c1},x +tax +//FRAGMENT vbsyy=vbsz1_minus_pbsc1_derefidx_vbsxx +lda {z1} +sec +sbc {c1},x +tay +//FRAGMENT vbsyy=vbsaa_minus_pbsc1_derefidx_vbsxx +sec +sbc {c1},x +tay +//FRAGMENT vbsyy=vbsxx_minus_pbsc1_derefidx_vbsxx +txa +tay +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsyy_minus_pbsc1_derefidx_vbsxx +tya +sec +sbc {c1},x +tay +//FRAGMENT vbsz1=vbsz2_minus_pbsc1_derefidx_vbsyy +lda {z2} +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsaa_minus_pbsc1_derefidx_vbsyy +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_pbsc1_derefidx_vbsyy +txa +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsz1=vbsyy_minus_pbsc1_derefidx_vbsyy +tya +tay +sec +sbc {c1},y +sta {z1} +//FRAGMENT vbsaa=vbsz1_minus_pbsc1_derefidx_vbsyy +lda {z1} +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsaa_minus_pbsc1_derefidx_vbsyy +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsxx_minus_pbsc1_derefidx_vbsyy +txa +sec +sbc {c1},y +//FRAGMENT vbsaa=vbsyy_minus_pbsc1_derefidx_vbsyy +tya +tay +sec +sbc {c1},y +//FRAGMENT vbsxx=vbsz1_minus_pbsc1_derefidx_vbsyy +lda {z1} +sec +sbc {c1},y +tax +//FRAGMENT vbsxx=vbsaa_minus_pbsc1_derefidx_vbsyy +sec +sbc {c1},y +tax +//FRAGMENT vbsxx=vbsxx_minus_pbsc1_derefidx_vbsyy +txa +sec +sbc {c1},y +tax +//FRAGMENT vbsxx=vbsyy_minus_pbsc1_derefidx_vbsyy +tya +tax +sec +sbc {c1},x +tax +//FRAGMENT vbsyy=vbsz1_minus_pbsc1_derefidx_vbsyy +lda {z1} +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsaa_minus_pbsc1_derefidx_vbsyy +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsxx_minus_pbsc1_derefidx_vbsyy +txa +sec +sbc {c1},y +tay +//FRAGMENT vbsyy=vbsyy_minus_pbsc1_derefidx_vbsyy +tya +tay +sec +sbc {c1},y +tay +//FRAGMENT vwuz1=pwuz2_derefidx_vbuc1 +ldy #{c1} +lda ({z2}),y +sta {z1} +iny +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_vbuz2 +lda {z2} +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT pptz1_derefidx_vbuc1=pbuz2 +ldy #{c1} +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT pptz1_derefidx_vbuc1=pwuz2 +ldy #{c1} +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT vwuz1=vwuc1_plus_vbuaa +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_vbuxx +txa +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_vbuyy +tya +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT _deref_pbuc1_eq_0_then_la1 +lda {c1} +cmp #0 +beq {la1} +//FRAGMENT vbuz1=_deref_pbuc1_rol_4 +lda {c1} +asl +asl +asl +asl +sta {z1} +//FRAGMENT vbuz1=vbuz2_bor__deref_pbuc1 +lda {c1} +ora {z2} +sta {z1} +//FRAGMENT vduz1=vduz2_plus_vbuz3 +lda {z3} +clc +adc {z2} +sta {z1} +lda {z2}+1 +adc #0 +sta {z1}+1 +lda {z2}+2 +adc #0 +sta {z1}+2 +lda {z2}+3 +adc #0 +sta {z1}+3 +//FRAGMENT vwuz1=vwuz2_ror_6 +lda {z2} +asl +sta $ff +lda {z2}+1 +rol +sta {z1} +lda #0 +rol +sta {z1}+1 +asl $ff +rol {z1} +rol {z1}+1 +//FRAGMENT vbuz1=vbuz2_bxor_pbuc1_derefidx_vbuz3 +lda {z2} +ldy {z3} +eor {c1},y +sta {z1} +//FRAGMENT vbuz1=vbuz2_bor_vbuc1 +lda #{c1} +ora {z2} +sta {z1} +//FRAGMENT vbuz1_eq__deref_pbuc1_then_la1 +lda {c1} +cmp {z1} +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_(pbuc2_derefidx_vbuz3) +ldx {z3} +ldy {c2},x +lda {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuc1_derefidx_vbuz1=pbuz2_derefidx_vbuz1 +ldy {z1} +lda ({z2}),y +sta {c1},y +//FRAGMENT vbsz1=_dec_vbsz1 +dec {z1} +//FRAGMENT pbuc1_derefidx_vbuz1=_dec_pbuc1_derefidx_vbuz1 +ldx {z1} +dec {c1},x +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) +ldx {z2} +ldy {c2},x +lda {c1},y +ldy #0 +sta ({z1}),y +//FRAGMENT pbuc1_derefidx_vbuz1_le_pbuc2_derefidx_vbuz1_then_la1 +ldy {z1} +lda {c2},y +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1=_deref_pbuz2_bor_vbuc1 +lda #{c1} +ldy #0 +ora ({z2}),y +sta {z1} +//FRAGMENT vduz1=vduz2_rol_2 +lda {z2} +asl +sta {z1} +lda {z2}+1 +rol +sta {z1}+1 +lda {z2}+2 +rol +sta {z1}+2 +lda {z2}+3 +rol +sta {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +//FRAGMENT vwuz1=vwuc1_plus_vwuz2 +lda {z2} +clc +adc #<{c1} +sta {z1} +lda {z2}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vbuaa=_deref_pbuc1_rol_4 +lda {c1} +asl +asl +asl +asl +//FRAGMENT vbuxx=_deref_pbuc1_rol_4 +lda {c1} +asl +asl +asl +asl +tax +//FRAGMENT vbuyy=_deref_pbuc1_rol_4 +lda {c1} +asl +asl +asl +asl +tay +//FRAGMENT vbuaa=vbuz1_bor__deref_pbuc1 +lda {c1} +ora {z1} +//FRAGMENT vbuxx=vbuz1_bor__deref_pbuc1 +lda {c1} +ora {z1} +tax +//FRAGMENT vbuyy=vbuz1_bor__deref_pbuc1 +lda {c1} +ora {z1} +tay +//FRAGMENT vbuz1=vbuaa_bor__deref_pbuc1 +ora {c1} +sta {z1} +//FRAGMENT vbuaa=vbuaa_bor__deref_pbuc1 +ora {c1} +//FRAGMENT vbuxx=vbuaa_bor__deref_pbuc1 +ora {c1} +tax +//FRAGMENT vbuyy=vbuaa_bor__deref_pbuc1 +ora {c1} +tay +//FRAGMENT vbuz1=vbuxx_bor__deref_pbuc1 +txa +ora {c1} +sta {z1} +//FRAGMENT vbuaa=vbuxx_bor__deref_pbuc1 +txa +ora {c1} +//FRAGMENT vbuxx=vbuxx_bor__deref_pbuc1 +txa +ora {c1} +tax +//FRAGMENT vbuyy=vbuxx_bor__deref_pbuc1 +txa +ora {c1} +tay +//FRAGMENT vbuz1=vbuyy_bor__deref_pbuc1 +tya +ora {c1} +sta {z1} +//FRAGMENT vbuaa=vbuyy_bor__deref_pbuc1 +tya +ora {c1} +//FRAGMENT vbuxx=vbuyy_bor__deref_pbuc1 +tya +ora {c1} +tax +//FRAGMENT vbuyy=vbuyy_bor__deref_pbuc1 +tya +ora {c1} +tay +//FRAGMENT vduz1=vduz2_plus_vbuxx +txa +clc +adc {z2} +sta {z1} +lda {z2}+1 +adc #0 +sta {z1}+1 +lda {z2}+2 +adc #0 +sta {z1}+2 +lda {z2}+3 +adc #0 +sta {z1}+3 +//FRAGMENT vduz1=vduz2_plus_vbuyy +tya +clc +adc {z2} +sta {z1} +lda {z2}+1 +adc #0 +sta {z1}+1 +lda {z2}+2 +adc #0 +sta {z1}+2 +lda {z2}+3 +adc #0 +sta {z1}+3 +//FRAGMENT vbuz1_neq_pbuc1_derefidx_vbuaa_then_la1 +tay +lda {c1},y +cmp {z1} +bne {la1} +//FRAGMENT vbuaa_neq_pbuc1_derefidx_vbuz1_then_la1 +ldy {z1} +cmp {c1},y +bne {la1} +//FRAGMENT vbuaa=vbuz1_bxor_pbuc1_derefidx_vbuz2 +lda {z1} +ldy {z2} +eor {c1},y +//FRAGMENT vbuxx=vbuz1_bxor_pbuc1_derefidx_vbuz2 +lda {z1} +ldx {z2} +eor {c1},x +tax +//FRAGMENT vbuyy=vbuz1_bxor_pbuc1_derefidx_vbuz2 +lda {z1} +ldy {z2} +eor {c1},y +tay +//FRAGMENT vbuz1=vbuz2_bxor_pbuc1_derefidx_vbuxx +lda {c1},x +eor {z2} +sta {z1} +//FRAGMENT vbuaa=vbuz1_bxor_pbuc1_derefidx_vbuxx +lda {c1},x +eor {z1} +//FRAGMENT vbuxx=vbuz1_bxor_pbuc1_derefidx_vbuxx +lda {c1},x +eor {z1} +tax +//FRAGMENT vbuyy=vbuz1_bxor_pbuc1_derefidx_vbuxx +lda {c1},x +eor {z1} +tay +//FRAGMENT vbuz1=vbuz2_bxor_pbuc1_derefidx_vbuyy +lda {c1},y +eor {z2} +sta {z1} +//FRAGMENT vbuaa=vbuz1_bxor_pbuc1_derefidx_vbuyy +lda {c1},y +eor {z1} +//FRAGMENT vbuxx=vbuz1_bxor_pbuc1_derefidx_vbuyy +lda {c1},y +eor {z1} +tax +//FRAGMENT vbuyy=vbuz1_bxor_pbuc1_derefidx_vbuyy +lda {c1},y +eor {z1} +tay +//FRAGMENT vbuz1=vbuaa_bxor_pbuc1_derefidx_vbuz2 +ldy {z2} +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuaa_bxor_pbuc1_derefidx_vbuz1 +ldy {z1} +eor {c1},y +//FRAGMENT vbuxx=vbuaa_bxor_pbuc1_derefidx_vbuz1 +ldx {z1} +eor {c1},x +tax +//FRAGMENT vbuyy=vbuaa_bxor_pbuc1_derefidx_vbuz1 +ldy {z1} +eor {c1},y +tay +//FRAGMENT vbuz1=vbuaa_bxor_pbuc1_derefidx_vbuxx +eor {c1},x +sta {z1} +//FRAGMENT vbuaa=vbuaa_bxor_pbuc1_derefidx_vbuxx +eor {c1},x +//FRAGMENT vbuxx=vbuaa_bxor_pbuc1_derefidx_vbuxx +eor {c1},x +tax +//FRAGMENT vbuyy=vbuaa_bxor_pbuc1_derefidx_vbuxx +eor {c1},x +tay +//FRAGMENT vbuz1=vbuaa_bxor_pbuc1_derefidx_vbuyy +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuaa_bxor_pbuc1_derefidx_vbuyy +eor {c1},y +//FRAGMENT vbuxx=vbuaa_bxor_pbuc1_derefidx_vbuyy +eor {c1},y +tax +//FRAGMENT vbuyy=vbuaa_bxor_pbuc1_derefidx_vbuyy +eor {c1},y +tay +//FRAGMENT vbuz1=vbuxx_bxor_pbuc1_derefidx_vbuz2 +ldy {z2} +txa +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuxx_bxor_pbuc1_derefidx_vbuz1 +ldy {z1} +txa +eor {c1},y +//FRAGMENT vbuxx=vbuxx_bxor_pbuc1_derefidx_vbuz1 +txa +ldx {z1} +eor {c1},x +tax +//FRAGMENT vbuyy=vbuxx_bxor_pbuc1_derefidx_vbuz1 +ldy {z1} +txa +eor {c1},y +tay +//FRAGMENT vbuz1=vbuxx_bxor_pbuc1_derefidx_vbuxx +txa +eor {c1},x +sta {z1} +//FRAGMENT vbuaa=vbuxx_bxor_pbuc1_derefidx_vbuxx +txa +eor {c1},x +//FRAGMENT vbuxx=vbuxx_bxor_pbuc1_derefidx_vbuxx +txa +eor {c1},x +tax +//FRAGMENT vbuyy=vbuxx_bxor_pbuc1_derefidx_vbuxx +txa +eor {c1},x +tay +//FRAGMENT vbuz1=vbuxx_bxor_pbuc1_derefidx_vbuyy +txa +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuxx_bxor_pbuc1_derefidx_vbuyy +txa +eor {c1},y +//FRAGMENT vbuxx=vbuxx_bxor_pbuc1_derefidx_vbuyy +txa +eor {c1},y +tax +//FRAGMENT vbuyy=vbuxx_bxor_pbuc1_derefidx_vbuyy +txa +eor {c1},y +tay +//FRAGMENT vbuz1=vbuyy_bxor_pbuc1_derefidx_vbuz2 +tya +ldy {z2} +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuyy_bxor_pbuc1_derefidx_vbuz1 +tya +ldy {z1} +eor {c1},y +//FRAGMENT vbuxx=vbuyy_bxor_pbuc1_derefidx_vbuz1 +ldx {z1} +tya +eor {c1},x +tax +//FRAGMENT vbuyy=vbuyy_bxor_pbuc1_derefidx_vbuz1 +tya +ldy {z1} +eor {c1},y +tay +//FRAGMENT vbuz1=vbuyy_bxor_pbuc1_derefidx_vbuxx +tya +eor {c1},x +sta {z1} +//FRAGMENT vbuaa=vbuyy_bxor_pbuc1_derefidx_vbuxx +tya +eor {c1},x +//FRAGMENT vbuxx=vbuyy_bxor_pbuc1_derefidx_vbuxx +tya +eor {c1},x +tax +//FRAGMENT vbuyy=vbuyy_bxor_pbuc1_derefidx_vbuxx +tya +eor {c1},x +tay +//FRAGMENT vbuz1=vbuyy_bxor_pbuc1_derefidx_vbuyy +tya +eor {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuyy_bxor_pbuc1_derefidx_vbuyy +tya +eor {c1},y +//FRAGMENT vbuxx=vbuyy_bxor_pbuc1_derefidx_vbuyy +tya +eor {c1},y +tax +//FRAGMENT vbuyy=vbuyy_bxor_pbuc1_derefidx_vbuyy +tya +eor {c1},y +tay +//FRAGMENT vbuyy=vbuaa_band_pbuc1_derefidx_vbuz1 +ldy {z1} +and {c1},y +tay +//FRAGMENT vbuxx=vbuxx_band_pbuc1_derefidx_vbuz1 +ldy {z1} +lda {c1},y +axs #0 +//FRAGMENT vbuyy=vbuxx_band_pbuc1_derefidx_vbuz1 +ldy {z1} +txa +and {c1},y +tay +//FRAGMENT vbuxx=vbuyy_band_pbuc1_derefidx_vbuz1 +ldx {z1} +tya +and {c1},x +tax +//FRAGMENT vbuyy=vbuyy_band_pbuc1_derefidx_vbuz1 +tya +ldy {z1} +and {c1},y +tay +//FRAGMENT vbuyy=vbuaa_band_pbuc1_derefidx_vbuxx +and {c1},x +tay +//FRAGMENT vbuz1=vbuxx_band_pbuc1_derefidx_vbuxx +lda {c1},x +sax {z1} +//FRAGMENT vbuaa=vbuxx_band_pbuc1_derefidx_vbuxx +txa +and {c1},x +//FRAGMENT vbuxx=vbuxx_band_pbuc1_derefidx_vbuxx +lda {c1},x +axs #0 +//FRAGMENT vbuyy=vbuxx_band_pbuc1_derefidx_vbuxx +txa +and {c1},x +tay +//FRAGMENT vbuz1=vbuyy_band_pbuc1_derefidx_vbuxx +tya +and {c1},x +sta {z1} +//FRAGMENT vbuaa=vbuyy_band_pbuc1_derefidx_vbuxx +tya +and {c1},x +//FRAGMENT vbuxx=vbuyy_band_pbuc1_derefidx_vbuxx +tya +and {c1},x +tax +//FRAGMENT vbuyy=vbuyy_band_pbuc1_derefidx_vbuxx +tya +and {c1},x +tay +//FRAGMENT vbuz1=vbuxx_band_pbuc1_derefidx_vbuyy +lda {c1},y +sax {z1} +//FRAGMENT vbuz1=vbuyy_band_pbuc1_derefidx_vbuyy +tya +and {c1},y +sta {z1} +//FRAGMENT vbuaa=vbuxx_band_pbuc1_derefidx_vbuyy +txa +and {c1},y +//FRAGMENT vbuaa=vbuyy_band_pbuc1_derefidx_vbuyy +tya +and {c1},y +//FRAGMENT vbuxx=vbuxx_band_pbuc1_derefidx_vbuyy +lda {c1},y +axs #0 +//FRAGMENT vbuxx=vbuyy_band_pbuc1_derefidx_vbuyy +ldx {c1},y +tya +axs #0 +//FRAGMENT vbuyy=vbuxx_band_pbuc1_derefidx_vbuyy +txa +and {c1},y +tay +//FRAGMENT vbuyy=vbuyy_band_pbuc1_derefidx_vbuyy +tya +and {c1},y +tay +//FRAGMENT vbuaa=vbuz1_bor_vbuc1 +lda #{c1} +ora {z1} +//FRAGMENT vbuxx=vbuz1_bor_vbuc1 +lda #{c1} +ora {z1} +tax +//FRAGMENT vbuyy=vbuz1_bor_vbuc1 +lda #{c1} +ora {z1} +tay +//FRAGMENT vbuz1=vbuxx_bor_vbuc1 +txa +ora #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuxx_bor_vbuc1 +txa +ora #{c1} +//FRAGMENT vbuyy=vbuxx_bor_vbuc1 +txa +ora #{c1} +tay +//FRAGMENT vbuz1=vbuyy_bor_vbuc1 +tya +ora #{c1} +sta {z1} +//FRAGMENT vbuaa=vbuyy_bor_vbuc1 +tya +ora #{c1} +//FRAGMENT vbuxx=vbuyy_bor_vbuc1 +tya +ora #{c1} +tax +//FRAGMENT vbuz1=vbuz2_band_pbuc1_derefidx_vbuaa +tay +lda {c1},y +and {z2} +sta {z1} +//FRAGMENT vbuz1=vbuxx_band_pbuc1_derefidx_vbuaa +tay +lda {c1},y +sax {z1} +//FRAGMENT vbuz1=vbuyy_band_pbuc1_derefidx_vbuaa +tax +tya +and {c1},x +sta {z1} +//FRAGMENT vbuaa=vbuz1_band_pbuc1_derefidx_vbuaa +tay +lda {c1},y +and {z1} +//FRAGMENT vbuaa=vbuxx_band_pbuc1_derefidx_vbuaa +tay +txa +and {c1},y +//FRAGMENT vbuaa=vbuyy_band_pbuc1_derefidx_vbuaa +tax +tya +and {c1},x +//FRAGMENT vbuxx=vbuz1_band_pbuc1_derefidx_vbuaa +tax +lda {c1},x +and {z1} +tax +//FRAGMENT vbuxx=vbuxx_band_pbuc1_derefidx_vbuaa +tay +lda {c1},y +axs #0 +//FRAGMENT vbuxx=vbuyy_band_pbuc1_derefidx_vbuaa +tax +tya +and {c1},x +tax +//FRAGMENT vbuyy=vbuz1_band_pbuc1_derefidx_vbuaa +tay +lda {c1},y +and {z1} +tay +//FRAGMENT vbuyy=vbuxx_band_pbuc1_derefidx_vbuaa +tay +txa +and {c1},y +tay +//FRAGMENT vbuyy=vbuyy_band_pbuc1_derefidx_vbuaa +tax +tya +and {c1},x +tay +//FRAGMENT vbuxx_eq__deref_pbuc1_then_la1 +cpx {c1} +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_(pbuc2_derefidx_vbuaa) +tax +ldy {c2},x +lda {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_(pbuc2_derefidx_vbuxx) +ldy {c2},x +lda {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuc1_derefidx_(pbuc2_derefidx_vbuyy) +ldx {c2},y +lda {c1},x +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) +ldy {z2} +ldx {c2},y +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuaa) +tay +ldx {c2},y +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuxx) +ldy {c2},x +ldx {c1},y +tay +txa +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuyy) +ldx {c2},y +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) +ldy {z2} +txa +ldx {c2},y +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_(pbuc2_derefidx_vbuaa) +tay +txa +ldx {c2},y +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_(pbuc2_derefidx_vbuxx) +txa +tay +ldx {c2},y +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuc1_derefidx_(pbuc2_derefidx_vbuyy) +txa +ldx {c2},y +tay +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) +ldx {z2} +lda {c2},x +tax +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_(pbuc2_derefidx_vbuaa) +tax +lda {c2},x +tax +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_(pbuc2_derefidx_vbuxx) +lda {c2},x +tax +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuc1_derefidx_(pbuc2_derefidx_vbuyy) +ldx {c2},y +lda {c1},x +sta ({z1}),y +//FRAGMENT pbuc1_derefidx_vbuaa=pbuz1_derefidx_vbuaa +tay +lda ({z1}),y +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuxx=_dec_pbuc1_derefidx_vbuxx +dec {c1},x +//FRAGMENT _deref_pbuz1=pbuc1_derefidx_(pbuc2_derefidx_vbuxx) +ldy {c2},x +lda {c1},y +ldy #0 +sta ({z1}),y +//FRAGMENT pbuc1_derefidx_vbuxx_le_pbuc2_derefidx_vbuxx_then_la1 +txa +tay +lda {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuaa=_deref_pbuz1_bor_vbuc1 +lda #{c1} +ldy #0 +ora ({z1}),y +//FRAGMENT vbuxx=_deref_pbuz1_bor_vbuc1 +lda #{c1} +ldy #0 +ora ({z1}),y +tax +//FRAGMENT vbuyy=_deref_pbuz1_bor_vbuc1 +lda #{c1} +ldy #0 +ora ({z1}),y +tay +//FRAGMENT vbsxx=_dec_vbsxx +dex +//FRAGMENT vduz1=vduz1_plus_vbuxx +txa +clc +adc {z1} +sta {z1} +lda {z1}+1 +adc #0 +sta {z1}+1 +lda {z1}+2 +adc #0 +sta {z1}+2 +lda {z1}+3 +adc #0 +sta {z1}+3 +//FRAGMENT vwuz1=vwuz1_band_vwuc1 +lda {z1} +and #<{c1} +sta {z1} +lda {z1}+1 +and #>{c1} +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_vwuz1 +clc +lda {z1} +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vwuz1=vwuz1_ror_6 +lda {z1} +asl +sta $ff +lda {z1}+1 +rol +sta {z1} +lda #0 +rol +sta {z1}+1 +asl $ff +rol {z1} +rol {z1}+1 +//FRAGMENT vwuz1=pbuz2_bxor_vwuc1 +lda #<{c1} +eor {z2} +sta {z1} +lda #>{c1} +eor {z2}+1 +sta {z1}+1 +//FRAGMENT vbuz1=vbuz1_bxor_pbuz2_derefidx_vbuz3 +lda {z1} +ldy {z3} +eor ({z2}),y +sta {z1} +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz1_derefidx_vbuz2_bor_pbuc1_derefidx_vbuz3 +ldy {z2} +lda ({z1}),y +ldy {z3} +ora {c1},y +ldy {z2} +sta ({z1}),y +//FRAGMENT vbuz1=vbuz1_bxor_pbuz2_derefidx_vbuaa +tay +lda {z1} +eor ({z2}),y +sta {z1} +//FRAGMENT vbuz1=vbuz1_bxor_pbuz2_derefidx_vbuxx +txa +tay +lda {z1} +eor ({z2}),y +sta {z1} +//FRAGMENT vbuz1=vbuz1_bxor_pbuz2_derefidx_vbuyy +lda {z1} +eor ({z2}),y +sta {z1} +//FRAGMENT vbuaa=vbuaa_bxor_pbuz1_derefidx_vbuz2 +ldy {z2} +eor ({z1}),y +//FRAGMENT vbuaa=vbuaa_bxor_pbuz1_derefidx_vbuaa +tay +eor ({z1}),y +//FRAGMENT vbuaa=vbuaa_bxor_pbuz1_derefidx_vbuxx +stx $ff +ldy $ff +eor ({z1}),y +//FRAGMENT vbuaa=vbuaa_bxor_pbuz1_derefidx_vbuyy +eor ({z1}),y +//FRAGMENT vbuxx=vbuxx_bxor_pbuz1_derefidx_vbuz2 +ldy {z2} +txa +eor ({z1}),y +tax +//FRAGMENT vbuxx=vbuxx_bxor_pbuz1_derefidx_vbuaa +tay +txa +eor ({z1}),y +tax +//FRAGMENT vbuxx=vbuxx_bxor_pbuz1_derefidx_vbuxx +txa +tay +eor ({z1}),y +tax +//FRAGMENT vbuxx=vbuxx_bxor_pbuz1_derefidx_vbuyy +txa +eor ({z1}),y +tax +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz1_derefidx_vbuz2_bor_pbuc1_derefidx_vbuaa +ldy {z2} +tax +lda ({z1}),y +ora {c1},x +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz1_derefidx_vbuz2_bor_pbuc1_derefidx_vbuxx +ldy {z2} +lda ({z1}),y +ora {c1},x +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz1_derefidx_vbuz2_bor_pbuc1_derefidx_vbuyy +tya +ldy {z2} +tax +lda ({z1}),y +ora {c1},x +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz1_derefidx_vbuxx_bor_pbuc1_derefidx_vbuz2 +txa +tay +lda ({z1}),y +ldy {z2} +stx $ff +ora {c1},y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz1_derefidx_vbuxx_bor_pbuc1_derefidx_vbuaa +tay +txa +ldx {c1},y +tay +lda ({z1}),y +sty $ff + +stx $ff +ora $ff +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz1_derefidx_vbuxx_bor_pbuc1_derefidx_vbuxx +txa +tay +lda ({z1}),y +stx $ff +ora {c1},x +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz1_derefidx_vbuxx_bor_pbuc1_derefidx_vbuyy +txa +ldx {c1},y +tay +lda ({z1}),y +sty $ff + +stx $ff +ora $ff +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz1_derefidx_vbuyy_bor_pbuc1_derefidx_vbuz2 +lda ({z1}),y +sty $ff + +ldy {z2} +ora {c1},y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz1_derefidx_vbuyy_bor_pbuc1_derefidx_vbuaa +tax +lda ({z1}),y +sty $ff + +ora {c1},x +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz1_derefidx_vbuyy_bor_pbuc1_derefidx_vbuxx +lda ({z1}),y +sty $ff + +ora {c1},x +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz1_derefidx_vbuyy_bor_pbuc1_derefidx_vbuyy +lda ({z1}),y +sty $ff + +ora {c1},y +ldy $ff +sta ({z1}),y +//FRAGMENT vwuz1=pbuz1_bxor_vwuc1 +lda #<{c1} +eor {z1} +sta {z1} +lda #>{c1} +eor {z1}+1 +sta {z1}+1 +//FRAGMENT vbsz1=vbsz2_minus_vbsc1 +lax {z2} +axs #{c1} +stx {z1} +//FRAGMENT vbsz1=vbsaa_minus_vbsc1 +sec +sbc #{c1} +sta {z1} +//FRAGMENT vbsz1=vbsxx_minus_vbsc1 +txa +axs #{c1} +stx {z1} +//FRAGMENT vbsz1=vbsyy_minus_vbsc1 +tya +sec +sbc #{c1} +sta {z1} +//FRAGMENT vbsaa=vbsz1_minus_vbsc1 +lda {z1} +sec +sbc #{c1} +//FRAGMENT vbsaa=vbsaa_minus_vbsc1 +sec +sbc #{c1} +//FRAGMENT vbsaa=vbsxx_minus_vbsc1 +txa +sec +sbc #{c1} +//FRAGMENT vbsaa=vbsyy_minus_vbsc1 +tya +sec +sbc #{c1} +//FRAGMENT vbsxx=vbsz1_minus_vbsc1 +lax {z1} +axs #{c1} +//FRAGMENT vbsxx=vbsaa_minus_vbsc1 +tax +axs #{c1} +//FRAGMENT vbsxx=vbsyy_minus_vbsc1 +tya +tax +axs #{c1} +//FRAGMENT vbsyy=vbsz1_minus_vbsc1 +lda {z1} +sec +sbc #{c1} +tay +//FRAGMENT vbsyy=vbsaa_minus_vbsc1 +sec +sbc #{c1} +tay +//FRAGMENT vbsyy=vbsxx_minus_vbsc1 +txa +sec +sbc #{c1} +tay +//FRAGMENT vbsz1=vbsc1_minus_vbsz2 +lda #{c1} +sec +sbc {z2} +sta {z1} +//FRAGMENT vbsz1=vbsc1_minus_vbsaa +eor #$ff +sec +adc #{c1} +sta {z1} +//FRAGMENT vbsz1=vbsc1_minus_vbsxx +txa +eor #$ff +sec +adc #{c1} +sta {z1} +//FRAGMENT vbsz1=vbsc1_minus_vbsyy +tya +eor #$ff +sec +adc #{c1} +sta {z1} +//FRAGMENT vbsaa=vbsc1_minus_vbsz1 +lda #{c1} +sec +sbc {z1} +//FRAGMENT vbsaa=vbsc1_minus_vbsaa +eor #$ff +sec +adc #{c1} +//FRAGMENT vbsaa=vbsc1_minus_vbsxx +txa +eor #$ff +sec +adc #{c1} +//FRAGMENT vbsaa=vbsc1_minus_vbsyy +tya +eor #$ff +sec +adc #{c1} +//FRAGMENT vbsxx=vbsc1_minus_vbsz1 +lda #{c1} +sec +sbc {z1} +tax +//FRAGMENT vbsxx=vbsc1_minus_vbsaa +eor #$ff +tax +axs #-{c1}-1 +//FRAGMENT vbsxx=vbsc1_minus_vbsxx +txa +eor #$ff +tax +axs #-{c1}-1 +//FRAGMENT vbsxx=vbsc1_minus_vbsyy +tya +eor #$ff +tax +axs #-{c1}-1 +//FRAGMENT vbsyy=vbsc1_minus_vbsz1 +lda #{c1} +sec +sbc {z1} +tay +//FRAGMENT vbsyy=vbsc1_minus_vbsaa +eor #$ff +sec +adc #{c1} +tay +//FRAGMENT vbsyy=vbsc1_minus_vbsxx +txa +eor #$ff +sec +adc #{c1} +tay +//FRAGMENT vbsyy=vbsc1_minus_vbsyy +tya +eor #$ff +sec +adc #{c1} +tay +//FRAGMENT vbsyy_lt_0_then_la1 +cpy #0 +bmi {la1} +//FRAGMENT _deref_pbuc1_lt_vbuz1_then_la1 +lda {c1} +cmp {z1} +bcc {la1} +//FRAGMENT vbuz1=pbuc1_derefidx_(pbuc2_derefidx_vbuz2) +ldx {z2} +ldy {c2},x +ldx {c1},y +stx {z1} +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_(pbuc3_derefidx_vbuz2) +ldx {z2} +ldy {c3},x +lda {c2},y +ldx {z1} +sta {c1},x +//FRAGMENT vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 +lda {z1} +ldx {z2} +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuz2)_then_la1 +lda {z1} +ldx {z2} +ldy {c2},x +cmp {c1},y +bcc {la1} +//FRAGMENT _deref_pbuc1_lt_vbuaa_then_la1 +ldy {c1} +sta $ff +cpy $ff +bcc {la1} +//FRAGMENT vbuaa=pbuc1_derefidx_(pbuc2_derefidx_vbuz1) +ldx {z1} +ldy {c2},x +lda {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_(pbuc2_derefidx_vbuz1) +ldx {z1} +ldy {c2},x +ldx {c1},y +//FRAGMENT vbuyy=pbuc1_derefidx_(pbuc2_derefidx_vbuz1) +ldy {z1} +ldx {c2},y +ldy {c1},x +//FRAGMENT vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuaa)_then_la1 +tax +lda {z1} +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +lda {z1} +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +lda {z1} +ldx {c2},y +cmp {c1},x +bcs {la1} +//FRAGMENT vbuaa_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz1)_then_la1 +ldx {z1} +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +lda {z1} +ldy {c2},x +cmp {c1},y +bcc {la1} +//FRAGMENT vbuz1_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +lda {z1} +ldx {c2},y +cmp {c1},x +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuz1)_then_la1 +ldy {z1} +txa +ldx {c2},y +cmp {c1},x +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +txa +ldy {c2},x +cmp {c1},y +bcc {la1} +//FRAGMENT vbuxx_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +txa +ldx {c2},y +cmp {c1},x +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuz1)_then_la1 +ldx {z1} +tya +ldy {c2},x +cmp {c1},y +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +tya +ldy {c2},x +cmp {c1},y +bcc {la1} +//FRAGMENT vbuyy_lt_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +tya +ldx {c2},y +cmp {c1},x +bcc {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz1)_then_la1 +ldy {z1} +txa +ldx {c2},y +cmp {c1},x +bcs {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +txa +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuxx_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +txa +ldx {c2},y +cmp {c1},x +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuz1)_then_la1 +ldx {z1} +tya +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuxx)_then_la1 +tya +ldy {c2},x +cmp {c1},y +bcs {la1} +//FRAGMENT vbuyy_ge_pbuc1_derefidx_(pbuc2_derefidx_vbuyy)_then_la1 +tya +ldx {c2},y +cmp {c1},x +bcs {la1} +//FRAGMENT _deref_pbuc1_lt_vbuxx_then_la1 +lda {c1} +stx $ff +cmp $ff +bcc {la1} +//FRAGMENT _deref_pbuc1_lt_vbuyy_then_la1 +ldx {c1} +sty $ff +cpx $ff +bcc {la1} +//FRAGMENT vbsxx=pbsc1_derefidx_vbuyy +ldx {c1},y +//FRAGMENT vbsz1=pbsc1_derefidx_vbuz2_minus_pbsc2_derefidx_vbuz2 +ldy {z2} +lda {c1},y +sec +sbc {c2},y +sta {z1} +//FRAGMENT pbsz1=pbsc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +//FRAGMENT _deref_pbsz1=vbsz2 +lda {z2} +ldy #0 +sta ({z1}),y +//FRAGMENT pbsz1=_inc_pbsz1 +inc {z1} +bne !+ +inc {z1}+1 +!: +//FRAGMENT vbsaa=pbsc1_derefidx_vbuz1_minus_pbsc2_derefidx_vbuz1 +ldy {z1} +lda {c1},y +sec +sbc {c2},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbuz1_minus_pbsc2_derefidx_vbuz1 +ldx {z1} +lda {c1},x +sec +sbc {c2},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbuz1_minus_pbsc2_derefidx_vbuz1 +ldy {z1} +lda {c1},y +sec +sbc {c2},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbuaa_minus_pbsc2_derefidx_vbuaa +tay +lda {c1},y +sec +sbc {c2},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbuaa_minus_pbsc2_derefidx_vbuaa +tay +lda {c1},y +sec +sbc {c2},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbuaa_minus_pbsc2_derefidx_vbuaa +tax +lda {c1},x +sec +sbc {c2},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbuaa_minus_pbsc2_derefidx_vbuaa +tay +lda {c1},y +sec +sbc {c2},y +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx +lda {c1},x +sec +sbc {c2},x +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx +lda {c1},x +sec +sbc {c2},x +//FRAGMENT vbsxx=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx +lda {c1},x +sec +sbc {c2},x +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbuxx_minus_pbsc2_derefidx_vbuxx +lda {c1},x +sec +sbc {c2},x +tay +//FRAGMENT vbsz1=pbsc1_derefidx_vbuyy_minus_pbsc2_derefidx_vbuyy +lda {c1},y +sec +sbc {c2},y +sta {z1} +//FRAGMENT vbsaa=pbsc1_derefidx_vbuyy_minus_pbsc2_derefidx_vbuyy +lda {c1},y +sec +sbc {c2},y +//FRAGMENT vbsxx=pbsc1_derefidx_vbuyy_minus_pbsc2_derefidx_vbuyy +lda {c1},y +sec +sbc {c2},y +tax +//FRAGMENT vbsyy=pbsc1_derefidx_vbuyy_minus_pbsc2_derefidx_vbuyy +lda {c1},y +sec +sbc {c2},y +tay +//FRAGMENT _deref_pbsz1=vbsaa +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbsz1=vbsxx +txa +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbsz1=vbsyy +tya +ldy #0 +sta ({z1}),y +//FRAGMENT vwuz1_eq_vwuz2_then_la1 +lda {z1} +cmp {z2} +bne !+ +lda {z1}+1 +cmp {z2}+1 +beq {la1} +!: +//FRAGMENT vwuz1_le_vwuz2_then_la1 +lda {z1}+1 +cmp {z2}+1 +bne !+ +lda {z1} +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 vduz1_lt_vwuc1_then_la1 +NO_SYNTHESIS +//FRAGMENT vduz1_lt_vwsc1_then_la1 +NO_SYNTHESIS +//FRAGMENT vduz1=vduz2_rol_4 +lda {z2} +asl +sta {z1} +lda {z2}+1 +rol +sta {z1}+1 +lda {z2}+2 +rol +sta {z1}+2 +lda {z2}+3 +rol +sta {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +//FRAGMENT vduz1=vduz2_plus_vduz3 +lda {z2} +clc +adc {z3} +sta {z1} +lda {z2}+1 +adc {z3}+1 +sta {z1}+1 +lda {z2}+2 +adc {z3}+2 +sta {z1}+2 +lda {z2}+3 +adc {z3}+3 +sta {z1}+3 +//FRAGMENT vduz1=vduz2_rol_1 +lda {z2} +asl +sta {z1} +lda {z2}+1 +rol +sta {z1}+1 +lda {z2}+2 +rol +sta {z1}+2 +lda {z2}+3 +rol +sta {z1}+3 +//FRAGMENT vduz1=vduz1_plus_vwuc1 +lda {z1} +clc +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +lda {z1}+2 +adc #0 +sta {z1}+2 +lda {z1}+3 +adc #0 +sta {z1}+3 +//FRAGMENT vduz1=vduz1_rol_2 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +//FRAGMENT _stackpushbyte_2 +pha +pha +//FRAGMENT vwsz1=_stackpullsword_ +pla +sta {z1} +pla +sta {z1}+1 +//FRAGMENT _stackidxsword_vbuc1=vwsz1 +tsx +lda {z1} +sta STACK_BASE+{c1},x +lda {z1}+1 +sta STACK_BASE+{c1}+1,x +//FRAGMENT pbuc1_derefidx_vbuaa=_inc_pbuc1_derefidx_vbuaa +tax +inc {c1},x +//FRAGMENT pwsz1_lt_pwsc1_then_la1 +lda {z1}+1 +cmp #>{c1} +bcc {la1} +bne !+ +lda {z1} +cmp #<{c1} +bcc {la1} +!: +//FRAGMENT vduz1_neq_vduc1_then_la1 +lda {z1}+3 +cmp #>{c1}>>$10 +bne {la1} +lda {z1}+2 +cmp #<{c1}>>$10 +bne {la1} +lda {z1}+1 +cmp #>{c1} +bne {la1} +lda {z1} +cmp #<{c1} +bne {la1} +//FRAGMENT vwuz1=vwuz2_plus_vwuc1 +lda {z2} +clc +adc #<{c1} +sta {z1} +lda {z2}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vduz1=vduz2_sethi_vwuz3 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +lda {z3} +sta {z1}+2 +lda {z3}+1 +sta {z1}+3 +//FRAGMENT vduz1=vduz2_setlo_vwuz3 +lda {z3} +sta {z1} +lda {z3}+1 +sta {z1}+1 +lda {z2}+2 +sta {z1}+2 +lda {z2}+3 +sta {z1}+3 +//FRAGMENT vduz1=vduz1_setlo_vwuz2 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +//FRAGMENT vbuz1_ge__deref_pbuc1_then_la1 +lda {c1} +ldy {z1} +sta $ff +cpy $ff +bcs {la1} +//FRAGMENT vbuxx_ge__deref_pbuc1_then_la1 +ldy {c1} +sty $ff +cpx $ff +bcs {la1} +//FRAGMENT vbuyy_ge__deref_pbuc1_then_la1 +lda {c1} +sta $ff +cpy $ff +bcs {la1} +//FRAGMENT vwsz1_eq_vwsz2_then_la1 +lda {z1} +cmp {z2} +bne !+ +lda {z1}+1 +cmp {z2}+1 +beq {la1} +!: +//FRAGMENT vwsz1_neq_vwsz2_then_la1 +lda {z1}+1 +cmp {z2}+1 +bne {la1} +lda {z1} +cmp {z2} +bne {la1} +//FRAGMENT vwsz1_lt_vwsz2_then_la1 +lda {z1} +cmp {z2} +lda {z1}+1 +sbc {z2}+1 +bvc !+ +eor #$80 +!: +bmi {la1} +!e: +//FRAGMENT vwsz1_gt_vwsz2_then_la1 +lda {z2} +cmp {z1} +lda {z2}+1 +sbc {z1}+1 +bvc !+ +eor #$80 +!: +bmi {la1} +!e: +//FRAGMENT vwsz1_ge_vwsz2_then_la1 +lda {z1} +cmp {z2} +lda {z1}+1 +sbc {z2}+1 +bvc !+ +eor #$80 +!: +bpl {la1} +//FRAGMENT vbsz1_neq_vbsz2_then_la1 +lda {z1} +cmp {z2} +bne {la1} +//FRAGMENT vbsz1_neq_vbsxx_then_la1 +cpx {z1} +bne {la1} +//FRAGMENT vbsxx_neq_vbsz1_then_la1 +cpx {z1} +bne {la1} +//FRAGMENT vwuz1=vwuc1_plus_pbuc2_derefidx_vbuz2 +ldy {z2} +lda {c2},y +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT pbuz1_derefidx_vbuz2=_byte_vwuz3 +lda {z3} +ldy {z2} +sta ({z1}),y +//FRAGMENT vwuz1=vwuc1_plus_pbuc2_derefidx_vbuaa +tay +lda {c2},y +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_pbuc2_derefidx_vbuxx +lda {c2},x +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_plus_pbuc2_derefidx_vbuyy +lda {c2},y +clc +adc #<{c1} +sta {z1} +lda #>{c1} +adc #0 +sta {z1}+1 +//FRAGMENT pbuz1_derefidx_vbuxx=_byte_vwuz2 +txa +tay +lda {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=_byte_vwuz2 +tya +tay +lda {z2} +sta ({z1}),y +//FRAGMENT vbuz1=vbuz2_bor__hi_vwuz3 +lda {z2} +ora {z3}+1 +sta {z1} +//FRAGMENT vbuz1=vbuz1_bor_vbuaa +ora {z1} +sta {z1} +//FRAGMENT _deref_pwuz1=vbuz2 +lda {z2} +ldy #0 +sta ({z1}),y +tya +iny +sta ({z1}),y +//FRAGMENT _deref_pwuz1=vbuaa +ldy #0 +sta ({z1}),y +tya +iny +sta ({z1}),y +//FRAGMENT _deref_pwuz1=vbuxx +txa +ldy #0 +sta ({z1}),y +tya +iny +sta ({z1}),y +//FRAGMENT _deref_pwuz1=vbuyy +tya +ldy #0 +sta ({z1}),y +tya +iny +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz3_derefidx_vbuz4 +ldy {z4} +lda ({z3}),y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuz2_derefidx_vbuz3 +ldy {z3} +sta $ff +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz2_derefidx_vbuz3 +ldy {z3} +stx $ff +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz2_derefidx_vbuz3 +sty $ff + +ldy {z3} +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz3_derefidx_vbuaa +tay +lda ({z3}),y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz2_derefidx_vbuaa +stx $ff +tay +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz2_derefidx_vbuaa +sty $ff + +tay +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz3_derefidx_vbuxx +txa +tay +lda ({z3}),y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuz2_derefidx_vbuxx +sta $ff +txa +tay +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuyy=pbuz2_derefidx_vbuxx +sty $ff + +txa +tay +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuz2=pbuz3_derefidx_vbuyy +lda ({z3}),y +ldy {z2} +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuaa=pbuz2_derefidx_vbuyy +sta $ff +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT pbuz1_derefidx_vbuxx=pbuz2_derefidx_vbuyy +stx $ff +lda ({z2}),y +ldy $ff +sta ({z1}),y +//FRAGMENT (_deref_pptc1)_derefidx_vbuc2=vbuc3 +lda #{c3} +ldy #{c2} +ldx {c1} +stx $fe +ldx {c1}+1 +stx $ff +sta ($fe),y +//FRAGMENT vwuz1=(_deref_pptc1)_derefidx_vbuc2 +ldy #{c2} +lda {c1} +sta $fe +lda {c1}+1 +sta $ff +lda ($fe),y +sta {z1} +iny +lda ($fe),y +sta {z1}+1 +//FRAGMENT vbuyy_neq_vbuaa_then_la1 +tax +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vwuz1=_deref_pbuz2_word__deref_pbuz3 +ldy #0 +lda ({z3}),y +sta {z1} +lda ({z2}),y +sta {z1}+1 +//FRAGMENT vbuz1=vbuz2_minus_2 +lda {z2} +sec +sbc #2 +sta {z1} +//FRAGMENT vbuaa=vbuz1_minus_2 +lda {z1} +sec +sbc #2 +//FRAGMENT vbuxx=vbuz1_minus_2 +ldx {z1} +dex +dex +//FRAGMENT vbuz1=_deref_pbuc1_plus_2 +lda {c1} +clc +adc #2 +sta {z1} +//FRAGMENT vbuaa=_deref_pbuc1_plus_2 +lda {c1} +clc +adc #2 +//FRAGMENT vbuxx=_deref_pbuc1_plus_2 +ldx {c1} +inx +inx +//FRAGMENT vbuyy=_deref_pbuc1_plus_2 +ldy {c1} +iny +iny +//FRAGMENT vbuaa_eq_vbuz1_then_la1 +cmp {z1} +beq {la1} +//FRAGMENT pbuz1=pbuz1_plus_vbuz2 +lda {z2} +clc +adc {z1} +sta {z1} +bcc !+ +inc {z1}+1 +!: +//FRAGMENT vbuz1=_neg_vbuyy +dey +tya +eor #$ff +sta {z1} +//FRAGMENT vbuaa=_neg_vbuyy +dey +tya +eor #$ff +//FRAGMENT vbuxx=_neg_vbuyy +tya +eor #$ff +tax +inx +//FRAGMENT vbuz1=vbuz2_band_vbuz3 +lda {z2} +and {z3} +sta {z1} +//FRAGMENT vbuz1=vbuaa_band_vbuz2 +and {z2} +sta {z1} +//FRAGMENT vbuz1=vbuxx_band_vbuz2 +lda {z2} +sax {z1} +//FRAGMENT vbuz1=vbuyy_band_vbuz2 +tya +and {z2} +sta {z1} +//FRAGMENT vbuz1=vbuz2_band_vbuxx +lda {z2} +sax {z1} +//FRAGMENT vbuz1=vbuaa_band_vbuxx +sax {z1} +//FRAGMENT vbuaa=vbuz1_band_vbuz2 +lda {z1} +and {z2} +//FRAGMENT vbuaa=vbuaa_band_vbuz1 +and {z1} +//FRAGMENT vbuaa=vbuxx_band_vbuz1 +txa +and {z1} +//FRAGMENT vbuaa=vbuyy_band_vbuz1 +tya +and {z1} +//FRAGMENT vbuxx=vbuz1_band_vbuz2 +lda {z1} +and {z2} +tax +//FRAGMENT vbuxx=vbuaa_band_vbuz1 +ldx {z1} +axs #0 +//FRAGMENT vbuxx=vbuxx_band_vbuz1 +lda {z1} +axs #0 +//FRAGMENT vbuxx=vbuyy_band_vbuz1 +ldx {z1} +tya +axs #0 +//FRAGMENT vbuyy=vbuz1_band_vbuz2 +lda {z1} +and {z2} +tay +//FRAGMENT vbuyy=vbuaa_band_vbuz1 +and {z1} +tay +//FRAGMENT vbuyy=vbuxx_band_vbuz1 +txa +and {z1} +tay +//FRAGMENT vbuyy=vbuyy_band_vbuz1 +tya +and {z1} +tay +//FRAGMENT vdsz1=vdsz2_rol_4 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +lda {z2}+2 +sta {z1}+2 +lda {z2}+3 +sta {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +//FRAGMENT vwuz1=vbuc1_plus__hi_vdsz2 +NO_SYNTHESIS +//FRAGMENT vwuz1=vwuc1_plus__hi_vdsz2 +clc +lda #<{c1} +adc {z2}+2 +sta {z1} +lda #>{c1} +adc {z2}+3 +sta {z1}+1 +//FRAGMENT vwuz1=vbsc1_plus__hi_vdsz2 +NO_SYNTHESIS +//FRAGMENT vwuz1=vwuz2_minus_vwuz1 +lda {z2} +sec +sbc {z1} +sta {z1} +lda {z2}+1 +sbc {z1}+1 +sta {z1}+1 +//FRAGMENT vdsz1=vdsz1_rol_4 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +asl {z1} +rol {z1}+1 +rol {z1}+2 +rol {z1}+3 +//FRAGMENT vwsz1=vwsz2_ror_2 +lda {z2}+1 +cmp #$80 +ror +sta {z1}+1 +lda {z2} +ror +sta {z1} +lda {z1}+1 +cmp #$80 +ror {z1}+1 +ror {z1} +//FRAGMENT vwsz1=vbsc1_plus_vwsz2 +lda {z2} +clc +adc #<{c1} +sta {z1} +lda {z2}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vwsz1=vwsz1_plus_vbuz2 +clc +lda {z1} +adc {z2} +sta {z1} +lda {z1}+1 +adc #0 +sta {z1}+1 +//FRAGMENT vwsz1=vwsc1_plus_vwsz1 +clc +lda {z1} +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vwsz1=vbsc1_plus_vwsz1 +lda {z1} +clc +adc #<{c1} +sta {z1} +lda {z1}+1 +adc #>{c1} +sta {z1}+1 +//FRAGMENT vdsz1=vdsc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +lda #<{c1}>>$10 +sta {z1}+2 +lda #>{c1}>>$10 +sta {z1}+3 +//FRAGMENT vdsz1_lt_0_then_la1 +lda {z1}+3 +bmi {la1} +//FRAGMENT vdsz1=_neg_vdsz1 +sec +lda {z1} +eor #$ff +adc #$0 +sta {z1} +lda {z1}+1 +eor #$ff +adc #$0 +sta {z1}+1 +lda {z1}+2 +eor #$ff +adc #$0 +sta {z1}+2 +lda {z1}+3 +eor #$ff +adc #$0 +sta {z1}+3 +//FRAGMENT pbuz1_derefidx_vbuz2=vbuz2 +lda {z2} +tay +sta ({z1}),y +//FRAGMENT pbuz1=pbuz2_minus_vbuc1 +sec +lda {z2} +sbc #{c1} +sta {z1} +lda {z2}+1 +sbc #0 +sta {z1}+1 +//FRAGMENT vwuz1=vwuz1_plus_pwuz2_derefidx_vbuc1 +ldy #{c1} +clc +lda {z1} +adc ({z2}),y +sta {z1} +iny +lda {z1}+1 +adc ({z2}),y +sta {z1}+1 +//FRAGMENT pssz1=_deref_pptz1 +ldy #0 +lda ({z1}),y +pha +iny +lda ({z1}),y +sta {z1}+1 +pla +sta {z1} +//FRAGMENT _deref_pptz1=pssz2 +ldy #0 +lda {z2} +sta ({z1}),y +iny +lda {z2}+1 +sta ({z1}),y +//FRAGMENT vbsz1_le_0_then_la1 +lda {z1} +cmp #1 +bmi {la1} +//FRAGMENT vwsz1=vwsz1_minus_vbsz2 +lda {z2} +sta $fe +ora #$7f +bmi !+ +lda #0 +!: +sta $ff +sec +lda {z1} +sbc $fe +sta {z1} +lda {z1}+1 +sbc $ff +sta {z1}+1 +//FRAGMENT _deref_pbuz1_eq__deref_pbuz2_then_la1 +ldy #0 +lda ({z1}),y +ldy #0 +cmp ({z2}),y +beq {la1} +//FRAGMENT vbsaa_le_0_then_la1 +cmp #1 +bmi {la1} +//FRAGMENT vbsaa_neq_vbsz1_then_la1 +cmp {z1} +bne {la1} +//FRAGMENT vwsz1=vwsz1_minus_vbsxx +txa +sta $fe +ora #$7f +bmi !+ +lda #0 +!: +sta $ff +sec +lda {z1} +sbc $fe +sta {z1} +lda {z1}+1 +sbc $ff +sta {z1}+1 +//FRAGMENT vwsz1=vwsz1_minus_vbsyy +tya +sta $fe +ora #$7f +bmi !+ +lda #0 +!: +sta $ff +sec +lda {z1} +sbc $fe +sta {z1} +lda {z1}+1 +sbc $ff +sta {z1}+1 +//FRAGMENT vbsxx_le_0_then_la1 +cpx #1 +bmi {la1} +//FRAGMENT vbsyy_neq_vbsz1_then_la1 +cpy {z1} +bne {la1} +//FRAGMENT vbsyy=_dec_vbsyy +dey +//FRAGMENT vbsyy_neq_vbsxx_then_la1 +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vbsyy_le_0_then_la1 +cpy #1 +bmi {la1} +//FRAGMENT vbsz1_neq_vbsyy_then_la1 +cpy {z1} +bne {la1} +//FRAGMENT vbsxx_neq_vbsyy_then_la1 +stx $ff +cpy $ff +bne {la1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc2_derefidx_vbuz3 +ldy {z2} +lda {c1},y +ldy {z3} +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc1_derefidx_vbuz3 +ldy {z2} +lda {c1},y +ldy {z3} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuz1=vbuz1_bor_pbuc1_derefidx_vbuz2 +lda {z1} +ldy {z2} +ora {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuz2 +ldx {z1} +lda {c1},x +ldx {z2} +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c2},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuz2 +tay +lda {c1},y +ldy {z2} +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuz1 +tay +lda {c1},y +ldy {z1} +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuz1 +tax +lda {c1},x +ldx {z1} +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuz1 +tay +lda {c1},y +ldy {z1} +clc +adc {c2},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuz2 +lda {c1},x +ldy {z2} +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuz1 +lda {c1},x +ldy {z1} +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuz1 +lda {c1},x +ldx {z1} +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuz1 +lda {c1},x +ldy {z1} +clc +adc {c2},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuz2 +lda {c1},y +ldy {z2} +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuz1 +lda {c1},y +ldy {z1} +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuz1 +lda {c1},y +ldx {z1} +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuz1 +lda {c1},y +ldy {z1} +clc +adc {c2},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc2_derefidx_vbuxx +lda {c2},x +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuxx +lda {c2},x +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuxx +lda {c2},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuxx +lda {c2},x +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuxx +tay +lda {c1},y +clc +adc {c2},x +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuxx +tay +lda {c1},y +clc +adc {c2},x +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuxx +tay +lda {c1},y +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuxx +tay +lda {c1},y +clc +adc {c2},x +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuxx +lda {c1},y +clc +adc {c2},x +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuxx +lda {c1},y +clc +adc {c2},x +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuxx +lda {c1},y +clc +adc {c2},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc2_derefidx_vbuxx +lda {c1},y +clc +adc {c2},x +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc2_derefidx_vbuyy +lda {c2},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuyy +lda {c2},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuyy +lda {c2},y +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc2_derefidx_vbuyy +lda {c2},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c2},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc2_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c2},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuyy +lda {c1},x +clc +adc {c2},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuyy +lda {c1},x +clc +adc {c2},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuyy +lda {c1},x +clc +adc {c2},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc2_derefidx_vbuyy +lda {c1},x +clc +adc {c2},y +tay +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuz2 +ldx {z1} +lda {c1},x +ldx {z2} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuz2 +ldy {z1} +lda {c1},y +ldy {z2} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuz2 +tay +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuz1 +tay +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuz1 +tax +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuz1 +tay +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuz2 +lda {c1},x +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuz1 +lda {c1},x +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuz1 +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuz1 +lda {c1},x +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuz2 +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuz1 +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuz1 +lda {c1},y +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuz1 +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},y +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuaa +tay +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuaa +tax +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc1_derefidx_vbuxx +lda {c1},x +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuxx +lda {c1},x +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuxx +lda {c1},x +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuxx +lda {c1},x +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuxx +tay +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuxx +tay +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuxx +tay +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuxx +tay +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},x +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},x +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},x +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuxx +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_plus_pbuc1_derefidx_vbuyy +lda {c1},y +ldy {z2} +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuyy +lda {c1},y +ldy {z1} +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuyy +lda {c1},y +ldx {z1} +clc +adc {c1},x +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_plus_pbuc1_derefidx_vbuyy +lda {c1},y +ldy {z1} +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_plus_pbuc1_derefidx_vbuyy +tax +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuyy +lda {c1},x +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuyy +lda {c1},x +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuyy +lda {c1},x +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_plus_pbuc1_derefidx_vbuyy +lda {c1},x +clc +adc {c1},y +tay +//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuyy +lda {c1},y +clc +adc {c1},y +sta {z1} +//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuyy +lda {c1},y +clc +adc {c1},y +//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuyy +lda {c1},y +clc +adc {c1},y +tax +//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_plus_pbuc1_derefidx_vbuyy +lda {c1},y +clc +adc {c1},y +tay +//FRAGMENT vbuxx=vbuxx_bor_pbuc1_derefidx_vbuz1 +txa +ldx {z1} +ora {c1},x +tax +//FRAGMENT vbuyy=vbuyy_bor_pbuc1_derefidx_vbuz1 +tya +ldy {z1} +ora {c1},y +tay +//FRAGMENT vbuz1=vbuz1_bor_pbuc1_derefidx_vbuxx +lda {c1},x +ora {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_bor_pbuc1_derefidx_vbuxx +txa +ora {c1},x +tax +//FRAGMENT vbuyy=vbuyy_bor_pbuc1_derefidx_vbuxx +tya +ora {c1},x +tay +//FRAGMENT vbuz1=vbuz1_bor_pbuc1_derefidx_vbuyy +lda {c1},y +ora {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_bor_pbuc1_derefidx_vbuyy +txa +ora {c1},y +tax +//FRAGMENT vbuyy=vbuyy_bor_pbuc1_derefidx_vbuyy +tya +ora {c1},y +tay +//FRAGMENT vbuz1=pbuz2_derefidx_(pbuz3_derefidx_vbuz4)_plus_pbuz5_derefidx_(pbuz6_derefidx_vbuz4) +ldy {z4} +lda ({z6}),y +sta $ff +lda ({z3}),y +tay +lda ({z2}),y +ldy $ff +clc +adc ({z5}),y +sta {z1} +//FRAGMENT vbuaa=pbuz1_derefidx_(pbuz2_derefidx_vbuz3)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuz3) +ldy {z3} +lda ({z5}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z4}),y +//FRAGMENT vbuxx=pbuz1_derefidx_(pbuz2_derefidx_vbuz3)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuz3) +ldy {z3} +lda ({z5}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z4}),y +tax +//FRAGMENT vbuyy=pbuz1_derefidx_(pbuz2_derefidx_vbuz3)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuz3) +ldy {z3} +lda ({z5}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z4}),y +tay +//FRAGMENT vbuz1=pbuz2_derefidx_(pbuz3_derefidx_vbuaa)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuaa) +tay +lda ({z5}),y +sta $ff +lda ({z3}),y +tay +lda ({z2}),y +ldy $ff +clc +adc ({z4}),y +sta {z1} +//FRAGMENT vbuaa=pbuz1_derefidx_(pbuz2_derefidx_vbuaa)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuaa) +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +//FRAGMENT vbuxx=pbuz1_derefidx_(pbuz2_derefidx_vbuaa)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuaa) +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tax +//FRAGMENT vbuyy=pbuz1_derefidx_(pbuz2_derefidx_vbuaa)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuaa) +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tay +//FRAGMENT vbuz1=pbuz2_derefidx_(pbuz3_derefidx_vbuxx)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuxx) +txa +tay +lda ({z5}),y +sta $ff +lda ({z3}),y +tay +lda ({z2}),y +ldy $ff +clc +adc ({z4}),y +sta {z1} +//FRAGMENT vbuaa=pbuz1_derefidx_(pbuz2_derefidx_vbuxx)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuxx) +txa +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +//FRAGMENT vbuxx=pbuz1_derefidx_(pbuz2_derefidx_vbuxx)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuxx) +txa +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tax +//FRAGMENT vbuyy=pbuz1_derefidx_(pbuz2_derefidx_vbuxx)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuxx) +txa +tay +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tay +//FRAGMENT vbuz1=pbuz2_derefidx_(pbuz3_derefidx_vbuyy)_plus_pbuz4_derefidx_(pbuz5_derefidx_vbuyy) +lda ({z5}),y +sta $ff +lda ({z3}),y +tay +lda ({z2}),y +ldy $ff +clc +adc ({z4}),y +sta {z1} +//FRAGMENT vbuaa=pbuz1_derefidx_(pbuz2_derefidx_vbuyy)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuyy) +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +//FRAGMENT vbuxx=pbuz1_derefidx_(pbuz2_derefidx_vbuyy)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuyy) +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tax +//FRAGMENT vbuyy=pbuz1_derefidx_(pbuz2_derefidx_vbuyy)_plus_pbuz3_derefidx_(pbuz4_derefidx_vbuyy) +lda ({z4}),y +sta $ff +lda ({z2}),y +tay +lda ({z1}),y +ldy $ff +clc +adc ({z3}),y +tay +//FRAGMENT vbuz1=vbuz1_bor_pbuc1_derefidx_vbuaa +tay +lda {c1},y +ora {z1} +sta {z1} +//FRAGMENT vbuxx=vbuxx_bor_pbuc1_derefidx_vbuaa +tay +txa +ora {c1},y +tax +//FRAGMENT vbuyy=vbuyy_bor_pbuc1_derefidx_vbuaa +tax +tya +ora {c1},x +tay +//FRAGMENT vbuz1=_hi_pvoz2 +lda {z2}+1 +sta {z1} +//FRAGMENT vbuz1=_lo_pvoz2 +lda {z2} +sta {z1} +//FRAGMENT vbuaa=_hi_pvoz1 +lda {z1}+1 +//FRAGMENT vbuxx=_hi_pvoz1 +ldx {z1}+1 +//FRAGMENT vbuaa=_lo_pvoz1 +lda {z1} +//FRAGMENT vbuxx=_lo_pvoz1 +ldx {z1} +//FRAGMENT vbuyy=_hi_pvoz1 +ldy {z1}+1 +//FRAGMENT vbuyy=_lo_pvoz1 +ldy {z1} +//FRAGMENT pwsc1_derefidx_vbuz1=pwsc1_derefidx_vbuz1_minus_vbuz2 +ldx {z1} +sec +lda {c1},x +sbc {z2} +sta {c1},x +bcs !+ +dec {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuz1=pwsc1_derefidx_vbuz1_minus_vbuxx +ldy {z1} +stx $ff +sec +lda {c1},y +sbc $ff +sta {c1},y +lda {c1}+1,y +sbc #0 +sta {c1},y +//FRAGMENT pwsc1_derefidx_vbuz1=pwsc1_derefidx_vbuz1_minus_vbuyy +tya +ldy {z1} +clc +sbc {c1},y +eor #$ff +sta {c1},y +bcc !+ +lda {c1}+1,y +sbc #$01 +sta {c1}+1,y +!: +//FRAGMENT pwsc1_derefidx_vbuaa=pwsc1_derefidx_vbuaa_minus_vbuz1 +tax +sec +lda {c1},x +sbc {z1} +sta {c1},x +bcs !+ +dec {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuaa=pwsc1_derefidx_vbuaa_minus_vbuxx +sec +stx $ff +tax +lda {c1},x +sbc $ff +sta {c1},x +bcs !+ +dec {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuaa=pwsc1_derefidx_vbuaa_minus_vbuyy +sec +sty $ff +tay +lda {c1},y +sbc $ff +sta {c1},y +lda {c1}+1,y +sbc #$00 +sta {c1}+1,y +//FRAGMENT pwsc1_derefidx_vbuxx=pwsc1_derefidx_vbuxx_minus_vbuz1 +sec +lda {c1},x +sbc {z1} +sta {c1},x +bcs !+ +dec {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuxx=pwsc1_derefidx_vbuxx_minus_vbuxx +txa +clc +sbc {c1},x +eor #$ff +sta {c1},x +bcc !+ +lda {c1}+1,x +sbc #$01 +sta {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuxx=pwsc1_derefidx_vbuxx_minus_vbuyy +tya +clc +sbc {c1},x +eor #$ff +sta {c1},x +bcc !+ +lda {c1}+1,x +sbc #$01 +sta {c1}+1,x +!: +//FRAGMENT pwsc1_derefidx_vbuyy=pwsc1_derefidx_vbuyy_minus_vbuz1 +sec +lda {c1},y +sbc {z1} +sta {c1},y +lda {c1}+1,y +sbc #0 +sta {c1}+1,y +//FRAGMENT pwsc1_derefidx_vbuyy=pwsc1_derefidx_vbuyy_minus_vbuxx +stx $ff +sec +lda {c1},y +sbc $ff +sta {c1},y +lda {c1}+1,y +sbc #0 +sta {c1},y +//FRAGMENT pwsc1_derefidx_vbuyy=pwsc1_derefidx_vbuyy_minus_vbuyy +tya +clc +sbc {c1},y +eor #$ff +sta {c1},y +bcc !+ +lda {c1}+1,y +sbc #$01 +sta {c1}+1,y +!: +//FRAGMENT vbuz1=_deref_pbuz2_ror_4 +ldy #0 +lda ({z2}),y +lsr +lsr +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=_deref_pbuz1_ror_4 +ldy #0 +lda ({z1}),y +lsr +lsr +lsr +lsr +//FRAGMENT vbuxx=_deref_pbuz1_ror_4 +ldy #0 +lda ({z1}),y +lsr +lsr +lsr +lsr +tax +//FRAGMENT vbuyy=_deref_pbuz1_ror_4 +ldy #0 +lda ({z1}),y +lsr +lsr +lsr +lsr +tay +//FRAGMENT vwsz1=_deref_pwsz2_minus__deref_pwsz3 +ldy #0 +sec +lda ({z2}),y +sbc ({z3}),y +sta {z1} +iny +lda ({z2}),y +sbc ({z3}),y +sta {z1}+1 +//FRAGMENT pbuz1_derefidx_vbuz2_eq_0_then_la1 +ldy {z2} +lda ({z1}),y + +cmp #0 +beq {la1} +//FRAGMENT pduc1_derefidx_vbuz1=pduc1_derefidx_vbuz1_plus_pduc2_derefidx_vbuz1 +ldy {z1} +clc +lda {c1},y +adc {c2},y +sta {c1},y +lda {c1}+1,y +adc {c2}+1,y +sta {c1}+1,y +lda {c1}+2,y +adc {c2}+2,y +sta {c1}+2,y +lda {c1}+3,y +adc {c2}+3,y +sta {c1}+3,y +//FRAGMENT pduc1_derefidx_vbuz1=pduc2_derefidx_vbuz1 +ldy {z1} +lda {c2},y +sta {c1},y +lda {c2}+1,y +sta {c1}+1,y +lda {c2}+2,y +sta {c1}+2,y +lda {c2}+3,y +sta {c1}+3,y +//FRAGMENT pbuz1_derefidx_vbuxx_eq_0_then_la1 +txa +tay +lda ({z1}),y + +cmp #0 +beq {la1} +//FRAGMENT pbuz1_derefidx_vbuyy_eq_0_then_la1 +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 +lda {c1},y +adc {c2},y +sta {c1},y +lda {c1}+1,y +adc {c2}+1,y +sta {c1}+1,y +lda {c1}+2,y +adc {c2}+2,y +sta {c1}+2,y +lda {c1}+3,y +adc {c2}+3,y +sta {c1}+3,y +//FRAGMENT pduc1_derefidx_vbuxx=pduc1_derefidx_vbuxx_plus_pduc2_derefidx_vbuxx +clc +lda {c1},x +adc {c2},x +sta {c1},x +lda {c1}+1,x +adc {c2}+1,x +sta {c1}+1,x +lda {c1}+2,x +adc {c2}+2,x +sta {c1}+2,x +lda {c1}+3,x +adc {c2}+3,x +sta {c1}+3,x +//FRAGMENT pduc1_derefidx_vbuyy=pduc1_derefidx_vbuyy_plus_pduc2_derefidx_vbuyy +clc +lda {c1},y +adc {c2},y +sta {c1},y +lda {c1}+1,y +adc {c2}+1,y +sta {c1}+1,y +lda {c1}+2,y +adc {c2}+2,y +sta {c1}+2,y +lda {c1}+3,y +adc {c2}+3,y +sta {c1}+3,y +//FRAGMENT pptc1_derefidx_vbuaa=pbuz1 +tay +lda {z1} +sta {c1},y +lda {z1}+1 +sta {c1}+1,y +//FRAGMENT pduc1_derefidx_vbuaa=pduc2_derefidx_vbuaa +tay +lda {c2},y +sta {c1},y +lda {c2}+1,y +sta {c1}+1,y +lda {c2}+2,y +sta {c1}+2,y +lda {c2}+3,y +sta {c1}+3,y +//FRAGMENT pduc1_derefidx_vbuxx=pduc2_derefidx_vbuxx +lda {c2},x +sta {c1},x +lda {c2}+1,x +sta {c1}+1,x +lda {c2}+2,x +sta {c1}+2,x +lda {c2}+3,x +sta {c1}+3,x +//FRAGMENT pduc1_derefidx_vbuyy=pduc2_derefidx_vbuyy +lda {c2},y +sta {c1},y +lda {c2}+1,y +sta {c1}+1,y +lda {c2}+2,y +sta {c1}+2,y +lda {c2}+3,y +sta {c1}+3,y +//FRAGMENT vdsz1_eq_vdsz2_then_la1 +lda {z1} +cmp {z2} +bne !+ +lda {z1}+1 +cmp {z2}+1 +bne !+ +lda {z1}+2 +cmp {z2}+2 +bne !+ +lda {z1}+3 +cmp {z2}+3 +beq {la1} +!: +//FRAGMENT vdsz1=vdsz1_plus_vwsz2 +lda {z2}+1 +ora #$7f +bmi !+ +lda #0 +!: +sta $ff +lda {z1} +clc +adc {z2} +sta {z1} +lda {z1}+1 +adc {z2}+1 +sta {z1}+1 +lda {z1}+2 +adc $ff +sta {z1}+2 +lda {z1}+3 +adc $ff +sta {z1}+3 +//FRAGMENT vdsz1=vdsz1_minus_vwsz2 +lda {z2}+1 +ora #$7f +bmi !+ +lda #0 +!: +sta $ff +sec +lda {z1} +sbc {z2} +sta {z1} +lda {z1}+1 +sbc {z2}+1 +sta {z1}+1 +lda {z1}+2 +sbc $ff +sta {z1}+2 +lda {z1}+3 +sbc $ff +sta {z1}+3 +//FRAGMENT vwsz1=_dec_vwsz1 +lda {z1} +bne !+ +dec {z1}+1 +!: +dec {z1} +//FRAGMENT vduz1_eq_vduz2_then_la1 +lda {z1} +cmp {z2} +bne !+ +lda {z1}+1 +cmp {z2}+1 +bne !+ +lda {z1}+2 +cmp {z2}+2 +bne !+ +lda {z1}+3 +cmp {z2}+3 +beq {la1} +!: +//FRAGMENT vbuz1=vbuz2_plus__deref_pbuc1 +lda {c1} +clc +adc {z2} +sta {z1} +//FRAGMENT vbuaa=vbuz1_plus__deref_pbuc1 +lda {c1} +clc +adc {z1} +//FRAGMENT vbuxx=vbuz1_plus__deref_pbuc1 +lda {c1} +clc +adc {z1} +tax +//FRAGMENT vbuyy=vbuz1_plus__deref_pbuc1 +lda {c1} +clc +adc {z1} +tay +//FRAGMENT vbuz1=vbuaa_plus__deref_pbuc1 +clc +adc {c1} +sta {z1} +//FRAGMENT vbuaa=vbuaa_plus__deref_pbuc1 +clc +adc {c1} +//FRAGMENT vbuxx=vbuaa_plus__deref_pbuc1 +clc +adc {c1} +tax +//FRAGMENT vbuyy=vbuaa_plus__deref_pbuc1 +clc +adc {c1} +tay +//FRAGMENT vbuz1=vbuxx_plus__deref_pbuc1 +txa +clc +adc {c1} +sta {z1} +//FRAGMENT vbuaa=vbuxx_plus__deref_pbuc1 +txa +clc +adc {c1} +//FRAGMENT vbuxx=vbuxx_plus__deref_pbuc1 +txa +clc +adc {c1} +tax +//FRAGMENT vbuyy=vbuxx_plus__deref_pbuc1 +txa +clc +adc {c1} +tay +//FRAGMENT vbuz1=vbuyy_plus__deref_pbuc1 +tya +clc +adc {c1} +sta {z1} +//FRAGMENT vbuaa=vbuyy_plus__deref_pbuc1 +tya +clc +adc {c1} +//FRAGMENT vbuxx=vbuyy_plus__deref_pbuc1 +tya +clc +adc {c1} +tax +//FRAGMENT vbuyy=vbuyy_plus__deref_pbuc1 +tya +clc +adc {c1} +tay +//FRAGMENT vbuz1=vbuz1_minus_1 +dec {z1} +//FRAGMENT vbuyy=vbuyy_minus_1 +tya +tay +dey +//FRAGMENT vwuz1=vwuz2_rol_5 +lda {z2} +asl +sta {z1} +lda {z2}+1 +rol +sta {z1}+1 +asl {z1} +rol {z1}+1 +asl {z1} +rol {z1}+1 +asl {z1} +rol {z1}+1 +asl {z1} +rol {z1}+1 +//FRAGMENT vwuz1=vwuz1_rol_5 +asl {z1} +rol {z1}+1 +asl {z1} +rol {z1}+1 +asl {z1} +rol {z1}+1 +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 diff --git a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraph.java b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraph.java index fe829aa80..320b7148d 100644 --- a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraph.java +++ b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraph.java @@ -9,7 +9,7 @@ import dk.camelot64.kickc.model.values.LabelRef; import dk.camelot64.kickc.model.values.ProcedureRef; import dk.camelot64.kickc.model.values.ScopeRef; import dk.camelot64.kickc.model.values.SymbolRef; -import dk.camelot64.kickc.passes.Pass2ConstantIdentification; +import dk.camelot64.kickc.passes.utils.ProcedureUtils; import java.io.Serializable; import java.util.*; @@ -45,7 +45,7 @@ public class ControlFlowGraph implements Serializable { } public List getAllBlocks() { - return blocks; + return blocks; } public void setAllBlocks(List blocks) { @@ -109,8 +109,8 @@ public class ControlFlowGraph implements Serializable { } public void setSequence(List sequence) { - if(sequence.size()!=blocks.size()) { - throw new CompileError("ERROR! Sequence does not contain all blocks from the program. Sequence: "+sequence.size()+" Blocks: "+blocks.size()); + if(sequence.size() != blocks.size()) { + throw new CompileError("ERROR! Sequence does not contain all blocks from the program. Sequence: " + sequence.size() + " Blocks: " + blocks.size()); } this.sequence = sequence; ArrayList seqBlocks = new ArrayList<>(); @@ -144,29 +144,26 @@ public class ControlFlowGraph implements Serializable { /** * Get all blocks that are program entry points. * This is the start-block and any blocks referenced by the address-off operator (&) + * * @param program The program * @return All entry-point blocks */ public List getEntryPointBlocks(Program program) { List entryPointBlocks = new ArrayList<>(); for(Procedure procedure : program.getScope().getAllProcedures(true)) { - if(Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), program) || Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) { + if(ProcedureUtils.isEntrypoint(procedure.getRef(), program) || Procedure.CallingConvention.STACK_CALL.equals(procedure.getCallingConvention())) { // Address-of is used on the procedure Label procedureLabel = procedure.getLabel(); ControlFlowBlock procedureBlock = getBlock(procedureLabel.getRef()); entryPointBlocks.add(procedureBlock); } } - final ProcedureRef startProcedure = program.getStartProcedure(); - final ControlFlowBlock startBlock = getBlock(startProcedure.getLabelRef()); - if(startBlock != null && !entryPointBlocks.contains(startBlock)) { - entryPointBlocks.add(startBlock); - } return entryPointBlocks; } /** * Get all called procedures in the graph + * * @return All called procedures */ public Set getAllCalledProcedures() { @@ -219,7 +216,7 @@ public class ControlFlowGraph implements Serializable { public Statement getStatementByIndex(int statementIdx) { for(ControlFlowBlock block : getAllBlocks()) { for(Statement statement : block.getStatements()) { - if(statement.getIndex()!=null && statementIdx == statement.getIndex()) { + if(statement.getIndex() != null && statementIdx == statement.getIndex()) { return statement; } } @@ -245,20 +242,22 @@ public class ControlFlowGraph implements Serializable { /** * Get information about the size of the program + * * @return Size information */ public String getSizeInfo() { StringBuilder sizeInfo = new StringBuilder(); - sizeInfo.append("SIZE blocks "+ getAllBlocks().size()).append("\n"); + sizeInfo.append("SIZE blocks " + getAllBlocks().size()).append("\n"); int numStmt = getAllBlocks().stream().mapToInt(block -> block.getStatements().size()).sum(); - sizeInfo.append("SIZE statements "+ numStmt).append("\n"); - int numPhiVars = getAllBlocks().stream().mapToInt(value -> value.getStatements().stream().mapToInt(value1 -> (value1 instanceof StatementPhiBlock)?((StatementPhiBlock) value1).getPhiVariables().size():0).sum()).sum(); - sizeInfo.append("SIZE phi variables "+ numPhiVars).append("\n"); + sizeInfo.append("SIZE statements " + numStmt).append("\n"); + int numPhiVars = getAllBlocks().stream().mapToInt(value -> value.getStatements().stream().mapToInt(value1 -> (value1 instanceof StatementPhiBlock) ? ((StatementPhiBlock) value1).getPhiVariables().size() : 0).sum()).sum(); + sizeInfo.append("SIZE phi variables " + numPhiVars).append("\n"); return sizeInfo.toString(); } /** * Get all statements executed between two statements (none of these are included in the result) + * * @param from The statement to start at * @param to The statement to end at * @return All statements executed between the two passed statements @@ -272,6 +271,7 @@ public class ControlFlowGraph implements Serializable { /** * Fill the between collection with all statements executed between two statements (none of these are included in the result) + * * @param from The statement to start at * @param to The statement to end at * @param between The between collection diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index 4b24007a6..a1510b4cc 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -985,8 +985,11 @@ public class Pass0GenerateStatementSequence extends KickCParserBaseVisitor comments = ensureUnusedComments(declComments); + Statement initStmt = new StatementAssignment(variable.getVariableRef(), initValue, true, statementSource, comments); addStatement(initStmt); + // Add comments to variable + variable.setComments(comments); } if(initializer != null) PrePostModifierHandler.addPostModifiers(this, initializer, statementSource); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUncalledProcedures.java b/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUncalledProcedures.java index c093fae25..3c1d8e943 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUncalledProcedures.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1EliminateUncalledProcedures.java @@ -4,6 +4,7 @@ import dk.camelot64.kickc.model.ControlFlowBlock; import dk.camelot64.kickc.model.Program; import dk.camelot64.kickc.model.symbols.Procedure; import dk.camelot64.kickc.model.values.ProcedureRef; +import dk.camelot64.kickc.passes.utils.ProcedureUtils; import java.util.Collection; import java.util.LinkedHashSet; @@ -20,17 +21,15 @@ public class Pass1EliminateUncalledProcedures extends Pass1Base { @Override public boolean step() { Set calledProcedures = getGraph().getAllCalledProcedures(); - calledProcedures.add(getProgram().getStartProcedure()); + //calledProcedures.add(getProgram().getStartProcedure()); Set unusedProcedures = new LinkedHashSet<>(); Collection allProcedures = getProgram().getScope().getAllProcedures(true); - for(Procedure procedure : allProcedures) { - // TODO Also look at kickasm/asm uses! (Maybe also look at some directive like "export" ) - if(!calledProcedures.contains(procedure.getRef()) && !Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), getProgram())) { - // The procedure is not used - mark for removal! - unusedProcedures.add(procedure.getRef()); - } - } + for(Procedure procedure : allProcedures) + if(!ProcedureUtils.isEntrypoint(procedure.getRef(), getProgram())) + if(!calledProcedures.contains(procedure.getRef())) + // The procedure is not used - mark for removal! + unusedProcedures.add(procedure.getRef()); for(ProcedureRef unusedProcedure : unusedProcedures) { removeProcedure(getProgram(), unusedProcedure); @@ -41,6 +40,7 @@ public class Pass1EliminateUncalledProcedures extends Pass1Base { /** * Removed a procedure from the program (the symbol in the symbol table and all blocks in the control flow graph) + * * @param program The program * @param procedureRef The procedure to be removed */ diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateSingleStaticAssignmentForm.java b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateSingleStaticAssignmentForm.java index 4cb147632..51a95801f 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateSingleStaticAssignmentForm.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateSingleStaticAssignmentForm.java @@ -258,7 +258,6 @@ public class Pass1GenerateSingleStaticAssignmentForm extends Pass1Base { if(symbol instanceof Procedure) { Procedure procedure = (Procedure) symbol; if(procedure.getInterruptType() != null || Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), program)) { - final ControlFlowBlock startBlock = program.getGraph().getBlock(program.getStartProcedure().getLabelRef()); // Find all root-level predecessors to the main block ControlFlowBlock mainBlock = program.getGraph().getBlock(new LabelRef(SymbolRef.MAIN_PROC_NAME)); List mainPredecessors = program.getGraph().getPredecessors(mainBlock); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index b7c9433a4..4ad299ca4 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -87,7 +87,6 @@ public class Pass4CodeGeneration { linkScriptBody = linkScriptBody.replace("%_O", outputFileName.toLowerCase()); linkScriptBody = linkScriptBody.replace("%^O", outputFileName.toUpperCase()); String entryName = program.getStartProcedure().getFullName(); - ; linkScriptBody = linkScriptBody.replace("%E", entryName); Number programPc = program.getProgramPc(); if(programPc == null) programPc = 0x080d; diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java b/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java index 085dfc83a..4c163ee71 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4MemoryCoalesce.java @@ -7,6 +7,7 @@ import dk.camelot64.kickc.model.values.ProcedureRef; import dk.camelot64.kickc.model.values.ScopeRef; import dk.camelot64.kickc.model.values.SymbolRef; import dk.camelot64.kickc.model.values.VariableRef; +import dk.camelot64.kickc.passes.utils.ProcedureUtils; import java.util.ArrayList; import java.util.Collection; @@ -32,22 +33,9 @@ public abstract class Pass4MemoryCoalesce extends Pass2Base { public static Collection getThreadHeads(Program program) { ArrayList threadHeads = new ArrayList<>(); Collection procedures = program.getScope().getAllProcedures(true); - for(Procedure procedure : procedures) { - if(procedure.getRef().equals(program.getStartProcedure())) { - // TODO: Handles main() correctly? + for(Procedure procedure : procedures) + if(ProcedureUtils.isEntrypoint(procedure.getRef(), program)) threadHeads.add(procedure.getRef()); - continue; - } - if(Pass2ConstantIdentification.isAddressOfUsed(procedure.getRef(), program)) { - threadHeads.add(procedure.getRef()); - continue; - } - if(procedure.getInterruptType()!=null) { - // TODO: Handles Interrupts correctly? - threadHeads.add(procedure.getRef()); - continue; - } - } return threadHeads; } diff --git a/src/main/java/dk/camelot64/kickc/passes/PassNEliminateEmptyProcedure.java b/src/main/java/dk/camelot64/kickc/passes/PassNEliminateEmptyProcedure.java index b5e078023..897ca8247 100644 --- a/src/main/java/dk/camelot64/kickc/passes/PassNEliminateEmptyProcedure.java +++ b/src/main/java/dk/camelot64/kickc/passes/PassNEliminateEmptyProcedure.java @@ -10,6 +10,7 @@ import dk.camelot64.kickc.model.symbols.Scope; import dk.camelot64.kickc.model.symbols.Symbol; import dk.camelot64.kickc.model.symbols.Variable; import dk.camelot64.kickc.model.values.ProcedureRef; +import dk.camelot64.kickc.model.values.SymbolRef; import dk.camelot64.kickc.model.values.SymbolVariableRef; import java.util.Collection; @@ -30,7 +31,8 @@ public class PassNEliminateEmptyProcedure extends Pass2SsaOptimization { boolean optimized = false; for(Procedure procedure : allProcedures) { if(hasEmptyBody(procedure.getRef())) { - if(!hasExternalUsages(procedure.getRef(), getProgram())) { + if(!hasExternalUsages(procedure.getRef(), getProgram()) && !SymbolRef.MAIN_PROC_NAME.equals(procedure.getLabel().getLocalName())) { + // TODO: Entry point procedures include isAddressOfUsed! // Remove all calls removeAllCalls(procedure.getRef()); // Remove the procedure diff --git a/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcLiveRangesEffectiveCallPaths.java b/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcLiveRangesEffectiveCallPaths.java index 93c091832..7f934a1b5 100644 --- a/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcLiveRangesEffectiveCallPaths.java +++ b/src/main/java/dk/camelot64/kickc/passes/calcs/PassNCalcLiveRangesEffectiveCallPaths.java @@ -11,6 +11,7 @@ import dk.camelot64.kickc.model.symbols.Variable; import dk.camelot64.kickc.model.values.*; import dk.camelot64.kickc.passes.Pass2AliasElimination; import dk.camelot64.kickc.passes.Pass2ConstantIdentification; +import dk.camelot64.kickc.passes.utils.ProcedureUtils; import java.util.*; @@ -69,8 +70,7 @@ public class PassNCalcLiveRangesEffectiveCallPaths extends PassNCalcBase rootPath = new ArrayList<>(); ArrayList rootAlive = new ArrayList<>(); diff --git a/src/main/java/dk/camelot64/kickc/passes/utils/ProcedureUtils.java b/src/main/java/dk/camelot64/kickc/passes/utils/ProcedureUtils.java new file mode 100644 index 000000000..e47f283fc --- /dev/null +++ b/src/main/java/dk/camelot64/kickc/passes/utils/ProcedureUtils.java @@ -0,0 +1,34 @@ +package dk.camelot64.kickc.passes.utils; + +import dk.camelot64.kickc.model.Program; +import dk.camelot64.kickc.model.symbols.Procedure; +import dk.camelot64.kickc.model.values.ProcedureRef; +import dk.camelot64.kickc.passes.Pass2ConstantIdentification; + +public class ProcedureUtils { + + /** + * Determines if a procedure is an entry point. + * Entry points are: + * - the starting procedure (typically main()) + * - interrupts + * - any procedure where address-of is used in the code. + * TODO: Should all stack call procedures be included (probably no!) + * TODO: Also look at kickasm/asm uses! (Maybe also look at some directive like "export" ) + * + * @param procedure The procedure to examine + * @param program The program + * @return true if the procedure is an entry point + */ + public static boolean isEntrypoint(ProcedureRef procedureRef, Program program) { + if(procedureRef.equals(program.getStartProcedure())) + return true; + final Procedure procedure = program.getScope().getProcedure(procedureRef); + if(procedure.getInterruptType()!=null) + return true; + if(Pass2ConstantIdentification.isAddressOfUsed(procedureRef, program)) + return true; + return false; + } + +} diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 972c4c95d..b811abd3d 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -42,6 +42,21 @@ public class TestPrograms { public TestPrograms() { } + @Test + public void testEmptyFunction2() throws IOException, URISyntaxException { + compileAndCompare("empty-function-2.c"); + } + + @Test + public void testEmptyFunction1() throws IOException, URISyntaxException { + compileAndCompare("empty-function-1.c"); + } + + @Test + public void testEmptyFunction0() throws IOException, URISyntaxException { + compileAndCompare("empty-function-0.c"); + } + @Test public void testStaticInitCode2() throws IOException, URISyntaxException { compileAndCompare("static-init-code-2.c"); @@ -1240,7 +1255,7 @@ public class TestPrograms { @Test public void testInnerIncrementProblem() throws IOException, URISyntaxException { - compileAndCompare("inner-increment-problem.c"); + compileAndCompare("inner-increment-problem.c", log()); } @Test @@ -3045,6 +3060,11 @@ public class TestPrograms { compileAndCompare("string-const-consolidation.c"); } + @Test + public void testCommentsGlobalInit() throws IOException, URISyntaxException { + compileAndCompare("test-comments-global.c"); + } + @Test public void testCommentsBlock() throws IOException, URISyntaxException { compileAndCompare("test-comments-block.c"); diff --git a/src/test/kc/empty-function-0.c b/src/test/kc/empty-function-0.c new file mode 100644 index 000000000..457d53ed3 --- /dev/null +++ b/src/test/kc/empty-function-0.c @@ -0,0 +1,14 @@ +// Test removal of empty function + +char v; + +char * const SCREEN = 0x0400; + +void main() { + set(); + SCREEN[0] = v; +} + +void set() { + v = 7; +} \ No newline at end of file diff --git a/src/test/kc/empty-function-1.c b/src/test/kc/empty-function-1.c new file mode 100644 index 000000000..77ce0f664 --- /dev/null +++ b/src/test/kc/empty-function-1.c @@ -0,0 +1,11 @@ +// Test removal of empty function + +char * const SCREEN = 0x0400; + +void main() { + empty(); + SCREEN[0] = 'x'; +} + +void empty() { +} \ No newline at end of file diff --git a/src/test/kc/empty-function-2.c b/src/test/kc/empty-function-2.c new file mode 100644 index 000000000..238f37b72 --- /dev/null +++ b/src/test/kc/empty-function-2.c @@ -0,0 +1,9 @@ +// Test removal of empty function +// main() should not be removed! + +void main() { + empty(); +} + +void empty() { +} \ No newline at end of file diff --git a/src/test/kc/struct-ptr-25.c b/src/test/kc/struct-ptr-25.c index 8608e7177..df13301c8 100644 --- a/src/test/kc/struct-ptr-25.c +++ b/src/test/kc/struct-ptr-25.c @@ -1,10 +1,14 @@ -char *fileCur; -char *fileTop; -char *filesEnd; -char *file; +char *fileCur = 0x1005; +char *fileTop = 0x1010; +char *filesEnd = 0x1010; +char *file = 0x1000; + +char * const SCREEN = 0x0400; void main(void) { if (fileTop == filesEnd) --fileTop; if (file <= fileCur) --fileCur; if (fileCur < fileTop) fileCur = fileTop; + + SCREEN[0] = *fileCur; } diff --git a/src/test/kc/test-comments-global.c b/src/test/kc/test-comments-global.c new file mode 100644 index 000000000..20c89f752 --- /dev/null +++ b/src/test/kc/test-comments-global.c @@ -0,0 +1,13 @@ +// Tests that global variables with initializer gets their comments + +// The screen (should become a var-comment in ASM) +__ma char * screen = 0x0400; + +// The program entry point +void main() { + // Put 'a' in screen + *screen = 'a'; + screen++; + // Put another 'a' in screen + *screen = 'a'; +} diff --git a/src/test/ref/address-2.asm b/src/test/ref/address-2.asm index 18c837f80..fb9cc5369 100644 --- a/src/test/ref/address-2.asm +++ b/src/test/ref/address-2.asm @@ -1,16 +1,17 @@ // Test that address vars are turned into load/store and located at hardcoded addresses // Hard-coded mainmem-page address - global variable .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label i = $2000 -__bbegin: - // i = 3 - lda #3 - sta i - jsr main - rts +_start: { + // i = 3 + lda #3 + sta i + jsr main + rts +} main: { __b1: // while(i<7) diff --git a/src/test/ref/address-5.asm b/src/test/ref/address-5.asm index 884039667..c75328192 100644 --- a/src/test/ref/address-5.asm +++ b/src/test/ref/address-5.asm @@ -1,16 +1,17 @@ // Test declaring a variable as at a hard-coded address // zero-page hard-coded address parameter .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = 3 -__bbegin: - // idx - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx + lda #0 + sta.z idx + jsr main + rts +} main: { // print('c') lda #'c' diff --git a/src/test/ref/address-6.asm b/src/test/ref/address-6.asm index 5926eec11..3b4b30c14 100644 --- a/src/test/ref/address-6.asm +++ b/src/test/ref/address-6.asm @@ -1,16 +1,17 @@ // Test declaring a variable as at a hard-coded address // mainmem-page hard-coded address parameter .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = $3000 -__bbegin: - // idx - lda #0 - sta idx - jsr main - rts +_start: { + // idx + lda #0 + sta idx + jsr main + rts +} main: { // print('c') lda #'c' diff --git a/src/test/ref/address-of-2.asm b/src/test/ref/address-of-2.asm index 3115a68e2..abcc461c2 100644 --- a/src/test/ref/address-of-2.asm +++ b/src/test/ref/address-of-2.asm @@ -1,18 +1,20 @@ // Test address-of by assigning the affected variable in multiple ways .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label val = 2 -__bbegin: - // val = 0 - lda #0 - sta.z val - jsr main - rts +_start: { + // val = 0 + lda #0 + sta.z val + jsr main + rts +} main: { .label SCREEN1 = $400 .label SCREEN2 = SCREEN1+$28 // Use address-of - hereafter all versions of val must be in the same memory + // Use address-of - hereafter all versions of val must be in the same memory .label ptr = val // SCREEN1[idx] = val lda.z val diff --git a/src/test/ref/arrays-init-kasm-1.asm b/src/test/ref/arrays-init-kasm-1.asm new file mode 100644 index 000000000..f0e17f3b9 --- /dev/null +++ b/src/test/ref/arrays-init-kasm-1.asm @@ -0,0 +1,18 @@ +// Test initializing array using KickAssembler +// Place array at hardcoded address +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label SCREEN = $400 +main: { + // SCREEN[0] = SINTAB[0] + lda SINTAB + sta SCREEN + // } + rts +} +.pc = $1000 "SINTAB" +// Sinus table at an absolute address in memory +SINTAB: +.fill 256, 128 + 128*sin(i*2*PI/256) + diff --git a/src/test/ref/asm-uses-0.asm b/src/test/ref/asm-uses-0.asm index 717358029..c70ad47a5 100644 --- a/src/test/ref/asm-uses-0.asm +++ b/src/test/ref/asm-uses-0.asm @@ -3,12 +3,6 @@ :BasicUpstart(main) .pc = $80d "Program" .label BG_COLOR = $d020 -main: { - // asm - jsr init - // } - rts -} // Function only used inside the inline asm init: { // *BG_COLOR = 0 @@ -17,3 +11,9 @@ init: { // } rts } +main: { + // asm + jsr init + // } + rts +} diff --git a/src/test/ref/atoi-1.asm b/src/test/ref/atoi-1.asm index 24ceb245e..a0b287e61 100644 --- a/src/test/ref/atoi-1.asm +++ b/src/test/ref/atoi-1.asm @@ -1,6 +1,6 @@ // Test atoi() .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -9,33 +9,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = 9 - .label conio_cursor_y = $a - .label conio_line_text = $b - .label conio_line_color = $d -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 9 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $a // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $b // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $d +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/bitmap-line-anim-1.asm b/src/test/ref/bitmap-line-anim-1.asm index 8336a31be..0327938e4 100644 --- a/src/test/ref/bitmap-line-anim-1.asm +++ b/src/test/ref/bitmap-line-anim-1.asm @@ -12,7 +12,7 @@ .label VIC_MEMORY = $d018 .label SCREEN = $400 .label BITMAP = $2000 - .label next = 2 + .label next = 5 main: { // *BORDER_COLOR = 0 lda #0 @@ -89,13 +89,13 @@ bitmap_line: { jsr bitmap_line_xdyi rts } -// bitmap_line_xdyi(byte zp(3) x, byte zp(4) y, byte zp($b) x1, byte zp(6) xd) +// bitmap_line_xdyi(byte zp(2) x, byte zp(3) y, byte zp(6) x1, byte zp($b) xd) bitmap_line_xdyi: { - .label x1 = $b - .label xd = 6 - .label x = 3 - .label e = 5 - .label y = 4 + .label x1 = 6 + .label xd = $b + .label x = 2 + .label e = 4 + .label y = 3 lda #bitmap_line.y1>>1 sta.z e lda #bitmap_line.y0 @@ -136,6 +136,7 @@ bitmap_line_xdyi: { } // bitmap_plot(byte register(X) x, byte register(Y) y) bitmap_plot: { + // Needs unsigned int arrays arranged as two underlying char arrays to allow char* plotter_x = plot_x[x]; - and eventually - char* plotter = plot_x[x] + plot_y[y]; .label plotter_x = 7 .label plotter_y = 9 .label plotter = 7 @@ -166,12 +167,12 @@ bitmap_plot: { // } rts } -// bitmap_line_ydxi(byte zp(4) y, byte zp(3) x, byte zp(6) xd) +// bitmap_line_ydxi(byte zp(3) y, byte zp(2) x, byte zp(6) xd) bitmap_line_ydxi: { .label xd = 6 - .label e = 5 - .label y = 4 - .label x = 3 + .label e = 4 + .label y = 3 + .label x = 2 // e = xd>>1 lda.z xd lsr @@ -210,12 +211,12 @@ bitmap_line_ydxi: { // } rts } -// bitmap_line_xdyd(byte zp(3) x, byte zp(4) y, byte zp(6) xd) +// bitmap_line_xdyd(byte zp(2) x, byte zp(3) y, byte zp(6) xd) bitmap_line_xdyd: { - .label x = 3 + .label x = 2 .label xd = 6 - .label e = 5 - .label y = 4 + .label e = 4 + .label y = 3 lda #bitmap_line.y1>>1 sta.z e lda #bitmap_line.y1 @@ -250,12 +251,12 @@ bitmap_line_xdyd: { // } rts } -// bitmap_line_ydxd(byte zp(4) y, byte zp(3) x, byte zp(6) xd) +// bitmap_line_ydxd(byte zp(3) y, byte zp(2) x, byte zp(6) xd) bitmap_line_ydxd: { .label xd = 6 - .label e = 5 - .label y = 4 - .label x = 3 + .label e = 4 + .label y = 3 + .label x = 2 // e = xd>>1 lda.z xd lsr @@ -325,7 +326,7 @@ init_screen: { // Clear all graphics on the bitmap bitmap_clear: { .label bitmap = 7 - .label y = 6 + .label y = 5 // bitmap = (char*) { bitmap_plot_xhi[0], bitmap_plot_xlo[0] } lda bitmap_plot_xlo sta.z bitmap diff --git a/src/test/ref/bitmap-line-anim-2.asm b/src/test/ref/bitmap-line-anim-2.asm index 06aef3b66..e59088262 100644 --- a/src/test/ref/bitmap-line-anim-2.asm +++ b/src/test/ref/bitmap-line-anim-2.asm @@ -14,7 +14,7 @@ .label VIC_MEMORY = $d018 .label SCREEN = $400 .label BITMAP = $2000 - .label next = 2 + .label next = $a main: { // *BORDER_COLOR = 0 lda #0 @@ -55,7 +55,7 @@ main: { jmp __b1 } // Draw a line on the bitmap using bresenhams algorithm -// bitmap_line(word zp(2) x2) +// bitmap_line(word zp($a) x2) bitmap_line: { .const x1 = 0 .const y1 = 0 @@ -64,11 +64,13 @@ bitmap_line: { .label dy = 8 .label sx = $12 .label sy = 6 + // X is the driver .label e1 = 4 - .label e = $a - .label y = $e - .label x = $c - .label x2 = 2 + // Y is the driver + .label e = $c + .label y = 2 + .label x = $e + .label x2 = $a // abs_u16(x2-x1) lda.z x2 sta.z abs_u16.w @@ -287,11 +289,11 @@ bitmap_line: { rts } // Plot a single dot in the bitmap -// bitmap_plot(word zp($c) x, byte register(X) y) +// bitmap_plot(word zp($e) x, byte register(X) y) bitmap_plot: { .label __0 = $16 .label plotter = $14 - .label x = $c + .label x = $e // plotter = (char*) { bitmap_plot_yhi[y], bitmap_plot_ylo[y] } lda bitmap_plot_yhi,x sta.z plotter+1 diff --git a/src/test/ref/bitmap-plot-0.asm b/src/test/ref/bitmap-plot-0.asm index 0d2085cb6..777878ebd 100644 --- a/src/test/ref/bitmap-plot-0.asm +++ b/src/test/ref/bitmap-plot-0.asm @@ -4,7 +4,7 @@ // The MOS 6526 Complex Interface Adapter (CIA) // http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -40,14 +40,15 @@ .label HARDWARE_IRQ = $fffe .label BITMAP = $2000 .label SCREEN = $400 - .label frame_cnt = 8 -__bbegin: - // frame_cnt = 1 // Counts frames - updated by the IRQ - lda #1 - sta.z frame_cnt - jsr main - rts + .label frame_cnt = 8 +_start: { + // frame_cnt = 1 + lda #1 + sta.z frame_cnt + jsr main + rts +} main: { .const toD0181_return = (>(SCREEN&$3fff)*4)|(>BITMAP)/4&$f .label x = 2 diff --git a/src/test/ref/bitmap-plot-1.asm b/src/test/ref/bitmap-plot-1.asm index e0a35a02d..d8d3e0245 100644 --- a/src/test/ref/bitmap-plot-1.asm +++ b/src/test/ref/bitmap-plot-1.asm @@ -4,7 +4,7 @@ // The MOS 6526 Complex Interface Adapter (CIA) // http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -47,16 +47,17 @@ .label HARDWARE_IRQ = $fffe .label BITMAP = $2000 .label SCREEN = $400 + // Counts frames - updated by the IRQ .label frame_cnt = $16 // Remainder after unsigned 16-bit division - .label rem16u = $14 -__bbegin: - // frame_cnt = 1 - // Counts frames - updated by the IRQ - lda #1 - sta.z frame_cnt - jsr main - rts + .label rem16u = $2e +_start: { + // frame_cnt = 1 + lda #1 + sta.z frame_cnt + jsr main + rts +} main: { .const toD0181_return = (>(SCREEN&$3fff)*4)|(>BITMAP)/4&$f .label __6 = 8 @@ -596,10 +597,14 @@ sin16s_gen2: { .label wavelength = $200 .label __6 = 8 .label __8 = $24 + // ampl is always positive so shifting left does not alter the sign + // u[4.28] step = PI*2/wavelength .label step = $20 .label sintab = $19 // u[4.28] // Iterate over the table + // u[4.28] + // Iterate over the table .label x = $c .label i = $17 // div32u16u(PI2_u4f28, wavelength) @@ -700,14 +705,23 @@ sin16s: { .label __4 = $26 .label x = $10 .label return = $1b + // sinx = x - x^3/6 + x5/128; .label x1 = $2a + // u[1.15] .label x2 = $14 + // u[2.14] x^2 .label x3 = $14 + // u[2.14] x^3 .label x3_6 = $2c + // u[1.15] x^3/6; .label usinx = $1b + // u[1.15] x - x^3/6 .label x4 = $14 + // u[3.13] x^4 .label x5 = $2c + // u[4.12] x^5 .label x5_128 = $2c + // u[1.15] (first bit is always zero) .label sinx = $1b // if(x >= PI_u4f28 ) lda.z x+3 @@ -962,6 +976,10 @@ div32u16u: { lda.z divr16u.return+1 sta.z quotient_hi+1 // divr16u(PI2_u4f28&$ffff @@ -1045,6 +1063,10 @@ divr16u: { cpx #$10 bne __b1 // rem16u = rem + lda.z rem + sta.z rem16u + lda.z rem+1 + sta.z rem16u+1 // } rts } diff --git a/src/test/ref/bitmap-plot-2.asm b/src/test/ref/bitmap-plot-2.asm index dae48c2c0..b151bed0a 100644 --- a/src/test/ref/bitmap-plot-2.asm +++ b/src/test/ref/bitmap-plot-2.asm @@ -4,7 +4,7 @@ // The MOS 6526 Complex Interface Adapter (CIA) // http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -48,30 +48,31 @@ .label HARDWARE_IRQ = $fffe .label BITMAP = $2000 .label SCREEN = $400 - .label frame_cnt = $1b - // Remainder after unsigned 16-bit division - .label rem16u = $19 -__bbegin: - // frame_cnt = 1 // Counts frames - updated by the IRQ - lda #1 - sta.z frame_cnt - jsr main - rts + .label frame_cnt = $19 + // Remainder after unsigned 16-bit division + .label rem16u = $2f +_start: { + // frame_cnt = 1 + lda #1 + sta.z frame_cnt + jsr main + rts +} main: { .const toD0181_return = (>(SCREEN&$3fff)*4)|(>BITMAP)/4&$f - .label __7 = $1c - .label __11 = $1e + .label __7 = $1a + .label __11 = $1c .label __26 = 9 .label __27 = 9 - .label __28 = $1c - .label __29 = $1e + .label __28 = $1a + .label __29 = $1c .label cos_x = 9 .label xpos = $b - .label x = $1c + .label x = $1a .label sin_y = 9 .label ypos = $b - .label y = $1e + .label y = $1c .label idx_x = 2 .label idx_y = 6 .label r = 4 @@ -283,11 +284,11 @@ main: { jmp __b7 } // Plot a single dot in the bitmap -// bitmap_plot(word zp($1c) x, byte register(A) y) +// bitmap_plot(word zp($1a) x, byte register(A) y) bitmap_plot: { - .label __0 = $2b + .label __0 = $1e .label plotter = $25 - .label x = $1c + .label x = $1a // plotter = (char*) { bitmap_plot_yhi[y], bitmap_plot_ylo[y] } tay lda bitmap_plot_yhi,y @@ -323,9 +324,9 @@ bitmap_plot: { // Fixes offsets introduced by using unsigned multiplication // mul16s(signed word zp(4) a, signed word zp(9) b) mul16s: { - .label __6 = $2b + .label __6 = $1e .label __9 = $25 - .label __11 = $2b + .label __11 = $1e .label __12 = $25 .label m = $b .label return = $b @@ -390,12 +391,12 @@ mul16s: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($25) a, word zp($1e) b) +// mul16u(word zp($25) a, word zp($1c) b) mul16u: { .label mb = $15 .label a = $25 .label res = $b - .label b = $1e + .label b = $1c .label return = $b // mb = b lda.z b @@ -520,11 +521,11 @@ bitmap_clear: { rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. -// memset(void* zp($25) str, byte register(X) c, word zp($1e) num) +// memset(void* zp($25) str, byte register(X) c, word zp($1c) num) memset: { - .label end = $1e + .label end = $1c .label dst = $25 - .label num = $1e + .label num = $1c .label str = $25 // if(num>0) lda.z num @@ -625,7 +626,7 @@ bitmap_init: { // Generate signed int sinus table - with values in the range min-max. // sintab - the table to generate into // wavelength - the number of sinus points in a total sinus wavelength (the size of the table) -// sin16s_gen2(signed word* zp($1c) sintab) +// sin16s_gen2(signed word* zp($1a) sintab) sin16s_gen2: { .const min = -$1001 .const max = $1001 @@ -633,8 +634,12 @@ sin16s_gen2: { .label wavelength = $200 .label __6 = $b .label __8 = $25 + // ampl is always positive so shifting left does not alter the sign + // u[4.28] step = PI*2/wavelength .label step = $21 - .label sintab = $1c + .label sintab = $1a + // u[4.28] + // Iterate over the table // u[4.28] // Iterate over the table .label x = $11 @@ -737,14 +742,23 @@ sin16s: { .label __4 = $27 .label x = $15 .label return = 4 + // sinx = x - x^3/6 + x5/128; .label x1 = $2d - .label x2 = $19 - .label x3 = $19 + // u[1.15] + .label x2 = $1e + // u[2.14] x^2 + .label x3 = $1e + // u[2.14] x^3 .label x3_6 = $2b + // u[1.15] x^3/6; .label usinx = 4 - .label x4 = $19 + // u[1.15] x - x^3/6 + .label x4 = $1e + // u[3.13] x^4 .label x5 = $2b + // u[4.12] x^5 .label x5_128 = $2b + // u[1.15] (first bit is always zero) .label sinx = 4 // if(x >= PI_u4f28 ) lda.z x+3 @@ -943,14 +957,14 @@ sin16s: { } // Calculate val*val for two unsigned int values - the result is 16 selected bits of the 32-bit result. // The select parameter indicates how many of the highest bits of the 32-bit result to skip -// mulu16_sel(word zp($19) v1, word zp($1e) v2, byte register(X) select) +// mulu16_sel(word zp($1e) v1, word zp($1c) v2, byte register(X) select) mulu16_sel: { .label __0 = $b .label __1 = $b - .label v1 = $19 - .label v2 = $1e + .label v1 = $1e + .label v2 = $1c .label return = $2b - .label return_1 = $19 + .label return_1 = $1e // mul16u(v1, v2) lda.z v1 sta.z mul16u.a @@ -999,6 +1013,10 @@ div32u16u: { lda.z divr16u.return+1 sta.z quotient_hi+1 // divr16u(PI2_u4f28&$ffff @@ -1022,10 +1040,10 @@ div32u16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($1e) dividend, word zp($19) rem) +// divr16u(word zp($1c) dividend, word zp($1e) rem) divr16u: { - .label rem = $19 - .label dividend = $1e + .label rem = $1e + .label dividend = $1c .label quotient = $25 .label return = $25 ldx #0 @@ -1082,6 +1100,10 @@ divr16u: { cpx #$10 bne __b1 // rem16u = rem + lda.z rem + sta.z rem16u + lda.z rem+1 + sta.z rem16u+1 // } rts } diff --git a/src/test/ref/bitmap-plot-3.asm b/src/test/ref/bitmap-plot-3.asm index 1cae6b26d..193cb7b9b 100644 --- a/src/test/ref/bitmap-plot-3.asm +++ b/src/test/ref/bitmap-plot-3.asm @@ -97,7 +97,9 @@ bitmap_line: { .label dy = 8 .label sx = $16 .label sy = 6 + // X is the driver .label e1 = $e + // Y is the driver .label e = $a .label y = $c .label x = 4 diff --git a/src/test/ref/c-types.asm b/src/test/ref/c-types.asm index a9e233322..bc6dbfa1d 100644 --- a/src/test/ref/c-types.asm +++ b/src/test/ref/c-types.asm @@ -2,8 +2,9 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 2 - .label print_char_cursor = 8 + .label print_screen = $400 + .label print_char_cursor = 6 + .label print_line_cursor = $a main: { // print_cls() jsr print_cls @@ -99,9 +100,9 @@ print_ln: { rts } // Print a signed long as HEX -// print_slong(signed dword zp(4) dw) +// print_slong(signed dword zp(2) dw) print_slong: { - .label dw = 4 + .label dw = 2 // if(dw<0) lda.z dw+3 bmi __b1 @@ -152,9 +153,9 @@ print_char: { rts } // Print a unsigned long as HEX -// print_ulong(dword zp(4) dw) +// print_ulong(dword zp(2) dw) print_ulong: { - .label dw = 4 + .label dw = 2 // print_uint(>dw) lda.z dw+2 sta.z print_uint.w @@ -171,9 +172,9 @@ print_ulong: { rts } // Print a unsigned int as HEX -// print_uint(word zp($a) w) +// print_uint(word zp(8) w) print_uint: { - .label w = $a + .label w = 8 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -207,9 +208,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp($a) str) +// print_str(byte* zp(8) str) print_str: { - .label str = $a + .label str = 8 __b1: // while(*str) ldy #0 @@ -276,9 +277,9 @@ testInt: { .byte 0 } // Print a signed int as HEX -// print_sint(signed word zp($a) w) +// print_sint(signed word zp(8) w) print_sint: { - .label w = $a + .label w = 8 // if(w<0) lda.z w+1 bmi __b1 @@ -354,9 +355,9 @@ testChar: { .const n = $e .label s = -$e // print_str("char: ") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln // } @@ -411,7 +412,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $a lda #>3 lda.z keycode lsr @@ -842,7 +844,7 @@ keyboard_matrix_read: { // Get the VIC screen address from the screen index // get_vic_screen(byte register(A) idx) get_vic_screen: { - .label return = $10 + .label return = 6 // if(idx==0) cmp #0 beq __b1 @@ -892,7 +894,7 @@ get_vic_screen: { // Get the VIC charset/bitmap address from the index // get_vic_charset(byte register(A) idx) get_vic_charset: { - .label return = 7 + .label return = $10 // if(idx==0) cmp #0 beq __b1 @@ -915,7 +917,7 @@ get_vic_charset: { // Get plane address from a plane index (from the form) // get_plane(byte register(A) idx) get_plane: { - .label return = 9 + .label return = 2 // if(idx==0) cmp #0 beq __b1 @@ -1117,7 +1119,7 @@ get_plane: { } // Show the form - and let the user change values form_mode: { - .label preset_current = $d + .label preset_current = $f // print_set_screen(COLS) // Form Colors lda #FORM_SCREEN+$28*2+$a @@ -1442,9 +1444,9 @@ form_render_values: { // field_idx is the index of the field to get the screen address for // form_field_ptr(byte register(X) field_idx) form_field_ptr: { - .label line = $14 - .label x = $16 - .label return = $1d + .label line = $1c + .label x = $13 + .label return = $1e // y = form_fields_y[field_idx] ldy form_fields_y,x // line = (byte*) { form_line_hi[y], form_line_lo[y] } @@ -1469,7 +1471,7 @@ form_field_ptr: { // idx is the ID of the preset // apply_preset(byte register(A) idx) apply_preset: { - .label preset = 7 + .label preset = $10 // if(idx==0) cmp #0 beq __b3 @@ -1588,7 +1590,7 @@ apply_preset: { // Reads keyboard and allows the user to navigate and change the fields of the form // Returns 0 if space is not pressed, non-0 if space is pressed form_control: { - .label field = $1d + .label field = $1e // form_field_ptr(form_field_idx) ldx.z form_field_idx jsr form_field_ptr @@ -1724,7 +1726,8 @@ form_control: { // Set the screen to use for the form. // screen is the start address of the screen to use form_set_screen: { - .label line = $10 + // Calculate the field line table + .label line = 6 ldx #0 lda #>1 lda.z yd lsr @@ -2604,9 +2609,10 @@ bitmap_line_xdyi: { } // bitmap_plot(byte register(Y) x, byte register(X) y) bitmap_plot: { - .label plotter_x = $1d - .label plotter_y = $1f - .label plotter = $1d + // Needs unsigned int arrays arranged as two underlying char arrays to allow char* plotter_x = plot_x[x]; - and eventually - char* plotter = plot_x[x] + plot_y[y]; + .label plotter_x = $1c + .label plotter_y = $1e + .label plotter = $1c // plotter_x = { bitmap_plot_xhi[x], bitmap_plot_xlo[x] } lda bitmap_plot_xhi,y sta.z plotter_x+1 @@ -2634,14 +2640,14 @@ bitmap_plot: { // } rts } -// bitmap_line_ydxi(byte zp($e) y, byte zp($21) x, byte zp($13) y1, byte zp($d) yd, byte zp($12) xd) +// bitmap_line_ydxi(byte zp($b) y, byte zp($f) x, byte zp($a) y1, byte zp(9) yd, byte zp($12) xd) bitmap_line_ydxi: { - .label y = $e - .label x = $21 - .label y1 = $13 - .label yd = $d + .label y = $b + .label x = $f + .label y1 = $a + .label yd = 9 .label xd = $12 - .label e = $f + .label e = $c // e = xd>>1 lda.z xd lsr @@ -2679,13 +2685,13 @@ bitmap_line_ydxi: { // } rts } -// bitmap_line_xdyd(byte zp($f) x, byte register(X) y, byte zp($16) x1, byte zp($12) xd, byte zp($e) yd) +// bitmap_line_xdyd(byte zp($c) x, byte register(X) y, byte zp($13) x1, byte zp($12) xd, byte zp($b) yd) bitmap_line_xdyd: { - .label x = $f - .label x1 = $16 + .label x = $c + .label x1 = $13 .label xd = $12 - .label yd = $e - .label e = $d + .label yd = $b + .label e = $f // e = yd>>1 lda.z yd lsr @@ -2723,14 +2729,14 @@ bitmap_line_xdyd: { // } rts } -// bitmap_line_ydxd(byte zp($e) y, byte zp($16) x, byte zp($13) y1, byte zp($d) yd, byte zp($12) xd) +// bitmap_line_ydxd(byte zp($20) y, byte zp($13) x, byte zp($a) y1, byte zp($f) yd, byte zp($12) xd) bitmap_line_ydxd: { - .label y = $e - .label x = $16 - .label y1 = $13 - .label yd = $d + .label y = $20 + .label x = $13 + .label y1 = $a + .label yd = $f .label xd = $12 - .label e = $f + .label e = $21 // e = xd>>1 lda.z xd lsr @@ -2771,7 +2777,7 @@ bitmap_line_ydxd: { // Clear all graphics on the bitmap bitmap_clear: { .label bitmap = $10 - .label y = $16 + .label y = $12 // bitmap = (char*) { bitmap_plot_xhi[0], bitmap_plot_xlo[0] } lda bitmap_plot_xlo sta.z bitmap @@ -2805,8 +2811,8 @@ bitmap_clear: { } // Initialize the bitmap plotter tables for a specific bitmap bitmap_init: { - .label __10 = $21 - .label yoffs = $14 + .label __10 = $20 + .label yoffs = $d ldy #$80 ldx #0 __b1: @@ -2874,8 +2880,8 @@ bitmap_init: { } gfx_init_charset: { .label charset = $10 - .label chargen = $14 - .label c = $21 + .label chargen = $d + .label c = $13 // *PROCPORT = $32 lda #$32 sta PROCPORT @@ -2923,7 +2929,7 @@ gfx_init_charset: { // Initialize VIC screen 4 - all chars are 00 gfx_init_screen4: { .label ch = $10 - .label cy = $e + .label cy = $f lda #0 sta.z cy lda #VIC_SCREEN3 @@ -3005,8 +3011,8 @@ gfx_init_screen3: { // Initialize VIC screen 2 ( value is %ccccrrrr where cccc is (x+y mod $f) and rrrr is %1111-%cccc) gfx_init_screen2: { .label col2 = $22 - .label ch = $10 - .label cy = $12 + .label ch = $14 + .label cy = $21 lda #VIC_SCREEN2 @@ -3100,7 +3106,7 @@ gfx_init_screen1: { gfx_init_screen0: { .label __1 = $22 .label ch = $14 - .label cy = $13 + .label cy = $12 lda #VIC_SCREEN0 diff --git a/src/test/ref/c64dtv-gfxmodes.asm b/src/test/ref/c64dtv-gfxmodes.asm index 138fdb695..f4d99600e 100644 --- a/src/test/ref/c64dtv-gfxmodes.asm +++ b/src/test/ref/c64dtv-gfxmodes.asm @@ -99,7 +99,7 @@ // Memory address of VIC Graphics is GraphicsBank*$10000 .label DTV_GRAPHICS_VIC_BANK = $d03d .label print_char_cursor = 6 - .label print_line_cursor = 8 + .label print_line_cursor = $b main: { // asm sei @@ -192,9 +192,6 @@ menu: { sta BG_COLOR // *BORDER_COLOR = 0 sta BORDER_COLOR - // print_set_screen(SCREEN) - // Display menu Text - jsr print_set_screen // print_cls() jsr print_cls // print_str_lines(MENU_TEXT) @@ -355,8 +352,8 @@ menu: { mode_8bppchunkybmm: { // 8BPP Chunky Bitmap (contains 8bpp pixels) .const PLANEB = $20000 - .label __7 = $d - .label gfxb = 8 + .label __7 = $b + .label gfxb = $d .label x = 6 .label y = 2 // *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY | DTV_COLORRAM_OFF @@ -478,6 +475,7 @@ mode_8bppchunkybmm: { } // Allow the user to control the DTV graphics using different keys mode_ctrl: { + // Read the current control byte // DTV Graphics Mode - Reset .label ctrl = 3 __b1: @@ -499,6 +497,7 @@ mode_ctrl: { __b4: // ctrl = dtv_control // Read the current control byte + // DTV Graphics Mode - Reset stx.z ctrl // keyboard_key_pressed(KEY_L) ldy #KEY_L @@ -601,7 +600,7 @@ mode_ctrl: { // Returns zero if the key is not pressed and a non-zero value if the key is currently pressed // keyboard_key_pressed(byte register(Y) key) keyboard_key_pressed: { - .label colidx = $13 + .label colidx = $11 // colidx = key&7 tya and #7 @@ -641,6 +640,7 @@ keyboard_matrix_read: { // The actual memory addressed will be $4000*cpuSegmentIdx // dtvSetCpuBankSegment1(byte register(A) cpuBankIdx) dtvSetCpuBankSegment1: { + // Move CPU BANK 1 SEGMENT ($4000-$7fff) // Move CPU BANK 1 SEGMENT ($4000-$7fff) .label cpuBank = $ff // *cpuBank = cpuBankIdx @@ -667,15 +667,16 @@ mode_8bpppixelcell: { // 8BPP Pixel Cell Charset (contains 256 64 byte chars) .label PLANEB = $4000 .label CHARGEN = $d000 - .label __3 = $a + .label __3 = 8 + // Screen Chars for Plane A (screen) - 16x16 repeating // Screen Chars for Plane A (screen) - 16x16 repeating .label gfxa = 6 .label ay = 2 - .label bits = $11 - .label chargen = 8 + .label bits = $f + .label chargen = $d .label gfxb = 4 - .label col = $13 - .label cr = $c + .label col = $11 + .label cr = $a .label ch = 3 // *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR | DTV_CHUNKY lda #DTV_HIGHCOLOR|DTV_LINEAR|DTV_CHUNKY @@ -860,14 +861,17 @@ mode_sixsfred: { .label PLANEB = $6000 .label COLORS = $8000 // Colors for high 4 bits of 8bpp + // Colors for high 4 bits of 8bpp .label col = 4 - .label cy = $c + .label cy = $a + // Graphics for Plane A () - horizontal stripes every 2 pixels // Graphics for Plane A () - horizontal stripes every 2 pixels .label gfxa = 6 - .label ay = $11 + .label ay = $f // Graphics for Plane B - vertical stripes every 2 pixels - .label gfxb = 8 - .label by = $13 + // Graphics for Plane B - vertical stripes every 2 pixels + .label gfxb = $d + .label by = $11 // *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR lda #DTV_HIGHCOLOR|DTV_LINEAR sta DTV_CONTROL @@ -1047,17 +1051,21 @@ mode_twoplanebitmap: { .label PLANEA = $4000 .label PLANEB = $6000 .label COLORS = $8000 - .label __3 = $a + .label __3 = 8 + // Color for bits 11 + // Colors for bits 01 / 10 // Color for bits 11 // Colors for bits 01 / 10 .label col = 6 .label cy = 2 // Graphics for Plane A - horizontal stripes - .label gfxa = 8 + // Graphics for Plane A - horizontal stripes + .label gfxa = $d .label ay = 3 // Graphics for Plane B - vertical stripes + // Graphics for Plane B - vertical stripes .label gfxb = 4 - .label by = $c + .label by = $a // *DTV_CONTROL = DTV_HIGHCOLOR | DTV_LINEAR lda #DTV_HIGHCOLOR|DTV_LINEAR sta DTV_CONTROL @@ -1260,16 +1268,19 @@ mode_sixsfred2: { .label PLANEA = $4000 .label PLANEB = $6000 .label COLORS = $8000 - .label __3 = $b + .label __3 = 9 + // Colors for high 4 bits of 8bpp // Colors for high 4 bits of 8bpp .label col = 4 .label cy = 2 // Graphics for Plane A () - horizontal stripes every 2 pixels + // Graphics for Plane A () - horizontal stripes every 2 pixels .label gfxa = 6 .label ay = 3 // Graphics for Plane B - vertical stripes every 2 pixels - .label gfxb = 8 - .label by = $c + // Graphics for Plane B - vertical stripes every 2 pixels + .label gfxb = $d + .label by = $a // *DTV_CONTROL = DTV_LINEAR lda #DTV_LINEAR sta DTV_CONTROL @@ -1461,11 +1472,12 @@ mode_hicolmcchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $8400 - .label __3 = $b + .label __3 = 9 + // Char Colors and screen chars // Char Colors and screen chars .label col = 6 - .label ch = 8 - .label cy = $11 + .label ch = $d + .label cy = $f // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -1598,11 +1610,12 @@ mode_hicolecmchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $8400 - .label __3 = $c + .label __3 = $a + // Char Colors and screen chars // Char Colors and screen chars .label col = 6 - .label ch = 8 - .label cy = $11 + .label ch = $d + .label cy = $f // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -1734,11 +1747,12 @@ mode_hicolstdchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $8400 - .label __3 = $c + .label __3 = $a + // Char Colors and screen chars // Char Colors and screen chars .label col = 6 - .label ch = 8 - .label cy = $13 + .label ch = $d + .label cy = $11 // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -1859,11 +1873,12 @@ mode_stdbitmap: { .const lines_cnt = 9 .label SCREEN = $4000 .label BITMAP = $6000 - .label col2 = $11 + .label col2 = $f + // Bitmap Colors // Bitmap Colors .label ch = 4 - .label cy = $13 - .label l = $c + .label cy = $11 + .label l = $a // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)BITMAP/$10000) // DTV Graphics Bank lda #0 @@ -1989,12 +2004,12 @@ mode_stdbitmap: { lines_y: .byte 0, 0, $c7, $c7, 0, 0, $64, $c7, $64, 0 } // Draw a line on the bitmap -// bitmap_line(byte zp($11) x0, byte zp($12) x1, byte register(X) y0, byte zp($a) y1) +// bitmap_line(byte zp($f) x0, byte zp($10) x1, byte register(X) y0, byte zp(8) y1) bitmap_line: { - .label xd = $b - .label x0 = $11 - .label x1 = $12 - .label y1 = $a + .label xd = 9 + .label x0 = $f + .label x1 = $10 + .label y1 = 8 // if(x0>1 lda.z yd lsr @@ -2161,9 +2176,10 @@ bitmap_line_xdyi: { } // bitmap_plot(byte register(Y) x, byte register(X) y) bitmap_plot: { - .label plotter_x = $d - .label plotter_y = $f - .label plotter = $d + // Needs unsigned int arrays arranged as two underlying char arrays to allow char* plotter_x = plot_x[x]; - and eventually - char* plotter = plot_x[x] + plot_y[y]; + .label plotter_x = $b + .label plotter_y = $d + .label plotter = $b // plotter_x = { bitmap_plot_xhi[x], bitmap_plot_xlo[x] } lda bitmap_plot_xhi,y sta.z plotter_x+1 @@ -2191,14 +2207,14 @@ bitmap_plot: { // } rts } -// bitmap_line_ydxi(byte zp(3) y, byte zp($12) x, byte zp($a) y1, byte zp(2) yd, byte zp($b) xd) +// bitmap_line_ydxi(byte zp(3) y, byte zp($10) x, byte zp(8) y1, byte zp(2) yd, byte zp(9) xd) bitmap_line_ydxi: { .label y = 3 - .label x = $12 - .label y1 = $a + .label x = $10 + .label y1 = 8 .label yd = 2 - .label xd = $b - .label e = $13 + .label xd = 9 + .label e = $11 // e = xd>>1 lda.z xd lsr @@ -2236,12 +2252,12 @@ bitmap_line_ydxi: { // } rts } -// bitmap_line_xdyd(byte zp(2) x, byte register(X) y, byte zp($11) x1, byte zp($b) xd, byte zp($13) yd) +// bitmap_line_xdyd(byte zp(2) x, byte register(X) y, byte zp($f) x1, byte zp(9) xd, byte zp($11) yd) bitmap_line_xdyd: { .label x = 2 - .label x1 = $11 - .label xd = $b - .label yd = $13 + .label x1 = $f + .label xd = 9 + .label yd = $11 .label e = 3 // e = yd>>1 lda.z yd @@ -2280,14 +2296,14 @@ bitmap_line_xdyd: { // } rts } -// bitmap_line_ydxd(byte zp(3) y, byte zp($11) x, byte zp($a) y1, byte zp(2) yd, byte zp($b) xd) +// bitmap_line_ydxd(byte zp(3) y, byte zp($f) x, byte zp(8) y1, byte zp(2) yd, byte zp(9) xd) bitmap_line_ydxd: { .label y = 3 - .label x = $11 - .label y1 = $a + .label x = $f + .label y1 = 8 .label yd = 2 - .label xd = $b - .label e = $13 + .label xd = 9 + .label e = $11 // e = xd>>1 lda.z xd lsr @@ -2328,7 +2344,7 @@ bitmap_line_ydxd: { // Clear all graphics on the bitmap bitmap_clear: { .label bitmap = 4 - .label y = $b + .label y = 9 // bitmap = (char*) { bitmap_plot_xhi[0], bitmap_plot_xlo[0] } lda bitmap_plot_xlo sta.z bitmap @@ -2362,7 +2378,7 @@ bitmap_clear: { } // Initialize the bitmap plotter tables for a specific bitmap bitmap_init: { - .label __10 = $12 + .label __10 = $10 .label yoffs = 4 ldy #$80 ldx #0 @@ -2446,11 +2462,12 @@ mode_mcchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $d800 - .label __5 = $11 + .label __5 = $f + // Char Colors and screen chars // Char Colors and screen chars .label col = 4 .label ch = $d - .label cy = $c + .label cy = $a // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -2588,11 +2605,12 @@ mode_ecmchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $d800 - .label __5 = $12 + .label __5 = $10 + // Char Colors and screen chars // Char Colors and screen chars .label col = $d .label ch = 6 - .label cy = $11 + .label cy = $f // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -2728,11 +2746,12 @@ mode_stdchar: { .label CHARSET = $9000 // Charset ROM .label COLORS = $d800 - .label __5 = $13 + .label __5 = $11 + // Char Colors and screen chars // Char Colors and screen chars .label col = 6 .label ch = $d - .label cy = $12 + .label cy = $10 // *DTV_GRAPHICS_VIC_BANK = (byte)((dword)CHARSET/$10000) // DTV Graphics Bank lda #0 @@ -2947,7 +2966,7 @@ memset: { .const num = $3e8 .label str = menu.SCREEN .label end = str+num - .label dst = $d + .label dst = $b lda #str @@ -2973,11 +2992,6 @@ memset: { inc.z dst+1 !: jmp __b1 -} -// Set the screen to print on. Also resets current line/char cursor. -print_set_screen: { - // } - rts } // Default vallues for the palette DTV_PALETTE_DEFAULT: .byte 0, $f, $36, $be, $58, $db, $86, $ff, $29, $26, $3b, 5, 7, $df, $9a, $a diff --git a/src/test/ref/cia-timer-cyclecount.asm b/src/test/ref/cia-timer-cyclecount.asm index 5bd2b5d79..fd7cb9be7 100644 --- a/src/test/ref/cia-timer-cyclecount.asm +++ b/src/test/ref/cia-timer-cyclecount.asm @@ -18,6 +18,7 @@ .label SCREEN = $400 main: { .label __1 = 9 + // Calculate the cycle count - 0x12 is the base usage of start/read .label cyclecount = 9 __b1: // clock_start() diff --git a/src/test/ref/circlechars.asm b/src/test/ref/circlechars.asm index f285dd350..24f07ee3d 100644 --- a/src/test/ref/circlechars.asm +++ b/src/test/ref/circlechars.asm @@ -2,7 +2,7 @@ // C standard library string.h // Functions to manipulate C strings and arrays. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -12,37 +12,40 @@ // Default address of screen character matrix .label DEFAULT_SCREEN = $400 .label SCREEN = $400 - .label conio_cursor_x = 9 - .label conio_cursor_y = $a - .label conio_line_text = $b - .label conio_line_color = $d -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 9 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $a // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $b // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $d +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label __9 = $10 .label __10 = $d + // yd = y-12 .label yd = $f + // dist_sq = xd*xd + yd*yd .label dist_sq = $10 .label y = 9 .label sc = $b diff --git a/src/test/ref/clobber-a-problem.asm b/src/test/ref/clobber-a-problem.asm index 0714b052a..7f35c5b12 100644 --- a/src/test/ref/clobber-a-problem.asm +++ b/src/test/ref/clobber-a-problem.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const DARK_GREY = $b .const BLACK = 0 @@ -7,12 +7,13 @@ .label BORDER_COLOR = $d020 .label RASTER = $d012 .label irq_raster_next = 2 -__bbegin: - // irq_raster_next = 0 - lda #0 - sta.z irq_raster_next - jsr main - rts +_start: { + // irq_raster_next = 0 + lda #0 + sta.z irq_raster_next + jsr main + rts +} main: { // *KERNEL_IRQ = &irq lda #HEAP_TOP - sta.z heap_head+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_COPY - lda.z malloc.mem+1 - sta.z SCREEN_COPY+1 - jsr malloc - // malloc(1000) - jsr main - rts +_start: { + // malloc(1000) + lda #HEAP_TOP + sta.z heap_head+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_COPY + lda.z malloc.mem+1 + sta.z SCREEN_COPY+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_DIST + lda.z malloc.mem+1 + sta.z SCREEN_DIST+1 + jsr main + rts +} main: { .label dst = 2 - .label src = 8 + .label src = $22 .label i = 4 .label center_y = $10 // init_angle_screen(SCREEN_DIST) @@ -147,7 +155,7 @@ main: { tax ldy #0 !: - lda __2,y + lda __0,y sta PROCESSING,x inx iny @@ -205,36 +213,38 @@ main: { jmp __b1 } // Start processing a char - by inserting it into the PROCESSING array -// startProcessing(byte zp($23) center_x, byte zp($10) center_y) +// startProcessing(byte zp($21) center_x, byte zp($10) center_y) startProcessing: { - .label __0 = $11 - .label __4 = 8 + .label __0 = $22 + .label __4 = $1f .label __6 = 6 - .label __8 = $18 - .label __9 = $18 - .label __11 = $1a - .label __12 = $1a - .label __23 = $11 - .label __24 = 8 + .label __8 = $16 + .label __9 = $16 + .label __11 = $18 + .label __12 = $18 + .label __23 = $22 + .label __24 = $1f .label __25 = 6 - .label __26 = $18 - .label __27 = $1a - .label center_x = $23 + .label __26 = $16 + .label __27 = $18 + .label center_x = $21 .label center_y = $10 .label i = 5 - .label offset = $11 - .label colPtr = $15 - .label spriteCol = $17 - .label screenPtr = $11 - .label spriteData = 8 + // Copy char into sprite + .label offset = $22 + .label colPtr = $13 + .label spriteCol = $15 + .label screenPtr = $22 + .label spriteData = $1f .label chargenData = 6 - .label spriteX = $18 - .label spriteY = $1a - .label spritePtr = $1c + .label spriteX = $16 + .label spriteY = $18 + .label spritePtr = $1a + // Busy-wait while finding an empty slot in the PROCESSING array // Busy-wait while finding an empty slot in the PROCESSING array .label freeIdx = 5 - .label __33 = $13 - .label __34 = $11 + .label __33 = $11 + .label __34 = $22 ldx #$ff __b1: lda #0 @@ -518,19 +528,19 @@ startProcessing: { // Find the non-space char closest to the center of the screen // If no non-space char is found the distance will be 0xffff getCharToProcess: { - .label __8 = $1d - .label __9 = $1d - .label __11 = $1d + .label __8 = $1b + .label __9 = $1b + .label __11 = $1b .label screen_line = 6 - .label dist_line = 8 + .label dist_line = $1f .label y = 5 - .label return_x = $17 - .label return_y = $1c + .label return_x = $15 + .label return_y = $1a .label closest_dist = $10 - .label closest_x = $17 - .label closest_y = $1c - .label __12 = $1f - .label __13 = $1d + .label closest_x = $15 + .label closest_y = $1a + .label __12 = $1d + .label __13 = $1b // screen_line = SCREEN_COPY lda.z SCREEN_COPY sta.z screen_line @@ -738,18 +748,18 @@ initSprites: { } // Populates 1000 chars (a screen) with values representing the angle to the center. // Utilizes symmetry around the center -// init_angle_screen(byte* zp($11) screen) +// init_angle_screen(byte* zp($22) screen) init_angle_screen: { - .label __7 = $18 - .label screen = $11 + .label __7 = $16 + .label screen = $22 .label screen_topline = 6 - .label screen_bottomline = $11 - .label xw = $1f - .label yw = $21 - .label angle_w = $18 - .label ang_w = $23 - .label x = $17 - .label xb = $1c + .label screen_bottomline = $22 + .label xw = $1d + .label yw = $1f + .label angle_w = $16 + .label ang_w = $21 + .label x = $15 + .label xb = $1a .label y = $10 // screen_topline = screen+40*12 lda.z screen @@ -864,18 +874,19 @@ init_angle_screen: { // Find the atan2(x, y) - which is the angle of the line from (0,0) to (x,y) // Finding the angle requires a binary search using CORDIC_ITERATIONS_16 // Returns the angle in hex-degrees (0=0, 0x8000=PI, 0x10000=2*PI) -// atan2_16(signed word zp($1f) x, signed word zp($21) y) +// atan2_16(signed word zp($1d) x, signed word zp($1f) y) atan2_16: { - .label __2 = $13 - .label __7 = $15 - .label yi = $13 - .label xi = $15 - .label angle = $18 - .label xd = $1d - .label yd = $1a - .label return = $18 - .label x = $1f - .label y = $21 + .label __2 = $11 + .label __7 = $13 + .label yi = $11 + .label xi = $13 + .label angle = $16 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i + .label xd = $1b + .label yd = $18 + .label return = $16 + .label x = $1d + .label y = $1f // (y>=0)?y:-y lda.z y+1 bmi !__b1+ @@ -1079,7 +1090,7 @@ atan2_16: { // Allocates a block of size chars of memory, returning a pointer to the beginning of the block. // The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. malloc: { - .label mem = $e + .label mem = $22 // mem = heap_head-size lda.z heap_head sec @@ -1486,6 +1497,6 @@ VYSIN: // Sprites currently being processed in the interrupt PROCESSING: .fill $e*NUM_PROCESSING, 0 - __2: .word 0, 0, 0, 0 + __0: .word 0, 0, 0, 0 .byte 0, 0, 0, STATUS_FREE .word 0 diff --git a/src/test/ref/complex/polygon/polygon.asm b/src/test/ref/complex/polygon/polygon.asm index 86dd426c9..431e7031a 100644 --- a/src/test/ref/complex/polygon/polygon.asm +++ b/src/test/ref/complex/polygon/polygon.asm @@ -5,7 +5,7 @@ // - Up-to-down EOR filling // - Double buffering .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -31,7 +31,6 @@ .const OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE = $1a .const OFFSET_STRUCT_MOS6569_VICII_MEMORY = $18 .const OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS = $19 - .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CANVAS2)/4&$f // The VIC-II MOS 6567/6569 .label VICII = $d000 // Color Ram @@ -56,27 +55,31 @@ // The default charset address .label PETSCII = $1000 .label COSTAB = SINTAB+$40 - .label canvas_show_memory = $11 - .label canvas_show_flag = $12 -__bbegin: - // canvas_show_memory = toD018(SCREEN, CANVAS2) // The current canvas being rendered to the screen - in D018 format. - lda #toD0181_return - sta.z canvas_show_memory - // canvas_show_flag = 0 + .label canvas_show_memory = $11 // Flag signalling that the canvas on screen needs to be updated. // Set to 1 by the renderer when a new canvas is ready for showing, and to 0 by the raster when the canvas is shown on screen. - lda #0 - sta.z canvas_show_flag - jsr main - rts + .label canvas_show_flag = $12 +_start: { + .const _init1_toD0181_return = (>(SCREEN&$3fff)*4)|(>CANVAS2)/4&$f + // canvas_show_memory = toD018(SCREEN, CANVAS2) + lda #_init1_toD0181_return + sta.z canvas_show_memory + // canvas_show_flag = 0 + lda #0 + sta.z canvas_show_flag + jsr main + rts +} main: { .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CANVAS1)/4&$f .const toD0182_return = (>(SCREEN&$3fff)*4)|(>CANVAS2)/4&$f .label cols = 3 // Setup 16x16 canvas for rendering + // Setup 16x16 canvas for rendering .label screen = 5 .label y = 2 + // Plot in line buffer .label x0 = $13 .label y0 = $14 .label x1 = $c @@ -87,6 +90,7 @@ main: { .label p1_idx = 8 .label p2_idx = 9 // The current canvas being rendered to + // The current canvas being rendered to .label canvas = $a // memset(CONSOLE, ' ', 40*25) // Clear the console @@ -148,9 +152,6 @@ main: { // setup_irq() // Set-up the raster IRQ jsr setup_irq - // textcolor(WHITE) - // Set text color - jsr textcolor lda #CANVAS1 @@ -266,8 +267,6 @@ main: { // Set flag used to signal when the canvas has been shown lda #1 sta.z canvas_show_flag - // clock() - jsr clock jmp __b8 __b2: ldx.z y @@ -309,12 +308,6 @@ main: { iny jmp __b4 } -// Returns the processor clock time used since the beginning of an implementation defined era (normally the beginning of the program). -// This uses CIA #2 Timer A+B on the C64, and must be initialized using clock_start() -clock: { - // } - rts -} // EOR fill from the line buffer onto the canvas // eorfill(byte* zp($1f) canvas) eorfill: { @@ -387,13 +380,19 @@ line: { .label dy = $18 .label sx = $19 .label sy = $1a + // Find the canvas column .label plot1_column = $21 .label plot2_y = $1b + // Find the canvas column .label plot2_column = $1c + // Find the canvas column .label plot3_column = $1f .label e1 = $e + // Find the canvas column .label plot4_column = $23 + // Find the canvas column .label plot5_column = $25 + // Find the canvas column .label plot6_column = $28 // abs_u8(x2-x1) lda.z x2 @@ -803,10 +802,6 @@ clock_start: { // } rts } -// Set the color for text output. The old color setting is returned. -textcolor: { - rts -} // Setup raster IRQ to change charset at different lines setup_irq: { // asm diff --git a/src/test/ref/complex/prebob/grid-bobs.asm b/src/test/ref/complex/prebob/grid-bobs.asm index 19b2f9a8a..972963365 100644 --- a/src/test/ref/complex/prebob/grid-bobs.asm +++ b/src/test/ref/complex/prebob/grid-bobs.asm @@ -33,17 +33,18 @@ // The BOB charset .label BOB_CHARSET = $2000 // BOB charset ID of the next glyph to be added - .label bob_charset_next_id = $11 + .label bob_charset_next_id = $15 // Current index within the progress cursor (0-7) - .label progress_idx = $10 + .label progress_idx = $e // Current position of the progress cursor - .label progress_cursor = $e + .label progress_cursor = $c // Pointer to the next clean-up to add // Prepare for next clean-up - .label renderBobCleanupNext = $c + .label renderBobCleanupNext = $f main: { .const origY = $a00 // Row and column offset vectors + // Row and column offset vectors .const rowOffsetX = $c00 .const colOffsetX = $100 .const colOffsetY = $1800 @@ -57,9 +58,10 @@ main: { .label y_1 = $a .label rowX = 4 .label rowY = 6 - .label col = $10 + .label col = $e // Origin point - .label origX = $e + // Origin point + .label origX = $c .label rowOffsetY = 2 // mulf_init() jsr mulf_init @@ -255,16 +257,16 @@ keyboard_matrix_read: { // Render a single BOB at a given x/y-position // X-position is 0-151. Each x-position is 2 pixels wide. // Y-position is 0-183. Each y-position is 1 pixel high. -// renderBob(byte zp($16) xpos, byte zp($17) ypos) +// renderBob(byte zp($13) xpos, byte zp($14) ypos) renderBob: { - .label __2 = $19 - .label __5 = $1b - .label xpos = $16 - .label ypos = $17 - .label x_char_offset = $18 - .label y_offset = $19 - .label screen = $19 - .label bob_table_idx = $1b + .label __2 = $16 + .label __5 = $18 + .label xpos = $13 + .label ypos = $14 + .label x_char_offset = $15 + .label y_offset = $16 + .label screen = $16 + .label bob_table_idx = $18 // x_char_offset = xpos/BOB_SHIFTS_X lda.z xpos lsr @@ -377,7 +379,7 @@ renderBob: { } // Clean Up the rendered BOB's renderBobCleanup: { - .label screen = $1c + .label screen = $19 ldx #0 __b1: // screen = RENDERBOB_CLEANUP[i] @@ -429,7 +431,7 @@ memset: { .const num = $3e8 .label str = BOB_SCREEN .label end = str+num - .label dst = $19 + .label dst = $f lda #str @@ -458,10 +460,10 @@ memset: { } // Initialize the tables used by renderBob() renderBobInit: { - .label __0 = $1e - .label __5 = $1e - .label __6 = $20 - .label __7 = $1e + .label __0 = $1b + .label __5 = $1b + .label __6 = $1d + .label __7 = $1b ldx #0 __b1: // ((unsigned int)y)*40 @@ -522,15 +524,14 @@ renderBobInit: { // Creates the pre-shifted bobs into BOB_CHARSET and populates the BOB_TABLES // Modifies PROTO_BOB by shifting it around prepareBobs: { - .label bob_table = $20 - .label shift_y = $12 + .label bob_table = $1b + .label shift_y = $11 // Populate charset and tables - .label bob_glyph = $19 - .label cell = $17 - .label bob_table_idx = $15 - .label shift_x = $16 - // progress_init(BASIC_SCREEN) - jsr progress_init + // Populate charset and tables + .label bob_glyph = $f + .label cell = $14 + .label bob_table_idx = $12 + .label shift_x = $13 // charsetFindOrAddGlyph(PROTO_BOB+48, BOB_CHARSET) // Ensure that glyph #0 is empty lda #BOB_CHARSET @@ -733,7 +734,7 @@ charsetFindOrAddGlyph: { } // Shift PROTO_BOB right one X pixel protoBobShiftRight: { - .label carry = $1b + .label carry = $14 .label i = $18 ldy #0 ldx #0 @@ -819,25 +820,25 @@ protoBobShiftDown: { dex jmp __b1 } -// Initialize the PETSCII progress bar -progress_init: { - // } - rts -} // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) mulf_init: { // x/2 - .label c = $12 + // x/2 + .label c = $11 // Counter used for determining x%2==0 - .label sqr1_hi = $13 + // Counter used for determining x%2==0 + .label sqr1_hi = $1b // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 - .label sqr = $1e - .label sqr1_lo = $20 + // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 + .label sqr = $19 + .label sqr1_lo = $f // Decrease or increase x_255 - initially we decrease - .label sqr2_hi = $1c - .label sqr2_lo = $19 + // Decrease or increase x_255 - initially we decrease + .label sqr2_hi = $16 + .label sqr2_lo = $1d //Start with g(0)=f(255) - .label dir = $15 + //Start with g(0)=f(255) + .label dir = $12 ldx #0 lda #(BOB_SCREEN&$3fff)*4)|(>BOB_CHARSET)/4&$f .const toD0182_return = (>(SCREEN_BASIC&$3fff)*4)|(>CHARSET_BASIC)/4&$f - .label __10 = 6 - .label __12 = 6 - .label __13 = 6 + .label __10 = 4 + .label __12 = 4 + .label __13 = 4 .label x = $c - .label y = 6 + .label y = 4 .label a = 2 - .label r = 9 - .label i = 5 + .label r = 7 + .label i = 3 // Render Rotated BOBs - .label angle = 8 + // Render Rotated BOBs + .label angle = 6 // mulf_init() jsr mulf_init // prepareBobs() @@ -344,7 +345,7 @@ renderBob: { // Fast multiply two signed chars to a unsigned int result // mulf8s(signed byte register(A) a, signed byte register(X) b) mulf8s: { - .label return = 6 + .label return = 4 // mulf8u_prepare((char)a) jsr mulf8u_prepare // mulf8s_prepared(b) @@ -358,7 +359,7 @@ mulf8s: { // mulf8s_prepared(signed byte zp($13) b) mulf8s_prepared: { .label memA = $fd - .label m = 6 + .label m = 4 .label b = $13 // mulf8u_prepared((char) b) lda.z b @@ -395,7 +396,7 @@ mulf8s_prepared: { mulf8u_prepared: { .label resL = $fe .label memB = $ff - .label return = 6 + .label return = 4 // *memB = b sta memB // asm @@ -488,7 +489,7 @@ memset: { .const num = $3e8 .label str = BOB_SCREEN .label end = str+num - .label dst = $c + .label dst = 8 lda #str @@ -517,10 +518,10 @@ memset: { } // Initialize the tables used by renderBob() renderBobInit: { - .label __0 = $16 - .label __5 = $16 - .label __6 = $18 - .label __7 = $16 + .label __0 = $14 + .label __5 = $14 + .label __6 = $16 + .label __7 = $14 ldx #0 __b1: // ((unsigned int)y)*40 @@ -581,15 +582,14 @@ renderBobInit: { // Creates the pre-shifted bobs into BOB_CHARSET and populates the BOB_TABLES // Modifies PROTO_BOB by shifting it around prepareBobs: { - .label bob_table = $16 + .label bob_table = $14 .label shift_y = $a // Populate charset and tables - .label bob_glyph = $c + // Populate charset and tables + .label bob_glyph = 8 .label cell = $f .label bob_table_idx = $b .label shift_x = $e - // progress_init(SCREEN_BASIC) - jsr progress_init // bobCharsetFindOrAddGlyph(PROTO_BOB+48) // Ensure that glyph #0 is empty lda #BOB_CHARSET @@ -879,23 +879,23 @@ shiftProtoBobDown: { dex jmp __b1 } -// Initialize the PETSCII progress bar -progress_init: { - // } - rts -} // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) mulf_init: { + // x/2 // x/2 .label c = $a // Counter used for determining x%2==0 - .label sqr1_hi = $18 + // Counter used for determining x%2==0 + .label sqr1_hi = $14 // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 - .label sqr = $14 - .label sqr1_lo = $16 + // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 + .label sqr = $10 + .label sqr1_lo = 8 // Decrease or increase x_255 - initially we decrease - .label sqr2_hi = $10 - .label sqr2_lo = $c + // Decrease or increase x_255 - initially we decrease + .label sqr2_hi = $c + .label sqr2_lo = $16 + //Start with g(0)=f(255) //Start with g(0)=f(255) .label dir = $b ldx #0 diff --git a/src/test/ref/complex/prebob/vogel-sprites.asm b/src/test/ref/complex/prebob/vogel-sprites.asm index 73f2480cd..dfc033b2b 100644 --- a/src/test/ref/complex/prebob/vogel-sprites.asm +++ b/src/test/ref/complex/prebob/vogel-sprites.asm @@ -3,7 +3,7 @@ // The MOS 6526 Complex Interface Adapter (CIA) // http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const VIC_RST8 = $80 .const VIC_DEN = $10 @@ -32,28 +32,29 @@ .label COS = SIN+$40 // The address of the sprite pointers on the current screen (screen+0x3f8). .label PLEX_SCREEN_PTR = SCREEN+$3f8 - .label plex_show_idx = $11 - .label plex_sprite_idx = $12 - .label plex_sprite_msb = $13 - .label plex_free_next = $14 -__bbegin: - // plex_show_idx=0 // The index in the PLEX tables of the next sprite to show - lda #0 - sta.z plex_show_idx - // plex_sprite_idx=0 + .label plex_show_idx = $11 // The index the next sprite to use for showing (sprites are used round-robin) - sta.z plex_sprite_idx - // plex_sprite_msb=1 + .label plex_sprite_idx = $12 // The MSB bit of the next sprite to use for showing - lda #1 - sta.z plex_sprite_msb - // plex_free_next = 0 + .label plex_sprite_msb = $13 // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown. - lda #0 - sta.z plex_free_next - jsr main - rts + .label plex_free_next = $14 +_start: { + // plex_show_idx=0 + lda #0 + sta.z plex_show_idx + // plex_sprite_idx=0 + sta.z plex_sprite_idx + // plex_sprite_msb=1 + lda #1 + sta.z plex_sprite_msb + // plex_free_next = 0 + lda #0 + sta.z plex_free_next + jsr main + rts +} main: { // asm sei @@ -122,6 +123,7 @@ loop: { .label r = 7 .label i = 2 // Render Rotated BOBs + // Render Rotated BOBs .label angle = 4 .label plexFreeNextYpos1_return = $15 .label i1 = 3 @@ -623,17 +625,22 @@ memset: { } // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) mulf_init: { + // x/2 // x/2 .label c = 7 // Counter used for determining x%2==0 + // Counter used for determining x%2==0 .label sqr1_hi = 8 // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 + // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 .label sqr = $f .label sqr1_lo = 5 // Decrease or increase x_255 - initially we decrease + // Decrease or increase x_255 - initially we decrease .label sqr2_hi = $c .label sqr2_lo = $a //Start with g(0)=f(255) + //Start with g(0)=f(255) .label dir = $e ldx #0 lda #(SCREEN&$3fff)*4)|(>CHARSET_DEFAULT)/4&$f .label s = 2 - .label __13 = $12 + .label __13 = $15 // asm // Create 2x2 font from CHARGEN sei @@ -189,7 +191,7 @@ main: { jmp __b6 __b2: // PLEX_PTR[s] = SPRITE_0+' ' - lda #toSpritePtr1_return+' ' + lda #SPRITE_0+' ' ldy.z s sta PLEX_PTR,y // PLEX_XPOS[s] = { XMOVEMENT_HI[x], XMOVEMENT[x] } @@ -220,9 +222,9 @@ main: { // elements before the marker are shifted right one at a time until encountering one smaller than the current one. // It is then inserted at the spot. Now the marker can move forward. plexSort: { - .label nxt_idx = $14 - .label nxt_y = $15 - .label m = $c + .label nxt_idx = $17 + .label nxt_y = $18 + .label m = $d lda #0 sta.z m __b1: @@ -289,10 +291,10 @@ plexSort: { } // Move the plex sprites in an Y-sine and scroll them to the left. plex_move: { - .label y_idx = $c - .label x_idx = $15 - .label s = $14 - .label __7 = $16 + .label y_idx = $d + .label x_idx = $18 + .label s = $17 + .label __7 = $19 // y_idx = y_sin_idx lda.z y_sin_idx sta.z y_idx @@ -339,7 +341,7 @@ plex_move: { sta.z scroll_text_next+1 __b3: // SPRITE_0+*scroll_text_next++ - lda #toSpritePtr1_return + lda #SPRITE_0 clc ldy #0 adc (scroll_text_next),y @@ -391,13 +393,14 @@ plexInit: { // - num_chars The number of chars to convert font_2x2_to_sprites: { .const num_chars = $40 - .label __3 = $18 - .label char_right = $a - .label sprite_idx = $15 - .label char_left = 8 - .label char_current = $16 - .label sprite = 6 - .label c = $14 + .label __3 = $1b + .label char_right = $b + .label sprite_idx = $18 + // Upper char + .label char_left = 9 + .label char_current = $19 + .label sprite = 7 + .label c = $17 lda #SPRITES @@ -519,18 +522,18 @@ font_2x2_to_sprites: { // - 0x80 - 0xbf Lower left glyphs // - 0xc0 - 0xff Lower right glyphs font_2x2: { - .label __5 = $12 - .label __7 = $12 - .label next_2x2_left = $16 - .label next_2x2_right = $a - .label glyph_bits = $c - .label glyph_bits_2x2 = $12 - .label l2 = $18 - .label l = $15 - .label next_2x2_left_1 = 8 - .label next_2x2 = $16 - .label next_original = 6 - .label c = $14 + .label __5 = $15 + .label __7 = $15 + .label next_2x2_left = $19 + .label next_2x2_right = $b + .label glyph_bits = $d + .label glyph_bits_2x2 = $15 + .label l2 = $1b + .label l = $18 + .label next_2x2_left_1 = 9 + .label next_2x2 = $19 + .label next_original = 7 + .label c = $17 lda #0 sta.z c lda #(PLAYFIELD_SCREEN_1&$3fff)*4)|(>PLAYFIELD_CHARSET)/4&$f - .label xpos = 3 - .label ypos = 2 + .label xpos = 2 + .label ypos = 3 // CIA2->PORT_A_DDR = %00000011 lda #3 sta CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR @@ -160,7 +154,7 @@ main: { rts } loop: { - .label s = 4 + .label s = 5 lda #0 sta.z sin_idx __b2: @@ -238,7 +232,7 @@ sprites_irq_init: { } // Setup the sprites sprites_init: { - .label xpos = 4 + .label xpos = 5 // *SPRITES_ENABLE = %00001111 lda #$f sta SPRITES_ENABLE @@ -278,8 +272,9 @@ sprites_init: { // Repeats 10 timers every 2 lines from line IRQ_RASTER_FIRST // Utilizes duplicated gfx in the sprites to allow for some leeway in updating the sprite pointers sprites_irq: { - .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40 - .label raster_sprite_gfx_modify = $a + .const toSpritePtr1_return = $ff&PLAYFIELD_SPRITES/$40 + // Wait for the y-position before changing sprite pointers + .label raster_sprite_gfx_modify = $b sta rega+1 stx regx+1 // asm @@ -416,9 +411,11 @@ SIN: .byte 51+AMPL/2+sin(toRadians([i*360]/256))*AMPL/2 } -.pc = PLAYFIELD_SPRITES "PLAYFIELD_SPRITES" - .var sprites = LoadPicture("playfield-sprites.png", List().add($010101, $000000)) - // Put the sprites into memory +.pc = $3000 "PLAYFIELD_SPRITES" +// Sprites covering the playfield +PLAYFIELD_SPRITES: +.var sprites = LoadPicture("playfield-sprites.png", List().add($010101, $000000)) + // Put the sprites into memory .for(var sy=0;sy<10;sy++) { .var sprite_gfx_y = sy*20 .for(var sx=0;sx<3;sx++) { @@ -432,6 +429,13 @@ SIN: } } -.pc = SIN_SPRITE "SIN_SPRITE" - .fill $40, $ff +.pc = $2800 "PLAYFIELD_CHARSET" +// Address of the charset +PLAYFIELD_CHARSET: +.fill 8,$00 // Place a filled char at the start of the charset + .import binary "playfield-screen.imap" + +.pc = $3800 "SIN_SPRITE" +SIN_SPRITE: +.fill $40, $ff diff --git a/src/test/ref/complex/tetris/tetris.asm b/src/test/ref/complex/tetris/tetris.asm index 6917f1048..1bc8f55ed 100644 --- a/src/test/ref/complex/tetris/tetris.asm +++ b/src/test/ref/complex/tetris/tetris.asm @@ -2,7 +2,7 @@ // The tetris game tries to match NES tetris gameplay pretty closely // Source: https://meatfighter.com/nintendotetrisai/ .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -66,7 +66,6 @@ .const OFFSET_STRUCT_MOS6581_SID_CH3_OSC = $1b .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1 .const OFFSET_STRUCT_MOS6526_CIA_INTERRUPT = $d - .const toSpritePtr1_return = PLAYFIELD_SPRITES/$40 .label SPRITES_XPOS = $d000 .label SPRITES_YPOS = $d001 .label SPRITES_COLOR = $d027 @@ -111,23 +110,25 @@ .label PLAYFIELD_SPRITE_PTRS_1 = PLAYFIELD_SCREEN_1+SPRITE_PTRS // Screen Sprite pointers on screen 2 .label PLAYFIELD_SPRITE_PTRS_2 = PLAYFIELD_SCREEN_2+SPRITE_PTRS - // Address of the sprites covering the playfield - .label PLAYFIELD_SPRITES = $3000 - // Address of the charset - .label PLAYFIELD_CHARSET = $2800 - .label render_screen_showing = $26 - .label score_bcd = $27 - .label irq_raster_next = $2b - .label irq_sprite_ypos = $2c - .label irq_sprite_ptr = $2d - .label irq_cnt = $2e + // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. + .label render_screen_showing = $22 + // Current score in BCD-format + .label score_bcd = $23 + // The raster line of the next IRQ + .label irq_raster_next = $27 + // Y-pos of the sprites on the next IRQ + .label irq_sprite_ypos = $28 + // Index of the sprites to show on the next IRQ + .label irq_sprite_ptr = $29 + // Counting the 10 IRQs + .label irq_cnt = $2a // Keyboard event buffer size. The number of events currently in the event buffer - .label keyboard_events_size = $20 + .label keyboard_events_size = $21 // The rate of moving down the current piece (number of frames between moves if movedown is not forced) .label current_movedown_slow = $11 - .label current_ypos = $d // Position of top left corner of current moving piece on the playfield .label current_xpos = $19 + .label current_ypos = $d // The curent piece orientation - each piece have 4 orientations (00/0x10/0x20/0x30). // The orientation chooses one of the 4 sub-graphics of the piece. .label current_orientation = $16 @@ -137,14 +138,6 @@ .label current_piece_char = $15 // Current level BCD-format .label level_bcd = $12 - // The current moving piece. Points to the start of the piece definition. - .label current_piece = $13 - // Is the game over? - .label game_over = $1b - // The index of the next moving piece. (0-6) - .label next_piece_idx = $1a - // Current level in normal (non-BCD) format - .label level = $10 // The screen currently being rendered to. 0x00 for screen 1 / 0x20 for screen 2. .label render_screen_render = 3 // The screen currently to show next to the user. 0x00 for screen 1 / 0x20 for screen 2. @@ -154,6 +147,14 @@ .label current_movedown_counter = 4 // Current number of cleared lines in BCD-format .label lines_bcd = $e + // Current level in normal (non-BCD) format + .label level = $10 + // The current moving piece. Points to the start of the piece definition. + .label current_piece = $13 + // Is the game over? + .label game_over = $1b + // The index of the next moving piece. (0-6) + .label next_piece_idx = $1a // The current moving piece. Points to the start of the piece definition. .label current_piece_1 = $a // The screen currently being rendered to. 0x00 for screen 1 / 0x20 for screen 2. @@ -164,40 +165,33 @@ .label current_piece_gfx_1 = 7 // The char of the current piece .label current_piece_char_1 = 9 -__bbegin: - // render_screen_showing = 0 - // The screen currently being showed to the user. 0x00 for screen 1 / 0x20 for screen 2. - lda #0 - sta.z render_screen_showing - // score_bcd = 0 - // Current score in BCD-format - sta.z score_bcd - sta.z score_bcd+1 - lda #<0>>$10 - sta.z score_bcd+2 - lda #>0>>$10 - sta.z score_bcd+3 - // kickasm -// Tetris Game for the Commodore 64 -// A sprite multiplexer covering the playfield with a black layer to allow for 3 single-pixel colors - // irq_raster_next = IRQ_RASTER_FIRST - // The raster line of the next IRQ - lda #IRQ_RASTER_FIRST - sta.z irq_raster_next - // irq_sprite_ypos = SPRITES_FIRST_YPOS + 21 - // Y-pos of the sprites on the next IRQ - lda #SPRITES_FIRST_YPOS+$15 - sta.z irq_sprite_ypos - // irq_sprite_ptr = toSpritePtr(PLAYFIELD_SPRITES) + 3 - // Index of the sprites to show on the next IRQ - lda #toSpritePtr1_return+3 - sta.z irq_sprite_ptr - // irq_cnt = 0 - // Counting the 10 IRQs - lda #0 - sta.z irq_cnt - jsr main - rts +_start: { + .const _init1_toSpritePtr1_return = $ff&PLAYFIELD_SPRITES/$40 + // render_screen_showing = 0 + lda #0 + sta.z render_screen_showing + // score_bcd = 0 + sta.z score_bcd + sta.z score_bcd+1 + lda #<0>>$10 + sta.z score_bcd+2 + lda #>0>>$10 + sta.z score_bcd+3 + // irq_raster_next = IRQ_RASTER_FIRST + lda #IRQ_RASTER_FIRST + sta.z irq_raster_next + // irq_sprite_ypos = SPRITES_FIRST_YPOS + 21 + lda #SPRITES_FIRST_YPOS+$15 + sta.z irq_sprite_ypos + // irq_sprite_ptr = toSpritePtr(PLAYFIELD_SPRITES) + 3 + lda #_init1_toSpritePtr1_return+3 + sta.z irq_sprite_ptr + // irq_cnt = 0 + lda #0 + sta.z irq_cnt + jsr main + rts +} main: { // SID->CH3_FREQ = 0xffff lda #<$ffff @@ -347,7 +341,7 @@ render_score: { .const lines_offset = $28*1+$16 .const level_offset = $28*$13+$1f .label score_bytes = score_bcd - .label screen = 7 + .label screen = $2c // if(render_screen_render==0) lda.z render_screen_render cmp #0 @@ -419,12 +413,12 @@ render_score: { // - offset: offset on the screen // - bcd: The BCD-value to render // - only_low: if non-zero only renders the low digit -// render_bcd(byte* zp(7) screen, word zp($a) offset, byte register(X) bcd, byte register(Y) only_low) +// render_bcd(byte* zp($2c) screen, word zp($2e) offset, byte register(X) bcd, byte register(Y) only_low) render_bcd: { .const ZERO_CHAR = $35 - .label screen = 7 - .label screen_pos = $a - .label offset = $a + .label screen = $2c + .label screen_pos = $2e + .label offset = $2e // screen_pos = screen+offset lda.z screen_pos clc @@ -468,12 +462,14 @@ render_bcd: { } // Render the next tetromino in the "next" area render_next: { + // Find the screen area // Find the screen area .const next_area_offset = $28*$c+$18+4 - .label next_piece_char = $3b - .label next_piece_gfx = 7 - .label screen_next_area = $a - .label l = 5 + .label next_piece_char = $32 + // Render the next piece + .label next_piece_gfx = $2c + .label screen_next_area = $2e + .label l = $c // if(render_screen_render==0) cpx #0 beq __b1 @@ -554,8 +550,8 @@ render_next: { // Ignores cases where parts of the tetromino is outside the playfield (sides/bottom) since the movement collision routine prevents this. render_moving: { .label ypos = $c - .label screen_line = $30 - .label xpos = $21 + .label screen_line = $2c + .label xpos = $1e .label i = $1d .label l = $1c // ypos = current_ypos @@ -621,11 +617,12 @@ render_moving: { } // Render the static playfield on the screen (all pieces already locked into place) render_playfield: { - .label screen_line = $a + .label screen_line = $2c // Do not render the top 2 lines. - .label i = $1c - .label c = $1d - .label l = $c + // Do not render the top 2 lines. + .label i = $1d + .label c = $1e + .label l = $1c lda #PLAYFIELD_COLS*2 sta.z i lda #2 @@ -672,11 +669,11 @@ render_playfield: { // Perform any movement of the current piece // key_event is the next keyboard_event() og 0xff if no keyboard event is pending // Returns a byte signaling whether rendering is needed. (0 no render, >0 render needed) -// play_movement(byte zp($2f) key_event) +// play_movement(byte zp($2b) key_event) play_movement: { - .label render = $21 - .label return = $21 - .label key_event = $2f + .label render = $1f + .label return = $1f + .label key_event = $2b // play_move_down(key_event) lda.z key_event jsr play_move_down @@ -710,6 +707,7 @@ play_movement: { // Return non-zero if a render is needed // play_move_rotate(byte register(A) key_event) play_move_rotate: { + // Handle keyboard events // Handle keyboard events .label orientation = $c // if(key_event==KEY_Z) @@ -774,21 +772,21 @@ play_move_rotate: { play_collision: { .label xpos = $1c .label ypos = $1d - .label piece_gfx = $a + .label piece_gfx = $2e .label yp = $1d - .label playfield_line = $32 - .label i = $3b - .label xp = $3c + .label playfield_line = $30 + .label i = $32 + .label xp = $3b .label l = $1e - .label i_1 = $1f + .label i_1 = $20 // piece_gfx = current_piece + orientation txa clc - adc.z piece_gfx + adc.z current_piece_1 sta.z piece_gfx - bcc !+ - inc.z piece_gfx+1 - !: + lda #0 + adc.z current_piece_1+1 + sta.z piece_gfx+1 lda #0 sta.z l sta.z i_1 @@ -1030,7 +1028,9 @@ play_move_down: { // Spawn a new piece // Moves the next piece into the current and spawns a new next piece play_spawn_current: { - .label __7 = $34 + .label __7 = $33 + // Spawn a new next piece + // Pick a random piece (0-6) // Spawn a new next piece // Pick a random piece (0-6) .label piece_idx = $1a @@ -1090,8 +1090,8 @@ play_spawn_current: { // Update the score based on the number of lines removed // play_update_score(byte register(X) removed) play_update_score: { - .label lines_before = $34 - .label add_bcd = $35 + .label lines_before = $33 + .label add_bcd = $34 // if(removed!=0) cpx #0 beq __breturn @@ -1221,11 +1221,11 @@ play_increase_level: { // Whenever a full line is detected the writing cursor is instructed to write to the same line once more. // Returns the number of lines removed play_remove_lines: { - .label c = $3b + .label c = $3a .label x = $1e .label y = $1c .label removed = $1d - .label full = $1f + .label full = $20 lda #0 sta.z removed sta.z y @@ -1290,13 +1290,15 @@ play_remove_lines: { } // Lock the current piece onto the playfield play_lock_current: { - .label yp = $d - .label playfield_line = $39 - .label xp = $1f - .label i = $3b - .label l = $3c - .label i_1 = $1e + .label yp = $3b + .label playfield_line = $38 + .label xp = $33 + .label i = $3a + .label l = $20 + .label i_1 = $32 // yp = current_ypos + lda.z current_ypos + sta.z yp lda #0 sta.z l sta.z i_1 @@ -1396,9 +1398,9 @@ keyboard_event_get: { // Handles debounce and only generates events when the status of a key changes. // Also stores current status of modifiers in keyboard_modifiers. keyboard_event_scan: { - .label row_scan = $3c - .label keycode = $1f - .label row = $1e + .label row_scan = $3b + .label keycode = $20 + .label row = $1f lda #0 sta.z keycode sta.z row @@ -1549,9 +1551,10 @@ render_show: { } // Initialize play data tables play_init: { - .label pli = $22 + .label pli = $2c // Initialize the playfield line pointers; - .label idx = $21 + // Initialize the playfield line pointers; + .label idx = $32 lda #0 sta.z idx lda #PLAYFIELD_CHARSET)/$40 // Initialize the screen line pointers; - .label li_1 = $22 - .label li_2 = $30 + // Initialize the screen line pointers; + .label li_1 = $2c + .label li_2 = $2e // CIA2->PORT_A_DDR = %00000011 lda #3 sta CIA2+OFFSET_STRUCT_MOS6526_CIA_PORT_A_DDR @@ -1790,14 +1794,14 @@ render_init: { } // Copy the original screen data to the passed screen // Also copies colors to 0xd800 -// render_screen_original(byte* zp($30) screen) +// render_screen_original(byte* zp($2e) screen) render_screen_original: { .const SPACE = 0 - .label screen = $30 - .label cols = $24 - .label oscr = $32 - .label ocols = $39 - .label y = $2f + .label screen = $2e + .label cols = $2c + .label oscr = $30 + .label ocols = $38 + .label y = $2b lda #0 sta.z y lda #' + sta SCREEN+$4f + // } + rts +} main: { + // Print message // Print message .label sc = 4 .label msg = 2 @@ -124,20 +139,6 @@ memset: { !: jmp __b2 } -syscall2: { - // *(SCREEN+78) = '<' - lda #'<' - sta SCREEN+$4e - // } - rts -} -syscall1: { - // *(SCREEN+79) = '>' - lda #'>' - sta SCREEN+$4f - // } - rts -} .segment Data MESSAGE: .text "hello world!" .byte 0 diff --git a/src/test/ref/complex/xmega65/xmega65logo.asm b/src/test/ref/complex/xmega65/xmega65logo.asm index b4ce9806f..76a02e478 100644 --- a/src/test/ref/complex/xmega65/xmega65logo.asm +++ b/src/test/ref/complex/xmega65/xmega65logo.asm @@ -3,6 +3,7 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + // Create pointers to the palette RGBs in the logo (assumes dimensions are 128x128) // Create pointers to the palette RGBs in the logo (assumes dimensions are 128x128) .label LOGO256_RED = LOGO256+$80*$80 .label LOGO256_GREEN = LOGO256_RED+$100 diff --git a/src/test/ref/const-early-identification.asm b/src/test/ref/const-early-identification.asm index fb134303e..5d2995db0 100644 --- a/src/test/ref/const-early-identification.asm +++ b/src/test/ref/const-early-identification.asm @@ -1,16 +1,17 @@ // Tests that constants are identified early .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 - .label A = 2 -__bbegin: - // A = 'a' // Not an early constant (address-of is used) - lda #'a' - sta.z A - jsr main - rts + .label A = 2 +_start: { + // A = 'a' + lda #'a' + sta.z A + jsr main + rts +} main: { .const B = 'b' .label addrA = A diff --git a/src/test/ref/constants.asm b/src/test/ref/constants.asm index a7e0d2f24..6cd88fb6c 100644 --- a/src/test/ref/constants.asm +++ b/src/test/ref/constants.asm @@ -6,6 +6,7 @@ .const GREEN = 5 .const RED = 2 .label BG_COLOR = $d021 + .label print_screen = $400 .label print_char_cursor = 2 .label print_line_cursor = 4 main: { @@ -192,16 +193,16 @@ test_bytes: { .const bc = 2 .const bd = bc-4 // assert_byte("0=0", bb, 0) - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 lda #0 sta.z assert_byte.c ldx #bb - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #(SCREEN&$3fff)*4)|(>CHARSET)/4&$f .label col00 = COLS+$c*$28+$13 .label __4 = $a + //byte angle_b = atan2_8(x, y); + //diff_sum += diff(angle_b, *screen_ref); + //*screen = angle_b - *screen_ref++; + //*screen = angle_b; .label xw = $17 .label yw = $19 .label angle_w = $a @@ -120,9 +125,9 @@ print_uint: { .label w = 4 // print_uchar(>w) ldx.z w+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 jsr print_uchar // print_uchar(>i; yd=yi>>i .label xd = $c .label yd = $13 .label return = $a diff --git a/src/test/ref/cordic-atan2-16.asm b/src/test/ref/cordic-atan2-16.asm index 2a70b36ce..8001f4376 100644 --- a/src/test/ref/cordic-atan2-16.asm +++ b/src/test/ref/cordic-atan2-16.asm @@ -90,6 +90,7 @@ atan2_16: { .label yi = $a .label xi = $d .label angle = 6 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i .label xd = 8 .label yd = $f .label return = 6 diff --git a/src/test/ref/cordic-atan2-clear.asm b/src/test/ref/cordic-atan2-clear.asm index bf361ee69..0048a7aba 100644 --- a/src/test/ref/cordic-atan2-clear.asm +++ b/src/test/ref/cordic-atan2-clear.asm @@ -13,6 +13,7 @@ main: { .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f // Clear the screen by modifying the charset + // Clear the screen by modifying the charset .label clear_char = 2 // init_font_hex(CHARSET) jsr init_font_hex @@ -177,6 +178,7 @@ atan2_16: { .label yi = $11 .label xi = 4 .label angle = 6 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i .label xd = $a .label yd = 8 .label return = 6 diff --git a/src/test/ref/declared-memory-var-7.asm b/src/test/ref/declared-memory-var-7.asm index a48a5f226..6a5c6ec70 100644 --- a/src/test/ref/declared-memory-var-7.asm +++ b/src/test/ref/declared-memory-var-7.asm @@ -1,16 +1,17 @@ // Test declaring a variable as "memory", meaning it will be stored in memory and accessed through an implicit pointer (using load/store) // Test a zeropage notregister variable .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = 2 -__bbegin: - // idx - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx + lda #0 + sta.z idx + jsr main + rts +} main: { ldx #0 __b1: diff --git a/src/test/ref/declared-memory-var-8.asm b/src/test/ref/declared-memory-var-8.asm index 5955cde1b..1c6713123 100644 --- a/src/test/ref/declared-memory-var-8.asm +++ b/src/test/ref/declared-memory-var-8.asm @@ -1,16 +1,17 @@ // Test declaring a variable as "memory", meaning it will be stored in main memory // Test a fixed main memory address __notssa variable .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = $1000 -__bbegin: - // idx - lda #0 - sta idx - jsr main - rts +_start: { + // idx + lda #0 + sta idx + jsr main + rts +} main: { ldx #0 __b1: diff --git a/src/test/ref/declared-ssa-var-0.asm b/src/test/ref/declared-ssa-var-0.asm index 4212c733a..5f5e828c5 100644 --- a/src/test/ref/declared-ssa-var-0.asm +++ b/src/test/ref/declared-ssa-var-0.asm @@ -1,18 +1,19 @@ // Tests declaring variables as __ssa / __notssa .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN1 = $400 .label SCREEN2 = $400+$28 .label SCREEN3 = $400+$50 .label SCREEN4 = $400+$78 .label idx_nssa_g = 2 -__bbegin: - // idx_nssa_g - lda #0 - sta.z idx_nssa_g - jsr main - rts +_start: { + // idx_nssa_g + lda #0 + sta.z idx_nssa_g + jsr main + rts +} main: { .label idx_nssa_l = 3 // idx_nssa_l diff --git a/src/test/ref/deep-nesting.asm b/src/test/ref/deep-nesting.asm index 7dc99b09a..50d82f6ae 100644 --- a/src/test/ref/deep-nesting.asm +++ b/src/test/ref/deep-nesting.asm @@ -700,11 +700,5 @@ f98: { } f99: { .label return = 1 - // f100(x) - jsr f100 - // } - rts -} -f100: { rts } diff --git a/src/test/ref/empty-function-0.asm b/src/test/ref/empty-function-0.asm new file mode 100644 index 000000000..a8d630e7b --- /dev/null +++ b/src/test/ref/empty-function-0.asm @@ -0,0 +1,13 @@ +// Test removal of empty function +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .const v = 7 + .label SCREEN = $400 +main: { + // SCREEN[0] = v + lda #v + sta SCREEN + // } + rts +} diff --git a/src/test/ref/empty-function-1.asm b/src/test/ref/empty-function-1.asm new file mode 100644 index 000000000..3975f34ef --- /dev/null +++ b/src/test/ref/empty-function-1.asm @@ -0,0 +1,12 @@ +// Test removal of empty function +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label SCREEN = $400 +main: { + // SCREEN[0] = 'x' + lda #'x' + sta SCREEN + // } + rts +} diff --git a/src/test/ref/empty-function-2.asm b/src/test/ref/empty-function-2.asm new file mode 100644 index 000000000..b87219678 --- /dev/null +++ b/src/test/ref/empty-function-2.asm @@ -0,0 +1,9 @@ +// Test removal of empty function +// main() should not be removed! +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +main: { + // } + rts +} diff --git a/src/test/ref/euclid-3.asm b/src/test/ref/euclid-3.asm index 72998d5fc..4f9e4cbb9 100644 --- a/src/test/ref/euclid-3.asm +++ b/src/test/ref/euclid-3.asm @@ -6,21 +6,22 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 4 - .label print_char_cursor = 6 + .label print_screen = $400 + .label print_line_cursor = 6 + .label print_char_cursor = 4 main: { // print_cls() jsr print_cls // print_euclid(128,2) - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 lda #2 sta.z print_euclid.b - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$80 sta.z print_euclid.a @@ -206,9 +207,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = 8 + .label dst = 6 lda #str diff --git a/src/test/ref/examples/3d/3d.asm b/src/test/ref/examples/3d/3d.asm index 0b1d66bd1..15e926c3f 100644 --- a/src/test/ref/examples/3d/3d.asm +++ b/src/test/ref/examples/3d/3d.asm @@ -21,25 +21,25 @@ // The VIC-II MOS 6567/6569 .label VICII = $d000 // The rotated point - updated by calling rotate_matrix() + // The rotated point - updated by calling rotate_matrix() .label xr = $f0 .label yr = $f1 .label zr = $f2 // The rotated point with perspective + // The rotated point with perspective .label pp = $f3 .label xp = $f4 .label yp = $f5 // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2 .label psp1 = $f6 .label psp2 = $f8 .label SCREEN = $400 - // A single sprite - .label SPRITE = $3000 .label COSH = SINH+$40 .label COSQ = SINQ+$40 .label print_screen = $400 - .label sx = 2 - .label sy = 3 - // kickasm + .label sx = 3 + .label sy = 4 main: { // asm sei @@ -65,7 +65,7 @@ main: { rts } anim: { - .label i = 4 + .label i = 2 lda #0 sta.z sy sta.z sx @@ -188,8 +188,8 @@ debug_print: { .const print_schar_pos12_row = 6 .const print_schar_pos12_col = $25 .label at_line = SCREEN+$13*$28 - .label c = 5 - .label i = 6 + .label c = 6 + .label i = 7 // print_schar_pos(sx, 0, 37) lda.z sx // print_schar_at(sb, print_screen+row*40+col) @@ -389,9 +389,9 @@ debug_print: { rts } // Print a signed char as hex at a specific screen position -// print_schar_at(signed byte zp(7) b, byte* zp($e) at) +// print_schar_at(signed byte zp(5) b, byte* zp($e) at) print_schar_at: { - .label b = 7 + .label b = 5 .label at = $e // if(b<0) lda.z b @@ -432,9 +432,9 @@ print_char_at: { rts } // Print a char as HEX at a specific position -// print_uchar_at(byte zp(7) b, byte* zp($e) at) +// print_uchar_at(byte zp(5) b, byte* zp($e) at) print_uchar_at: { - .label b = 7 + .label b = 5 .label at = $e // b>>4 lda.z b @@ -615,17 +615,21 @@ store_matrix: { // Prepare the 3x3 rotation matrix into rotation_matrix[] // Angles sx, sy, sz are based on 2*PI=$100 // Method described in C= Hacking Magazine Issue 8. http://www.ffd2.com/fridge/chacking/c=hacking8.txt -// calculate_matrix(signed byte register(X) sx, signed byte zp(3) sy) +// calculate_matrix(signed byte register(X) sx, signed byte zp(4) sy) calculate_matrix: { - .label sy = 3 + .label sy = 4 .label t1 = 5 .label t2 = 6 .label t3 = 7 .label t4 = 8 .label t5 = 9 + // = sx+sy+sz .label t6 = $a + // = sx-sy+sz .label t7 = $b + // = sx+sy-sz .label t8 = $c + // = sy+sz-sx .label t9 = $d // t1 = sy-sz lda.z sy @@ -818,8 +822,8 @@ debug_print_init: { .label __59 = $1a .label __62 = $1c .label __65 = $1e - .label c = 4 - .label i = 5 + .label c = 3 + .label i = 4 // print_cls() jsr print_cls // print_str_at("sx", SCREEN+40*0+34) @@ -1210,7 +1214,7 @@ sprites_init: { ldx #0 __b1: // sprites_ptr[i] = (char)(SPRITE/$40) - lda #SPRITE/$40 + lda #$ff&SPRITE/$40 sta sprites_ptr,x // SPRITES_COLOR[i] = GREEN lda #GREEN @@ -1301,8 +1305,10 @@ SINQ: } } -.pc = SPRITE "SPRITE" - .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) +.pc = $3000 "SPRITE" +// A single sprite +SPRITE: +.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) .for (var y=0; y<21; y++) .for (var x=0;x<3; x++) .byte pic.getSinglecolorByte(x,y) diff --git a/src/test/ref/examples/3d/perspective.asm b/src/test/ref/examples/3d/perspective.asm index 69a441417..a8b9e474b 100644 --- a/src/test/ref/examples/3d/perspective.asm +++ b/src/test/ref/examples/3d/perspective.asm @@ -8,13 +8,16 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + // The rotated point - updated by calling rotate() // The rotated point - updated by calling rotate() .label xr = $f0 .label yr = $f1 .label zr = $f2 // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. + // Pointers used to multiply perspective (d/z0-z) onto x- & y-coordinates. Points into mulf_sqr1 / mulf_sqr2. .label psp1 = $f3 .label psp2 = $f5 + .label print_screen = $400 .label print_char_cursor = 4 .label print_line_cursor = 2 main: { @@ -44,9 +47,9 @@ do_perspective: { .label y = -$47 .label z = $36 // print_str("(") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 __b1: // print_line_cursor + $28 @@ -141,9 +144,9 @@ print_ln: { rts } // Print a zero-terminated string -// print_str(byte* zp(6) str) +// print_str(byte* zp(2) str) print_str: { - .label str = 6 + .label str = 2 __b1: // while(*str) ldy #0 @@ -272,9 +275,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = 6 + .label dst = 4 lda #str @@ -303,9 +306,9 @@ memset: { } // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x) and g(x) = f(1-x) mulf_init: { - .label val = $a - .label sqr = 6 - .label add = 8 + .label val = 6 + .label sqr = 2 + .label add = 4 lda #<1 sta.z add lda #>1 diff --git a/src/test/ref/examples/atari2600/atari2600-sprites.asm b/src/test/ref/examples/atari2600/atari2600-sprites.asm index cc9a917e7..49a5ebdfa 100644 --- a/src/test/ref/examples/atari2600/atari2600-sprites.asm +++ b/src/test/ref/examples/atari2600/atari2600-sprites.asm @@ -8,9 +8,9 @@ .segmentdef Data [startAfter="Code",max=$fff9] .segmentdef Vectors [start=$fffa,max=$ffff] .segment Vectors -.word __bbegin // NMI -.word __bbegin // RESET -.word __bbegin // IRQ +.word _start // NMI +.word _start // RESET +.word _start // IRQ .segment Code // The number of CPU cycles per scanline @@ -34,20 +34,21 @@ .label TIA = 0 // Atari RIOT registers .label RIOT = $280 + // Player 0 X position .label p0_xpos = $82 // Counts frames .label idx = $80 // Player 0 Y position .label p0_ypos = $83 .label idx2 = $81 -__bbegin: - // p0_xpos - // Player 0 X position - lda #0 - sta.z p0_xpos - jsr main - rts .segment Code +_start: { + // p0_xpos + lda #0 + sta.z p0_xpos + jsr main + rts +} main: { // asm cld diff --git a/src/test/ref/examples/bresenham/bitmap-bresenham.asm b/src/test/ref/examples/bresenham/bitmap-bresenham.asm index b651e739f..c7b479c44 100644 --- a/src/test/ref/examples/bresenham/bitmap-bresenham.asm +++ b/src/test/ref/examples/bresenham/bitmap-bresenham.asm @@ -236,6 +236,7 @@ bitmap_line_xdyi: { } // bitmap_plot(byte register(X) x, byte register(Y) y) bitmap_plot: { + // Needs unsigned int arrays arranged as two underlying char arrays to allow char* plotter_x = plot_x[x]; - and eventually - char* plotter = plot_x[x] + plot_y[y]; .label plotter_x = 9 .label plotter_y = $b .label plotter = 9 diff --git a/src/test/ref/examples/chargen/chargen-analysis.asm b/src/test/ref/examples/chargen/chargen-analysis.asm index c82092e14..8b82bd356 100644 --- a/src/test/ref/examples/chargen/chargen-analysis.asm +++ b/src/test/ref/examples/chargen/chargen-analysis.asm @@ -73,8 +73,10 @@ main: { .label i = 4 .label ch = 7 // Which char canvas to use + // Which char canvas to use .label cur_pos = 5 // Is shift pressed + // Is shift pressed .label shift = 6 lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS - // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT - // The current text color - lda #LIGHT_BLUE - sta.z conio_textcolor - // conio_scroll_enable = 1 - // Is scrolling enabled when outputting beyond the end of the screen (1: yes, 0: no). - // If disabled the cursor just moves back to (0,0) instead - lda #1 - sta.z conio_scroll_enable - // XSize - lda #0 - sta.z XSize - // YSize - sta.z YSize - jsr main - rts +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT + lda #LIGHT_BLUE + sta.z conio_textcolor + // conio_scroll_enable = 1 + lda #1 + sta.z conio_scroll_enable + // XSize + lda #0 + sta.z XSize + // YSize + sta.z YSize + jsr main + rts +} main: { // *VIC_MEMORY = 0x17 lda #$17 @@ -193,8 +194,6 @@ MakeNiceScreen: { jsr bgcolor // clrscr () jsr clrscr - // cursor (0) - jsr cursor // cputcxy (0, 0, CH_ULCORNER) /* Top line */ ldy #CH_ULCORNER @@ -782,13 +781,6 @@ cvline: { inc.z i jmp __b1 } -// If onoff is 1, a cursor is displayed when waiting for keyboard input. -// If onoff is 0, the cursor is hidden when waiting for keyboard input. -// The function returns the old cursor setting. -cursor: { - // } - rts -} // Set the color for the background. The old color setting is returned. bgcolor: { // The background color register address diff --git a/src/test/ref/examples/eightqueens/eightqueens-recursive.asm b/src/test/ref/examples/eightqueens/eightqueens-recursive.asm index 67d8c1176..4d295a999 100644 --- a/src/test/ref/examples/eightqueens/eightqueens-recursive.asm +++ b/src/test/ref/examples/eightqueens/eightqueens-recursive.asm @@ -4,7 +4,7 @@ // // This is a recursive solution .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -25,43 +25,44 @@ .label DEFAULT_SCREEN = $400 // The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 - .label conio_cursor_x = $14 - .label conio_cursor_y = $15 - .label conio_line_text = $16 - .label conio_line_color = $18 - .label count = 2 -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $14 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $15 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $16 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - // count = 0 + .label conio_line_color = $18 // The number of found solutions - lda #<0 - sta.z count - sta.z count+1 - lda #<0>>$10 - sta.z count+2 - lda #>0>>$10 - sta.z count+3 - jsr main - rts + .label count = 2 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + // count = 0 + lda #<0 + sta.z count + sta.z count+1 + lda #<0>>$10 + sta.z count+2 + lda #>0>>$10 + sta.z count+3 + jsr main + rts +} main: { // clrscr() jsr clrscr @@ -411,6 +412,7 @@ printf_ulong: { printf_number_buffer: { .label __19 = $a .label buffer_sign = $1a + // There is a minimum length - work out the padding .label len = $11 .label padding = $10 .label format_min_length = $10 diff --git a/src/test/ref/examples/eightqueens/eightqueens.asm b/src/test/ref/examples/eightqueens/eightqueens.asm index aaceb4e78..fcdb511ad 100644 --- a/src/test/ref/examples/eightqueens/eightqueens.asm +++ b/src/test/ref/examples/eightqueens/eightqueens.asm @@ -4,7 +4,7 @@ // // This is an iterative solution. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -13,35 +13,36 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 + // The number of bytes on the screen + // The current cursor x-position .label conio_cursor_x = $19 + // The current cursor y-position .label conio_cursor_y = $1a + // The current text cursor line start .label conio_line_text = $1b + // The current color cursor line start .label conio_line_color = $1d // The number of found solutions .label count = 2 -__bbegin: - // conio_cursor_x = 0 - // The number of bytes on the screen - // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 - // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT - // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS - // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr @@ -710,6 +711,7 @@ ultoa_append: { // The solution uses the board itself as a "cursor" moving through all possibilities // When all columns on a row is exhausted move back down to the lower level and move forward one position until we are done with the last position on the first row queens: { + // The current row where the queen is moving // The current row where the queen is moving .label row = $d lda #<0 diff --git a/src/test/ref/examples/fastmultiply/fastmultiply8.asm b/src/test/ref/examples/fastmultiply/fastmultiply8.asm index a4285bbe0..29ba5e41e 100644 --- a/src/test/ref/examples/fastmultiply/fastmultiply8.asm +++ b/src/test/ref/examples/fastmultiply/fastmultiply8.asm @@ -8,6 +8,7 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + // Pointers to a, b and c=a*b // Pointers to a, b and c=a*b .label ap = $fd .label bp = $fe diff --git a/src/test/ref/examples/fire/fire.asm b/src/test/ref/examples/fire/fire.asm index 6558733ac..23c8bc2c7 100644 --- a/src/test/ref/examples/fire/fire.asm +++ b/src/test/ref/examples/fire/fire.asm @@ -98,7 +98,9 @@ main: { } // Animate the fire on the passed screen. Uses BUFFER to store the current values. fire: { + // Average characters from below the current character (24 lines) .label screen = 2 + // Average characters from below the current character (24 lines) .label screen_1 = $b .label buffer = 4 .label buffer_1 = 9 diff --git a/src/test/ref/examples/helloworld/helloworld.asm b/src/test/ref/examples/helloworld/helloworld.asm index d59b22081..bcc37ace4 100644 --- a/src/test/ref/examples/helloworld/helloworld.asm +++ b/src/test/ref/examples/helloworld/helloworld.asm @@ -1,39 +1,40 @@ // Functions for performing input and output. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e // Color Ram .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = 6 - .label conio_cursor_y = 7 - .label conio_line_text = 8 - .label conio_line_color = $a -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 6 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = 7 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = 8 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $a +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // printf("hello world!\n") jsr cputs diff --git a/src/test/ref/examples/irq/irq-hyperscreen.asm b/src/test/ref/examples/irq/irq-hyperscreen.asm index 3b89cbc7f..24e13a928 100644 --- a/src/test/ref/examples/irq/irq-hyperscreen.asm +++ b/src/test/ref/examples/irq/irq-hyperscreen.asm @@ -25,39 +25,6 @@ // The vector used when the KERNAL serves IRQ interrupts .label KERNEL_IRQ = $314 .label GHOST_BYTE = $3fff -main: { - // *GHOST_BYTE = 0 - lda #0 - sta GHOST_BYTE - // asm - sei - // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR - // Disable CIA 1 Timer IRQ - lda #CIA_INTERRUPT_CLEAR - sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT - // VICII->CONTROL1 &=$7f - // Set raster line to $fa - lda #$7f - and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 - sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 - // VICII->RASTER = $fa - lda #$fa - sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER - // VICII->IRQ_ENABLE = IRQ_RASTER - // Enable Raster Interrupt - lda #IRQ_RASTER - sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE - // *KERNEL_IRQ = &irq_bottom_1 - // Set the IRQ routine - lda #irq_bottom_1 - sta KERNEL_IRQ+1 - // asm - cli - // } - rts -} // Interrupt Routine 2 irq_bottom_2: { // VICII->BORDER_COLOR = WHITE @@ -116,3 +83,36 @@ irq_bottom_1: { // } jmp $ea81 } +main: { + // *GHOST_BYTE = 0 + lda #0 + sta GHOST_BYTE + // asm + sei + // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR + // Disable CIA 1 Timer IRQ + lda #CIA_INTERRUPT_CLEAR + sta CIA1+OFFSET_STRUCT_MOS6526_CIA_INTERRUPT + // VICII->CONTROL1 &=$7f + // Set raster line to $fa + lda #$7f + and VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_CONTROL1 + // VICII->RASTER = $fa + lda #$fa + sta VICII+OFFSET_STRUCT_MOS6569_VICII_RASTER + // VICII->IRQ_ENABLE = IRQ_RASTER + // Enable Raster Interrupt + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_ENABLE + // *KERNEL_IRQ = &irq_bottom_1 + // Set the IRQ routine + lda #irq_bottom_1 + sta KERNEL_IRQ+1 + // asm + cli + // } + rts +} diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.asm b/src/test/ref/examples/multiplexer/simple-multiplexer.asm index 2246ac309..7fcbdcc72 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.asm +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.asm @@ -3,7 +3,7 @@ // The MOS 6526 Complex Interface Adapter (CIA) // http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const VIC_RST8 = $80 .const VIC_DEN = $10 @@ -24,33 +24,33 @@ // The VIC-II MOS 6567/6569 .label VICII = $d000 // Location of screen & sprites + // Location of screen & sprites .label SCREEN = $400 - .label SPRITE = $2000 // The address of the sprite pointers on the current screen (screen+0x3f8). .label PLEX_SCREEN_PTR = SCREEN+$3f8 - .label plex_show_idx = 6 - .label plex_sprite_idx = 7 - .label plex_sprite_msb = 8 - .label plex_free_next = 9 -__bbegin: - // plex_show_idx=0 // The index in the PLEX tables of the next sprite to show - lda #0 - sta.z plex_show_idx - // plex_sprite_idx=0 + .label plex_show_idx = 6 // The index the next sprite to use for showing (sprites are used round-robin) - sta.z plex_sprite_idx - // plex_sprite_msb=1 + .label plex_sprite_idx = 7 // The MSB bit of the next sprite to use for showing - lda #1 - sta.z plex_sprite_msb - // plex_free_next = 0 + .label plex_sprite_msb = 8 // The index of the sprite that is free next. Since sprites are used round-robin this moves forward each time a sprite is shown. - lda #0 - sta.z plex_free_next - // kickasm - jsr main - rts + .label plex_free_next = 9 +_start: { + // plex_show_idx=0 + lda #0 + sta.z plex_show_idx + // plex_sprite_idx=0 + sta.z plex_sprite_idx + // plex_sprite_msb=1 + lda #1 + sta.z plex_sprite_msb + // plex_free_next = 0 + lda #0 + sta.z plex_free_next + jsr main + rts +} main: { // asm sei @@ -63,6 +63,7 @@ main: { } // The raster loop loop: { + // The current index into the y-sinus // The current index into the y-sinus .label sin_idx = 2 .label plexFreeNextYpos1_return = $a @@ -300,6 +301,7 @@ plexSort: { } // Initialize the program init: { + // Set the x-positions & pointers // Set the x-positions & pointers .label xp = 4 // *D011 = VIC_DEN | VIC_RSEL | 3 @@ -315,7 +317,7 @@ init: { ldx #0 __b1: // PLEX_PTR[sx] = (char)(SPRITE/$40) - lda #SPRITE/$40 + lda #$ff&SPRITE/$40 sta PLEX_PTR,x // PLEX_XPOS[sx] = xp txa @@ -385,8 +387,9 @@ YSIN: .for(var i=0;i<256;i++) .byte round(min+(ampl/2)+(ampl/2)*sin(toRadians(360*i/256))) -.pc = SPRITE "SPRITE" - .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) +.pc = $2000 "SPRITE" +SPRITE: +.var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) .for (var y=0; y<21; y++) .for (var x=0;x<3; x++) .byte pic.getSinglecolorByte(x,y) diff --git a/src/test/ref/examples/music/music.asm b/src/test/ref/examples/music/music.asm index 5b4df9f3f..f73fe28a5 100644 --- a/src/test/ref/examples/music/music.asm +++ b/src/test/ref/examples/music/music.asm @@ -9,17 +9,17 @@ .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 // The VIC-II MOS 6567/6569 .label VICII = $d000 - .label MUSIC = $1000 - // kickasm - // Load the SID - .const music = LoadSid("toiletrensdyr.sid") - -// Place the SID into memory + // Pointer to the music init routine + // Pointer to the music init routine + .label musicInit = MUSIC + // Pointer to the music play routine + // Pointer to the music play routine + .label musicPlay = MUSIC+3 // Play the music main: { - // asm + // (*musicInit)() // Initialize the music - jsr music.init + jsr musicInit // Wait for the RASTER __b1: // while (VICII->RASTER != $fd) @@ -28,13 +28,16 @@ main: { bne __b1 // (VICII->BORDER_COLOR)++; inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // asm + // (*musicPlay)() // Play the music - jsr music.play + jsr musicPlay // (VICII->BORDER_COLOR)--; dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR jmp __b1 } -.pc = MUSIC "MUSIC" - .fill music.size, music.getData(i) +.pc = $1000 "MUSIC" +// SID tune at an absolute address +MUSIC: +.const music = LoadSid("toiletrensdyr.sid") + .fill music.size, music.getData(i) diff --git a/src/test/ref/examples/music/music_irq.asm b/src/test/ref/examples/music/music_irq.asm index f265c2227..e86be0429 100644 --- a/src/test/ref/examples/music/music_irq.asm +++ b/src/test/ref/examples/music/music_irq.asm @@ -21,17 +21,34 @@ .label CIA1 = $dc00 // The vector used when the KERNAL serves IRQ interrupts .label KERNEL_IRQ = $314 - .label MUSIC = $1000 - // kickasm - // Load the SID - .const music = LoadSid("toiletrensdyr.sid") - -// Place the SID into memory + // Pointer to the music init routine + // Pointer to the music init routine + .label musicInit = MUSIC + // Pointer to the music play routine + // Pointer to the music play routine + .label musicPlay = MUSIC+3 +// Raster IRQ Routine playing music +irq_play: { + // (VICII->BORDER_COLOR)++; + inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // (*musicPlay)() + // Play SID + jsr musicPlay + // VICII->IRQ_STATUS = IRQ_RASTER + // Acknowledge the IRQ + lda #IRQ_RASTER + sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS + // (VICII->BORDER_COLOR)--; + dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // } + jmp $ea31 +} // Setup Raster IRQ and initialize SID player main: { // asm sei - jsr music.init + // (*musicInit)() + jsr musicInit // CIA1->INTERRUPT = CIA_INTERRUPT_CLEAR // Disable CIA 1 Timer IRQ lda #CIA_INTERRUPT_CLEAR @@ -59,22 +76,9 @@ main: { // } rts } -// Raster IRQ Routine playing music -irq_play: { - // (VICII->BORDER_COLOR)++; - inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // asm - // Play SID - jsr music.play - // VICII->IRQ_STATUS = IRQ_RASTER - // Acknowledge the IRQ - lda #IRQ_RASTER - sta VICII+OFFSET_STRUCT_MOS6569_VICII_IRQ_STATUS - // (VICII->BORDER_COLOR)--; - dec VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR - // } - jmp $ea31 -} -.pc = MUSIC "MUSIC" - .fill music.size, music.getData(i) +.pc = $1000 "MUSIC" +// SID tune at an absolute address +MUSIC: +.const music = LoadSid("toiletrensdyr.sid") + .fill music.size, music.getData(i) diff --git a/src/test/ref/examples/nes-conio/nes-conio.asm b/src/test/ref/examples/nes-conio/nes-conio.asm index 9a0d0c34b..d1aef92e2 100644 --- a/src/test/ref/examples/nes-conio/nes-conio.asm +++ b/src/test/ref/examples/nes-conio/nes-conio.asm @@ -81,36 +81,39 @@ // Pointer to the start of RAM memory .label MEMORY = 0 // NES Picture Processing Unit (PPU) + // NES Picture Processing Unit (PPU) .label PPU = $2000 // NES CPU and audion processing unit (APU) + // NES CPU and audion processing unit (APU) .label APU = $4000 + // The current cursor x-position .label conio_cursor_x = $11 + // The current cursor y-position .label conio_cursor_y = $12 + // The current text cursor line start .label conio_line_text = $13 .label x_scroll = $15 .label y_scroll = $16 -__bbegin: - // conio_cursor_x = 0 - // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 - // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT - // The current text cursor line start - lda #PPU_NAME_TABLE_0 - sta.z conio_line_text+1 - // x_scroll - lda #0 - sta.z x_scroll - // y_scroll - sta.z y_scroll - jsr main - rts .segment Code +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #PPU_NAME_TABLE_0 + sta.z conio_line_text+1 + // x_scroll + lda #0 + sta.z x_scroll + // y_scroll + sta.z y_scroll + jsr main + rts +} // RESET Called when the NES is reset, including when it is turned on. main: { .const screensizex1_return = $20 @@ -363,6 +366,7 @@ cputln: { } // Scroll the entire screen if the cursor is beyond the last line cscroll: { + // Scroll lines up // Scroll lines up .label line1 = $17 .label line2 = $f @@ -456,6 +460,7 @@ cscroll: { // ppuDataTransfer(void* zp(5) ppuData, void* zp(7) cpuData, word zp(9) size) ppuDataTransfer: { .label ppuDataPrepare1_ppuData = 5 + // Transfer to PPU .label cpuSrc = 7 .label i = $b .label ppuData = 5 @@ -511,6 +516,7 @@ ppuDataFetch: { .const size = $20 .label cpuData = conio_cscroll_buffer // Fetch from PPU to CPU + // Fetch from PPU to CPU .label cpuDst = 7 .label i = 5 .label ppuData = $19 @@ -626,9 +632,9 @@ ppuDataSet: { // Set the cursor to the specified position // gotoxy(byte register(X) x, byte register(A) y) gotoxy: { - .label __5 = $13 - .label __6 = $13 - .label line_offset = $13 + .label __5 = $1b + .label __6 = $1b + .label line_offset = $1b // if(y>CONIO_HEIGHT) cmp #$1e+1 bcc __b1 @@ -667,6 +673,10 @@ gotoxy: { adc #>PPU_NAME_TABLE_0 sta.z __5+1 // conio_line_text = CONIO_SCREEN_TEXT + line_offset + lda.z __5 + sta.z conio_line_text + lda.z __5+1 + sta.z conio_line_text+1 // } rts } @@ -682,9 +692,9 @@ cputsxy: { rts } // Output a NUL-terminated string at the current cursor position -// cputs(byte* zp($d) s) +// cputs(byte* zp($1b) s) cputs: { - .label s = $d + .label s = $1b lda #num_buffer @@ -716,10 +726,10 @@ cputs: { // uctoa(byte register(X) value, byte* zp($f) buffer) uctoa: { .const max_digits = 2 - .label digit_value = $1b + .label digit_value = $1d .label buffer = $f - .label digit = $11 - .label started = $12 + .label digit = $d + .label started = $e lda #num_buffer @@ -784,10 +794,10 @@ uctoa: { // - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased. // (For decimal the subs used are 10000, 1000, 100, 10, 1) // returns : the value reduced by sub * digit so that it is less than sub. -// uctoa_append(byte* zp($f) buffer, byte register(X) value, byte zp($1b) sub) +// uctoa_append(byte* zp($f) buffer, byte register(X) value, byte zp($1d) sub) uctoa_append: { .label buffer = $f - .label sub = $1b + .label sub = $1d ldy #0 __b1: // while (value >= sub) @@ -919,7 +929,7 @@ vblank: { // - bit 6: B // - bit 7: A readJoy1: { - .label __1 = $1c + .label __1 = $1e // APU->JOY1 = 1 // Latch the controller buttons lda #1 diff --git a/src/test/ref/examples/nes-demo/nes-demo.asm b/src/test/ref/examples/nes-demo/nes-demo.asm index e6689e237..4482b7145 100644 --- a/src/test/ref/examples/nes-demo/nes-demo.asm +++ b/src/test/ref/examples/nes-demo/nes-demo.asm @@ -82,10 +82,143 @@ // Pointer to the start of RAM memory .label MEMORY = 0 // NES Picture Processing Unit (PPU) + // NES Picture Processing Unit (PPU) .label PPU = $2000 // NES CPU and audion processing unit (APU) + // NES CPU and audion processing unit (APU) .label APU = $4000 .segment Code +// NMI Called when the PPU refreshes the screen (also known as the V-Blank period) +vblank: { + pha + txa + pha + tya + pha + // readJoy1() + jsr readJoy1 + // joy = readJoy1() + tax + // joy&JOY_DOWN + txa + and #JOY_DOWN + // if(joy&JOY_DOWN) + cmp #0 + beq __b1 + // SPRITE_BUFFER[0].y++; + inc SPRITE_BUFFER + // SPRITE_BUFFER[1].y++; + inc SPRITE_BUFFER+1*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[2].y++; + inc SPRITE_BUFFER+2*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[3].y++; + inc SPRITE_BUFFER+3*SIZEOF_STRUCT_SPRITEDATA + __b1: + // joy&JOY_UP + txa + and #JOY_UP + // if(joy&JOY_UP) + cmp #0 + beq __b2 + // SPRITE_BUFFER[0].y--; + dec SPRITE_BUFFER + // SPRITE_BUFFER[1].y--; + dec SPRITE_BUFFER+1*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[2].y--; + dec SPRITE_BUFFER+2*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[3].y--; + dec SPRITE_BUFFER+3*SIZEOF_STRUCT_SPRITEDATA + __b2: + // joy&JOY_LEFT + txa + and #JOY_LEFT + // if(joy&JOY_LEFT) + cmp #0 + beq __b3 + // SPRITE_BUFFER[0].x--; + dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X + // SPRITE_BUFFER[1].x--; + dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+1*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[2].x--; + dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+2*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[3].x--; + dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+3*SIZEOF_STRUCT_SPRITEDATA + __b3: + // joy&JOY_RIGHT + txa + and #JOY_RIGHT + // if(joy&JOY_RIGHT) + cmp #0 + beq ppuSpriteBufferDmaTransfer1 + // SPRITE_BUFFER[0].x++; + inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X + // SPRITE_BUFFER[1].x++; + inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+1*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[2].x++; + inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+2*SIZEOF_STRUCT_SPRITEDATA + // SPRITE_BUFFER[3].x++; + inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+3*SIZEOF_STRUCT_SPRITEDATA + ppuSpriteBufferDmaTransfer1: + // PPU->OAMADDR = 0 + lda #0 + sta PPU+OFFSET_STRUCT_RICOH_2C02_OAMADDR + // APU->OAMDMA = >spriteBuffer + lda #>SPRITE_BUFFER + sta APU+OFFSET_STRUCT_RICOH_2A03_OAMDMA + // PPU->PPUSCROLL = 0 + // Set scroll + lda #0 + sta PPU+OFFSET_STRUCT_RICOH_2C02_PPUSCROLL + // PPU->PPUSCROLL = -8 + lda #-8 + sta PPU+OFFSET_STRUCT_RICOH_2C02_PPUSCROLL + // } + pla + tay + pla + tax + pla + rti +} +// Read Standard Controller #1 +// Returns a byte representing the pushed buttons +// - bit 0: right +// - bit 1: left +// - bit 2: down +// - bit 3: up +// - bit 4: start +// - bit 5: select +// - bit 6: B +// - bit 7: A +readJoy1: { + .label __1 = 8 + // APU->JOY1 = 1 + // Latch the controller buttons + lda #1 + sta APU+OFFSET_STRUCT_RICOH_2A03_JOY1 + // APU->JOY1 = 0 + lda #0 + sta APU+OFFSET_STRUCT_RICOH_2A03_JOY1 + tax + __b1: + // for(char i=0;i<8;i++) + cpx #8 + bcc __b2 + // } + rts + __b2: + // joy<<1 + asl + sta.z __1 + // APU->JOY1&1 + lda #1 + and APU+OFFSET_STRUCT_RICOH_2A03_JOY1 + // joy = joy<<1 | APU->JOY1&1 + ora.z __1 + // for(char i=0;i<8;i++) + inx + jmp __b1 +} // RESET Called when the NES is reset, including when it is turned on. main: { // asm @@ -368,6 +501,7 @@ ppuDataTransfer: { .label ppuData = PPU_PALETTE .label cpuData = PALETTE // Transfer to PPU + // Transfer to PPU .label cpuSrc = 6 .label i = 4 // PPU->PPUADDR = >ppuData @@ -413,137 +547,6 @@ ppuDataTransfer: { !: jmp __b1 } -// NMI Called when the PPU refreshes the screen (also known as the V-Blank period) -vblank: { - pha - txa - pha - tya - pha - // readJoy1() - jsr readJoy1 - // joy = readJoy1() - tax - // joy&JOY_DOWN - txa - and #JOY_DOWN - // if(joy&JOY_DOWN) - cmp #0 - beq __b1 - // SPRITE_BUFFER[0].y++; - inc SPRITE_BUFFER - // SPRITE_BUFFER[1].y++; - inc SPRITE_BUFFER+1*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[2].y++; - inc SPRITE_BUFFER+2*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[3].y++; - inc SPRITE_BUFFER+3*SIZEOF_STRUCT_SPRITEDATA - __b1: - // joy&JOY_UP - txa - and #JOY_UP - // if(joy&JOY_UP) - cmp #0 - beq __b2 - // SPRITE_BUFFER[0].y--; - dec SPRITE_BUFFER - // SPRITE_BUFFER[1].y--; - dec SPRITE_BUFFER+1*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[2].y--; - dec SPRITE_BUFFER+2*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[3].y--; - dec SPRITE_BUFFER+3*SIZEOF_STRUCT_SPRITEDATA - __b2: - // joy&JOY_LEFT - txa - and #JOY_LEFT - // if(joy&JOY_LEFT) - cmp #0 - beq __b3 - // SPRITE_BUFFER[0].x--; - dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X - // SPRITE_BUFFER[1].x--; - dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+1*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[2].x--; - dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+2*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[3].x--; - dec SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+3*SIZEOF_STRUCT_SPRITEDATA - __b3: - // joy&JOY_RIGHT - txa - and #JOY_RIGHT - // if(joy&JOY_RIGHT) - cmp #0 - beq ppuSpriteBufferDmaTransfer1 - // SPRITE_BUFFER[0].x++; - inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X - // SPRITE_BUFFER[1].x++; - inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+1*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[2].x++; - inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+2*SIZEOF_STRUCT_SPRITEDATA - // SPRITE_BUFFER[3].x++; - inc SPRITE_BUFFER+OFFSET_STRUCT_SPRITEDATA_X+3*SIZEOF_STRUCT_SPRITEDATA - ppuSpriteBufferDmaTransfer1: - // PPU->OAMADDR = 0 - lda #0 - sta PPU+OFFSET_STRUCT_RICOH_2C02_OAMADDR - // APU->OAMDMA = >spriteBuffer - lda #>SPRITE_BUFFER - sta APU+OFFSET_STRUCT_RICOH_2A03_OAMDMA - // PPU->PPUSCROLL = 0 - // Set scroll - lda #0 - sta PPU+OFFSET_STRUCT_RICOH_2C02_PPUSCROLL - // PPU->PPUSCROLL = -8 - lda #-8 - sta PPU+OFFSET_STRUCT_RICOH_2C02_PPUSCROLL - // } - pla - tay - pla - tax - pla - rti -} -// Read Standard Controller #1 -// Returns a byte representing the pushed buttons -// - bit 0: right -// - bit 1: left -// - bit 2: down -// - bit 3: up -// - bit 4: start -// - bit 5: select -// - bit 6: B -// - bit 7: A -readJoy1: { - .label __1 = 8 - // APU->JOY1 = 1 - // Latch the controller buttons - lda #1 - sta APU+OFFSET_STRUCT_RICOH_2A03_JOY1 - // APU->JOY1 = 0 - lda #0 - sta APU+OFFSET_STRUCT_RICOH_2A03_JOY1 - tax - __b1: - // for(char i=0;i<8;i++) - cpx #8 - bcc __b2 - // } - rts - __b2: - // joy<<1 - asl - sta.z __1 - // APU->JOY1&1 - lda #1 - and APU+OFFSET_STRUCT_RICOH_2A03_JOY1 - // joy = joy<<1 | APU->JOY1&1 - ora.z __1 - // for(char i=0;i<8;i++) - inx - jmp __b1 -} .segment Data // Flag tile FLAG: .byte $54, $55, $56, $57 diff --git a/src/test/ref/examples/nes-dxycp/nes-dxycp.asm b/src/test/ref/examples/nes-dxycp/nes-dxycp.asm index 2088f02ce..6951e6645 100644 --- a/src/test/ref/examples/nes-dxycp/nes-dxycp.asm +++ b/src/test/ref/examples/nes-dxycp/nes-dxycp.asm @@ -74,28 +74,31 @@ // Pointer to the start of RAM memory .label MEMORY = 0 // NES Picture Processing Unit (PPU) + // NES Picture Processing Unit (PPU) .label PPU = $2000 // NES CPU and audion processing unit (APU) + // NES CPU and audion processing unit (APU) .label APU = $4000 - .label y_sin_idx = $c - .label x_sin_idx = $d - .label x_sin_idx_2 = $e -__bbegin: - // y_sin_idx = 0 // Index into the Y sine - lda #0 - sta.z y_sin_idx - // x_sin_idx = 73 + .label y_sin_idx = $c // Index into the X sine - lda #$49 - sta.z x_sin_idx - // x_sin_idx_2 = 82 + .label x_sin_idx = $d // Index into the small X sine - lda #$52 - sta.z x_sin_idx_2 - jsr main - rts + .label x_sin_idx_2 = $e .segment Code +_start: { + // y_sin_idx = 0 + lda #0 + sta.z y_sin_idx + // x_sin_idx = 73 + lda #$49 + sta.z x_sin_idx + // x_sin_idx_2 = 82 + lda #$52 + sta.z x_sin_idx_2 + jsr main + rts +} // RESET Called when the NES is reset, including when it is turned on. main: { // asm @@ -263,6 +266,7 @@ ppuDataTransfer: { .label ppuData = PPU_PALETTE .label cpuData = PALETTE // Transfer to PPU + // Transfer to PPU .label cpuSrc = 6 .label i = 4 // PPU->PPUADDR = >ppuData @@ -315,6 +319,7 @@ vblank: { .label __23 = $b .label __25 = $b .label __28 = $f + // Update sprite positions .label y_idx = 9 .label x_idx = $a .label x_idx_2 = $b diff --git a/src/test/ref/examples/nmisamples/nmisamples.asm b/src/test/ref/examples/nmisamples/nmisamples.asm index feee55de5..1bda8828f 100644 --- a/src/test/ref/examples/nmisamples/nmisamples.asm +++ b/src/test/ref/examples/nmisamples/nmisamples.asm @@ -2,7 +2,7 @@ // Code by Scan of Desire (Richard-William Loerakker) // Sample from ART OF NOISE: MOMENTS IN LOVE .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // Value that disables all CIA interrupts when stored to the CIA Interrupt registers .const CIA_INTERRUPT_CLEAR = $7f @@ -23,14 +23,15 @@ // The vector used when the KERNAL serves NMI interrupts .label KERNEL_NMI = $318 .label sample = 2 -__bbegin: - // sample = SAMPLE - lda #SAMPLE - sta.z sample+1 - jsr main - rts +_start: { + // sample = SAMPLE + lda #SAMPLE + sta.z sample+1 + jsr main + rts +} main: { // asm // Boosting 8580 Digis diff --git a/src/test/ref/examples/plasma/plasma-unroll.asm b/src/test/ref/examples/plasma/plasma-unroll.asm index 12521d978..d475de26f 100644 --- a/src/test/ref/examples/plasma/plasma-unroll.asm +++ b/src/test/ref/examples/plasma/plasma-unroll.asm @@ -27,13 +27,13 @@ .label COLS = $d800 .label SCREEN1 = $2800 .label CHARSET = $2000 - .label print_line_cursor = $400 + .label print_screen = $400 .label print_char_cursor = $b // Plasma state variables - .label c1A = 2 - .label c1B = 3 - .label c2A = 4 - .label c2B = 5 + .label c1A = $d + .label c1B = $f + .label c2A = $12 + .label c2B = 2 main: { .const toD0181_return = (>(SCREEN1&$3fff)*4)|(>CHARSET)/4&$f .label col = $b @@ -82,10 +82,10 @@ main: { } // Render plasma to the passed screen doplasma: { - .label c1a = $f - .label c1b = $12 + .label c1a = 4 + .label c1b = 5 .label yval = $e - .label i = $d + .label i = 3 .label c2a = 7 .label c2b = 8 .label i1 = 6 @@ -348,9 +348,9 @@ makecharset: { sta SID+OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #<0 sta.z c @@ -481,7 +481,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num .label dst = $10 lda #(SCREEN1&$3fff)*4)|(>CHARSET)/4&$f .const toD0182_return = (>(SCREEN2&$3fff)*4)|(>CHARSET)/4&$f @@ -96,9 +96,9 @@ main: { // Render plasma to the passed screen // doplasma(byte* zp(9) screen) doplasma: { - .label c1a = $e - .label c1b = $11 - .label i = $d + .label c1a = 4 + .label c1b = 5 + .label i = 3 .label c2a = 7 .label c2b = 8 .label i1 = 6 @@ -244,9 +244,9 @@ makecharset: { sta SID+OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #<0 sta.z c @@ -377,7 +377,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num .label dst = $f lda #= PI_u4f28 ) lda.z x+3 diff --git a/src/test/ref/examples/sinplotter/sine-plotter.asm b/src/test/ref/examples/sinplotter/sine-plotter.asm index 5c42dcc04..dfeb80623 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.asm +++ b/src/test/ref/examples/sinplotter/sine-plotter.asm @@ -35,7 +35,7 @@ .label SCREEN = $400 .label BITMAP = $2000 // Remainder after unsigned 16-bit division - .label rem16u = $12 + .label rem16u = $16 main: { .const vicSelectGfxBank1_toDd001_return = 3 .const toD0181_return = (>(SCREEN&$3fff)*4)|(>BITMAP)/4&$f @@ -282,10 +282,14 @@ sin16s_gen2: { .label ampl = max-min .label __6 = 8 .label __8 = $1c + // ampl is always positive so shifting left does not alter the sign + // u[4.28] step = PI*2/wavelength .label step = $18 .label sintab = 6 // u[4.28] // Iterate over the table + // u[4.28] + // Iterate over the table .label x = 2 .label i = $14 // div32u16u(PI2_u4f28, wavelength) @@ -375,13 +379,13 @@ sin16s_gen2: { } // Multiply of two signed ints to a signed long // Fixes offsets introduced by using unsigned multiplication -// mul16s(signed word zp($16) a) +// mul16s(signed word zp($1c) a) mul16s: { .label __6 = $22 .label __11 = $22 .label m = 8 .label return = 8 - .label a = $16 + .label a = $1c // mul16u((unsigned int)a, (unsigned int) b) lda.z a sta.z mul16u.a @@ -420,10 +424,10 @@ mul16s: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($12) a, word zp($c) b) +// mul16u(word zp($16) a, word zp($c) b) mul16u: { .label mb = $e - .label a = $12 + .label a = $16 .label res = 8 .label return = 8 .label b = $c @@ -488,16 +492,25 @@ mul16u: { sin16s: { .label __4 = $1e .label x = $e - .label return = $16 + .label return = $1c + // sinx = x - x^3/6 + x5/128; .label x1 = $22 - .label x2 = $1c - .label x3 = $1c + // u[1.15] + .label x2 = $12 + // u[2.14] x^2 + .label x3 = $12 + // u[2.14] x^3 .label x3_6 = $24 - .label usinx = $16 - .label x4 = $1c + // u[1.15] x^3/6; + .label usinx = $1c + // u[1.15] x - x^3/6 + .label x4 = $12 + // u[3.13] x^4 .label x5 = $24 + // u[4.12] x^5 .label x5_128 = $24 - .label sinx = $16 + // u[1.15] (first bit is always zero) + .label sinx = $1c // if(x >= PI_u4f28 ) lda.z x+3 cmp #>PI_u4f28>>$10 @@ -695,14 +708,14 @@ sin16s: { } // Calculate val*val for two unsigned int values - the result is 16 selected bits of the 32-bit result. // The select parameter indicates how many of the highest bits of the 32-bit result to skip -// mulu16_sel(word zp($1c) v1, word zp($c) v2, byte register(X) select) +// mulu16_sel(word zp($12) v1, word zp($c) v2, byte register(X) select) mulu16_sel: { .label __0 = 8 .label __1 = 8 - .label v1 = $1c + .label v1 = $12 .label v2 = $c .label return = $24 - .label return_1 = $1c + .label return_1 = $12 // mul16u(v1, v2) lda.z v1 sta.z mul16u.a @@ -733,7 +746,7 @@ mulu16_sel: { // The 16-bit unsigned int remainder can be found in rem16u after the division div32u16u: { .label quotient_hi = $24 - .label quotient_lo = $1c + .label quotient_lo = $12 .label return = $18 // divr16u(>dividend, divisor, 0) lda #>$10 @@ -774,12 +787,12 @@ div32u16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($16) dividend, word zp($12) rem) +// divr16u(word zp($1c) dividend, word zp($16) rem) divr16u: { - .label rem = $12 - .label dividend = $16 - .label quotient = $1c - .label return = $1c + .label rem = $16 + .label dividend = $1c + .label quotient = $12 + .label return = $12 ldx #0 txa sta.z quotient diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.asm b/src/test/ref/examples/sinsprites/sinus-sprites.asm index d40281e5f..105d580ca 100644 --- a/src/test/ref/examples/sinsprites/sinus-sprites.asm +++ b/src/test/ref/examples/sinsprites/sinus-sprites.asm @@ -29,11 +29,11 @@ .label sprites = $2000 .label SCREEN = $400 // Current index within the progress cursor (0-7) - .label progress_idx = 4 + .label progress_idx = $a // Current position of the progress cursor - .label progress_cursor = 5 - .label sin_idx_x = 2 - .label sin_idx_y = 3 + .label progress_cursor = 2 + .label sin_idx_x = 6 + .label sin_idx_y = 8 main: { // init() jsr init @@ -53,10 +53,10 @@ anim: { .label __7 = $a .label xidx = 9 .label yidx = 4 - .label x = $10 + .label x = $f .label x_msb = $a .label j2 = $b - .label j = 8 + .label j = 5 // (VICII->BORDER_COLOR)++; inc VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR // xidx = sin_idx_x @@ -214,7 +214,7 @@ init: { rts } clear_screen: { - .label sc = $10 + .label sc = $f lda #SCREEN @@ -248,15 +248,16 @@ clear_screen: { // - length is the length of the sine table // - min is the minimum value of the generated sinus // - max is the maximum value of the generated sinus -// gen_sintab(byte* zp($10) sintab, byte zp($a) length, byte zp(9) min, byte register(X) max) +// gen_sintab(byte* zp($f) sintab, byte zp(8) length, byte zp(6) min, byte register(X) max) gen_sintab: { + // amplitude/2 // amplitude/2 .label f_2pi = $e2e5 .label __20 = $13 - .label i = $b - .label min = 9 - .label length = $a - .label sintab = $10 + .label i = 9 + .label min = 6 + .label length = 8 + .label sintab = $f // setFAC((unsigned int)max) txa sta.z setFAC.w @@ -574,14 +575,14 @@ setARGtoFAC: { rts } // Initialize the PETSCII progress bar -// progress_init(byte* zp(5) line) +// progress_init(byte* zp(2) line) progress_init: { - .label line = 5 + .label line = 2 rts } gen_sprites: { - .label spr = $10 - .label i = 8 + .label spr = 2 + .label i = $b lda #sprites @@ -617,19 +618,22 @@ gen_sprites: { // Generate a sprite from a C64 CHARGEN character (by making each pixel 3x3 pixels large) // - c is the character to generate // - sprite is a pointer to the position of the sprite to generate -// gen_chargen_sprite(byte register(X) ch, byte* zp($13) sprite) +// gen_chargen_sprite(byte register(X) ch, byte* zp($f) sprite) gen_chargen_sprite: { - .label __0 = $15 - .label __14 = $15 - .label sprite = $13 - .label chargen = $15 - .label bits = $a + .label __0 = $13 + .label __14 = $13 + .label sprite = $f + .label chargen = $13 + // current chargen line + .label bits = 5 // current sprite char - .label s_gen = $f - .label x = $b - .label y = 9 + // current sprite char + .label s_gen = 9 + .label x = 6 + .label y = 4 // Find the current chargen pixel (c) - .label c = $c + // Find the current chargen pixel (c) + .label c = 8 // ((unsigned int)ch)*8 txa sta.z __14 @@ -746,11 +750,11 @@ gen_chargen_sprite: { } place_sprites: { .label sprites_ptr = SCREEN+$3f8 - .label spr_id = 9 - .label spr_x = $b - .label col = $f - .label j2 = $c - .label j = $a + .label spr_id = 6 + .label spr_x = 9 + .label col = $b + .label j2 = $a + .label j = 8 // VICII->SPRITES_ENABLE = %01111111 lda #$7f sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE diff --git a/src/test/ref/examples/zpcode/zpcode.asm b/src/test/ref/examples/zpcode/zpcode.asm index cab057b3c..d92ca6df5 100644 --- a/src/test/ref/examples/zpcode/zpcode.asm +++ b/src/test/ref/examples/zpcode/zpcode.asm @@ -14,8 +14,22 @@ .label RASTER = $d012 .label BG_COLOR = $d020 +.segment ZpCode +zpLoop: { + ldx #0 + __b1: + // (*BG_COLOR)++; + inc BG_COLOR + // for(char i:0..100) + inx + cpx #$65 + bne __b1 + // } + rts +} .segment Code main: { + // Transfer ZP-code to zeropage // Transfer ZP-code to zeropage .label zpCode = zpLoop // asm @@ -48,20 +62,6 @@ main: { inx jmp __b1 } -.segment ZpCode -zpLoop: { - ldx #0 - __b1: - // (*BG_COLOR)++; - inc BG_COLOR - // for(char i:0..100) - inx - cpx #$65 - bne __b1 - // } - rts -} -.segment Code // Code in "normal" memory loop: { ldx #0 diff --git a/src/test/ref/fastmultiply-127.asm b/src/test/ref/fastmultiply-127.asm index 3780c41ce..e3c38f9be 100644 --- a/src/test/ref/fastmultiply-127.asm +++ b/src/test/ref/fastmultiply-127.asm @@ -6,15 +6,16 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 3 - .label print_char_cursor = 5 + .label print_screen = $400 + .label print_char_cursor = 8 + .label print_line_cursor = 6 main: { // print_cls() jsr print_cls // print_str("unsigned") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln // print_mulf8u127(0,0) @@ -141,10 +142,10 @@ main: { str1: .text "signed" .byte 0 } -// print_mulf8s127(signed byte zp(9) a, signed byte zp(2) b) +// print_mulf8s127(signed byte zp(5) a, signed byte zp(2) b) print_mulf8s127: { - .label c = 7 - .label a = 9 + .label c = 3 + .label a = 5 .label b = 2 // mulf8s127(a,b) ldy.z b @@ -198,9 +199,9 @@ print_ln: { rts } // Print a signed int as HEX -// print_sint(signed word zp(7) w) +// print_sint(signed word zp(3) w) print_sint: { - .label w = 7 + .label w = 3 // if(w<0) lda.z w+1 bmi __b1 @@ -241,9 +242,9 @@ print_char: { rts } // Print a unsigned int as HEX -// print_uint(word zp(7) w) +// print_uint(word zp(3) w) print_uint: { - .label w = 7 + .label w = 3 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -302,15 +303,15 @@ print_schar: { tax jmp __b2 } -// mulf8s127(signed byte zp(9) a, signed byte register(Y) b) +// mulf8s127(signed byte zp(5) a, signed byte register(Y) b) mulf8s127: { - .label __9 = $a - .label __10 = $c - .label __11 = $a - .label __12 = $c - .label a = 9 - .label return = 7 - .label c = 7 + .label __9 = 8 + .label __10 = $a + .label __11 = 8 + .label __12 = $a + .label a = 5 + .label return = 3 + .label c = 3 // mulf8u127((unsigned char)a, (unsigned char)b) ldx.z a tya @@ -387,7 +388,7 @@ mulf8u127: { .label res = $fe .label resL = $fe .label resH = $ff - .label return = 7 + .label return = 3 // *memA = a stx memA // *memB = b @@ -420,9 +421,9 @@ mulf8u127: { rts } // Print a zero-terminated string -// print_str(byte* zp(7) str) +// print_str(byte* zp(3) str) print_str: { - .label str = 7 + .label str = 3 __b1: // while(*str) ldy #0 @@ -443,10 +444,10 @@ print_str: { !: jmp __b1 } -// print_mulf8u127(byte register(Y) a, byte zp(9) b) +// print_mulf8u127(byte register(Y) a, byte zp(5) b) print_mulf8u127: { - .label c = 7 - .label b = 9 + .label c = 3 + .label b = 5 // mulf8u127(a,b) tya tax @@ -490,9 +491,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = $a + .label dst = 6 lda #str diff --git a/src/test/ref/function-pointer-noarg-3.asm b/src/test/ref/function-pointer-noarg-3.asm index 6b3bc8f46..6b1830097 100644 --- a/src/test/ref/function-pointer-noarg-3.asm +++ b/src/test/ref/function-pointer-noarg-3.asm @@ -2,10 +2,20 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - // kickasm - ff: - jmp (main.f) - +fn2: { + .label BG_COLOR = $d021 + // (*BG_COLOR)++; + inc BG_COLOR + // } + rts +} +fn1: { + .label BORDER_COLOR = $d020 + // (*BORDER_COLOR)++; + inc BORDER_COLOR + // } + rts +} main: { .label f = 2 ldx #0 @@ -34,17 +44,7 @@ main: { jmp __b2 } -fn2: { - .label BG_COLOR = $d021 - // (*BG_COLOR)++; - inc BG_COLOR - // } - rts -} -fn1: { - .label BORDER_COLOR = $d020 - // (*BORDER_COLOR)++; - inc BORDER_COLOR - // } - rts -} +// Inline KickAsm function +ff: +jmp (main.f) + diff --git a/src/test/ref/function-pointer-noarg-call-10.asm b/src/test/ref/function-pointer-noarg-call-10.asm index 0eb722e26..dd4208ddc 100644 --- a/src/test/ref/function-pointer-noarg-call-10.asm +++ b/src/test/ref/function-pointer-noarg-call-10.asm @@ -1,15 +1,16 @@ // Tests calling into different function pointers which call a common sub-method .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = 7 -__bbegin: - // idx = 0 - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx = 0 + lda #0 + sta.z idx + jsr main + rts +} main: { // do10(&hello) lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 __b1: // print_str(txt) @@ -61,9 +62,9 @@ print_ln: { rts } // Print a zero-terminated string -// print_str(byte* zp(6) str) +// print_str(byte* zp(2) str) print_str: { - .label str = 6 + .label str = 2 lda #txt @@ -113,7 +114,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = 6 lda #50) + lda RASTER + cmp #$32+1 + // (*BG_COLOR)--; + dec BG_COLOR + // } + jmp $ea81 +} main: { // asm sei @@ -46,17 +60,3 @@ main: { bcs __b1 jmp __b1 } -irq: { - // (*BG_COLOR)++; - inc BG_COLOR - // *IRQ_STATUS = IRQ_RASTER - lda #IRQ_RASTER - sta IRQ_STATUS - // if (*RASTER>50) - lda RASTER - cmp #$32+1 - // (*BG_COLOR)--; - dec BG_COLOR - // } - jmp $ea81 -} diff --git a/src/test/ref/kickasm-uses-prevent-deletion.asm b/src/test/ref/kickasm-uses-prevent-deletion.asm index 263feabeb..e3dc90a6b 100644 --- a/src/test/ref/kickasm-uses-prevent-deletion.asm +++ b/src/test/ref/kickasm-uses-prevent-deletion.asm @@ -7,6 +7,17 @@ // The vector used when the KERNAL serves IRQ interrupts .label KERNEL_IRQ = $314 .label BG_COLOR = $d021 +// The Interrupt Handler +irq: { + // *BG_COLOR = WHITE + lda #WHITE + sta BG_COLOR + // *BG_COLOR = BLACK + lda #BLACK + sta BG_COLOR + // } + jmp $ea31 +} main: { // kickasm sei @@ -19,14 +30,3 @@ main: { // } rts } -// The Interrupt Handler -irq: { - // *BG_COLOR = WHITE - lda #WHITE - sta BG_COLOR - // *BG_COLOR = BLACK - lda #BLACK - sta BG_COLOR - // } - jmp $ea31 -} diff --git a/src/test/ref/linegen.asm b/src/test/ref/linegen.asm index b4f16ffa1..8b2d2d1dc 100644 --- a/src/test/ref/linegen.asm +++ b/src/test/ref/linegen.asm @@ -7,10 +7,11 @@ :BasicUpstart(main) .pc = $80d "Program" .const SIZEOF_WORD = 2 + .label print_screen = $400 // Remainder after unsigned 16-bit division - .label rem16u = $13 - .label print_char_cursor = 5 - .label print_line_cursor = 3 + .label rem16u = $17 + .label print_char_cursor = 3 + .label print_line_cursor = 7 main: { .label i = 2 // lin16u_gen(557, 29793, lintab1, 20) @@ -57,9 +58,9 @@ main: { // print_cls() jsr print_cls // print_str(" ") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda #0 @@ -243,9 +244,9 @@ print_ln: { rts } // Print a unsigned int as HEX -// print_uint(word zp(7) w) +// print_uint(word zp(5) w) print_uint: { - .label w = 7 + .label w = 5 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -293,9 +294,9 @@ print_char: { rts } // Print a zero-terminated string -// print_str(byte* zp(7) str) +// print_str(byte* zp(5) str) print_str: { - .label str = 7 + .label str = 5 __b1: // while(*str) ldy #0 @@ -327,7 +328,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = 7 lda #$400 - sta.z MEM+1 - jsr malloc - // malloc() - lda.z malloc.return - sta.z malloc.return_1 - lda.z malloc.return+1 - sta.z malloc.return_1+1 - // SCREEN_1 = malloc() - // malloc() - jsr malloc - // malloc() - // SCREEN_2 = malloc() - jsr main - rts +_start: { + // malloc() + lda #<$400 + sta.z MEM + lda #>$400 + sta.z MEM+1 + jsr malloc + // malloc() + lda.z malloc.return + sta.z malloc.return_1 + lda.z malloc.return+1 + sta.z malloc.return_1+1 + jsr malloc + // malloc() + jsr main + rts +} main: { // *SCREEN_1 = 0 lda #0 diff --git a/src/test/ref/longbranch-interrupt-problem.asm b/src/test/ref/longbranch-interrupt-problem.asm index a36e01bfc..84b50122d 100644 --- a/src/test/ref/longbranch-interrupt-problem.asm +++ b/src/test/ref/longbranch-interrupt-problem.asm @@ -1,16 +1,17 @@ // Tests that long branch fixing works with interrupt exits (to $ea81) .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label KERNEL_IRQ = $314 .label BG_COLOR = $d020 .label col = 2 -__bbegin: - // col = 0 - lda #0 - sta.z col - jsr main - rts +_start: { + // col = 0 + lda #0 + sta.z col + jsr main + rts +} main: { // *KERNEL_IRQ = &irq lda #$400 + lda #>print_screen sta.z print_char_cursor+1 __b1: - // init() - jsr init lda #<0 sta.z root sta.z root+1 @@ -96,9 +96,9 @@ end: { } // Print a newline print_ln: { - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 __b1: // print_line_cursor + $28 @@ -122,9 +122,9 @@ print_ln: { rts } // Print a unsigned int as HEX -// print_uint(word zp($e) w) +// print_uint(word zp($c) w) print_uint: { - .label w = $e + .label w = $c // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -181,9 +181,9 @@ start: { rts } sum: { - .label current = 4 - .label s = $c - .label return = $c + .label current = 2 + .label s = 8 + .label return = 8 // current = root lda #<0 sta.z s @@ -220,10 +220,10 @@ sum: { sta.z current jmp __b1 } -// prepend(word zp(6) x) +// prepend(word zp(4) x) prepend: { - .label new = $10 - .label x = 6 + .label new = $e + .label x = 4 // alloc() jsr alloc // new = alloc() @@ -250,8 +250,8 @@ prepend: { rts } alloc: { - .label __1 = $10 - .label return = $10 + .label __1 = $e + .label return = $e // heap + free_ lda.z free_ asl @@ -275,9 +275,6 @@ alloc: { !: // } rts -} -init: { - rts } print_hextab: .text "0123456789abcdef" heap: .fill 4*$fa0, 0 diff --git a/src/test/ref/millfork-benchmarks/plasma-kc.asm b/src/test/ref/millfork-benchmarks/plasma-kc.asm index 8b1d34ff5..45b75b187 100644 --- a/src/test/ref/millfork-benchmarks/plasma-kc.asm +++ b/src/test/ref/millfork-benchmarks/plasma-kc.asm @@ -1,7 +1,7 @@ // Print a number of zero-terminated strings, each followed by a newline. // The sequence of lines is terminated by another zero. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const PAGE1 = SCREEN1>>6&$f0|CHARSET>>$a&$e .const PAGE2 = SCREEN2>>6&$f0|CHARSET>>$a&$e @@ -11,23 +11,25 @@ .label SCREEN1 = $e000 .label SCREEN2 = $e400 .label CHARSET = $e800 - .label last_time = $c + .label print_screen = $400 + .label last_time = $a // The random state variable - .label rand_state = 9 + .label rand_state = 7 .label print_line_cursor = 5 - .label print_char_cursor = 7 - .label Ticks = $10 - .label Ticks_1 = $12 -__bbegin: - // last_time - lda #<0 - sta.z last_time - sta.z last_time+1 - jsr main - rts + .label Ticks = $e + .label Ticks_1 = $11 + .label print_char_cursor = $13 +_start: { + // last_time + lda #<0 + sta.z last_time + sta.z last_time+1 + jsr main + rts +} main: { - .label block = $e - .label v = $f + .label block = $c + .label v = $d .label count = 5 // makechar() jsr makechar @@ -97,17 +99,17 @@ main: { dec.z count jmp __b1 } -// doplasma(byte* zp(7) scrn) +// doplasma(byte* zp($13) scrn) doplasma: { .const c2A = 0 .const c2B = 0 - .label c1a = $14 - .label c1b = $19 - .label ii = $b + .label c1a = $10 + .label c1b = $15 + .label ii = 9 .label c2a = 3 .label c2b = 4 .label i = 2 - .label scrn = 7 + .label scrn = $13 lda #0 sta.z c1b sta.z c1a @@ -235,9 +237,9 @@ end: { } // Print a newline print_ln: { - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 __b1: // print_line_cursor + $28 @@ -261,14 +263,14 @@ print_ln: { rts } // Print a unsigned int as HEX -// print_uint(word zp($12) w) +// print_uint(word zp($11) w) print_uint: { - .label w = $12 + .label w = $11 // print_uchar(>w) ldx.z w+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 jsr print_uchar // print_uchar(1 @@ -434,10 +436,10 @@ makechar: { // Information https://en.wikipedia.org/wiki/Xorshift // Source http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html rand: { - .label __0 = $1a - .label __1 = $1c - .label __2 = $1e - .label return = $17 + .label __0 = $16 + .label __1 = $18 + .label __2 = $1a + .label return = $13 // rand_state << 7 lda.z rand_state+1 lsr diff --git a/src/test/ref/millfork-benchmarks/romsum-kc.asm b/src/test/ref/millfork-benchmarks/romsum-kc.asm index 49bdf7c6d..eb106523b 100644 --- a/src/test/ref/millfork-benchmarks/romsum-kc.asm +++ b/src/test/ref/millfork-benchmarks/romsum-kc.asm @@ -1,32 +1,34 @@ // Print a number of zero-terminated strings, each followed by a newline. // The sequence of lines is terminated by another zero. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label rom = $e000 + .label print_screen = $400 .label last_time = $b .label print_char_cursor = 4 .label print_line_cursor = 2 .label Ticks = $d .label Ticks_1 = $f -__bbegin: - // last_time - lda #<0 - sta.z last_time - sta.z last_time+1 - jsr main - rts +_start: { + // last_time + lda #<0 + sta.z last_time + sta.z last_time+1 + jsr main + rts +} main: { .label i = $d // start() jsr start - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<0 sta.z i diff --git a/src/test/ref/millfork-benchmarks/sieve-kc.asm b/src/test/ref/millfork-benchmarks/sieve-kc.asm index 09d55d954..346db4a26 100644 --- a/src/test/ref/millfork-benchmarks/sieve-kc.asm +++ b/src/test/ref/millfork-benchmarks/sieve-kc.asm @@ -1,22 +1,24 @@ // Print a number of zero-terminated strings, each followed by a newline. // The sequence of lines is terminated by another zero. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const COUNT = $4000 .const SQRT_COUNT = $80 + .label print_screen = $400 .label last_time = 6 .label print_line_cursor = 2 - .label print_char_cursor = 4 .label Ticks = 8 .label Ticks_1 = $a -__bbegin: - // last_time - lda #<0 - sta.z last_time - sta.z last_time+1 - jsr main - rts + .label print_char_cursor = 4 +_start: { + // last_time + lda #<0 + sta.z last_time + sta.z last_time+1 + jsr main + rts +} main: { // start() jsr start @@ -75,9 +77,9 @@ end: { } // Print a newline print_ln: { - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 __b1: // print_line_cursor + $28 @@ -106,9 +108,9 @@ print_uint: { .label w = $a // print_uchar(>w) ldx.z w+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 jsr print_uchar // print_uchar(Sieve diff --git a/src/test/ref/min-fmul-16.asm b/src/test/ref/min-fmul-16.asm index 5c959666a..b328e5f21 100644 --- a/src/test/ref/min-fmul-16.asm +++ b/src/test/ref/min-fmul-16.asm @@ -6,11 +6,11 @@ .label RASTER = $d012 .label BORDER_COLOR = $d020 .label SCREEN = $400 - .label print_char_cursor = 2 + .label print_char_cursor = 5 main: { .label a = $4d2 .label b = $929 - .label r = $10 + .label r = $e // mulf_init() jsr mulf_init // asm @@ -33,23 +33,16 @@ main: { dec BORDER_COLOR // print_ulong(r) jsr print_ulong - // print_set_screen(SCREEN) - jsr print_set_screen lda #SCREEN sta.z print_char_cursor+1 jmp __b2 } -// Set the screen to print on. Also resets current line/char cursor. -print_set_screen: { - // } - rts -} // Print a unsigned long as HEX -// print_ulong(dword zp($10) dw) +// print_ulong(dword zp($e) dw) print_ulong: { - .label dw = $10 + .label dw = $e // print_uint(>dw) lda.z dw+2 sta.z print_uint.w @@ -66,9 +59,9 @@ print_ulong: { rts } // Print a unsigned int as HEX -// print_uint(word zp(4) w) +// print_uint(word zp(2) w) print_uint: { - .label w = 4 + .label w = 2 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -121,7 +114,7 @@ mulf16u: { .label memA = $f8 .label memB = $fa .label memR = $fc - .label return = $10 + .label return = $e // *memA = a lda #$400 - sta.z print_char_cursor+1 - lda #<$400 + lda #print_screen + sta.z print_char_cursor_1+1 + lda #$400 + lda #>print_screen sta.z print_line_cursor_1+1 lda #<0 sta.z i @@ -186,11 +187,11 @@ print_ln: { adc.z print_line_cursor_1+1 sta.z print_line_cursor+1 // while (print_line_cursordecimal_digits_long @@ -250,11 +251,11 @@ print_str: { print_char: { // *(print_char_cursor++) = ch ldy #0 - sta (print_char_cursor_1),y + sta (print_char_cursor),y // *(print_char_cursor++) = ch; - inc.z print_char_cursor_1 + inc.z print_char_cursor bne !+ - inc.z print_char_cursor_1+1 + inc.z print_char_cursor+1 !: // } rts @@ -264,13 +265,13 @@ print_char: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// ultoa(dword zp($d) value, byte* zp($11) buffer) +// ultoa(dword zp(9) value, byte* zp($d) buffer) ultoa: { .const max_digits = $a - .label digit_value = $13 - .label buffer = $11 - .label digit = $c - .label value = $d + .label digit_value = $11 + .label buffer = $d + .label digit = 8 + .label value = 9 lda #decimal_digits_long @@ -358,12 +359,12 @@ ultoa: { // - sub : the value of a '1' in the digit. Subtracted continually while the digit is increased. // (For decimal the subs used are 10000, 1000, 100, 10, 1) // returns : the value reduced by sub * digit so that it is less than sub. -// ultoa_append(byte* zp($11) buffer, dword zp($d) value, dword zp($13) sub) +// ultoa_append(byte* zp($d) buffer, dword zp(9) value, dword zp($11) sub) ultoa_append: { - .label buffer = $11 - .label value = $d - .label sub = $13 - .label return = $d + .label buffer = $d + .label value = 9 + .label sub = $11 + .label return = 9 ldx #0 __b1: // while (value >= sub) @@ -419,9 +420,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = $11 + .label dst = $f lda #str diff --git a/src/test/ref/nomodify-3.asm b/src/test/ref/nomodify-3.asm index 9414615a0..b0e1d04f9 100644 --- a/src/test/ref/nomodify-3.asm +++ b/src/test/ref/nomodify-3.asm @@ -1,15 +1,16 @@ // Test that a volatile nomodify-variable works as expected .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label i = 2 -__bbegin: - // i = 7 - lda #7 - sta.z i - jsr main - rts +_start: { + // i = 7 + lda #7 + sta.z i + jsr main + rts +} main: { // SCREEN[0] = i lda.z i diff --git a/src/test/ref/plasma-center.asm b/src/test/ref/plasma-center.asm index 2d2f0c796..ff9ba2d2d 100644 --- a/src/test/ref/plasma-center.asm +++ b/src/test/ref/plasma-center.asm @@ -1,6 +1,6 @@ // Plasma based on the distance/angle to the screen center .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" // SID Channel Control Register Noise Waveform .const SID_CONTROL_NOISE = $80 @@ -26,47 +26,51 @@ // Plasma screen 2 .label SCREEN2 = $2c00 // Top of the heap used by malloc() + // Top of the heap used by malloc() .label HEAP_TOP = $a000 - .label print_line_cursor = $400 + .label print_screen = $400 // Head of the heap. Moved backward each malloc() - .label heap_head = $c + .label heap_head = $18 // Squares for each char value SQUARES[i] = i*i // Initialized by init_squares() - .label SQUARES = $e - .label print_char_cursor = 4 - .label SCREEN_DIST = $10 - .label SCREEN_ANGLE = $12 + .label SQUARES = 9 + .label print_char_cursor = 7 + // Screen containing distance to center + .label SCREEN_DIST = $b + // Screen containing angle to center + .label SCREEN_ANGLE = $d // Offsets for the sines .label sin_offset_x = 2 - .label sin_offset_y = 3 -__bbegin: - // malloc(1000) - lda #<$3e8 - sta.z malloc.size - lda #>$3e8 - sta.z malloc.size+1 - lda #HEAP_TOP - sta.z heap_head+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_DIST - lda.z malloc.mem+1 - sta.z SCREEN_DIST+1 - lda #<$3e8 - sta.z malloc.size - lda #>$3e8 - sta.z malloc.size+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_ANGLE - lda.z malloc.mem+1 - sta.z SCREEN_ANGLE+1 - jsr main - rts + .label sin_offset_y = $f +_start: { + // malloc(1000) + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + lda #HEAP_TOP + sta.z heap_head+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_DIST + lda.z malloc.mem+1 + sta.z SCREEN_DIST+1 + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_ANGLE + lda.z malloc.mem+1 + sta.z SCREEN_ANGLE+1 + jsr main + rts +} main: { .const toD0181_return = (>(SCREEN1&$3fff)*4)|(>CHARSET)/4&$f .const toD0182_return = (>(SCREEN2&$3fff)*4)|(>CHARSET)/4&$f @@ -117,14 +121,14 @@ main: { jmp __b2 } // Render plasma to the passed screen -// doplasma(byte* zp(4) screen) +// doplasma(byte* zp(7) screen) doplasma: { - .label angle = 7 - .label dist = 9 - .label sin_x = $14 - .label sin_y = $1e - .label screen = 4 - .label y = 6 + .label angle = 3 + .label dist = 5 + .label sin_x = $1a + .label sin_y = $10 + .label screen = 7 + .label y = $12 // angle = SCREEN_ANGLE lda.z SCREEN_ANGLE sta.z angle @@ -216,11 +220,11 @@ doplasma: { rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. -// memset(void* zp(7) str, byte register(X) c) +// memset(void* zp(3) str, byte register(X) c) memset: { - .label end = $14 - .label dst = 7 - .label str = 7 + .label end = $1a + .label dst = 3 + .label str = 3 // end = (char*)str + num lda.z str clc @@ -253,13 +257,13 @@ memset: { } // Make a plasma-friendly charset where the chars are randomly filled make_plasma_charset: { - .label __7 = $16 - .label __10 = $1e - .label __11 = $1e - .label s = $17 - .label i = 6 - .label c = 9 - .label __16 = $1e + .label __7 = $12 + .label __10 = $10 + .label __11 = $10 + .label s = $f + .label i = 2 + .label c = 5 + .label __16 = $10 // SID->CH3_FREQ = 0xffff lda #<$ffff sta SID+OFFSET_STRUCT_MOS6581_SID_CH3_FREQ @@ -270,9 +274,9 @@ make_plasma_charset: { sta SID+OFFSET_STRUCT_MOS6581_SID_CH3_CONTROL // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #<0 sta.z c @@ -396,9 +400,9 @@ print_char: { print_cls: { // memset(print_screen, ' ', 1000) ldx #' ' - lda #print_line_cursor + lda #>print_screen sta.z memset.str+1 jsr memset // } @@ -406,19 +410,19 @@ print_cls: { } // Populates 1000 bytes (a screen) with values representing the angle to the center. // Utilizes symmetry around the center -// init_angle_screen(byte* zp(9) screen) +// init_angle_screen(byte* zp(5) screen) init_angle_screen: { - .label __7 = $1c - .label screen = 9 - .label screen_topline = 7 - .label screen_bottomline = 9 - .label xw = $18 - .label yw = $1a - .label angle_w = $1c - .label ang_w = $17 - .label x = $16 - .label xb = $b - .label y = 6 + .label __7 = $10 + .label screen = 5 + .label screen_topline = 3 + .label screen_bottomline = 5 + .label xw = $14 + .label yw = $16 + .label angle_w = $10 + .label ang_w = $13 + .label x = $12 + .label xb = 2 + .label y = $f // screen_topline = screen+40*12 lda.z screen clc @@ -532,18 +536,19 @@ init_angle_screen: { // Find the atan2(x, y) - which is the angle of the line from (0,0) to (x,y) // Finding the angle requires a binary search using CORDIC_ITERATIONS_16 // Returns the angle in hex-degrees (0=0, 0x8000=PI, 0x10000=2*PI) -// atan2_16(signed word zp($18) x, signed word zp($1a) y) +// atan2_16(signed word zp($14) x, signed word zp($16) y) atan2_16: { - .label __2 = $14 - .label __7 = $1e - .label yi = $14 - .label xi = $1e - .label angle = $1c - .label xd = $e - .label yd = $c - .label return = $1c - .label x = $18 - .label y = $1a + .label __2 = 7 + .label __7 = $1a + .label yi = 7 + .label xi = $1a + .label angle = $10 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i + .label xd = 9 + .label yd = $18 + .label return = $10 + .label x = $14 + .label y = $16 // (y>=0)?y:-y lda.z y+1 bmi !__b1+ @@ -746,17 +751,17 @@ atan2_16: { } // Populates 1000 bytes (a screen) with values representing the distance to the center. // The actual value stored is distance*2 to increase precision -// init_dist_screen(byte* zp(7) screen) +// init_dist_screen(byte* zp(3) screen) init_dist_screen: { - .label screen = 7 - .label screen_bottomline = 9 - .label yds = $18 - .label screen_topline = 7 - .label y = 6 - .label xds = $1a - .label ds = $1a - .label x = $16 - .label xb = $b + .label screen = 3 + .label screen_bottomline = 5 + .label yds = $14 + .label screen_topline = 3 + .label y = 2 + .label xds = $16 + .label ds = $16 + .label x = $f + .label xb = $12 // init_squares() jsr init_squares // screen_bottomline = screen+40*24 @@ -874,12 +879,12 @@ init_dist_screen: { // Find the (integer) square root of a unsigned int value // If the square is not an integer then it returns the largest integer N where N*N <= val // Uses a table of squares that must be initialized by calling init_squares() -// sqrt(word zp($1a) val) +// sqrt(word zp($16) val) sqrt: { - .label __1 = $14 - .label __2 = $14 - .label found = $14 - .label val = $1a + .label __1 = 7 + .label __2 = 7 + .label found = 7 + .label val = $16 // bsearch16u(val, SQUARES, NUM_SQUARES) lda.z SQUARES sta.z bsearch16u.items @@ -908,14 +913,14 @@ sqrt: { // - items - Pointer to the start of the array to search in // - num - The number of items in the array // Returns pointer to an entry in the array that matches the search key -// bsearch16u(word zp($1a) key, word* zp($14) items, byte register(X) num) +// bsearch16u(word zp($16) key, word* zp(7) items, byte register(X) num) bsearch16u: { - .label __2 = $14 - .label pivot = $1c - .label result = $1e - .label return = $14 - .label items = $14 - .label key = $1a + .label __2 = 7 + .label pivot = $18 + .label result = $1a + .label return = 7 + .label items = 7 + .label key = $16 ldx #NUM_SQUARES __b3: // while (num > 0) @@ -1002,8 +1007,8 @@ bsearch16u: { // Uses a table of squares that must be initialized by calling init_squares() // sqr(byte register(A) val) sqr: { - .label return = $1a - .label return_1 = $18 + .label return = $16 + .label return_1 = $14 // return SQUARES[val]; asl tay @@ -1018,8 +1023,8 @@ sqr: { // Initialize squares table // Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 init_squares: { - .label squares = $1c - .label sqr = $1e + .label squares = $10 + .label sqr = $1a // malloc(NUM_SQUARES*sizeof(unsigned int)) lda #$400 - sta.z screen+1 - jsr main - rts +_start: { + // screen = $400 + lda #<$400 + sta.z screen + lda #>$400 + sta.z screen+1 + jsr main + rts +} main: { // setscreen(&screen, screen1) lda # sqr(potential) .label test_last = 2 // The index into PRIMES[] used for prime testing. It runs from 2 to test_last for each number tested. - .label test_idx = 5 - .label print_char_cursor = 8 + .label test_idx = 9 // The index of the last prime we put into the PRIME[] table .label prime_idx = 3 main: { @@ -28,9 +29,9 @@ main: { sta PRIMES+2*SIZEOF_WORD+1 lda #<3 sta PRIMES+2*SIZEOF_WORD - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<2 sta.z prime_idx @@ -162,9 +163,9 @@ print_char: { rts } // Print a unsigned int as DECIMAL -// print_uint_decimal(word zp(6) w) +// print_uint_decimal(word zp(5) w) print_uint_decimal: { - .label w = 6 + .label w = 5 // utoa(w, decimal_digits, DECIMAL) lda.z w sta.z utoa.value @@ -214,7 +215,7 @@ utoa: { .const max_digits = 5 .label digit_value = $11 .label buffer = $d - .label digit = $a + .label digit = 9 .label value = $f lda #dividend, divisor, 0) lda.z dividend+1 diff --git a/src/test/ref/primes-1000.asm b/src/test/ref/primes-1000.asm index 2464bf229..cba7dcd23 100644 --- a/src/test/ref/primes-1000.asm +++ b/src/test/ref/primes-1000.asm @@ -5,25 +5,26 @@ :BasicUpstart(main) .pc = $80d "Program" .const SIZEOF_SIGNED_WORD = 2 + .label print_screen = $400 // Remainder after unsigned 16-bit division - .label rem16u = $f + .label rem16u = $15 // Remainder after signed 16 bit division - .label rem16s = $f - .label testnum = 8 + .label rem16s = $15 + .label testnum = 6 .label lasttest = 2 - .label primeptr = 6 - .label print_char_cursor = $a + .label primeptr = $19 .label lastprime = 4 + .label print_char_cursor = 8 main: { - .label __0 = $11 - .label __12 = $19 - .label __13 = $d - .label __14 = $1d - .label __15 = $1b - .label p = $19 - .label __16 = $19 - .label __17 = $d - .label __18 = $1d + .label __0 = $d + .label __12 = $15 + .label __13 = $b + .label __14 = $19 + .label __15 = $17 + .label p = $15 + .label __16 = $15 + .label __17 = $b + .label __18 = $19 // primenum[1] = 2 lda #<2 sta primenum+1*SIZEOF_SIGNED_WORD @@ -34,9 +35,9 @@ main: { sta primenum+2*SIZEOF_SIGNED_WORD lda #>3 sta primenum+2*SIZEOF_SIGNED_WORD+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<2 sta.z lastprime @@ -257,9 +258,9 @@ print_sint_decimal: { jmp __b2 } // Print a zero-terminated string -// print_str(byte* zp($d) str) +// print_str(byte* zp($b) str) print_str: { - .label str = $d + .label str = $b lda #decimal_digits @@ -289,12 +290,12 @@ print_str: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// utoa(word zp($19) value, byte* zp($d) buffer) +// utoa(word zp($19) value, byte* zp($b) buffer) utoa: { .const max_digits = 5 - .label digit_value = $1f - .label buffer = $d - .label digit = $c + .label digit_value = $1d + .label buffer = $b + .label digit = $a .label value = $19 lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $f // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $11 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/printf-12.asm b/src/test/ref/printf-12.asm index dd32c741d..62a6dea84 100644 --- a/src/test/ref/printf-12.asm +++ b/src/test/ref/printf-12.asm @@ -1,7 +1,7 @@ // Tests printf function call rewriting // Print a bunch of different stuff using printf .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const BINARY = 2 .const OCTAL = 8 @@ -14,33 +14,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $11 - .label conio_cursor_y = $12 - .label conio_line_text = $13 - .label conio_line_color = $15 -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $11 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $12 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $13 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $15 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .const ui = $162e .label sc = -$c @@ -846,6 +847,7 @@ printf_slong: { .const format_upper_case = 0 .const value = -main.sl // Format number into buffer + // Format number into buffer .const uvalue = value // printf_buffer.sign = 0 // Handle any sign @@ -1095,6 +1097,7 @@ printf_sint: { .const format_upper_case = 0 .const value = -main.si // Format number into buffer + // Format number into buffer .const uvalue = value // printf_buffer.sign = 0 // Handle any sign @@ -1262,6 +1265,7 @@ printf_schar: { .const format_upper_case = 0 .const value = -main.sc // Format number into buffer + // Format number into buffer .const uvalue = value // printf_buffer.sign = 0 // Handle any sign diff --git a/src/test/ref/printf-13.asm b/src/test/ref/printf-13.asm index 3a26a9b9f..44b5a20a1 100644 --- a/src/test/ref/printf-13.asm +++ b/src/test/ref/printf-13.asm @@ -1,7 +1,7 @@ // Tests printf function call rewriting // Print using different formats .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const BINARY = 2 .const OCTAL = 8 @@ -14,33 +14,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $10 - .label conio_cursor_y = $11 - .label conio_line_text = $12 - .label conio_line_color = $14 -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $10 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $11 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $12 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $14 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/printf-14.asm b/src/test/ref/printf-14.asm index baf7ad608..6b1ea8dbf 100644 --- a/src/test/ref/printf-14.asm +++ b/src/test/ref/printf-14.asm @@ -1,7 +1,7 @@ // Tests printf function call rewriting // Print a char using %u .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -10,33 +10,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $a - .label conio_cursor_y = $b - .label conio_line_text = $c - .label conio_line_color = $e -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $a // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $b // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $c // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $e +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label c = 7 // clrscr() diff --git a/src/test/ref/printf-15.asm b/src/test/ref/printf-15.asm index d79fdeee2..7e322df7d 100644 --- a/src/test/ref/printf-15.asm +++ b/src/test/ref/printf-15.asm @@ -1,40 +1,41 @@ // Tests printf function call rewriting // A few strings with newlines .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e // Color Ram .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = 8 - .label conio_cursor_y = 9 - .label conio_line_text = $a - .label conio_line_color = $c -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 8 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = 9 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $a // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $c +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/printf-16.asm b/src/test/ref/printf-16.asm index 3cabe5ced..75baed8f5 100644 --- a/src/test/ref/printf-16.asm +++ b/src/test/ref/printf-16.asm @@ -1,7 +1,7 @@ // Tests printf function call rewriting // Test parameter field syntax %2$d .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -10,33 +10,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = 7 - .label conio_cursor_y = 8 - .label conio_line_text = 9 - .label conio_line_color = $b -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 7 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = 8 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = 9 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $b +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/printf-2.asm b/src/test/ref/printf-2.asm index 7ab32e757..29491b06a 100644 --- a/src/test/ref/printf-2.asm +++ b/src/test/ref/printf-2.asm @@ -1,7 +1,7 @@ // Tests printf implementation // Format a number .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const BINARY = 2 .const OCTAL = 8 @@ -14,33 +14,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $f - .label conio_cursor_y = $10 - .label conio_line_text = $11 - .label conio_line_color = $13 -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $f // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $10 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $11 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $13 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // clrscr() jsr clrscr diff --git a/src/test/ref/printf-speed.asm b/src/test/ref/printf-speed.asm index 989481254..f5c99377e 100644 --- a/src/test/ref/printf-speed.asm +++ b/src/test/ref/printf-speed.asm @@ -1,7 +1,7 @@ // Tests the speed of printf() // Functions for performing input and output. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -21,33 +21,34 @@ .label DEFAULT_SCREEN = $400 // The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 - .label conio_cursor_x = 8 - .label conio_cursor_y = 9 - .label conio_line_text = $a - .label conio_line_color = $c -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 8 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = 9 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $a // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $c +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label i = 2 // tod_init(TOD_ZERO) diff --git a/src/test/ref/printmsg.asm b/src/test/ref/printmsg.asm index 0057f9215..2dc0ca52b 100644 --- a/src/test/ref/printmsg.asm +++ b/src/test/ref/printmsg.asm @@ -3,13 +3,14 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 2 + .label print_screen = $400 .label print_char_cursor = 6 + .label print_line_cursor = 2 main: { // print_str(msg) - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda.z print_line_cursor diff --git a/src/test/ref/prng-xorshift.asm b/src/test/ref/prng-xorshift.asm index 8e5e6d883..f24da2708 100644 --- a/src/test/ref/prng-xorshift.asm +++ b/src/test/ref/prng-xorshift.asm @@ -2,7 +2,7 @@ // Source http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html // Information https://en.wikipedia.org/wiki/Xorshift .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const WHITE = 1 .const LIGHT_BLUE = $e @@ -12,43 +12,44 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $16 - .label conio_cursor_y = $17 - .label conio_line_text = $18 - .label conio_line_color = $1a - .label conio_textcolor = $1c - // The maximal random value - // The random state variable - .label _rand_state = $11 -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $18 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $19 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $21 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT + .label conio_line_color = $23 // The current text color - lda #LIGHT_BLUE - sta.z conio_textcolor - jsr main - rts + .label conio_textcolor = $1a + // The maximal random value + // The random state variable + .label _rand_state = $14 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT + lda #LIGHT_BLUE + sta.z conio_textcolor + jsr main + rts +} main: { - .label first = $1d + .label first = $1b .label cnt = 2 .label rnd = 8 .label row = 7 @@ -200,7 +201,7 @@ printf_ulong: { // This handles minimum length, zero-filling, and left/right justification from the format // printf_number_buffer(byte zp($a) buffer_sign, byte register(X) format_min_length, byte zp($10) format_justify_left, byte zp($13) format_zero_padding, byte zp($b) format_upper_case) printf_number_buffer: { - .label __19 = $27 + .label __19 = $11 .label buffer_sign = $a .label padding = $c .label format_zero_padding = $13 @@ -451,11 +452,11 @@ cscroll: { rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. -// memset(void* zp($27) str, byte register(X) c) +// memset(void* zp($11) str, byte register(X) c) memset: { - .label end = $25 - .label dst = $27 - .label str = $27 + .label end = $27 + .label dst = $11 + .label str = $11 // end = (char*)str + num lda #$28 clc @@ -488,13 +489,13 @@ memset: { } // Copy block of memory (forwards) // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. -// memcpy(void* zp($14) destination, void* zp($27) source) +// memcpy(void* zp($16) destination, void* zp($11) source) memcpy: { - .label src_end = $25 - .label dst = $14 - .label src = $27 - .label source = $27 - .label destination = $14 + .label src_end = $27 + .label dst = $16 + .label src = $11 + .label source = $11 + .label destination = $16 // src_end = (char*)source+num lda.z source clc @@ -530,9 +531,9 @@ memcpy: { jmp __b1 } // Output a NUL-terminated string at the current cursor position -// cputs(byte* zp($23) s) +// cputs(byte* zp($25) s) cputs: { - .label s = $23 + .label s = $25 __b1: // c=*s++ ldy #0 @@ -554,7 +555,7 @@ cputs: { // Converts a string to uppercase. strupr: { .label str = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS - .label src = $14 + .label src = $16 lda #str @@ -602,11 +603,11 @@ toupper: { rts } // Computes the length of the string str up to but not including the terminating null character. -// strlen(byte* zp($23) str) +// strlen(byte* zp($25) str) strlen: { - .label len = $27 - .label str = $23 - .label return = $27 + .label len = $11 + .label str = $25 + .label return = $11 lda #<0 sta.z len sta.z len+1 @@ -640,11 +641,11 @@ strlen: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// ultoa(dword zp(2) value, byte* zp($27) buffer) +// ultoa(dword zp(2) value, byte* zp($11) buffer) ultoa: { .const max_digits = $a - .label digit_value = $1f - .label buffer = $27 + .label digit_value = $1d + .label buffer = $11 .label digit = $10 .label value = 2 lda #CONIO_HEIGHT) cmp #$19+1 bcc __b1 @@ -856,10 +857,10 @@ gotoxy: { } // Returns a pseudo-random number in the range of 0 to RAND_MAX (65535) _rand: { - .label __0 = $23 - .label __1 = $27 + .label __0 = $21 + .label __1 = $23 .label __2 = $25 - .label return = $1d + .label return = $1b .label return_1 = 8 // _rand_state << 7 lda.z _rand_state+1 @@ -944,11 +945,11 @@ printf_uint: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// utoa(word zp(8) value, byte* zp($14) buffer) +// utoa(word zp(8) value, byte* zp($16) buffer) utoa: { .const max_digits = 5 .label digit_value = $27 - .label buffer = $14 + .label buffer = $16 .label digit = $13 .label value = 8 lda #COLORRAM diff --git a/src/test/ref/problem-ma-var-overwrite.asm b/src/test/ref/problem-ma-var-overwrite.asm index 408689a30..10bda6616 100644 --- a/src/test/ref/problem-ma-var-overwrite.asm +++ b/src/test/ref/problem-ma-var-overwrite.asm @@ -1,15 +1,16 @@ // Demonstrates that a local __ma variable overwrites a parameter§ .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label h1 = 2 -__bbegin: - // h1 - lda #<0 - sta.z h1 - sta.z h1+1 - jsr main - rts +_start: { + // h1 + lda #<0 + sta.z h1 + sta.z h1+1 + jsr main + rts +} main: { // test(h1, 0xD800, 0xC000) lda.z h1 diff --git a/src/test/ref/procedure-callingconvention-stack-0.asm b/src/test/ref/procedure-callingconvention-stack-0.asm index 85b19e47d..c19db545a 100644 --- a/src/test/ref/procedure-callingconvention-stack-0.asm +++ b/src/test/ref/procedure-callingconvention-stack-0.asm @@ -4,6 +4,26 @@ .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 +// plus(byte zp(2) a, byte register(A) b) +plus: { + .const OFFSET_STACK_A = 1 + .const OFFSET_STACK_B = 0 + .const OFFSET_STACK_RETURN = 1 + .label a = 2 + // } + tsx + lda STACK_BASE+OFFSET_STACK_A,x + sta.z a + tsx + lda STACK_BASE+OFFSET_STACK_B,x + // return a+b; + clc + adc.z a + // } + tsx + sta STACK_BASE+OFFSET_STACK_RETURN,x + rts +} main: { // plus('0', 7) lda #'0' @@ -18,22 +38,3 @@ main: { // } rts } -// plus(byte zp(2) a, byte register(A) b) -plus: { - .const OFFSET_STACK_A = 1 - .const OFFSET_STACK_B = 0 - .const OFFSET_STACK_RETURN = 1 - .label a = 2 - tsx - lda STACK_BASE+OFFSET_STACK_A,x - sta.z a - tsx - lda STACK_BASE+OFFSET_STACK_B,x - // return a+b; - clc - adc.z a - // } - tsx - sta STACK_BASE+OFFSET_STACK_RETURN,x - rts -} diff --git a/src/test/ref/procedure-callingconvention-stack-1.asm b/src/test/ref/procedure-callingconvention-stack-1.asm index 85b19e47d..c19db545a 100644 --- a/src/test/ref/procedure-callingconvention-stack-1.asm +++ b/src/test/ref/procedure-callingconvention-stack-1.asm @@ -4,6 +4,26 @@ .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 +// plus(byte zp(2) a, byte register(A) b) +plus: { + .const OFFSET_STACK_A = 1 + .const OFFSET_STACK_B = 0 + .const OFFSET_STACK_RETURN = 1 + .label a = 2 + // } + tsx + lda STACK_BASE+OFFSET_STACK_A,x + sta.z a + tsx + lda STACK_BASE+OFFSET_STACK_B,x + // return a+b; + clc + adc.z a + // } + tsx + sta STACK_BASE+OFFSET_STACK_RETURN,x + rts +} main: { // plus('0', 7) lda #'0' @@ -18,22 +38,3 @@ main: { // } rts } -// plus(byte zp(2) a, byte register(A) b) -plus: { - .const OFFSET_STACK_A = 1 - .const OFFSET_STACK_B = 0 - .const OFFSET_STACK_RETURN = 1 - .label a = 2 - tsx - lda STACK_BASE+OFFSET_STACK_A,x - sta.z a - tsx - lda STACK_BASE+OFFSET_STACK_B,x - // return a+b; - clc - adc.z a - // } - tsx - sta STACK_BASE+OFFSET_STACK_RETURN,x - rts -} diff --git a/src/test/ref/procedure-callingconvention-stack-10.asm b/src/test/ref/procedure-callingconvention-stack-10.asm index 800845400..4636aa789 100644 --- a/src/test/ref/procedure-callingconvention-stack-10.asm +++ b/src/test/ref/procedure-callingconvention-stack-10.asm @@ -1,18 +1,19 @@ // Test a procedure with calling convention stack // Returning and passing struct values .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const STACK_BASE = $103 .const OFFSET_STRUCT_POINT_Y = 1 .label SCREEN = $400 .label idx = 3 -__bbegin: - // idx = 0 - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx = 0 + lda #0 + sta.z idx + jsr main + rts +} // print(byte register(Y) p_x, byte register(X) p_y) print: { .const OFFSET_STACK_P_X = 1 diff --git a/src/test/ref/procedure-callingconvention-stack-11.asm b/src/test/ref/procedure-callingconvention-stack-11.asm index 3b2e50fb8..c57e2b8f7 100644 --- a/src/test/ref/procedure-callingconvention-stack-11.asm +++ b/src/test/ref/procedure-callingconvention-stack-11.asm @@ -1,19 +1,20 @@ // Test a procedure with calling convention stack // Returning and passing struct of struct values .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const STACK_BASE = $103 .const OFFSET_STRUCT_POINT_Y = 1 .const OFFSET_STRUCT_VECTOR_P2 = 2 .label SCREEN = $400 .label idx = 3 -__bbegin: - // idx = 0 - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx = 0 + lda #0 + sta.z idx + jsr main + rts +} // print(byte register(Y) v_p1_x, byte zp(4) v_p1_y, byte zp(5) v_p2_x, byte register(X) v_p2_y) print: { .const OFFSET_STACK_V_P1_X = 3 diff --git a/src/test/ref/procedure-callingconvention-stack-12.asm b/src/test/ref/procedure-callingconvention-stack-12.asm index 1e01bce61..d06370426 100644 --- a/src/test/ref/procedure-callingconvention-stack-12.asm +++ b/src/test/ref/procedure-callingconvention-stack-12.asm @@ -1,17 +1,18 @@ // Test a procedure with calling convention stack // Test that comments are handled correctly .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 .label idx = 4 -__bbegin: - // idx = 0 - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx = 0 + lda #0 + sta.z idx + jsr main + rts +} // print(byte* zp(2) str, byte zp(5) spacing) print: { .const OFFSET_STACK_STR = 1 diff --git a/src/test/ref/procedure-callingconvention-stack-13.asm b/src/test/ref/procedure-callingconvention-stack-13.asm index 6ec79ee6b..da0e941fc 100644 --- a/src/test/ref/procedure-callingconvention-stack-13.asm +++ b/src/test/ref/procedure-callingconvention-stack-13.asm @@ -5,21 +5,11 @@ .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 -main: { - // pow2(6) - lda #6 - pha - jsr pow2 - pla - // *SCREEN = pow2(6) - sta SCREEN - // } - rts -} // pow2(byte register(A) n) pow2: { .const OFFSET_STACK_N = 0 .const OFFSET_STACK_RETURN = 0 + // } tsx lda STACK_BASE+OFFSET_STACK_N,x // if (n == 0) @@ -44,3 +34,14 @@ pow2: { sta STACK_BASE+OFFSET_STACK_RETURN,x rts } +main: { + // pow2(6) + lda #6 + pha + jsr pow2 + pla + // *SCREEN = pow2(6) + sta SCREEN + // } + rts +} diff --git a/src/test/ref/procedure-callingconvention-stack-2.asm b/src/test/ref/procedure-callingconvention-stack-2.asm index 309ff5370..04050e599 100644 --- a/src/test/ref/procedure-callingconvention-stack-2.asm +++ b/src/test/ref/procedure-callingconvention-stack-2.asm @@ -4,40 +4,15 @@ .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 -main: { - .label __0 = 2 - // plus(0x1234, 0x2345) - lda #>$1234 - pha - lda #<$1234 - pha - lda #>$2345 - pha - lda #<$2345 - pha - jsr plus - pla - pla - pla - sta.z __0 - pla - sta.z __0+1 - // SCREEN[0] = plus(0x1234, 0x2345) - lda.z __0 - sta SCREEN - lda.z __0+1 - sta SCREEN+1 - // } - rts -} -// plus(word zp(4) a, word zp(6) b) +// plus(word zp(4) a, word zp(2) b) plus: { .const OFFSET_STACK_A = 2 .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 2 .label a = 4 - .label b = 6 + .label b = 2 .label return = 4 + // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a @@ -64,3 +39,29 @@ plus: { sta STACK_BASE+OFFSET_STACK_RETURN+1,x rts } +main: { + .label __0 = 4 + // plus(0x1234, 0x2345) + lda #>$1234 + pha + lda #<$1234 + pha + lda #>$2345 + pha + lda #<$2345 + pha + jsr plus + pla + pla + pla + sta.z __0 + pla + sta.z __0+1 + // SCREEN[0] = plus(0x1234, 0x2345) + lda.z __0 + sta SCREEN + lda.z __0+1 + sta SCREEN+1 + // } + rts +} diff --git a/src/test/ref/procedure-callingconvention-stack-3.asm b/src/test/ref/procedure-callingconvention-stack-3.asm index 9d01469e0..bc1279471 100644 --- a/src/test/ref/procedure-callingconvention-stack-3.asm +++ b/src/test/ref/procedure-callingconvention-stack-3.asm @@ -7,40 +7,15 @@ .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 -main: { - .label __0 = 2 - // plus('0', 7) - lda #0 - pha - lda #<'0' - pha - lda #0 - pha - lda #<7 - pha - jsr plus - pla - pla - pla - sta.z __0 - pla - sta.z __0+1 - // SCREEN[0] = plus('0', 7) - lda.z __0 - sta SCREEN - lda.z __0+1 - sta SCREEN+1 - // } - rts -} -// plus(word zp(4) a, word zp(6) b) +// plus(word zp(4) a, word zp(2) b) plus: { .const OFFSET_STACK_A = 2 .const OFFSET_STACK_B = 0 .const OFFSET_STACK_RETURN = 2 .label a = 4 - .label b = 6 + .label b = 2 .label return = 4 + // } tsx lda STACK_BASE+OFFSET_STACK_A,x sta.z a @@ -67,3 +42,29 @@ plus: { sta STACK_BASE+OFFSET_STACK_RETURN+1,x rts } +main: { + .label __0 = 4 + // plus('0', 7) + lda #0 + pha + lda #<'0' + pha + lda #0 + pha + lda #<7 + pha + jsr plus + pla + pla + pla + sta.z __0 + pla + sta.z __0+1 + // SCREEN[0] = plus('0', 7) + lda.z __0 + sta SCREEN + lda.z __0+1 + sta SCREEN+1 + // } + rts +} diff --git a/src/test/ref/procedure-callingconvention-stack-4.asm b/src/test/ref/procedure-callingconvention-stack-4.asm index b3a313069..8c87ddd57 100644 --- a/src/test/ref/procedure-callingconvention-stack-4.asm +++ b/src/test/ref/procedure-callingconvention-stack-4.asm @@ -1,17 +1,18 @@ // Test a procedure with calling convention stack // A slightly more complex call .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const STACK_BASE = $103 .label SCREEN = $400 .label i = 3 -__bbegin: - // i = 0 - lda #0 - sta.z i - jsr main - rts +_start: { + // i = 0 + lda #0 + sta.z i + jsr main + rts +} main: { .label a = 2 lda #0 diff --git a/src/test/ref/procedure-callingconvention-stack-5.asm b/src/test/ref/procedure-callingconvention-stack-5.asm index 4412d7f44..ba9035335 100644 --- a/src/test/ref/procedure-callingconvention-stack-5.asm +++ b/src/test/ref/procedure-callingconvention-stack-5.asm @@ -1,23 +1,24 @@ // Test a procedure with calling convention stack // Return value larger than parameter .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const SIZEOF_SIGNED_WORD = 2 .const STACK_BASE = $103 .label SCREEN = $400 - .label current = 2 -__bbegin: - // current = 48 - lda #<$30 - sta.z current - lda #>$30 - sta.z current+1 - jsr main - rts + .label current = 4 +_start: { + // current = 48 + lda #<$30 + sta.z current + lda #>$30 + sta.z current+1 + jsr main + rts +} main: { - .label __0 = 4 - .label __1 = 6 + .label __0 = 2 + .label __1 = 4 // next() pha pha @@ -49,7 +50,7 @@ main: { } next: { .const OFFSET_STACK_RETURN = 0 - .label return = 8 + .label return = 6 // return current++; lda.z current sta.z return diff --git a/src/test/ref/procedure-callingconvention-stack-7.asm b/src/test/ref/procedure-callingconvention-stack-7.asm index d5fbb50ef..ff8afb099 100644 --- a/src/test/ref/procedure-callingconvention-stack-7.asm +++ b/src/test/ref/procedure-callingconvention-stack-7.asm @@ -1,9 +1,13 @@ // Test a procedure with calling convention stack // Illustrates live ranges for main::val and printline::i .pc = $801 "Basic" -:BasicUpstart(main) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 +_start: { + jsr main + rts +} printline: { ldx #0 __b1: diff --git a/src/test/ref/procedure-callingconvention-stack-8.asm b/src/test/ref/procedure-callingconvention-stack-8.asm index 4479aae68..86cbb2b09 100644 --- a/src/test/ref/procedure-callingconvention-stack-8.asm +++ b/src/test/ref/procedure-callingconvention-stack-8.asm @@ -1,16 +1,17 @@ // Test a procedure with calling convention stack // Illustrates live ranges for printline::i and global variable val .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label val = 2 -__bbegin: - // val = 0 - lda #0 - sta.z val - jsr main - rts +_start: { + // val = 0 + lda #0 + sta.z val + jsr main + rts +} printline: { ldx #0 __b1: diff --git a/src/test/ref/procedure-callingconvention-stack-9.asm b/src/test/ref/procedure-callingconvention-stack-9.asm index cc308fd3d..7271b4cd0 100644 --- a/src/test/ref/procedure-callingconvention-stack-9.asm +++ b/src/test/ref/procedure-callingconvention-stack-9.asm @@ -1,16 +1,17 @@ // Test a procedure with calling convention stack // Illustrates live range problem with function variable printother::i and global variable val .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label val = 2 -__bbegin: - // val = 0 - lda #0 - sta.z val - jsr main - rts +_start: { + // val = 0 + lda #0 + sta.z val + jsr main + rts +} printother: { ldx #0 __b1: diff --git a/src/test/ref/processor-port-test.asm b/src/test/ref/processor-port-test.asm index 092495325..c9516b905 100644 --- a/src/test/ref/processor-port-test.asm +++ b/src/test/ref/processor-port-test.asm @@ -23,8 +23,9 @@ .label KERNAL_ROM = $e000 .label IO_RAM = $d000 .label SCREEN = $400 - .label print_line_cursor = 4 - .label print_char_cursor = 6 + .label print_screen = $400 + .label print_char_cursor = 4 + .label print_line_cursor = 8 main: { // asm // Avoid interrupts @@ -57,9 +58,9 @@ main: { // print_cls() jsr print_cls // print_str("ddr port ddr2 $00 $01 $a000 $d000 $e000") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln // testProcport(PROCPORT_DDR_MEMORY_MASK, PROCPORT_RAM_ALL, PROCPORT_DDR_MEMORY_MASK) @@ -409,9 +410,9 @@ print_char: { rts } // Print a zero-terminated string -// print_str(byte* zp(8) str) +// print_str(byte* zp(6) str) print_str: { - .label str = 8 + .label str = 6 __b1: // while(*str) ldy #0 @@ -443,7 +444,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = 8 lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $21 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT + .label conio_line_color = $23 // The current text color - lda #LIGHT_BLUE - sta.z conio_textcolor - jsr main - rts + .label conio_textcolor = $1a + // The random state variable + .label rand_state = $14 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + // conio_textcolor = CONIO_TEXTCOLOR_DEFAULT + lda #LIGHT_BLUE + sta.z conio_textcolor + jsr main + rts +} main: { - .label first = $1d + .label first = $1b .label cnt = 2 .label rnd = 8 .label row = 7 @@ -202,7 +203,7 @@ printf_ulong: { // This handles minimum length, zero-filling, and left/right justification from the format // printf_number_buffer(byte zp($a) buffer_sign, byte register(X) format_min_length, byte zp($10) format_justify_left, byte zp($13) format_zero_padding, byte zp($b) format_upper_case) printf_number_buffer: { - .label __19 = $27 + .label __19 = $11 .label buffer_sign = $a .label padding = $c .label format_zero_padding = $13 @@ -453,11 +454,11 @@ cscroll: { rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. -// memset(void* zp($27) str, byte register(X) c) +// memset(void* zp($11) str, byte register(X) c) memset: { - .label end = $25 - .label dst = $27 - .label str = $27 + .label end = $27 + .label dst = $11 + .label str = $11 // end = (char*)str + num lda #$28 clc @@ -490,13 +491,13 @@ memset: { } // Copy block of memory (forwards) // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. -// memcpy(void* zp($14) destination, void* zp($27) source) +// memcpy(void* zp($16) destination, void* zp($11) source) memcpy: { - .label src_end = $25 - .label dst = $14 - .label src = $27 - .label source = $27 - .label destination = $14 + .label src_end = $27 + .label dst = $16 + .label src = $11 + .label source = $11 + .label destination = $16 // src_end = (char*)source+num lda.z source clc @@ -532,9 +533,9 @@ memcpy: { jmp __b1 } // Output a NUL-terminated string at the current cursor position -// cputs(byte* zp($23) s) +// cputs(byte* zp($25) s) cputs: { - .label s = $23 + .label s = $25 __b1: // c=*s++ ldy #0 @@ -556,7 +557,7 @@ cputs: { // Converts a string to uppercase. strupr: { .label str = printf_buffer+OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS - .label src = $14 + .label src = $16 lda #str @@ -604,11 +605,11 @@ toupper: { rts } // Computes the length of the string str up to but not including the terminating null character. -// strlen(byte* zp($23) str) +// strlen(byte* zp($25) str) strlen: { - .label len = $27 - .label str = $23 - .label return = $27 + .label len = $11 + .label str = $25 + .label return = $11 lda #<0 sta.z len sta.z len+1 @@ -642,11 +643,11 @@ strlen: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// ultoa(dword zp(2) value, byte* zp($27) buffer) +// ultoa(dword zp(2) value, byte* zp($11) buffer) ultoa: { .const max_digits = $a - .label digit_value = $1f - .label buffer = $27 + .label digit_value = $1d + .label buffer = $11 .label digit = $10 .label value = 2 lda #CONIO_HEIGHT) cmp #$19+1 bcc __b1 @@ -869,11 +870,11 @@ gotoxy: { // Information https://en.wikipedia.org/wiki/Xorshift // Source http://www.retroprogramming.com/2017/07/xorshift-pseudorandom-numbers-in-z80.html rand: { - .label __0 = $23 - .label __1 = $27 + .label __0 = $21 + .label __1 = $23 .label __2 = $25 .label return = 8 - .label return_1 = $1d + .label return_1 = $1b // rand_state << 7 lda.z rand_state+1 lsr @@ -957,11 +958,11 @@ printf_uint: { // - value : The number to be converted to RADIX // - buffer : receives the string representing the number and zero-termination. // - radix : The radix to convert the number to (from the enum RADIX) -// utoa(word zp(8) value, byte* zp($14) buffer) +// utoa(word zp(8) value, byte* zp($16) buffer) utoa: { .const max_digits = 5 .label digit_value = $27 - .label buffer = $14 + .label buffer = $16 .label digit = $13 .label value = 8 lda #COLORRAM diff --git a/src/test/ref/register-0.asm b/src/test/ref/register-0.asm index a761f82e1..53c271033 100644 --- a/src/test/ref/register-0.asm +++ b/src/test/ref/register-0.asm @@ -1,16 +1,17 @@ // Test declaring a variable as at a hard-coded register // hard-coded register parameter .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label idx = 3 -__bbegin: - // idx - lda #0 - sta.z idx - jsr main - rts +_start: { + // idx + lda #0 + sta.z idx + jsr main + rts +} main: { // print('c') lda #'c' diff --git a/src/test/ref/sandbox.asm b/src/test/ref/sandbox.asm index a04ba3990..3e30e718a 100644 --- a/src/test/ref/sandbox.asm +++ b/src/test/ref/sandbox.asm @@ -286,6 +286,7 @@ myprintf: { .label bDigits = $d .label bLen = $e // formats + // formats .label b = $c .label bArg = 9 .label w1 = 2 diff --git a/src/test/ref/screen-center-angle.asm b/src/test/ref/screen-center-angle.asm index cbf0ecb33..484cf20b8 100644 --- a/src/test/ref/screen-center-angle.asm +++ b/src/test/ref/screen-center-angle.asm @@ -309,6 +309,7 @@ atan2_16: { .label yi = 6 .label xi = $a .label angle = $d + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i .label xd = 8 .label yd = $f .label return = $d diff --git a/src/test/ref/screen-center-distance.asm b/src/test/ref/screen-center-distance.asm index 068f3dd40..b6914fa7d 100644 --- a/src/test/ref/screen-center-distance.asm +++ b/src/test/ref/screen-center-distance.asm @@ -22,6 +22,7 @@ .label CHARSET = $2000 .label SCREEN = $2800 // Top of the heap used by malloc() + // Top of the heap used by malloc() .label HEAP_TOP = $a000 // Squares for each char value SQUARES[i] = i*i // Initialized by init_squares() diff --git a/src/test/ref/screen-show-spiral-buckets.asm b/src/test/ref/screen-show-spiral-buckets.asm index 3fc45d6e1..81b3ac901 100644 --- a/src/test/ref/screen-show-spiral-buckets.asm +++ b/src/test/ref/screen-show-spiral-buckets.asm @@ -1,7 +1,7 @@ // Fill screen using a spiral based on distance-to-center / angle-to-center // Utilizes a bucket sort for identifying the minimum angle/distance .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const SIZEOF_WORD = 2 // The number of iterations performed during 16-bit CORDIC atan2 calculation @@ -21,91 +21,103 @@ // Screen containing angle to center .label SCREEN_FILL = $400 // Top of the heap used by malloc() + // Top of the heap used by malloc() .label HEAP_TOP = $a000 // Head of the heap. Moved backward each malloc() .label heap_head = 4 // Squares for each char value SQUARES[i] = i*i // Initialized by init_squares() .label SQUARES = 6 - .label SCREEN_DIST = $10 - .label SCREEN_ANGLE = $12 - .label BUCKET_SIZES = $14 - .label BUCKETS = $16 - .label BUCKET_IDX = $18 -__bbegin: - // malloc(1000) - lda #<$3e8 - sta.z malloc.size - lda #>$3e8 - sta.z malloc.size+1 - lda #HEAP_TOP - sta.z heap_head+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_DIST - lda.z malloc.mem+1 - sta.z SCREEN_DIST+1 - lda #<$3e8 - sta.z malloc.size - lda #>$3e8 - sta.z malloc.size+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_ANGLE - lda.z malloc.mem+1 - sta.z SCREEN_ANGLE+1 - // malloc(NUM_BUCKETS*sizeof(byte)) - lda #NUM_BUCKETS*SIZEOF_BYTE - sta.z malloc.size+1 - jsr malloc - // malloc(NUM_BUCKETS*sizeof(byte)) - lda.z malloc.mem - sta.z BUCKET_SIZES - lda.z malloc.mem+1 - sta.z BUCKET_SIZES+1 - // malloc(NUM_BUCKETS*sizeof(word*)) - lda #NUM_BUCKETS*SIZEOF_POINTER - sta.z malloc.size+1 - jsr malloc - // malloc(NUM_BUCKETS*sizeof(word*)) - lda.z malloc.mem - sta.z BUCKETS - lda.z malloc.mem+1 - sta.z BUCKETS+1 - // malloc(NUM_BUCKETS*sizeof(byte)) - lda #NUM_BUCKETS*SIZEOF_BYTE - sta.z malloc.size+1 - jsr malloc - // malloc(NUM_BUCKETS*sizeof(byte)) - lda.z malloc.mem - sta.z BUCKET_IDX - lda.z malloc.mem+1 - sta.z BUCKET_IDX+1 - jsr main - rts + // Screen containing distance to center + .label SCREEN_DIST = $1b + // Screen containing angle to center + .label SCREEN_ANGLE = $e + // Array containing the bucket size for each of the distance buckets + .label BUCKET_SIZES = $10 + // Buckets containing screen indices for each distance from the center. + // BUCKETS[dist] is an array of words containing screen indices. + // The size of the array BUCKETS[dist] is BUCKET_SIZES[dist] + .label BUCKETS = $12 + // Current index into each bucket. Used while populating the buckets. (After population the end the values will be equal to the bucket sizes) + .label BUCKET_IDX = $14 +_start: { + // malloc(1000) + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + lda #HEAP_TOP + sta.z heap_head+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_DIST + lda.z malloc.mem+1 + sta.z SCREEN_DIST+1 + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_ANGLE + lda.z malloc.mem+1 + sta.z SCREEN_ANGLE+1 + // malloc(NUM_BUCKETS*sizeof(byte)) + lda #NUM_BUCKETS*SIZEOF_BYTE + sta.z malloc.size+1 + jsr malloc + // malloc(NUM_BUCKETS*sizeof(byte)) + lda.z malloc.mem + sta.z BUCKET_SIZES + lda.z malloc.mem+1 + sta.z BUCKET_SIZES+1 + // malloc(NUM_BUCKETS*sizeof(word*)) + lda #NUM_BUCKETS*SIZEOF_POINTER + sta.z malloc.size+1 + jsr malloc + // malloc(NUM_BUCKETS*sizeof(word*)) + lda.z malloc.mem + sta.z BUCKETS + lda.z malloc.mem+1 + sta.z BUCKETS+1 + // malloc(NUM_BUCKETS*sizeof(byte)) + lda #NUM_BUCKETS*SIZEOF_BYTE + sta.z malloc.size+1 + jsr malloc + // malloc(NUM_BUCKETS*sizeof(byte)) + lda.z malloc.mem + sta.z BUCKET_IDX + lda.z malloc.mem+1 + sta.z BUCKET_IDX+1 + jsr main + rts +} main: { - .label bucket = $1a - .label bucket_size = $1c + .label bucket = $16 + .label bucket_size = $18 + // Animate a spiral walking through the buckets one at a time // Animate a spiral walking through the buckets one at a time .label bucket_idx = 2 - .label offset = $18 - .label fill = $1d - .label angle = $1f + .label offset = $14 + .label fill = $19 + .label angle = $1b + // Find the minimum unfilled angle in the current bucket // Find the minimum unfilled angle in the current bucket .label min_angle = 3 + // Found something to fill! .label fill1 = 4 .label min_offset = 4 - .label min_offset_1 = $18 + .label min_offset_1 = $14 // asm sei // init_dist_screen(SCREEN_DIST) @@ -261,24 +273,26 @@ main: { jmp __b8 } // Initialize buckets containing indices of chars on the screen with specific distances to the center. -// init_buckets(byte* zp($10) screen) +// init_buckets(byte* zp($1b) screen) init_buckets: { .label __4 = 6 - .label __7 = $22 + .label __7 = $20 .label __11 = $26 - .label __12 = $28 - .label __14 = $28 - .label screen = $10 - .label dist = $e - .label i1 = $1a - .label i2 = $1d - .label distance = $21 - .label bucket = $28 - .label dist_1 = $1f + .label __12 = $1d + .label __14 = $1d + .label screen = $1b + // first find bucket sizes - by counting number of chars with each distance value + .label dist = $c + .label i1 = $16 + .label i2 = $19 + .label distance = $1f + .label bucket = $1d + // first find bucket sizes - by counting number of chars with each distance value + .label dist_1 = $22 .label i4 = $24 .label __15 = 6 .label __16 = $26 - .label __17 = $28 + .label __17 = $1d ldy #0 // Init bucket sizes to 0 __b1: @@ -483,19 +497,19 @@ malloc: { } // Populates 1000 bytes (a screen) with values representing the angle to the center. // Utilizes symmetry around the center -// init_angle_screen(byte* zp($1a) screen) +// init_angle_screen(byte* zp($16) screen) init_angle_screen: { .label __7 = $24 - .label screen = $1a - .label screen_topline = $e - .label screen_bottomline = $1a + .label screen = $16 + .label screen_topline = $c + .label screen_bottomline = $16 .label xw = $26 - .label yw = $28 + .label yw = $1d .label angle_w = $24 - .label ang_w = $21 - .label x = $c - .label xb = $d - .label y = $1c + .label ang_w = $1f + .label x = $a + .label xb = $b + .label y = $18 // screen_topline = screen+40*12 lda.z screen clc @@ -609,18 +623,19 @@ init_angle_screen: { // Find the atan2(x, y) - which is the angle of the line from (0,0) to (x,y) // Finding the angle requires a binary search using CORDIC_ITERATIONS_16 // Returns the angle in hex-degrees (0=0, 0x8000=PI, 0x10000=2*PI) -// atan2_16(signed word zp($26) x, signed word zp($28) y) +// atan2_16(signed word zp($26) x, signed word zp($1d) y) atan2_16: { - .label __2 = $1d - .label __7 = $1f - .label yi = $1d - .label xi = $1f + .label __2 = $19 + .label __7 = $22 + .label yi = $19 + .label xi = $22 .label angle = $24 - .label xd = $a - .label yd = 8 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i + .label xd = 8 + .label yd = 6 .label return = $24 .label x = $26 - .label y = $28 + .label y = $1d // (y>=0)?y:-y lda.z y+1 bmi !__b1+ @@ -827,14 +842,14 @@ atan2_16: { // init_dist_screen(byte* zp(8) screen) init_dist_screen: { .label screen = 8 - .label screen_bottomline = $a - .label yds = $22 + .label screen_bottomline = $16 + .label yds = $20 .label screen_topline = 8 - .label y = $1c - .label xds = $24 - .label ds = $24 - .label x = $c - .label xb = $d + .label y = $18 + .label xds = $22 + .label ds = $22 + .label x = $a + .label xb = $b // init_squares() jsr init_squares // screen_bottomline = screen+40*24 @@ -952,12 +967,12 @@ init_dist_screen: { // Find the (integer) square root of a unsigned int value // If the square is not an integer then it returns the largest integer N where N*N <= val // Uses a table of squares that must be initialized by calling init_squares() -// sqrt(word zp($24) val) +// sqrt(word zp($22) val) sqrt: { - .label __1 = $e - .label __2 = $e - .label found = $e - .label val = $24 + .label __1 = $c + .label __2 = $c + .label found = $c + .label val = $22 // bsearch16u(val, SQUARES, NUM_SQUARES) lda.z SQUARES sta.z bsearch16u.items @@ -986,14 +1001,14 @@ sqrt: { // - items - Pointer to the start of the array to search in // - num - The number of items in the array // Returns pointer to an entry in the array that matches the search key -// bsearch16u(word zp($24) key, word* zp($e) items, byte register(X) num) +// bsearch16u(word zp($22) key, word* zp($c) items, byte register(X) num) bsearch16u: { - .label __2 = $e - .label pivot = $26 - .label result = $28 - .label return = $e - .label items = $e - .label key = $24 + .label __2 = $c + .label pivot = $24 + .label result = $26 + .label return = $c + .label items = $c + .label key = $22 ldx #NUM_SQUARES __b3: // while (num > 0) @@ -1080,8 +1095,8 @@ bsearch16u: { // Uses a table of squares that must be initialized by calling init_squares() // sqr(byte register(A) val) sqr: { - .label return = $24 - .label return_1 = $22 + .label return = $22 + .label return_1 = $20 // return SQUARES[val]; asl tay @@ -1096,8 +1111,8 @@ sqr: { // Initialize squares table // Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 init_squares: { - .label squares = $1a - .label sqr = $e + .label squares = $19 + .label sqr = $c // malloc(NUM_SQUARES*sizeof(unsigned int)) lda #$3e8 - sta.z malloc.size+1 - lda #HEAP_TOP - sta.z heap_head+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_DIST - lda.z malloc.mem+1 - sta.z SCREEN_DIST+1 - lda #<$3e8 - sta.z malloc.size - lda #>$3e8 - sta.z malloc.size+1 - jsr malloc - // malloc(1000) - lda.z malloc.mem - sta.z SCREEN_ANGLE - lda.z malloc.mem+1 - sta.z SCREEN_ANGLE+1 - jsr main - rts +_start: { + // malloc(1000) + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + lda #HEAP_TOP + sta.z heap_head+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_DIST + lda.z malloc.mem+1 + sta.z SCREEN_DIST+1 + lda #<$3e8 + sta.z malloc.size + lda #>$3e8 + sta.z malloc.size+1 + jsr malloc + // malloc(1000) + lda.z malloc.mem + sta.z SCREEN_ANGLE + lda.z malloc.mem+1 + sta.z SCREEN_ANGLE+1 + jsr main + rts +} main: { + // Find the minimum dist/angle that is not already filled .label dist = 2 .label angle = 4 .label fill = $15 @@ -311,6 +316,7 @@ atan2_16: { .label yi = $11 .label xi = $24 .label angle = $13 + // Optimized shift of 2 values: xd=xi>>i; yd=yi>>i .label xd = $1e .label yd = $17 .label return = $13 diff --git a/src/test/ref/semi-struct-1.asm b/src/test/ref/semi-struct-1.asm index 76741972c..c433fdd5f 100644 --- a/src/test/ref/semi-struct-1.asm +++ b/src/test/ref/semi-struct-1.asm @@ -12,8 +12,9 @@ .const SIZEOF_POINT = 2 // The number of points .const NUM_POINTS = 4 - .label print_line_cursor = 2 - .label print_char_cursor = 4 + .label print_screen = $400 + .label print_line_cursor = 4 + .label print_char_cursor = 9 // Initialize some points and print them main: { // init_points() @@ -25,17 +26,17 @@ main: { } // Print points print_points: { - .label point = 9 - .label i = 8 + .label point = 7 + .label i = 6 // print_cls() jsr print_cls - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -141,9 +142,9 @@ print_char: { rts } // Print a zero-terminated string -// print_str(byte* zp(6) str) +// print_str(byte* zp(2) str) print_str: { - .label str = 6 + .label str = 2 lda #print_points.str @@ -179,9 +180,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = 6 + .label dst = 4 lda #str @@ -211,7 +212,7 @@ memset: { // Initialize points init_points: { .label getPoint1_return = 9 - .label pos = 8 + .label pos = 6 lda #$a sta.z pos ldx #0 diff --git a/src/test/ref/semi-struct-2.asm b/src/test/ref/semi-struct-2.asm index baae55d24..586400437 100644 --- a/src/test/ref/semi-struct-2.asm +++ b/src/test/ref/semi-struct-2.asm @@ -30,17 +30,18 @@ .const OFFSET_STRUCT_MOS6526_CIA_PORT_B = 1 // The CIA#1: keyboard matrix, joystick #1/#2 .label CIA1 = $dc00 - .label print_line_cursor = $c - .label print_char_cursor = 2 - .label print_line_cursor_1 = 4 + .label print_screen = $400 + .label print_char_cursor = 4 + .label print_line_cursor = 8 + .label print_line_cursor_1 = $a // Initialize 2 file entries and print them main: { .const fileEntry1_idx = 1 .const fileEntry2_idx = 2 - .label fileEntry1___0 = 6 - .label fileEntry2___0 = $a - .label entry1 = 6 - .label entry2 = $a + .label fileEntry1___0 = 2 + .label fileEntry2___0 = 6 + .label entry1 = 2 + .label entry2 = 6 // keyboard_init() jsr keyboard_init // mul8u(idx, SIZEOF_ENTRY) @@ -88,9 +89,9 @@ main: { // print_cls() jsr print_cls // print_str("** entry 1 **") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor_1+1 jsr print_ln lda.z print_line_cursor @@ -145,9 +146,9 @@ main: { // print_cls() jsr print_cls // print_str("** entry 2 **") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor_1+1 jsr print_ln lda.z print_line_cursor @@ -225,9 +226,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = 4 + .label dst = $a lda #str @@ -284,9 +285,9 @@ keyboard_matrix_read: { rts } // Print a zero-terminated string -// print_str(byte* zp(4) str) +// print_str(byte* zp($a) str) print_str: { - .label str = 4 + .label str = $a __b1: // while(*str) ldy #0 @@ -350,9 +351,9 @@ print_ln: { jmp __b1 } // Print the contents of a file entry -// printEntry(byte* zp(6) entry) +// printEntry(byte* zp(2) entry) printEntry: { - .label entry = 6 + .label entry = 2 lda.z print_line_cursor sta.z print_char_cursor lda.z print_line_cursor+1 @@ -694,9 +695,9 @@ print_uchar: { rts } // Print a unsigned int as HEX -// print_uint(word zp(8) w) +// print_uint(word zp($a) w) print_uint: { - .label w = 8 + .label w = $a // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -708,14 +709,14 @@ print_uint: { } // Set all values in the passed struct // Sets the values to n, n+1, n... to help test that everything works as intended -// initEntry(byte* zp(8) entry, byte register(X) n) +// initEntry(byte* zp(4) entry, byte register(X) n) initEntry: { - .label __1 = $e - .label __3 = $10 - .label __5 = $12 - .label __7 = $14 - .label __17 = $16 - .label entry = 8 + .label __1 = 8 + .label __3 = $a + .label __5 = $c + .label __7 = $e + .label __17 = $10 + .label entry = 4 // 0x1111+n txa clc @@ -853,9 +854,9 @@ initEntry: { // Perform binary multiplication of two unsigned 8-bit chars into a 16-bit unsigned int // mul8u(byte register(X) a) mul8u: { - .label mb = $c - .label res = $a - .label return = $a + .label mb = 8 + .label res = 6 + .label return = 6 lda #SIZEOF_ENTRY diff --git a/src/test/ref/sieve-min.asm b/src/test/ref/sieve-min.asm index 6ab2d5289..6b29b1c07 100644 --- a/src/test/ref/sieve-min.asm +++ b/src/test/ref/sieve-min.asm @@ -8,11 +8,14 @@ .const SQRT_COUNT = $80 .label SCREEN = $400 /* Sqrt of COUNT */ + /* Sqrt of COUNT */ .label sieve = $1000 + .label print_screen = $400 .label print_char_cursor = $a main: { .label i = $a .label sieve_i = 2 + /* Prime number - mark all multiples */ .label j = 6 .label s = 8 .label i_1 = 4 @@ -38,9 +41,9 @@ main: { cmp #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<2 sta.z i_1 diff --git a/src/test/ref/sieve.asm b/src/test/ref/sieve.asm index eb199b38f..812ad421f 100644 --- a/src/test/ref/sieve.asm +++ b/src/test/ref/sieve.asm @@ -28,7 +28,9 @@ .label CIA2_TIMER_AB = $dd04 .label SCREEN = $400 /* Sqrt of COUNT */ + /* Sqrt of COUNT */ .label sieve = $1000 + .label print_screen = $400 // Remainder after unsigned 16-bit division .label rem16u = $13 .label print_char_cursor = $a @@ -43,6 +45,7 @@ main: { .label sec100s = 4 .label i = $a .label sieve_i = 2 + /* Prime number - mark all multiples */ .label j = 6 .label s = 8 .label i_1 = 4 @@ -54,9 +57,9 @@ main: { // print_cls() jsr print_cls // print_str("Sieve benchmark - calculating primes") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda.z print_line_cursor @@ -835,12 +838,12 @@ clock_start: { rts } // Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str. -// memset(void* zp($1b) str, byte register(X) c, word zp($15) num) +// memset(void* zp($15) str, byte register(X) c, word zp($13) num) memset: { - .label end = $15 - .label dst = $1b - .label num = $15 - .label str = $1b + .label end = $13 + .label dst = $15 + .label num = $13 + .label str = $15 // if(num>0) lda.z num bne !+ @@ -882,9 +885,9 @@ memset: { print_cls: { // memset(print_screen, ' ', 1000) ldx #' ' - lda #<$400 + lda #$400 + lda #>print_screen sta.z memset.str+1 lda #<$3e8 sta.z memset.num diff --git a/src/test/ref/signed-indexed-subtract.asm b/src/test/ref/signed-indexed-subtract.asm index b249a0e96..d64d2bceb 100644 --- a/src/test/ref/signed-indexed-subtract.asm +++ b/src/test/ref/signed-indexed-subtract.asm @@ -2,7 +2,8 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 3 + .label print_screen = $400 + .label print_line_cursor = 7 .label print_char_cursor = 5 main: { .label j = 2 @@ -26,13 +27,13 @@ main: { bne __b1 // print_cls() jsr print_cls - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z j @@ -86,9 +87,9 @@ print_ln: { rts } // Print a signed int as HEX -// print_sint(signed word zp(7) w) +// print_sint(signed word zp(3) w) print_sint: { - .label w = 7 + .label w = 3 // if(w<0) lda.z w+1 bmi __b1 @@ -129,9 +130,9 @@ print_char: { rts } // Print a unsigned int as HEX -// print_uint(word zp(7) w) +// print_uint(word zp(3) w) print_uint: { - .label w = 7 + .label w = 3 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -175,7 +176,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = 7 lda #f_127 sta.z setMEMtoFAC.mem+1 jsr setMEMtoFAC - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #1 sta.z i diff --git a/src/test/ref/sinusgen16.asm b/src/test/ref/sinusgen16.asm index 8190c79a4..e7c9a47b8 100644 --- a/src/test/ref/sinusgen16.asm +++ b/src/test/ref/sinusgen16.asm @@ -14,21 +14,21 @@ // PI/2 in u[4.28] format .const PI_HALF_u4f28 = $1921fb54 .const SIZEOF_SIGNED_WORD = 2 - .label print_line_cursor = $400 + .label print_screen = $400 // Remainder after unsigned 16-bit division - .label rem16u = $1a - .label print_char_cursor = 4 + .label rem16u = $18 + .label print_char_cursor = 6 main: { .label wavelength = $78 - .label sw = 6 + .label sw = 4 .label st1 = 2 // sin16s_gen(sintab1, wavelength) jsr sin16s_gen // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #w) ldx.z w+1 jsr print_uchar @@ -200,9 +200,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num - .label dst = 8 + .label dst = $c lda #str @@ -232,15 +232,18 @@ memset: { // Generate signed (large) unsigned int sinus table - on the full -$7fff - $7fff range // sintab - the table to generate into // wavelength - the number of sinus points in a total sinus wavelength (the size of the table) -// sin16s_gen(signed word* zp($e) sintab) +// sin16s_gen(signed word* zp($c) sintab) sin16s_gen: { - .label __2 = $14 - .label step = $1e - .label sintab = $e + .label __2 = $12 + // u[4.28] step = PI*2/wavelength + .label step = $1c + .label sintab = $c // u[4.28] // Iterate over the table - .label x = $a - .label i = 8 + // u[4.28] + // Iterate over the table + .label x = 8 + .label i = 6 // div32u16u(PI2_u4f28, wavelength) jsr div32u16u // div32u16u(PI2_u4f28, wavelength) @@ -322,20 +325,29 @@ sin16s_gen: { // Calculate signed int sinus sin(x) // x: unsigned long input u[4.28] in the interval $00000000 - PI2_u4f28 // result: signed int sin(x) s[0.15] - using the full range -$7fff - $7fff -// sin16s(dword zp($10) x) +// sin16s(dword zp($e) x) sin16s: { - .label __4 = $22 - .label x = $10 - .label return = $14 - .label x1 = $28 - .label x2 = $1a - .label x3 = $1a - .label x3_6 = $26 - .label usinx = $14 - .label x4 = $1a - .label x5 = $26 - .label x5_128 = $26 - .label sinx = $14 + .label __4 = $20 + .label x = $e + .label return = $12 + // sinx = x - x^3/6 + x5/128; + .label x1 = $26 + // u[1.15] + .label x2 = $18 + // u[2.14] x^2 + .label x3 = $18 + // u[2.14] x^3 + .label x3_6 = $24 + // u[1.15] x^3/6; + .label usinx = $12 + // u[1.15] x - x^3/6 + .label x4 = $18 + // u[3.13] x^4 + .label x5 = $24 + // u[4.12] x^5 + .label x5_128 = $24 + // u[1.15] (first bit is always zero) + .label sinx = $12 // if(x >= PI_u4f28 ) lda.z x+3 cmp #>PI_u4f28>>$10 @@ -533,14 +545,14 @@ sin16s: { } // Calculate val*val for two unsigned int values - the result is 16 selected bits of the 32-bit result. // The select parameter indicates how many of the highest bits of the 32-bit result to skip -// mulu16_sel(word zp($1a) v1, word zp($1c) v2, byte register(X) select) +// mulu16_sel(word zp($18) v1, word zp($1a) v2, byte register(X) select) mulu16_sel: { - .label __0 = $22 - .label __1 = $22 - .label v1 = $1a - .label v2 = $1c - .label return = $26 - .label return_1 = $1a + .label __0 = $20 + .label __1 = $20 + .label v1 = $18 + .label v2 = $1a + .label return = $24 + .label return_1 = $18 // mul16u(v1, v2) lda.z v1 sta.z mul16u.a @@ -567,13 +579,13 @@ mulu16_sel: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($26) a, word zp($1c) b) +// mul16u(word zp($24) a, word zp($1a) b) mul16u: { - .label mb = $16 - .label a = $26 - .label res = $22 - .label b = $1c - .label return = $22 + .label mb = $14 + .label a = $24 + .label res = $20 + .label b = $1a + .label return = $20 // mb = b lda.z b sta.z mb @@ -631,9 +643,9 @@ mul16u: { // Divide unsigned 32-bit unsigned long dividend with a 16-bit unsigned int divisor // The 16-bit unsigned int remainder can be found in rem16u after the division div32u16u: { - .label quotient_hi = $28 - .label quotient_lo = $26 - .label return = $1e + .label quotient_hi = $26 + .label quotient_lo = $24 + .label return = $1c // divr16u(>dividend, divisor, 0) lda #>$10 sta.z divr16u.dividend @@ -673,12 +685,12 @@ div32u16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($1c) dividend, word zp($1a) rem) +// divr16u(word zp($1a) dividend, word zp($18) rem) divr16u: { - .label rem = $1a - .label dividend = $1c - .label quotient = $26 - .label return = $26 + .label rem = $18 + .label dividend = $1a + .label quotient = $24 + .label return = $24 ldx #0 txa sta.z quotient diff --git a/src/test/ref/sinusgen16b.asm b/src/test/ref/sinusgen16b.asm index 208e51232..b3f047cb2 100644 --- a/src/test/ref/sinusgen16b.asm +++ b/src/test/ref/sinusgen16b.asm @@ -18,13 +18,13 @@ // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .const SIZEOF_SIGNED_WORD = 2 - .label print_line_cursor = $400 + .label print_screen = $400 // Remainder after unsigned 16-bit division - .label rem16u = $b - .label print_char_cursor = 7 + .label rem16u = 9 + .label print_char_cursor = $1b main: { .label wavelength = $78 - .label sw = 9 + .label sw = 7 .label st1 = 2 .label st2 = 4 .label i = 6 @@ -36,9 +36,9 @@ main: { jsr print_cls lda #0 sta.z i - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #w) ldx.z w+1 jsr print_uchar @@ -220,9 +220,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num - .label dst = $b + .label dst = 9 lda #str @@ -252,15 +252,18 @@ memset: { // Generate signed (large) word sinus table - on the full -$7fff - $7fff range // sintab - the table to generate into // wavelength - the number of sinus points in a total sinus wavelength (the size of the table) -// sin16s_genb(signed word* zp($17) sintab) +// sin16s_genb(signed word* zp($f) sintab) sin16s_genb: { - .label __3 = $1d - .label step = $1f - .label sintab = $17 + .label __3 = $15 + // u[4.28] step = PI*2/wavelength + .label step = $1d + .label sintab = $f // u[4.28] // Iterate over the table - .label x = $13 - .label i = $11 + // u[4.28] + // Iterate over the table + .label x = $11 + .label i = $1b // div32u16u(PI2_u4f28, wavelength) jsr div32u16u // div32u16u(PI2_u4f28, wavelength) @@ -338,19 +341,28 @@ sin16s_genb: { // Calculate signed word sinus sin(x) // x: unsigned dword input u[4.28] in the interval $00000000 - PI2_u4f28 // result: signed word sin(x) s[0.15] - using the full range -$7fff - $7fff -// sin16sb(word zp($b) x) +// sin16sb(word zp(9) x) sin16sb: { - .label x = $b - .label return = $1d - .label x1 = $b - .label x2 = $d - .label x3 = $d - .label x3_6 = $23 - .label usinx = $1d - .label x4 = $d - .label x5 = $23 - .label x5_128 = $23 - .label sinx = $1d + .label x = 9 + .label return = $15 + // sinx = x - x^3/6 + x5/128; + .label x1 = 9 + // u[1.15] + .label x2 = $b + // u[2.14] x^2 + .label x3 = $b + // u[2.14] x^3 + .label x3_6 = $21 + // u[1.15] x^3/6; + .label usinx = $15 + // u[1.15] x - x^3/6 + .label x4 = $b + // u[3.13] x^4 + .label x5 = $21 + // u[4.12] x^5 + .label x5_128 = $21 + // u[1.15] (first bit is always zero) + .label sinx = $15 // if(x >= PI_u4f12 ) lda.z x+1 cmp #>PI_u4f12 @@ -501,14 +513,14 @@ sin16sb: { } // Calculate val*val for two unsigned int values - the result is 16 selected bits of the 32-bit result. // The select parameter indicates how many of the highest bits of the 32-bit result to skip -// mulu16_sel(word zp($d) v1, word zp($f) v2, byte register(X) select) +// mulu16_sel(word zp($b) v1, word zp($d) v2, byte register(X) select) mulu16_sel: { - .label __0 = $19 - .label __1 = $19 - .label v1 = $d - .label v2 = $f - .label return = $d - .label return_1 = $23 + .label __0 = $17 + .label __1 = $17 + .label v1 = $b + .label v2 = $d + .label return = $b + .label return_1 = $21 // mul16u(v1, v2) lda.z v1 sta.z mul16u.a @@ -535,13 +547,13 @@ mulu16_sel: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($23) a, word zp($f) b) +// mul16u(word zp($21) a, word zp($d) b) mul16u: { - .label mb = $25 - .label a = $23 - .label res = $19 - .label b = $f - .label return = $19 + .label mb = $23 + .label a = $21 + .label res = $17 + .label b = $d + .label return = $17 // mb = b lda.z b sta.z mb @@ -599,9 +611,9 @@ mul16u: { // Divide unsigned 32-bit unsigned long dividend with a 16-bit unsigned int divisor // The 16-bit unsigned int remainder can be found in rem16u after the division div32u16u: { - .label quotient_hi = $29 - .label quotient_lo = $f - .label return = $1f + .label quotient_hi = $27 + .label quotient_lo = $d + .label return = $1d // divr16u(>dividend, divisor, 0) lda #>$10 sta.z divr16u.dividend @@ -641,12 +653,12 @@ div32u16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($d) dividend, word zp($b) rem) +// divr16u(word zp($b) dividend, word zp(9) rem) divr16u: { - .label rem = $b - .label dividend = $d - .label quotient = $f - .label return = $f + .label rem = 9 + .label dividend = $b + .label quotient = $d + .label return = $d ldx #0 txa sta.z quotient @@ -707,15 +719,18 @@ divr16u: { // Generate signed (large) unsigned int sinus table - on the full -$7fff - $7fff range // sintab - the table to generate into // wavelength - the number of sinus points in a total sinus wavelength (the size of the table) -// sin16s_gen(signed word* zp($17) sintab) +// sin16s_gen(signed word* zp($15) sintab) sin16s_gen: { - .label __2 = $1d - .label step = $1f - .label sintab = $17 + .label __2 = $1b + // u[4.28] step = PI*2/wavelength + .label step = $1d + .label sintab = $15 // u[4.28] // Iterate over the table - .label x = $13 - .label i = $11 + // u[4.28] + // Iterate over the table + .label x = $11 + .label i = $f // div32u16u(PI2_u4f28, wavelength) jsr div32u16u // div32u16u(PI2_u4f28, wavelength) @@ -797,20 +812,29 @@ sin16s_gen: { // Calculate signed int sinus sin(x) // x: unsigned long input u[4.28] in the interval $00000000 - PI2_u4f28 // result: signed int sin(x) s[0.15] - using the full range -$7fff - $7fff -// sin16s(dword zp($19) x) +// sin16s(dword zp($17) x) sin16s: { - .label __4 = $25 - .label x = $19 - .label return = $1d - .label x1 = $29 - .label x2 = $d - .label x3 = $d - .label x3_6 = $23 - .label usinx = $1d - .label x4 = $d - .label x5 = $23 - .label x5_128 = $23 - .label sinx = $1d + .label __4 = $23 + .label x = $17 + .label return = $1b + // sinx = x - x^3/6 + x5/128; + .label x1 = $27 + // u[1.15] + .label x2 = $b + // u[2.14] x^2 + .label x3 = $b + // u[2.14] x^3 + .label x3_6 = $21 + // u[1.15] x^3/6; + .label usinx = $1b + // u[1.15] x - x^3/6 + .label x4 = $b + // u[3.13] x^4 + .label x5 = $21 + // u[4.12] x^5 + .label x5_128 = $21 + // u[1.15] (first bit is always zero) + .label sinx = $1b // if(x >= PI_u4f28 ) lda.z x+3 cmp #>PI_u4f28>>$10 diff --git a/src/test/ref/sinusgen8.asm b/src/test/ref/sinusgen8.asm index 123053a17..9daa63254 100644 --- a/src/test/ref/sinusgen8.asm +++ b/src/test/ref/sinusgen8.asm @@ -13,7 +13,7 @@ // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .const wavelength = $c0 - .label print_line_cursor = $400 + .label print_screen = $400 .label print_char_cursor = 3 main: { .label i = 2 @@ -21,9 +21,9 @@ main: { jsr sin8s_gen // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -150,7 +150,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num .label dst = 5 lda #= PI_u4f12 ) lda.z x+1 cmp #>PI_u4f12 @@ -390,11 +397,11 @@ sin8s: { } // Calculate val*val for two unsigned char values - the result is 8 selected bits of the 16-bit result. // The select parameter indicates how many of the highest bits of the 16-bit result to skip -// mulu8_sel(byte register(X) v1, byte register(Y) v2, byte zp($c) select) +// mulu8_sel(byte register(X) v1, byte register(Y) v2, byte zp($a) select) mulu8_sel: { - .label __0 = $f - .label __1 = $f - .label select = $c + .label __0 = $d + .label __1 = $d + .label select = $a // mul8u(v1, v2) tya jsr mul8u @@ -415,9 +422,9 @@ mulu8_sel: { // Perform binary multiplication of two unsigned 8-bit chars into a 16-bit unsigned int // mul8u(byte register(X) a, byte register(A) b) mul8u: { - .label mb = $d - .label res = $f - .label return = $f + .label mb = $b + .label res = $d + .label return = $d // mb = b sta.z mb lda #0 @@ -460,7 +467,7 @@ mul8u: { // The remainder will be set into the global variable rem16u // Implemented using simple binary division div16u: { - .label return = $11 + .label return = $f // divr16u(dividend, divisor, 0) jsr divr16u // divr16u(dividend, divisor, 0) @@ -471,12 +478,12 @@ div16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($f) dividend, word zp($d) rem) +// divr16u(word zp($d) dividend, word zp($b) rem) divr16u: { - .label rem = $d - .label dividend = $f - .label quotient = $11 - .label return = $11 + .label rem = $b + .label dividend = $d + .label quotient = $f + .label return = $f ldx #0 txa sta.z quotient diff --git a/src/test/ref/sinusgen8b.asm b/src/test/ref/sinusgen8b.asm index 5a17a05fd..cfe09aa32 100644 --- a/src/test/ref/sinusgen8b.asm +++ b/src/test/ref/sinusgen8b.asm @@ -19,17 +19,17 @@ // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 .const SIZEOF_SIGNED_WORD = 2 - .label print_line_cursor = $400 + .label print_screen = $400 // Remainder after unsigned 16-bit division .label rem16u = $11 .label print_char_cursor = 3 main: { .label wavelength = $c0 - .label __3 = $1d - .label __9 = $1d - .label __10 = $1d - .label sb = $1c - .label sw = $1d + .label __3 = $1b + .label __9 = $1b + .label __10 = $1b + .label sb = $1a + .label sw = $1b .label i = 2 // sin8s_gen(sintabb, wavelength) jsr sin8s_gen @@ -37,9 +37,9 @@ main: { jsr sin16s_gen // print_cls() jsr print_cls - lda #print_line_cursor + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -196,7 +196,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = print_line_cursor + .label str = print_screen .label end = str+num .label dst = $11 lda #= PI_u4f28 ) lda.z x+3 cmp #>PI_u4f28>>$10 @@ -529,12 +541,12 @@ sin16s: { } // Calculate val*val for two unsigned int values - the result is 16 selected bits of the 32-bit result. // The select parameter indicates how many of the highest bits of the 32-bit result to skip -// mulu16_sel(word zp($11) v1, word zp($1d) v2, byte register(X) select) +// mulu16_sel(word zp($11) v1, word zp($1b) v2, byte register(X) select) mulu16_sel: { - .label __0 = $23 - .label __1 = $23 + .label __0 = $21 + .label __1 = $21 .label v1 = $11 - .label v2 = $1d + .label v2 = $1b .label return = $27 .label return_1 = $11 // mul16u(v1, v2) @@ -563,13 +575,13 @@ mulu16_sel: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($13) a, word zp($1d) b) +// mul16u(word zp($13) a, word zp($1b) b) mul16u: { .label mb = $d .label a = $13 - .label res = $23 - .label b = $1d - .label return = $23 + .label res = $21 + .label b = $1b + .label return = $21 // mb = b lda.z b sta.z mb @@ -629,7 +641,7 @@ mul16u: { div32u16u: { .label quotient_hi = $29 .label quotient_lo = $13 - .label return = $1f + .label return = $1d // divr16u(>dividend, divisor, 0) lda #>$10 sta.z divr16u.dividend @@ -669,10 +681,10 @@ div32u16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($1d) dividend, word zp($11) rem) +// divr16u(word zp($1b) dividend, word zp($11) rem) divr16u: { .label rem = $11 - .label dividend = $1d + .label dividend = $1b .label quotient = $13 .label return = $13 ldx #0 @@ -735,10 +747,13 @@ divr16u: { // Generate signed char sinus table - on the full -$7f - $7f range // sintab - the table to generate into // wavelength - the number of sinus points in a total sinus wavelength (the size of the table) -// sin8s_gen(signed byte* zp($19) sintab) +// sin8s_gen(signed byte* zp($1b) sintab) sin8s_gen: { + // u[4.28] step = PI*2/wavelength .label step = $13 - .label sintab = $19 + .label sintab = $1b + // u[4.12] + // Iterate over the table // u[4.12] // Iterate over the table .label x = $17 @@ -802,17 +817,21 @@ sin8s_gen: { // Calculate signed char sinus sin(x) // x: unsigned int input u[4.12] in the interval $0000 - PI2_u4f12 // result: signed char sin(x) s[0.7] - using the full range -$7f - $7f -// sin8s(word zp($1d) x) +// sin8s(word zp($25) x) sin8s: { // u[2.6] x^3 .const DIV_6 = $2b - .label __4 = $1d - .label x = $1d + .label __4 = $25 + .label x = $25 + // sinx = x - x^3/6 + x5/128; .label x1 = $2b + // u[2.6] x^2 .label x3 = $2c + // u[1.7] x^3/6; .label usinx = $2d // Move x1 into the range 0-PI/2 using sinus mirror symmetries - .label isUpper = $1c + // Move x1 into the range 0-PI/2 using sinus mirror symmetries + .label isUpper = $1a // if(x >= PI_u4f12 ) lda.z x+1 cmp #>PI_u4f12 @@ -943,11 +962,11 @@ sin8s: { } // Calculate val*val for two unsigned char values - the result is 8 selected bits of the 16-bit result. // The select parameter indicates how many of the highest bits of the 16-bit result to skip -// mulu8_sel(byte register(X) v1, byte register(Y) v2, byte zp($1b) select) +// mulu8_sel(byte register(X) v1, byte register(Y) v2, byte zp($19) select) mulu8_sel: { - .label __0 = $29 - .label __1 = $29 - .label select = $1b + .label __0 = $27 + .label __1 = $27 + .label select = $19 // mul8u(v1, v2) tya jsr mul8u @@ -968,9 +987,9 @@ mulu8_sel: { // Perform binary multiplication of two unsigned 8-bit chars into a 16-bit unsigned int // mul8u(byte register(X) a, byte register(A) b) mul8u: { - .label mb = $27 - .label res = $29 - .label return = $29 + .label mb = $29 + .label res = $27 + .label return = $27 // mb = b sta.z mb lda #0 diff --git a/src/test/ref/sinusgenscale8.asm b/src/test/ref/sinusgenscale8.asm index f21fbc472..0de7e0e85 100644 --- a/src/test/ref/sinusgenscale8.asm +++ b/src/test/ref/sinusgenscale8.asm @@ -12,8 +12,9 @@ .const PI_u4f12 = $3244 // PI/2 in u[4.12] format .const PI_HALF_u4f12 = $1922 + .label print_screen = $400 .label print_char_cursor = 8 - .label print_line_cursor = 6 + .label print_line_cursor = $a main: { .label tabsize = $14 // print_cls() @@ -36,12 +37,15 @@ sin8u_table: { .const sum = min+max .const mid = sum/2+1 .label amplitude = max-min + //if( sum & 1 > 0) mid++; + // u[4.28] step = PI*2/wavelength .label step = $e .label sinx = $12 - .label sinx_sc = $a + .label sinx_sc = 6 .label sinx_tr = $13 .label sintab = 4 // Iterate over the table + // Iterate over the table .label x = 2 .label i = $10 // div16u(PI2_u4f12, tabsize) @@ -50,9 +54,9 @@ sin8u_table: { // step = div16u(PI2_u4f12, tabsize) // print_str("step:") // u[4.12] - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda #= PI_u4f12 ) lda.z x+1 @@ -604,8 +612,8 @@ sin8s: { // The select parameter indicates how many of the highest bits of the 16-bit result to skip // mulu8_sel(byte register(X) v1, byte register(Y) v2, byte zp($13) select) mulu8_sel: { - .label __0 = $a - .label __1 = $a + .label __0 = 6 + .label __1 = 6 .label select = $13 // mul8u(v1, v2) tya @@ -641,9 +649,9 @@ div16u: { // Returns the quotient dividend/divisor. // The final remainder will be set into the global variable rem16u // Implemented using simple binary division -// divr16u(word zp($c) dividend, word zp($10) rem) +// divr16u(word zp($c) dividend, word zp($a) rem) divr16u: { - .label rem = $10 + .label rem = $a .label dividend = $c .label quotient = $e .label return = $e @@ -721,7 +729,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $10 lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $14 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $16 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label pStar = 3 .label i = 2 diff --git a/src/test/ref/stars-2.asm b/src/test/ref/stars-2.asm index 1a55f2b37..54f414ee1 100644 --- a/src/test/ref/stars-2.asm +++ b/src/test/ref/stars-2.asm @@ -1,7 +1,7 @@ // Stars struct of array // Functions for performing input and output. .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e .const OFFSET_STRUCT_PRINTF_BUFFER_NUMBER_DIGITS = 1 @@ -10,33 +10,34 @@ .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = $b - .label conio_cursor_y = $c - .label conio_line_text = $d - .label conio_line_color = $f -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = $b // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = $c // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = $d // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $f +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label i = 2 // clrscr() diff --git a/src/test/ref/static-init-code-0.asm b/src/test/ref/static-init-code-0.asm index 651dac900..67b694bba 100644 --- a/src/test/ref/static-init-code-0.asm +++ b/src/test/ref/static-init-code-0.asm @@ -5,22 +5,18 @@ :BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 + // Initialize a volatile ZP-variable (will be done in the initializer) .label c1 = 2 + // Initialize another volatile ZP-variable (will be done in the initializer) .label c2 = 3 _start: { - jsr _init - jsr main - rts -} -_init: { // c1 = 'o' - // Initialize a volatile ZP-variable (will be done in the initializer) lda #'o' sta.z c1 // c2 = 'k' - // Initialize another volatile ZP-variable (will be done in the initializer) lda #'k' sta.z c2 + jsr main rts } main: { diff --git a/src/test/ref/struct-ptr-19.asm b/src/test/ref/struct-ptr-19.asm index 42fa69d42..4b90c17e0 100644 --- a/src/test/ref/struct-ptr-19.asm +++ b/src/test/ref/struct-ptr-19.asm @@ -5,9 +5,10 @@ .const SIZEOF_STRUCT_POINT = 2 .const OFFSET_STRUCT_POINT_Y = 1 .label SCREEN = $400 + .label idx = 2 main: { .label ptr = point - .label point = 2 + .label point = 3 // point = { 1, 2 } ldy #SIZEOF_STRUCT_POINT !: @@ -16,28 +17,32 @@ main: { dey bne !- // print(point) - lda.z point - ldy point+OFFSET_STRUCT_POINT_Y - ldx #0 + ldy.z point + ldx point+OFFSET_STRUCT_POINT_Y + lda #0 + sta.z idx jsr print // print(*ptr) - lda.z ptr - ldy ptr+OFFSET_STRUCT_POINT_Y + ldy.z ptr + ldx ptr+OFFSET_STRUCT_POINT_Y jsr print // } rts } -// print(byte register(A) p_x, byte register(Y) p_y) +// print(byte register(Y) p_x, byte register(X) p_y) print: { // SCREEN[idx++] = p.x - sta SCREEN,x - // SCREEN[idx++] = p.x; - inx - // SCREEN[idx++] = p.y tya - sta SCREEN,x + ldy.z idx + sta SCREEN,y + // SCREEN[idx++] = p.x; + iny + // SCREEN[idx++] = p.y + txa + sta SCREEN,y // SCREEN[idx++] = p.y; - inx + iny + sty.z idx // } rts } diff --git a/src/test/ref/struct-ptr-22.asm b/src/test/ref/struct-ptr-22.asm index 155ef40e4..cb5c42c91 100644 --- a/src/test/ref/struct-ptr-22.asm +++ b/src/test/ref/struct-ptr-22.asm @@ -3,8 +3,9 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_char_cursor = 4 - .label print_line_cursor = 2 + .label print_screen = $400 + .label print_char_cursor = 6 + .label print_line_cursor = 4 main: { .label __13 = 6 // file->bufEdit = 0x4000 @@ -33,9 +34,9 @@ main: { // writes address 0x4004 (right!) jsr print_cls // print_str("$0000=") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda.z print_line_cursor @@ -134,9 +135,9 @@ print_char: { rts } // Print a zero-terminated string -// print_str(byte* zp(6) str) +// print_str(byte* zp(2) str) print_str: { - .label str = 6 + .label str = 2 __b1: // while(*str) ldy #0 @@ -168,9 +169,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = 6 + .label dst = 4 lda #str diff --git a/src/test/ref/struct-ptr-25.asm b/src/test/ref/struct-ptr-25.asm index a903f1905..7761eae52 100644 --- a/src/test/ref/struct-ptr-25.asm +++ b/src/test/ref/struct-ptr-25.asm @@ -1,7 +1,11 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + .label SCREEN = $400 main: { + // SCREEN[0] = *fileCur + lda $1010-1 + sta SCREEN // } rts } diff --git a/src/test/ref/struct-ptr-26.asm b/src/test/ref/struct-ptr-26.asm index 155c3d8f8..24752b7c0 100644 --- a/src/test/ref/struct-ptr-26.asm +++ b/src/test/ref/struct-ptr-26.asm @@ -3,6 +3,7 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + .label print_screen = $400 .label print_char_cursor = 2 main: { .label file = $4000 @@ -34,9 +35,9 @@ print_uint: { .label w = 4 // print_uchar(>w) ldx.z w+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 jsr print_uchar // print_uchar($400 + sta.z screen+1 + jsr main + rts +} +// The program entry point +main: { + // *screen = 'a' + // Put 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // screen++; + inc.z screen + bne !+ + inc.z screen+1 + !: + // *screen = 'a' + // Put another 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // } + rts +} diff --git a/src/test/ref/test-comments-single.asm b/src/test/ref/test-comments-single.asm index a0b1094e9..f3c76b67f 100644 --- a/src/test/ref/test-comments-single.asm +++ b/src/test/ref/test-comments-single.asm @@ -3,6 +3,7 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + // One of the bytes used for addition // One of the bytes used for addition .const a = 'a' // The C64 screen diff --git a/src/test/ref/test-comparisons-sword.asm b/src/test/ref/test-comparisons-sword.asm index 8b217041c..843540cab 100644 --- a/src/test/ref/test-comparisons-sword.asm +++ b/src/test/ref/test-comparisons-sword.asm @@ -12,7 +12,8 @@ .const FF = $57 // filled circle .const TT = $51 - .label print_line_cursor = 6 + .label print_screen = $400 + .label print_line_cursor = $d .label print_char_cursor = 9 main: { .label w1 = $f @@ -23,15 +24,15 @@ main: { .label i = 2 // print_cls() jsr print_cls - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 lda #0 sta.z s - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -125,7 +126,7 @@ print_ln: { compare: { .label w1 = $b .label w2 = $11 - .label ops = $d + .label ops = 6 .label r = 8 // if(op==LT) cmp #LT @@ -396,9 +397,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp($d) str) +// print_str(byte* zp(6) str) print_str: { - .label str = $d + .label str = 6 __b1: // while(*str) ldy #0 @@ -430,7 +431,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $d lda #$400 + lda #>print_screen sta.z print_line_cursor+1 lda #0 sta.z s - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -121,7 +122,7 @@ print_ln: { compare: { .label w1 = 9 .label w2 = $11 - .label ops = $d + .label ops = 6 .label r = 8 // if(op==0) cmp #0 @@ -364,9 +365,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp($d) str) +// print_str(byte* zp(6) str) print_str: { - .label str = $d + .label str = 6 __b1: // while(*str) ldy #0 @@ -398,7 +399,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $d lda #$400 + lda #>print_screen sta.z print_line_cursor+1 lda #0 sta.z i - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #7 sta.z a @@ -507,11 +508,11 @@ print_ln: { // } rts } -// printu(byte register(X) a, byte* zp($a) op, byte zp(7) b, byte zp(4) res) +// printu(byte register(X) a, byte* zp(5) op, byte zp(7) b, byte zp(4) res) printu: { .label b = 7 .label res = 4 - .label op = $a + .label op = 5 // print_char(' ') lda #' ' jsr print_char @@ -570,9 +571,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp($a) str) +// print_str(byte* zp(5) str) print_str: { - .label str = $a + .label str = 5 __b1: // while(*str) ldy #0 @@ -604,7 +605,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $a lda #w) lda.z w+1 sta.z print_uchar.b @@ -183,9 +184,9 @@ print_uint: { rts } // Print a char as HEX -// print_uchar(byte zp(6) b) +// print_uchar(byte zp(4) b) print_uchar: { - .label b = 6 + .label b = 4 // b>>4 lda.z b lsr @@ -208,9 +209,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp(7) str) +// print_str(byte* zp(5) str) print_str: { - .label str = 7 + .label str = 5 __b1: // while(*str) ldy #0 @@ -237,10 +238,10 @@ print_str: { // Implemented using simple binary division // Follows the C99 standard by truncating toward zero on negative results. // See http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1124.pdf section 6.5.5 -// div16s(signed word zp($11) dividend, signed word zp($13) divisor) +// div16s(signed word zp(2) dividend, signed word zp($13) divisor) div16s: { .label return = $b - .label dividend = $11 + .label dividend = 2 .label divisor = $13 // divr16s(dividend, divisor, 0) lda.z dividend @@ -400,7 +401,7 @@ divr16u: { rts } test_8s: { - .label dividend = 6 + .label dividend = 4 .label divisor = $15 .label res = $16 .label i = $f @@ -469,9 +470,9 @@ test_8s: { divisors: .byte 5, 7, -$b, -$d, $11, $13 } // Print a signed char as HEX -// print_schar(signed byte zp(6) b) +// print_schar(signed byte zp(4) b) print_schar: { - .label b = 6 + .label b = 4 // if(b<0) lda.z b bmi __b1 @@ -635,7 +636,7 @@ divr8u: { rts } test_16u: { - .label dividend = $11 + .label dividend = 2 .label divisor = 9 .label res = $b .label i = $10 @@ -717,10 +718,10 @@ test_16u: { // Returns the quotient dividend/divisor. // The remainder will be set into the global variable rem16u // Implemented using simple binary division -// div16u(word zp($11) dividend, word zp(9) divisor) +// div16u(word zp(2) dividend, word zp(9) divisor) div16u: { .label return = $b - .label dividend = $11 + .label dividend = 2 .label divisor = 9 // divr16u(dividend, divisor, 0) lda.z dividend @@ -733,17 +734,17 @@ div16u: { rts } test_8u: { - .label dividend = 6 + .label dividend = 4 .label divisor = $17 .label res = $18 .label i = $15 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #0 sta.z i @@ -821,7 +822,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = $11 lda #$400 + lda #>print_screen sta.z print_char_cursor_1+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor_1+1 lda #<$12345678 sta.z dw @@ -245,9 +246,9 @@ print_char: { rts } // Print a unsigned int as HEX -// print_uint(word zp($c) w) +// print_uint(word zp($e) w) print_uint: { - .label w = $c + .label w = $e // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -258,9 +259,9 @@ print_uint: { rts } // Print a unsigned long as HEX -// print_ulong(dword zp($e) dw) +// print_ulong(dword zp($a) dw) print_ulong: { - .label dw = $e + .label dw = $a // print_uint(>dw) lda.z dw+2 sta.z print_uint.w @@ -292,9 +293,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = $c + .label dst = $10 lda #str diff --git a/src/test/ref/test-multiply-16bit.asm b/src/test/ref/test-multiply-16bit.asm index 3b9fda382..737347f43 100644 --- a/src/test/ref/test-multiply-16bit.asm +++ b/src/test/ref/test-multiply-16bit.asm @@ -3,8 +3,9 @@ :BasicUpstart(main) .pc = $80d "Program" .label BG_COLOR = $d021 - .label print_line_cursor = 2 - .label print_char_cursor = 8 + .label print_screen = $400 + .label print_char_cursor = $19 + .label print_line_cursor = $17 main: { // *BG_COLOR = 5 lda #5 @@ -22,12 +23,12 @@ main: { } // Perform many possible word multiplications (slow and fast) and compare the results mul16s_compare: { - .label a = $16 - .label b = $18 - .label ms = 4 - .label mn = $e - .label mf = $a - .label i = $1a + .label a = $12 + .label b = $14 + .label ms = 2 + .label mn = $a + .label mf = 6 + .label i = $16 lda.z print_line_cursor sta.z print_char_cursor lda.z print_line_cursor+1 @@ -175,9 +176,9 @@ print_ln: { rts } // Print a zero-terminated string -// print_str(byte* zp($22) str) +// print_str(byte* zp($20) str) print_str: { - .label str = $22 + .label str = $20 __b1: // while(*str) ldy #0 @@ -212,13 +213,13 @@ print_char: { // } rts } -// mul16s_error(signed word zp($16) a, signed word zp($18) b, signed dword zp(4) ms, signed dword zp($e) mn, signed dword zp($a) mf) +// mul16s_error(signed word zp($12) a, signed word zp($14) b, signed dword zp(2) ms, signed dword zp($a) mn, signed dword zp(6) mf) mul16s_error: { - .label a = $16 - .label b = $18 - .label ms = 4 - .label mn = $e - .label mf = $a + .label a = $12 + .label b = $14 + .label ms = 2 + .label mn = $a + .label mf = 6 // print_str("signed word multiply mismatch ") lda #dw) lda.z dw+2 sta.z print_uint.w @@ -345,9 +346,9 @@ print_ulong: { rts } // Print a unsigned int as HEX -// print_uint(word zp($16) w) +// print_uint(word zp($12) w) print_uint: { - .label w = $16 + .label w = $12 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -381,9 +382,9 @@ print_uchar: { rts } // Print a signed int as HEX -// print_sint(signed word zp($16) w) +// print_sint(signed word zp($12) w) print_sint: { - .label w = $16 + .label w = $12 // if(w<0) lda.z w+1 bmi __b1 @@ -411,16 +412,16 @@ print_sint: { } // Fast multiply two signed ints to a signed double unsigned int result // Fixes offsets introduced by using unsigned multiplication -// mulf16s(signed word zp($16) a, signed word zp($18) b) +// mulf16s(signed word zp($12) a, signed word zp($14) b) mulf16s: { .label __6 = $1c .label __9 = $1e .label __11 = $1c .label __12 = $1e - .label m = $a - .label return = $a - .label a = $16 - .label b = $18 + .label m = 6 + .label return = 6 + .label a = $12 + .label b = $14 // mulf16u((unsigned int)a, (unsigned int)b) lda.z a sta.z mulf16u.a @@ -486,7 +487,7 @@ mulf16u: { .label memA = $f8 .label memB = $fa .label memR = $fc - .label return = $a + .label return = 6 .label a = $1c .label b = $1e // *memA = a @@ -606,16 +607,16 @@ mulf16u: { } // Multiply of two signed ints to a signed long // Fixes offsets introduced by using unsigned multiplication -// mul16s(signed word zp($16) a, signed word zp($18) b) +// mul16s(signed word zp($12) a, signed word zp($14) b) mul16s: { - .label __6 = $20 - .label __9 = $22 - .label __11 = $20 - .label __12 = $22 - .label m = $e - .label return = $e - .label a = $16 - .label b = $18 + .label __6 = $1e + .label __9 = $20 + .label __11 = $1e + .label __12 = $20 + .label m = $a + .label return = $a + .label a = $12 + .label b = $14 // mul16u((unsigned int)a, (unsigned int) b) lda.z a sta.z mul16u.a @@ -675,13 +676,13 @@ mul16s: { rts } // Perform binary multiplication of two unsigned 16-bit unsigned ints into a 32-bit unsigned long -// mul16u(word zp($22) a, word zp($1e) b) +// mul16u(word zp($20) a, word zp($1e) b) mul16u: { - .label mb = $12 - .label a = $22 - .label res = $e + .label mb = $e + .label a = $20 + .label res = $a .label b = $1e - .label return = $e + .label return = $a // mb = b lda.z b sta.z mb @@ -738,14 +739,14 @@ mul16u: { } // Slow multiplication of signed words // Perform a signed multiplication by repeated addition/subtraction -// muls16s(signed word zp($16) a, signed word zp($18) b) +// muls16s(signed word zp($12) a, signed word zp($14) b) muls16s: { - .label m = 4 + .label m = 2 .label j = $1c - .label return = 4 + .label return = 2 .label i = $1e - .label a = $16 - .label b = $18 + .label a = $12 + .label b = $14 // if(a<0) lda.z a+1 bmi __b8 @@ -864,19 +865,19 @@ muls16s: { mul16u_compare: { .label a = $1c .label b = $1e - .label ms = 4 - .label mn = $e - .label mf = $a - .label i = $1a + .label ms = 2 + .label mn = $a + .label mf = 6 + .label i = $16 lda #0 sta.z i sta.z b sta.z b+1 sta.z a sta.z a+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 __b1: // print_str(".") @@ -980,9 +981,9 @@ mul16u_compare: { jmp __b1 !__b1: // print_ln() - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda.z print_line_cursor @@ -1001,13 +1002,13 @@ mul16u_compare: { str1: .text "word multiply results match!" .byte 0 } -// mul16u_error(word zp($16) a, word zp($1e) b, dword zp(4) ms, dword zp($e) mn, dword zp($a) mf) +// mul16u_error(word zp($12) a, word zp($1e) b, dword zp(2) ms, dword zp($a) mn, dword zp(6) mf) mul16u_error: { - .label a = $16 + .label a = $12 .label b = $1e - .label ms = 4 - .label mn = $e - .label mf = $a + .label ms = 2 + .label mn = $a + .label mf = 6 // print_str("multiply mismatch ") lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln // } @@ -1083,9 +1084,9 @@ mul16u_error: { // Calculate an unsigned multiplication by repeated addition // muls16u(word zp($1c) a, word zp($1e) b) muls16u: { - .label return = 4 - .label m = 4 - .label i = $16 + .label return = 2 + .label m = 2 + .label i = $12 .label a = $1c .label b = $1e // if(a!=0) @@ -1148,15 +1149,20 @@ muls16u: { // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) mulf_init: { // x/2 - .label c = $1a + // x/2 + .label c = $16 // Counter used for determining x%2==0 - .label sqr1_hi = $22 + // Counter used for determining x%2==0 + .label sqr1_hi = $17 // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 - .label sqr = $20 - .label sqr1_lo = $18 + // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 + .label sqr = $1c + .label sqr1_lo = $14 // Decrease or increase x_255 - initially we decrease - .label sqr2_hi = $1e - .label sqr2_lo = $1c + // Decrease or increase x_255 - initially we decrease + .label sqr2_hi = $20 + .label sqr2_lo = $19 + //Start with g(0)=f(255) //Start with g(0)=f(255) .label dir = $1b ldx #0 @@ -1295,9 +1301,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = $22 + .label dst = $20 lda #str diff --git a/src/test/ref/test-multiply-8bit.asm b/src/test/ref/test-multiply-8bit.asm index 2043cb3d3..29830278e 100644 --- a/src/test/ref/test-multiply-8bit.asm +++ b/src/test/ref/test-multiply-8bit.asm @@ -3,8 +3,9 @@ :BasicUpstart(main) .pc = $80d "Program" .label BG_COLOR = $d021 - .label print_line_cursor = 2 - .label print_char_cursor = 4 + .label print_screen = $400 + .label print_char_cursor = 7 + .label print_line_cursor = 3 main: { // *BG_COLOR = 5 lda #5 @@ -26,11 +27,11 @@ main: { } // Perform all possible signed byte multiplications (slow and fast) and compare the results mul8s_compare: { - .label ms = 7 - .label mf = 9 - .label mn = $e + .label ms = 5 + .label mf = $b + .label mn = 9 .label a = $d - .label b = 6 + .label b = 2 lda #-$80 sta.z a __b1: @@ -118,12 +119,12 @@ mul8s_compare: { str: .text "signed multiply results match!" .byte 0 } -// mul8s_error(signed byte register(X) a, signed byte zp(6) b, signed word zp(7) ms, signed word zp($e) mn, signed word zp(9) mf) +// mul8s_error(signed byte register(X) a, signed byte zp(2) b, signed word zp(5) ms, signed word zp(9) mn, signed word zp($b) mf) mul8s_error: { - .label b = 6 - .label ms = 7 - .label mn = $e - .label mf = 9 + .label b = 2 + .label ms = 5 + .label mn = 9 + .label mf = $b lda.z print_line_cursor sta.z print_char_cursor lda.z print_line_cursor+1 @@ -208,9 +209,9 @@ print_ln: { rts } // Print a signed int as HEX -// print_sint(signed word zp(7) w) +// print_sint(signed word zp(5) w) print_sint: { - .label w = 7 + .label w = 5 // if(w<0) lda.z w+1 bmi __b1 @@ -251,9 +252,9 @@ print_char: { rts } // Print a unsigned int as HEX -// print_uint(word zp(7) w) +// print_uint(word zp(5) w) print_uint: { - .label w = 7 + .label w = 5 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -287,9 +288,9 @@ print_uchar: { rts } // Print a zero-terminated string -// print_str(byte* zp($b) str) +// print_str(byte* zp($e) str) print_str: { - .label str = $b + .label str = $e __b1: // while(*str) ldy #0 @@ -340,7 +341,7 @@ print_schar: { // Fixes offsets introduced by using unsigned multiplication // mul8s(signed byte zp($d) a, signed byte register(Y) b) mul8s: { - .label m = $e + .label m = 9 .label a = $d // mul8u((char)a, (char) b) ldx.z a @@ -376,9 +377,9 @@ mul8s: { // Perform binary multiplication of two unsigned 8-bit chars into a 16-bit unsigned int // mul8u(byte register(X) a, byte register(A) b) mul8u: { - .label mb = $b - .label res = $e - .label return = $e + .label mb = $e + .label res = 9 + .label return = 9 // mb = b sta.z mb lda #0 @@ -419,7 +420,7 @@ mul8u: { // Fast multiply two signed chars to a unsigned int result // mulf8s(signed byte register(A) a, signed byte register(X) b) mulf8s: { - .label return = 9 + .label return = $b // mulf8u_prepare((char)a) jsr mulf8u_prepare // mulf8s_prepared(b) @@ -430,11 +431,11 @@ mulf8s: { } // Calculate fast multiply with a prepared unsigned char to a unsigned int result // The prepared number is set by calling mulf8s_prepare(char a) -// mulf8s_prepared(signed byte zp($12) b) +// mulf8s_prepared(signed byte zp($10) b) mulf8s_prepared: { .label memA = $fd - .label m = 9 - .label b = $12 + .label m = $b + .label b = $10 // mulf8u_prepared((char) b) lda.z b jsr mulf8u_prepared @@ -471,7 +472,7 @@ mulf8s_prepared: { mulf8u_prepared: { .label resL = $fe .label memB = $ff - .label return = 9 + .label return = $b // *memB = b sta memB // asm @@ -514,8 +515,8 @@ mulf8u_prepare: { // Perform a signed multiplication by repeated addition/subtraction // muls8s(signed byte zp($d) a, signed byte register(X) b) muls8s: { - .label m = 7 - .label return = 7 + .label m = 5 + .label return = 5 .label a = $d // if(a<0) lda.z a @@ -589,10 +590,10 @@ muls8s: { } // Perform all possible byte multiplications (slow and fast) and compare the results mul8u_compare: { - .label ms = 7 - .label mf = 9 - .label mn = $e - .label b = 6 + .label ms = 5 + .label mf = $b + .label mn = 9 + .label b = 2 .label a = $d lda #0 sta.z a @@ -672,12 +673,12 @@ mul8u_compare: { str: .text "multiply results match!" .byte 0 } -// mul8u_error(byte register(X) a, byte zp(6) b, word zp(7) ms, word zp($e) mn, word zp(9) mf) +// mul8u_error(byte register(X) a, byte zp(2) b, word zp(5) ms, word zp(9) mn, word zp($b) mf) mul8u_error: { - .label b = 6 - .label ms = 7 - .label mn = $e - .label mf = 9 + .label b = 2 + .label ms = 5 + .label mn = 9 + .label mf = $b // print_str("multiply mismatch ") lda #mula_sqr1_lo @@ -810,9 +811,9 @@ mulf_tables_cmp: { bcc __b2 !: // print_str("multiply tables match!") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 jsr print_ln lda.z print_line_cursor @@ -841,9 +842,9 @@ mulf_tables_cmp: { lda #2 sta BG_COLOR // print_str("multiply table mismatch at ") - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #$400 + lda #>print_screen sta.z print_line_cursor+1 rts __b4: @@ -891,6 +892,7 @@ mulf_tables_cmp: { // Initialize the multiplication tables using ASM code from // http://codebase64.org/doku.php?id=base:seriously_fast_multiplication mulf_init_asm: { + // Ensure the ASM tables are not detected as unused by the optimizer // Ensure the ASM tables are not detected as unused by the optimizer .label mem = $ff // asm @@ -950,15 +952,20 @@ mulf_init_asm: { // Initialize the mulf_sqr multiplication tables with f(x)=int(x*x/4) mulf_init: { // x/2 - .label c = $12 + // x/2 + .label c = $10 // Counter used for determining x%2==0 - .label sqr1_hi = 9 + // Counter used for determining x%2==0 + .label sqr1_hi = 7 + // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 // Fill mulf_sqr1 = f(x) = int(x*x/4): If f(x) = x*x/4 then f(x+1) = f(x) + x/2 + 1/4 .label sqr = $e - .label sqr1_lo = 7 + .label sqr1_lo = 5 + // Decrease or increase x_255 - initially we decrease // Decrease or increase x_255 - initially we decrease .label sqr2_hi = $b - .label sqr2_lo = $10 + .label sqr2_lo = 9 + //Start with g(0)=f(255) //Start with g(0)=f(255) .label dir = $d ldx #0 @@ -1097,9 +1104,9 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num - .label dst = $10 + .label dst = $e lda #str diff --git a/src/test/ref/test-signed-word-minus-byte.asm b/src/test/ref/test-signed-word-minus-byte.asm index 2464e41b2..24ab36768 100644 --- a/src/test/ref/test-signed-word-minus-byte.asm +++ b/src/test/ref/test-signed-word-minus-byte.asm @@ -2,7 +2,8 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" - .label print_line_cursor = 5 + .label print_screen = $400 + .label print_line_cursor = 9 .label print_char_cursor = 7 main: { .label w2 = $b @@ -12,13 +13,13 @@ main: { jsr print_cls lda #0 sta.z i - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<$4d2 sta.z w1 @@ -96,9 +97,9 @@ print_ln: { rts } // Print a signed int as HEX -// print_sint(signed word zp(9) w) +// print_sint(signed word zp(5) w) print_sint: { - .label w = 9 + .label w = 5 // if(w<0) lda.z w+1 bmi __b1 @@ -139,9 +140,9 @@ print_char: { rts } // Print a unsigned int as HEX -// print_uint(word zp(9) w) +// print_uint(word zp(5) w) print_uint: { - .label w = 9 + .label w = 5 // print_uchar(>w) ldx.z w+1 jsr print_uchar @@ -185,7 +186,7 @@ print_cls: { memset: { .const c = ' ' .const num = $3e8 - .label str = $400 + .label str = print_screen .label end = str+num .label dst = 9 lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = 6 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = 8 +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { // tod_init(TOD_ZERO) lda TOD_ZERO @@ -300,10 +301,10 @@ memcpy: { jmp __b1 } // Convert time of day to a human-readable string "hh:mm:ss:10" -// tod_str(byte zp($d) tod_TENTHS, byte zp($12) tod_SEC, byte register(Y) tod_MIN, byte register(X) tod_HOURS) +// tod_str(byte zp($12) tod_TENTHS, byte zp($d) tod_SEC, byte register(Y) tod_MIN, byte register(X) tod_HOURS) tod_str: { - .label tod_TENTHS = $d - .label tod_SEC = $12 + .label tod_TENTHS = $12 + .label tod_SEC = $d // tod.HOURS>>4 txa lsr @@ -425,10 +426,10 @@ gotoxy: { } // Initialize time-of-day clock // This uses the MOS6526 CIA#1 -// tod_init(byte zp($c) tod_TENTHS, byte zp($d) tod_SEC, byte register(X) tod_MIN, byte register(Y) tod_HOURS) +// tod_init(byte zp($a) tod_TENTHS, byte zp($b) tod_SEC, byte register(X) tod_MIN, byte register(Y) tod_HOURS) tod_init: { - .label tod_TENTHS = $c - .label tod_SEC = $d + .label tod_TENTHS = $a + .label tod_SEC = $b // CIA1->TIMER_A_CONTROL |= 0x80 // Set 50hz (this assumes PAL!) (bit7=1) lda #$80 diff --git a/src/test/ref/toupper-1.asm b/src/test/ref/toupper-1.asm index 8eb863af7..3ab64e71a 100644 --- a/src/test/ref/toupper-1.asm +++ b/src/test/ref/toupper-1.asm @@ -1,39 +1,40 @@ // Test toupper() .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .const LIGHT_BLUE = $e // Color Ram .label COLORRAM = $d800 // Default address of screen character matrix .label DEFAULT_SCREEN = $400 - .label conio_cursor_x = 6 - .label conio_cursor_y = 7 - .label conio_line_text = 8 - .label conio_line_color = $a -__bbegin: - // conio_cursor_x = 0 // The number of bytes on the screen // The current cursor x-position - lda #0 - sta.z conio_cursor_x - // conio_cursor_y = 0 + .label conio_cursor_x = 6 // The current cursor y-position - sta.z conio_cursor_y - // conio_line_text = CONIO_SCREEN_TEXT + .label conio_cursor_y = 7 // The current text cursor line start - lda #DEFAULT_SCREEN - sta.z conio_line_text+1 - // conio_line_color = CONIO_SCREEN_COLORS + .label conio_line_text = 8 // The current color cursor line start - lda #COLORRAM - sta.z conio_line_color+1 - jsr main - rts + .label conio_line_color = $a +_start: { + // conio_cursor_x = 0 + lda #0 + sta.z conio_cursor_x + // conio_cursor_y = 0 + sta.z conio_cursor_y + // conio_line_text = CONIO_SCREEN_TEXT + lda #DEFAULT_SCREEN + sta.z conio_line_text+1 + // conio_line_color = CONIO_SCREEN_COLORS + lda #COLORRAM + sta.z conio_line_color+1 + jsr main + rts +} main: { .label c = 2 .label c1 = 3 diff --git a/src/test/ref/travis1.asm b/src/test/ref/travis1.asm index 07359a731..5dbfdc608 100644 --- a/src/test/ref/travis1.asm +++ b/src/test/ref/travis1.asm @@ -3,6 +3,7 @@ :BasicUpstart(main) .pc = $80d "Program" .const READY_FRAMES = 5 + .label print_screen = $400 .label print_char_cursor = 7 .label print_line_cursor = 5 main: { @@ -10,13 +11,13 @@ main: { lda #0 sta.z i tax - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 __b1: // game_ready() diff --git a/src/test/ref/true-inline-words.asm b/src/test/ref/true-inline-words.asm index 4ee6fe3cb..c7628b557 100644 --- a/src/test/ref/true-inline-words.asm +++ b/src/test/ref/true-inline-words.asm @@ -2,14 +2,19 @@ :BasicUpstart(main) .pc = $80d "Program" main: { + // constant byte array // constant byte array .const b = 4 + // constant byte .const w = b*$100 + // constant inline word .const w2 = 1*$100+1+w // Test the result + // Test the result .label pos = $501 .label BG_COLOR = $d021 // constant inline words inside expression + // constant inline words inside expression .label sc = w2 // *sc = bs[1] // implicit cast to (byte*) diff --git a/src/test/ref/type-signed.asm b/src/test/ref/type-signed.asm index 500fea49f..ef25020cc 100644 --- a/src/test/ref/type-signed.asm +++ b/src/test/ref/type-signed.asm @@ -2,6 +2,7 @@ .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" + .label print_screen = $400 .label print_line_cursor = 7 .label print_char_cursor = $b main: { @@ -10,13 +11,13 @@ main: { .label i = 6 lda #0 sta.z i - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_line_cursor+1 - lda #<$400 + lda #$400 + lda #>print_screen sta.z print_char_cursor+1 lda #<$1024 sta.z b diff --git a/src/test/ref/typedef-2.asm b/src/test/ref/typedef-2.asm index 1e432eba2..2ef0c73f2 100644 --- a/src/test/ref/typedef-2.asm +++ b/src/test/ref/typedef-2.asm @@ -1,16 +1,17 @@ .pc = $801 "Basic" -:BasicUpstart(__bbegin) +:BasicUpstart(_start) .pc = $80d "Program" .label SCREEN = $400 .label ptr = 2 -__bbegin: - // ptr = 0x1000 - lda #<$1000 - sta.z ptr - lda #>$1000 - sta.z ptr+1 - jsr main - rts +_start: { + // ptr = 0x1000 + lda #<$1000 + sta.z ptr + lda #>$1000 + sta.z ptr+1 + jsr main + rts +} main: { // SCREEN[0] =