From 77c15f80aa9a69074ec4c38663b78eb270580920 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 20 Sep 2020 22:32:42 +0200 Subject: [PATCH] Added a working memory block remapping (MAP instruction) test. --- .../cache/fragment-cache-csg65ce02.asm | 2 +- .../cache/fragment-cache-mega45gs02.asm | 1743 ++++++------- .../fragment/cache/fragment-cache-mos6502.asm | 2 +- .../cache/fragment-cache-mos6502x.asm | 2 +- .../cache/fragment-cache-wdc65c02.asm | 2 +- .../dk/camelot64/kickc/test/TestPrograms.java | 5 + src/test/kc/.vscode/tasks.json | 1 - src/test/kc/examples/mega65/memorymap-test.c | 146 +- .../ref/examples/mega65/memorymap-test.asm | 190 ++ .../ref/examples/mega65/memorymap-test.cfg | 63 + .../ref/examples/mega65/memorymap-test.log | 2275 +++++++++++++++++ .../ref/examples/mega65/memorymap-test.sym | 346 +++ src/test/ref/examples/mega65/raster65.asm | 9 +- src/test/ref/examples/mega65/raster65.log | 29 +- src/test/ref/examples/mega65/test-vic4.asm | 3 + src/test/ref/examples/mega65/test-vic4.log | 9 + 16 files changed, 3742 insertions(+), 1085 deletions(-) create mode 100644 src/test/ref/examples/mega65/memorymap-test.asm create mode 100644 src/test/ref/examples/mega65/memorymap-test.cfg create mode 100644 src/test/ref/examples/mega65/memorymap-test.log create mode 100644 src/test/ref/examples/mega65/memorymap-test.sym diff --git a/src/main/fragment/cache/fragment-cache-csg65ce02.asm b/src/main/fragment/cache/fragment-cache-csg65ce02.asm index b38989b40..2e5bfa842 100644 --- a/src/main/fragment/cache/fragment-cache-csg65ce02.asm +++ b/src/main/fragment/cache/fragment-cache-csg65ce02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c +//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-mega45gs02.asm b/src/main/fragment/cache/fragment-cache-mega45gs02.asm index 66d3c6848..c15818df6 100644 --- a/src/main/fragment/cache/fragment-cache-mega45gs02.asm +++ b/src/main/fragment/cache/fragment-cache-mega45gs02.asm @@ -1,4 +1,12 @@ -//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c +//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd +//FRAGMENT vbuz1=vbuc1 +lda #{c1} +sta {z1} +//FRAGMENT pbuz1=pbuc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 //FRAGMENT _deref_pbuc1=vbuc2 lda #{c2} sta {c1} @@ -6,63 +14,12 @@ sta {c1} lda #{c2} ora {c1} sta {c1} -//FRAGMENT pbuz1=pbuc1 -lda #<{c1} -sta {z1} -lda #>{c1} -sta {z1}+1 -//FRAGMENT pbuz1_lt_pbuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bcc {la1} -bne !+ -lda {z1} -cmp #<{c1} -bcc {la1} -!: -//FRAGMENT vbuz1=_lo_pbuz2 -lda {z2} -sta {z1} -//FRAGMENT _deref_pbuz1=vbuz2 -lda {z2} -ldy #0 -sta ({z1}),y -//FRAGMENT pbuz1=_inc_pbuz1 -inw {z1} -//FRAGMENT _deref_pbuz1=vbuc1 -lda #{c1} -ldy #0 -sta ({z1}),y -//FRAGMENT vbuaa=_lo_pbuz1 -lda {z1} -//FRAGMENT vbuxx=_lo_pbuz1 -ldx {z1} -//FRAGMENT _deref_pbuz1=vbuaa -ldy #0 -sta ({z1}),y -//FRAGMENT _deref_pbuz1=vbuxx -txa -ldy #0 -sta ({z1}),y -//FRAGMENT _deref_pbuz1=vbuyy -tya -ldy #0 -sta ({z1}),y -//FRAGMENT _deref_pbuz1=vbuzz -tza -ldy #0 -sta ({z1}),y -//FRAGMENT vbuyy=_lo_pbuz1 -ldy {z1} -//FRAGMENT vbuzz=_lo_pbuz1 -ldz {z1} -//FRAGMENT vbuz1=vbuc1 -lda #{c1} -sta {z1} //FRAGMENT vbuz1=_deref_pbuz2 ldy #0 lda ({z2}),y sta {z1} +//FRAGMENT pbuz1=_inc_pbuz1 +inw {z1} //FRAGMENT vbuc1_neq_vbuz1_then_la1 lda #{c1} cmp {z1} @@ -144,6 +101,10 @@ sta {z1} lda #0 adc {z2}+1 sta {z1}+1 +//FRAGMENT _deref_pbuz1=vbuz2 +lda {z2} +ldy #0 +sta ({z1}),y //FRAGMENT vbuaa=_deref_pbuz1 ldy #0 lda ({z1}),y @@ -174,6 +135,18 @@ sta ({z1}),y txa ldz {z2} sta ({z1}),z +//FRAGMENT _deref_pbuz1=vbuxx +txa +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=vbuyy +tya +ldy #0 +sta ({z1}),y +//FRAGMENT _deref_pbuz1=vbuzz +tza +ldy #0 +sta ({z1}),y //FRAGMENT vbuxx=vbuc1 ldx #{c1} //FRAGMENT vbuzz=vbuc1 @@ -218,126 +191,52 @@ cpz #{c1} bne {la1} //FRAGMENT vbuaa=vbuzz tza -//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1 -lda #{c1} -ldy {z1} -cmp {c2},y -bne {la1} -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 -ldy {z1} -lda {c2},y -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuz1 -ldy {z1} -tya -sta {c1},y -//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuaa_then_la1 -tay -lda #{c1} -cmp {c2},y -bne {la1} -//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 -lda {c2},x -cmp #{c1} -bne {la1} -//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuyy_then_la1 -lda #{c1} -cmp {c2},y -bne {la1} -//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuzz_then_la1 -tza -tay -lda #{c1} -cmp {c2},y -bne {la1} -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx -lda {c2},x -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy -lda {c2},y -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuzz -tza -tay -lda {c2},y -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuxx -txa -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuyy -tya -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuzz -tza -tax -sta {c1},x -//FRAGMENT vbuxx=_inc_vbuxx -inx -//FRAGMENT vbuyy=vbuc1 -ldy #{c1} -//FRAGMENT vbuyy=_inc_vbuyy -iny -//FRAGMENT vbuzz=_inc_vbuzz -inz -//FRAGMENT vduz1=vduc1 +//FRAGMENT vwuz1=vbuc1 lda #<{c1} sta {z1} lda #>{c1} sta {z1}+1 -lda #<{c1}>>$10 -sta {z1}+2 -lda #>{c1}>>$10 -sta {z1}+3 -//FRAGMENT vbuz1_lt_vbuc1_then_la1 -lda {z1} -cmp #{c1} -bcc {la1} -//FRAGMENT _deref_pduc1=vduz1 -ldq {z1} -stq {c1} -//FRAGMENT vduz1=vduz1_plus_vduz2 -clc -ldq {z1} -adcq {z2} -stq {z1} -//FRAGMENT vduz1=vduz1_plus_vbuz2 -lda {z2} -clc -adc {z1} +//FRAGMENT _deref_pbuc1=_deref_pbuc2 +lda {c2} +sta {c1} +//FRAGMENT vwuz1=vwuc1_minus_vbuz2 +sec +lda #<{c1} +sbc {z2} sta {z1} -lda {z1}+1 -adc #0 +lda #>{c1} +sbc #0 sta {z1}+1 -lda {z1}+2 -adc #0 -sta {z1}+2 -lda {z1}+3 -adc #0 -sta {z1}+3 -//FRAGMENT vbuaa_lt_vbuc1_then_la1 -cmp #{c1} -bcc {la1} -//FRAGMENT vduz1=vwuc1 -NO_SYNTHESIS -//FRAGMENT vduz1=vwsc1 -NO_SYNTHESIS -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_ror_1 -ldy {z2} -lda {c1},y +//FRAGMENT vbuz1=vbuz2_ror_5 +lda {z2} +lsr +lsr +lsr +lsr lsr sta {z1} -//FRAGMENT vbuz1=vbuz2_band_vbuc1 +//FRAGMENT vbuz1=vbuc1_rol_vbuz2 lda #{c1} -and {z2} -sta {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuz2 -lda {z2} -ldy {z1} -sta {c1},y -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2 ldy {z2} -lda {c1},y +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: sta {z1} +//FRAGMENT vwuz1=vwuz2 +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 +//FRAGMENT vbuz1=_lo_vwuz2 +lda {z2} +sta {z1} +//FRAGMENT _deref_pbuc1=vbuz1 +lda {z1} +sta {c1} //FRAGMENT vbuz1=vbuz2_rol_4 lda {z2} asl @@ -345,293 +244,466 @@ asl asl asl sta {z1} -//FRAGMENT vbuz1=vbuz1_plus_vbuc1 +//FRAGMENT vbuz1=_hi_vwuz2 +lda {z2}+1 +sta {z1} +//FRAGMENT vbuz1=vbuz2_band_vbuc1 lda #{c1} -clc -adc {z1} +and {z2} sta {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=vbuc2 -lda #{c2} -ldy {z1} -sta {c1},y -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_ror_2 -ldy {z2} -lda {c1},y -lsr -lsr -sta {z1} -//FRAGMENT vbuz1=vbuz2_ror_1 +//FRAGMENT vbuz1=vbuz2_bor_vbuz3 lda {z2} -lsr +ora {z3} sta {z1} -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz2 -ldy {z2} -lda {c2},y -ldy {z1} -sta {c1},y -//FRAGMENT _deref_pbuc1=vbuz1 -lda {z1} -sta {c1} -//FRAGMENT vbuz1=vbuz2_plus_1 -lda {z2} -inc +//FRAGMENT vwuz1=vwuc1_minus_vbuaa +tax +stx $ff +lda #<{c1} +sec +sbc $ff sta {z1} -//FRAGMENT vbuz1_neq_0_then_la1 -lda {z1} -cmp #0 -bne {la1} -//FRAGMENT vbuz1=_deref_pbuc1 -lda {c1} +lda #>{c1} +sbc #00 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_minus_vbuxx +stx $ff +lda #<{c1} +sec +sbc $ff sta {z1} -//FRAGMENT vbuz1_eq__deref_pbuc1_then_la1 -lda {c1} -cmp {z1} -beq {la1} -//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuz1 -ldy {z1} -lda {c2},y -sta {c1} -//FRAGMENT _deref_pbuc1=_deref_pbuc1_band_vbuc2 -lda #{c2} -and {c1} -sta {c1} -//FRAGMENT _deref_qprc1=pprc2 -lda #<{c2} -sta {c1} -lda #>{c2} -sta {c1}+1 -//FRAGMENT pbuz1_neq_pbuc1_then_la1 -lda {z1}+1 -cmp #>{c1} -bne {la1} -lda {z1} -cmp #<{c1} -bne {la1} -//FRAGMENT vbuaa_neq_vbuc1_then_la1 -cmp #{c1} -bne {la1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_ror_1 -tay -lda {c1},y -lsr +lda #>{c1} +sbc #00 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_minus_vbuyy +tya +tax +stx $ff +lda #<{c1} +sec +sbc $ff sta {z1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_ror_1 -lda {c1},x -lsr -sta {z1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_ror_1 -lda {c1},y -lsr -sta {z1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz_ror_1 +lda #>{c1} +sbc #00 +sta {z1}+1 +//FRAGMENT vwuz1=vwuc1_minus_vbuzz tza -tay -lda {c1},y +tax +stx $ff +lda #<{c1} +sec +sbc $ff +sta {z1} +lda #>{c1} +sbc #00 +sta {z1}+1 +//FRAGMENT vbuz1=vbuxx_ror_5 +txa +lsr +lsr +lsr +lsr lsr sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_ror_1 -ldy {z1} -lda {c1},y +//FRAGMENT vbuz1=vbuyy_ror_5 +tya lsr -//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_ror_1 -tay -lda {c1},y lsr -//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_ror_1 -lda {c1},x lsr -//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_ror_1 -lda {c1},y lsr -//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz_ror_1 +lsr +sta {z1} +//FRAGMENT vbuz1=vbuzz_ror_5 tza -tay -lda {c1},y lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_ror_1 +lsr +lsr +lsr +lsr +sta {z1} +//FRAGMENT vbuaa=vbuz1_ror_5 +lda {z1} +lsr +lsr +lsr +lsr +lsr +//FRAGMENT vbuaa=vbuxx_ror_5 +txa +lsr +lsr +lsr +lsr +lsr +//FRAGMENT vbuaa=vbuyy_ror_5 +tya +lsr +lsr +lsr +lsr +lsr +//FRAGMENT vbuaa=vbuzz_ror_5 +tza +lsr +lsr +lsr +lsr +lsr +//FRAGMENT vbuxx=vbuz1_ror_5 +lda {z1} +lsr +lsr +lsr +lsr +lsr +tax +//FRAGMENT vbuxx=vbuxx_ror_5 +txa +lsr +lsr +lsr +lsr +lsr +tax +//FRAGMENT vbuxx=vbuyy_ror_5 +tya +lsr +lsr +lsr +lsr +lsr +tax +//FRAGMENT vbuxx=vbuzz_ror_5 +tza +lsr +lsr +lsr +lsr +lsr +tax +//FRAGMENT vbuyy=vbuz1_ror_5 +lda {z1} +lsr +lsr +lsr +lsr +lsr +tay +//FRAGMENT vbuyy=vbuxx_ror_5 +txa +lsr +lsr +lsr +lsr +lsr +tay +//FRAGMENT vbuyy=vbuyy_ror_5 +tya +lsr +lsr +lsr +lsr +lsr +tay +//FRAGMENT vbuyy=vbuzz_ror_5 +tza +lsr +lsr +lsr +lsr +lsr +tay +//FRAGMENT vbuzz=vbuz1_ror_5 +lda {z1} +lsr +lsr +lsr +lsr +lsr +taz +//FRAGMENT vbuzz=vbuxx_ror_5 +txa +lsr +lsr +lsr +lsr +lsr +taz +//FRAGMENT vbuzz=vbuyy_ror_5 +tya +lsr +lsr +lsr +lsr +lsr +taz +//FRAGMENT vbuzz=vbuzz_ror_5 +tza +lsr +lsr +lsr +lsr +lsr +taz +//FRAGMENT vbuaa=vbuc1_rol_vbuz1 +lda #{c1} +ldy {z1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_vbuz1 +lda #{c1} ldx {z1} -lda {c1},x -lsr +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: tax -//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_ror_1 -tax -lda {c1},x -lsr -tax -//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_ror_1 -lda {c1},x -lsr -tax -//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_ror_1 -lda {c1},y -lsr -tax -//FRAGMENT vbuxx=pbuc1_derefidx_vbuzz_ror_1 -tza -tax -lda {c1},x -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_ror_1 +//FRAGMENT vbuyy=vbuc1_rol_vbuz1 +lda #{c1} ldy {z1} -lda {c1},y -lsr +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: tay -//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_ror_1 -tay -lda {c1},y -lsr -tay -//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_ror_1 -lda {c1},x -lsr -tay -//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_ror_1 -lda {c1},y -lsr -tay -//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz_ror_1 -tza -tay -lda {c1},y -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1_ror_1 +//FRAGMENT vbuzz=vbuc1_rol_vbuz1 +lda #{c1} ldy {z1} -lda {c1},y -lsr +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: taz -//FRAGMENT vbuzz=pbuc1_derefidx_vbuaa_ror_1 +//FRAGMENT vbuz1=vbuc1_rol_vbuaa tay -lda {c1},y -lsr -taz -//FRAGMENT vbuzz=pbuc1_derefidx_vbuxx_ror_1 -lda {c1},x -lsr -taz -//FRAGMENT vbuzz=pbuc1_derefidx_vbuyy_ror_1 -lda {c1},y -lsr -taz -//FRAGMENT vbuzz=pbuc1_derefidx_vbuzz_ror_1 -tza -tay -lda {c1},y -lsr -taz -//FRAGMENT vbuaa=vbuz1_band_vbuc1 lda #{c1} -and {z1} -//FRAGMENT vbuxx=vbuz1_band_vbuc1 +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +sta {z1} +//FRAGMENT vbuaa=vbuc1_rol_vbuaa +tay lda #{c1} -and {z1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_vbuaa tax -//FRAGMENT vbuyy=vbuz1_band_vbuc1 lda #{c1} -and {z1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: +tax +//FRAGMENT vbuyy=vbuc1_rol_vbuaa tay -//FRAGMENT vbuzz=vbuz1_band_vbuc1 lda #{c1} -and {z1} -taz -//FRAGMENT vbuz1=vbuaa_band_vbuc1 -and #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuaa_band_vbuc1 -and #{c1} -//FRAGMENT vbuxx=vbuaa_band_vbuc1 -and #{c1} -tax -//FRAGMENT vbuyy=vbuaa_band_vbuc1 -and #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: tay -//FRAGMENT vbuzz=vbuaa_band_vbuc1 -and #{c1} -taz -//FRAGMENT vbuz1=vbuxx_band_vbuc1 -txa -and #{c1} -sta {z1} -//FRAGMENT vbuaa=vbuxx_band_vbuc1 -txa -and #{c1} -//FRAGMENT vbuxx=vbuxx_band_vbuc1 -txa -and #{c1} -tax -//FRAGMENT vbuyy=vbuxx_band_vbuc1 -txa -and #{c1} +//FRAGMENT vbuzz=vbuc1_rol_vbuaa tay -//FRAGMENT vbuzz=vbuxx_band_vbuc1 -txa -and #{c1} +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: taz -//FRAGMENT vbuz1=vbuyy_band_vbuc1 -tya -and #{c1} +//FRAGMENT vbuz1=vbuc1_rol_vbuxx +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: sta {z1} -//FRAGMENT vbuaa=vbuyy_band_vbuc1 -tya -and #{c1} -//FRAGMENT vbuxx=vbuyy_band_vbuc1 -tya -and #{c1} +//FRAGMENT vbuaa=vbuc1_rol_vbuxx +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_vbuxx +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: tax -//FRAGMENT vbuyy=vbuyy_band_vbuc1 -tya -and #{c1} +//FRAGMENT vbuyy=vbuc1_rol_vbuxx +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: tay -//FRAGMENT vbuzz=vbuyy_band_vbuc1 -tya -and #{c1} +//FRAGMENT vbuzz=vbuc1_rol_vbuxx +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: taz -//FRAGMENT vbuz1=vbuzz_band_vbuc1 -tza -and #{c1} +//FRAGMENT vbuz1=vbuc1_rol_vbuyy +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: sta {z1} -//FRAGMENT vbuaa=vbuzz_band_vbuc1 -tza -and #{c1} -//FRAGMENT vbuxx=vbuzz_band_vbuc1 -tza -and #{c1} +//FRAGMENT vbuaa=vbuc1_rol_vbuyy +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_vbuyy +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: tax -//FRAGMENT vbuyy=vbuzz_band_vbuc1 -tza -and #{c1} +//FRAGMENT vbuyy=vbuc1_rol_vbuyy +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: tay -//FRAGMENT vbuzz=vbuzz_band_vbuc1 -tza -and #{c1} +//FRAGMENT vbuzz=vbuc1_rol_vbuyy +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: taz -//FRAGMENT pbuc1_derefidx_vbuxx=vbuz1 +//FRAGMENT vbuz1=vbuc1_rol_vbuzz +tza +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +sta {z1} +//FRAGMENT vbuaa=vbuc1_rol_vbuzz +tza +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +//FRAGMENT vbuxx=vbuc1_rol_vbuzz +tza +tax +lda #{c1} +cpx #0 +beq !e+ +!: +asl +dex +bne !- +!e: +tax +//FRAGMENT vbuyy=vbuc1_rol_vbuzz +tza +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +tay +//FRAGMENT vbuzz=vbuc1_rol_vbuzz +tza +tay +lda #{c1} +cpy #0 +beq !e+ +!: +asl +dey +bne !- +!e: +taz +//FRAGMENT vbuaa=_lo_vwuz1 lda {z1} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuz1 -lda {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuz1 -tza -tay -lda {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuaa -ldy {z1} -sta {c1},y -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1 -ldy {z1} -lda {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1 -ldy {z1} -ldx {c1},y -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1 +//FRAGMENT vbuxx=_lo_vwuz1 ldx {z1} -ldy {c1},x -//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1 -ldx {z1} -ldz {c1},x +//FRAGMENT _deref_pbuc1=vbuaa +sta {c1} //FRAGMENT vbuaa=vbuz1_rol_4 lda {z1} asl @@ -659,35 +731,6 @@ asl asl asl taz -//FRAGMENT vbuz1=vbuaa_rol_4 -asl -asl -asl -asl -sta {z1} -//FRAGMENT vbuaa=vbuaa_rol_4 -asl -asl -asl -asl -//FRAGMENT vbuxx=vbuaa_rol_4 -asl -asl -asl -asl -tax -//FRAGMENT vbuyy=vbuaa_rol_4 -asl -asl -asl -asl -tay -//FRAGMENT vbuzz=vbuaa_rol_4 -asl -asl -asl -asl -taz //FRAGMENT vbuz1=vbuxx_rol_4 txa asl @@ -790,588 +833,288 @@ asl asl asl taz -//FRAGMENT vbuxx=vbuxx_plus_vbuc1 -txa -clc -adc #{c1} -tax -//FRAGMENT vbuyy=vbuyy_plus_vbuc1 -tya -clc -adc #{c1} -tay -//FRAGMENT vbuzz=vbuzz_plus_vbuc1 -tza -clc -adc #{c1} -taz -//FRAGMENT pbuc1_derefidx_vbuz1=vbuxx -ldy {z1} -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuyy -tya -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=vbuzz -ldy {z1} -tza -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuaa=vbuc2 -tay -lda #{c2} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=vbuc2 -lda #{c2} -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuc2 -lda #{c2} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuc2 -tza -tay -lda #{c2} -sta {c1},y -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_ror_2 -ldy {z1} -lda {c1},y -lsr -lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_ror_2 -ldx {z1} -lda {c1},x -lsr -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_ror_2 -ldy {z1} -lda {c1},y -lsr -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1_ror_2 -ldy {z1} -lda {c1},y -lsr -lsr -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuaa_ror_2 -tay -lda {c1},y -lsr -lsr +//FRAGMENT vbuaa=_hi_vwuz1 +lda {z1}+1 +//FRAGMENT vbuxx=_hi_vwuz1 +ldx {z1}+1 +//FRAGMENT vbuz1=vbuaa_band_vbuc1 +and #{c1} sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuaa_ror_2 -tay -lda {c1},y -lsr -lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuaa_ror_2 -tax -lda {c1},x -lsr -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuaa_ror_2 -tay -lda {c1},y -lsr -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuaa_ror_2 -tay -lda {c1},y -lsr -lsr -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_ror_2 -lda {c1},x -lsr -lsr -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_ror_2 -lda {c1},x -lsr -lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_ror_2 -lda {c1},x -lsr -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_ror_2 -lda {c1},x -lsr -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuxx_ror_2 -lda {c1},x -lsr -lsr -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_ror_2 -lda {c1},y -lsr -lsr -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_ror_2 -lda {c1},y -lsr -lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_ror_2 -lda {c1},y -lsr -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_ror_2 -lda {c1},y -lsr -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuyy_ror_2 -lda {c1},y -lsr -lsr -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz_ror_2 -tza -tay -lda {c1},y -lsr -lsr -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz_ror_2 -tza -tay -lda {c1},y -lsr -lsr -//FRAGMENT vbuxx=pbuc1_derefidx_vbuzz_ror_2 -tza -tax -lda {c1},x -lsr -lsr -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz_ror_2 -tza -tay -lda {c1},y -lsr -lsr -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuzz_ror_2 -tza -tay -lda {c1},y -lsr -lsr -taz -//FRAGMENT vbuz1=vbuaa_ror_1 -lsr -sta {z1} -//FRAGMENT vbuz1=vbuxx_ror_1 +//FRAGMENT vbuz1=vbuxx_band_vbuc1 txa -lsr +and #{c1} sta {z1} -//FRAGMENT vbuz1=vbuyy_ror_1 +//FRAGMENT vbuz1=vbuyy_band_vbuc1 tya -lsr +and #{c1} sta {z1} -//FRAGMENT vbuz1=vbuzz_ror_1 +//FRAGMENT vbuz1=vbuzz_band_vbuc1 tza -lsr +and #{c1} sta {z1} -//FRAGMENT vbuaa=vbuz1_ror_1 -lda {z1} -lsr -//FRAGMENT vbuaa=vbuaa_ror_1 -lsr -//FRAGMENT vbuaa=vbuxx_ror_1 -txa -lsr -//FRAGMENT vbuaa=vbuyy_ror_1 -tya -lsr -//FRAGMENT vbuaa=vbuzz_ror_1 -tza -lsr -//FRAGMENT vbuxx=vbuz1_ror_1 -lda {z1} -lsr -tax -//FRAGMENT vbuxx=vbuaa_ror_1 -lsr -tax -//FRAGMENT vbuxx=vbuxx_ror_1 -txa -lsr -tax -//FRAGMENT vbuxx=vbuyy_ror_1 -tya -lsr -tax -//FRAGMENT vbuxx=vbuzz_ror_1 -tza -lsr -tax -//FRAGMENT vbuyy=vbuz1_ror_1 -lda {z1} -lsr -tay -//FRAGMENT vbuyy=vbuaa_ror_1 -lsr -tay -//FRAGMENT vbuyy=vbuxx_ror_1 -txa -lsr -tay -//FRAGMENT vbuyy=vbuyy_ror_1 -tya -lsr -tay -//FRAGMENT vbuyy=vbuzz_ror_1 -tza -lsr -tay -//FRAGMENT vbuzz=vbuz1_ror_1 -lda {z1} -lsr -taz -//FRAGMENT vbuzz=vbuaa_ror_1 -lsr -taz -//FRAGMENT vbuzz=vbuxx_ror_1 -txa -lsr -taz -//FRAGMENT vbuzz=vbuyy_ror_1 -tya -lsr -taz -//FRAGMENT vbuzz=vbuzz_ror_1 -tza -lsr -taz -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuz1 -ldy {z1} -lda {c2},y -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuz1 -ldx {z1} -lda {c2},x -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuz1 -ldx {z1} -tza -tay -lda {c2},x -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuxx -lda {c2},x -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuxx -lda {c2},x -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuxx -tza -tay -lda {c2},x -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuyy -lda {c2},y -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuyy -lda {c2},y -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuyy -tza -tax -lda {c2},y -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuzz -tza -tay -lda {c2},y -ldy {z1} -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuzz -tza -tay -lda {c2},y -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuzz -tza -tax -lda {c2},x -sta {c1},y -//FRAGMENT _deref_pbuc1=vbuaa -sta {c1} -//FRAGMENT vbuz1=vbuaa_plus_1 -inc -sta {z1} -//FRAGMENT vbuz1=vbuxx_plus_1 -inx -stx {z1} -//FRAGMENT vbuaa=_deref_pbuc1 -lda {c1} -//FRAGMENT vbuxx=_deref_pbuc1 -ldx {c1} -//FRAGMENT vbuaa_eq__deref_pbuc1_then_la1 -cmp {c1} -beq {la1} -//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuxx -lda {c2},x -sta {c1} -//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuyy -lda {c2},y -sta {c1} -//FRAGMENT _deref_pbuc1=pbuc2_derefidx_vbuzz -tza -tay -lda {c2},y -sta {c1} -//FRAGMENT pbuc1_derefidx_vbuaa=pbuc2_derefidx_vbuaa -tay -lda {c2},y -sta {c1},y -//FRAGMENT vbuxx_neq_0_then_la1 -cpx #0 -bne {la1} -//FRAGMENT vbuxx_neq_vbuc1_then_la1 -cpx #{c1} -bne {la1} -//FRAGMENT vbuxx_lt_vbuc1_then_la1 -cpx #{c1} -bcc {la1} -//FRAGMENT vbuaa=_dec_vbuaa -sec -sbc #1 -//FRAGMENT vbuaa=_inc_vbuaa -inc -//FRAGMENT vbuxx=_dec_vbuxx -dex -//FRAGMENT vbuyy=_dec_vbuyy -dey -//FRAGMENT vbuzz=_dec_vbuzz -dez -//FRAGMENT pbuc1_derefidx_vbuxx=vbuaa -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuxx=vbuyy -tya -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuxx=vbuzz -tza -sta {c1},x -//FRAGMENT pbuc1_derefidx_vbuyy=vbuaa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuyy=vbuxx -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuyy=vbuzz -tza -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuaa -tax -tza -tay -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuxx -tza -tay -txa -sta {c1},y -//FRAGMENT pbuc1_derefidx_vbuzz=vbuyy -tza -tax -tya -sta {c1},x -//FRAGMENT vbuaa=vbuc1 +//FRAGMENT vbuaa=vbuz1_band_vbuc1 lda #{c1} -//FRAGMENT vbuyy_lt_vbuc1_then_la1 -cpy #{c1} -bcc {la1} -//FRAGMENT vbuzz_lt_vbuc1_then_la1 -cpz #{c1} -bcc {la1} -//FRAGMENT vbuyy_neq_0_then_la1 -cpy #0 -bne {la1} -//FRAGMENT vbuzz_neq_0_then_la1 -cpz #0 -bne {la1} -//FRAGMENT vbuxx_eq__deref_pbuc1_then_la1 -cpx {c1} -beq {la1} -//FRAGMENT vbuyy=_deref_pbuc1 -ldy {c1} -//FRAGMENT vbuyy_eq__deref_pbuc1_then_la1 -cpy {c1} -beq {la1} -//FRAGMENT vbuzz=_deref_pbuc1 -ldz {c1} -//FRAGMENT vbuzz_eq__deref_pbuc1_then_la1 -cpz {c1} -beq {la1} -//FRAGMENT vbuyy_neq_vbuc1_then_la1 -cpy #{c1} -bne {la1} -//FRAGMENT vbuzz_neq_vbuc1_then_la1 -cpz #{c1} -bne {la1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy -lda {c1},y -sta {z1} -//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz -tza -tay -lda {c1},y -sta {z1} -//FRAGMENT vbuaa=vbuz1_plus_1 -lda {z1} -inc -//FRAGMENT vbuyy=vbuz1_plus_1 -ldy {z1} -iny -//FRAGMENT _deref_pbuc1=vbuyy -sty {c1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz -tza -tay -lda {c1},y -//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz -tza -tax -ldy {c1},x -//FRAGMENT vbuaa=vbuaa_plus_1 -inc -//FRAGMENT vbuaa=vbuyy_plus_1 +and {z1} +//FRAGMENT vbuaa=vbuaa_band_vbuc1 +and #{c1} +//FRAGMENT vbuaa=vbuxx_band_vbuc1 +txa +and #{c1} +//FRAGMENT vbuaa=vbuyy_band_vbuc1 tya -inc -//FRAGMENT vbuz1=pbuc1_derefidx_vbuz2_band_vbuc2 -lda #{c2} -ldy {z2} -and {c1},y -sta {z1} -//FRAGMENT vbuaa_neq_0_then_la1 -cmp #0 -bne {la1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuz1_band_vbuc2 -lda #{c2} -ldy {z1} -and {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuz1_band_vbuc2 -lda #{c2} -ldx {z1} -and {c1},x -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuz1_band_vbuc2 -lda #{c2} -ldy {z1} -and {c1},y -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuz1_band_vbuc2 -lda #{c2} -ldy {z1} -and {c1},y -taz -//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 vbuzz=pbuc1_derefidx_vbuaa_band_vbuc2 -tay -lda #{c2} -and {c1},y -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuxx_band_vbuc2 -lda #{c2} -and {c1},x -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuxx_band_vbuc2 -lda #{c2} -and {c1},x -//FRAGMENT vbuxx=pbuc1_derefidx_vbuxx_band_vbuc2 -lda #{c2} -and {c1},x -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuxx_band_vbuc2 -lda #{c2} -and {c1},x -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuxx_band_vbuc2 -lda #{c2} -and {c1},x -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuyy_band_vbuc2 -lda #{c2} -and {c1},y -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuyy_band_vbuc2 -lda #{c2} -and {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuyy_band_vbuc2 -lda #{c2} -and {c1},y -tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuyy_band_vbuc2 -lda #{c2} -and {c1},y -tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuyy_band_vbuc2 -lda #{c2} -and {c1},y -taz -//FRAGMENT vbuz1=pbuc1_derefidx_vbuzz_band_vbuc2 -tza -tay -lda #{c2} -and {c1},y -sta {z1} -//FRAGMENT vbuaa=pbuc1_derefidx_vbuzz_band_vbuc2 -tza -tay -lda #{c2} -and {c1},y -//FRAGMENT vbuxx=pbuc1_derefidx_vbuzz_band_vbuc2 +and #{c1} +//FRAGMENT vbuaa=vbuzz_band_vbuc1 tza +and #{c1} +//FRAGMENT vbuxx=vbuz1_band_vbuc1 +lda #{c1} +and {z1} tax -lda #{c2} -and {c1},x +//FRAGMENT vbuxx=vbuaa_band_vbuc1 +and #{c1} tax -//FRAGMENT vbuyy=pbuc1_derefidx_vbuzz_band_vbuc2 +//FRAGMENT vbuxx=vbuxx_band_vbuc1 +txa +and #{c1} +tax +//FRAGMENT vbuxx=vbuyy_band_vbuc1 +tya +and #{c1} +tax +//FRAGMENT vbuxx=vbuzz_band_vbuc1 tza +and #{c1} +tax +//FRAGMENT vbuyy=vbuz1_band_vbuc1 +lda #{c1} +and {z1} tay -lda #{c2} -and {c1},y +//FRAGMENT vbuyy=vbuaa_band_vbuc1 +and #{c1} tay -//FRAGMENT vbuzz=pbuc1_derefidx_vbuzz_band_vbuc2 +//FRAGMENT vbuyy=vbuxx_band_vbuc1 +txa +and #{c1} +tay +//FRAGMENT vbuyy=vbuyy_band_vbuc1 +tya +and #{c1} +tay +//FRAGMENT vbuyy=vbuzz_band_vbuc1 tza +and #{c1} tay -lda #{c2} -and {c1},y +//FRAGMENT vbuzz=vbuz1_band_vbuc1 +lda #{c1} +and {z1} taz -//FRAGMENT vbuxx=vbuz1_plus_1 -ldx {z1} -inx +//FRAGMENT vbuzz=vbuaa_band_vbuc1 +and #{c1} +taz +//FRAGMENT vbuzz=vbuxx_band_vbuc1 +txa +and #{c1} +taz +//FRAGMENT vbuzz=vbuyy_band_vbuc1 +tya +and #{c1} +taz +//FRAGMENT vbuzz=vbuzz_band_vbuc1 +tza +and #{c1} +taz +//FRAGMENT vbuz1=vbuxx_bor_vbuz2 +txa +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuyy_bor_vbuz2 +tya +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuzz_bor_vbuz2 +tza +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuz2_bor_vbuaa +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuxx_bor_vbuaa +stx $ff +ora $ff +sta {z1} +//FRAGMENT vbuz1=vbuyy_bor_vbuaa +sty $ff +ora $ff +sta {z1} +//FRAGMENT vbuz1=vbuzz_bor_vbuaa +tay +tza +sty $ff +ora $ff +sta {z1} +//FRAGMENT vbuz1=vbuz2_bor_vbuxx +txa +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuxx_bor_vbuxx +stx {z1} //FRAGMENT _deref_pbuc1=vbuxx stx {c1} +//FRAGMENT vbuyy=_lo_vwuz1 +ldy {z1} +//FRAGMENT _deref_pbuc1=vbuyy +sty {c1} +//FRAGMENT vbuzz=_lo_vwuz1 +ldz {z1} //FRAGMENT _deref_pbuc1=vbuzz stz {c1} +//FRAGMENT vbuyy=_hi_vwuz1 +ldy {z1}+1 +//FRAGMENT vbuzz=_hi_vwuz1 +ldz {z1}+1 +//FRAGMENT vbuz1=vbuz2_bor_vbuyy +tya +ora {z2} +sta {z1} +//FRAGMENT vbuz1=vbuxx +stx {z1} +//FRAGMENT vbuz1=vbuyy +sty {z1} +//FRAGMENT vbuz1=vbuzz +tza +sta {z1} +//FRAGMENT vbuyy=vbuc1 +ldy #{c1} +//FRAGMENT vbuaa=vbuz1_bor_vbuaa +ora {z1} +//FRAGMENT vbuxx=vbuz1_bor_vbuaa +ora {z1} +tax +//FRAGMENT vbuyy=vbuz1_bor_vbuaa +ora {z1} +tay +//FRAGMENT vbuzz=vbuz1_bor_vbuaa +ora {z1} +taz +//FRAGMENT vbuz1=vbuz2_bor_vbuzz +tza +ora {z2} +sta {z1} +//FRAGMENT vbuaa=vbuxx_bor_vbuaa +stx $ff +ora $ff +//FRAGMENT vbuaa=vbuyy_bor_vbuaa +sty $ff +ora $ff +//FRAGMENT vbuaa=vbuzz_bor_vbuaa +tay +tza +sty $ff +ora $ff +//FRAGMENT vbuxx=vbuaa +tax +//FRAGMENT vbuyy=vbuaa +tay +//FRAGMENT vbuzz=vbuaa +taz +//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuz1_then_la1 +lda #{c1} +ldy {z1} +cmp {c2},y +bne {la1} +//FRAGMENT pbuc1_derefidx_vbuz1=pbuc2_derefidx_vbuz1 +ldy {z1} +lda {c2},y +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuz1=vbuz1 +ldy {z1} +tya +sta {c1},y +//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuaa_then_la1 +tay +lda #{c1} +cmp {c2},y +bne {la1} +//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuxx_then_la1 +lda {c2},x +cmp #{c1} +bne {la1} +//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuyy_then_la1 +lda #{c1} +cmp {c2},y +bne {la1} +//FRAGMENT vbuc1_neq_pbuc2_derefidx_vbuzz_then_la1 +tza +tay +lda #{c1} +cmp {c2},y +bne {la1} +//FRAGMENT pbuc1_derefidx_vbuxx=pbuc2_derefidx_vbuxx +lda {c2},x +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=pbuc2_derefidx_vbuyy +lda {c2},y +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=pbuc2_derefidx_vbuzz +tza +tay +lda {c2},y +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuxx=vbuxx +txa +sta {c1},x +//FRAGMENT pbuc1_derefidx_vbuyy=vbuyy +tya +sta {c1},y +//FRAGMENT pbuc1_derefidx_vbuzz=vbuzz +tza +tax +sta {c1},x +//FRAGMENT vbuxx=_inc_vbuxx +inx +//FRAGMENT vbuyy=_inc_vbuyy +iny +//FRAGMENT vbuzz=_inc_vbuzz +inz +//FRAGMENT vduz1=vduc1 +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 +lda #<{c1}>>$10 +sta {z1}+2 +lda #>{c1}>>$10 +sta {z1}+3 +//FRAGMENT vbuz1_lt_vbuc1_then_la1 +lda {z1} +cmp #{c1} +bcc {la1} +//FRAGMENT _deref_pduc1=vduz1 +ldq {z1} +stq {c1} +//FRAGMENT vduz1=vduz1_plus_vduz2 +clc +ldq {z1} +adcq {z2} +stq {z1} +//FRAGMENT vduz1=vduz1_plus_vbuz2 +lda {z2} +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 vbuaa_lt_vbuc1_then_la1 +cmp #{c1} +bcc {la1} +//FRAGMENT vduz1=vwuc1 +NO_SYNTHESIS +//FRAGMENT vduz1=vwsc1 +NO_SYNTHESIS diff --git a/src/main/fragment/cache/fragment-cache-mos6502.asm b/src/main/fragment/cache/fragment-cache-mos6502.asm index cb8dbef44..0ccffdb26 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c +//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-mos6502x.asm b/src/main/fragment/cache/fragment-cache-mos6502x.asm index 2ba889d19..f6f0366b5 100644 --- a/src/main/fragment/cache/fragment-cache-mos6502x.asm +++ b/src/main/fragment/cache/fragment-cache-mos6502x.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c +//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd //FRAGMENT vbuz1=vbuc1 lda #{c1} sta {z1} diff --git a/src/main/fragment/cache/fragment-cache-wdc65c02.asm b/src/main/fragment/cache/fragment-cache-wdc65c02.asm index 650149bb9..7c4c6a22b 100644 --- a/src/main/fragment/cache/fragment-cache-wdc65c02.asm +++ b/src/main/fragment/cache/fragment-cache-wdc65c02.asm @@ -1,4 +1,4 @@ -//KICKC FRAGMENT CACHE 17a386c45a 17a386dc9c +//KICKC FRAGMENT CACHE 1813f9ad84 1813f9c5cd //FRAGMENT vbuz1=_deref_pbuc1 lda {c1} sta {z1} diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 88dbe7423..77916c20c 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -237,6 +237,11 @@ public class TestPrograms { compileAndCompare("examples/nes-demo/nes-demo.c"); } + @Test + public void testMega65MemoryMapTest() throws IOException, URISyntaxException { + compileAndCompare("examples/mega65/memorymap-test.c"); + } + @Test public void testMega65Addressing32bit() throws IOException, URISyntaxException { compileAndCompare("examples/mega65/32bit-addressing-mega65.c"); diff --git a/src/test/kc/.vscode/tasks.json b/src/test/kc/.vscode/tasks.json index 7674bf64e..ab9551c74 100644 --- a/src/test/kc/.vscode/tasks.json +++ b/src/test/kc/.vscode/tasks.json @@ -110,7 +110,6 @@ "command": "~/c64/kickc_local/bin/kickc.sh", "args": [ "-vasmout", - "-Oloophead" "-Sc", "-odir", "~/c64/tmp/", diff --git a/src/test/kc/examples/mega65/memorymap-test.c b/src/test/kc/examples/mega65/memorymap-test.c index a25815aab..0aeef448f 100644 --- a/src/test/kc/examples/mega65/memorymap-test.c +++ b/src/test/kc/examples/mega65/memorymap-test.c @@ -1,91 +1,103 @@ // Test the MAP instruction for remapping memory #pragma target(mega65) -#pragma emulator("/Users/jespergravgaard/c64/mega65/xemu-hernandp/build/bin/xmega65.native -prg") #include void main() { - /* - // Remap block at $4000 to point to $10000 - // offset = $10000-$4000 = $c000 - asm { - lda #$c0 // lower blocks offset page - ldx #$40 // lower blocks to map + lower blocks offset - ldy #0 - ldz #0 - map - eom - } - // Put data into $4000 - asm { - lda #$55 - sta $4000 - } - */ - - char * block1 = 0x4000; char * block2 = 0x8000; - memoryBlockRemap((unsigned char)>block1, 0x100); - memoryBlockRemap((unsigned char)>block2, 0x120); - - // TODO: The mapper can only map the lower 32K to one memory address and the upper 32K to another - // TODO: The mapper always remaps both - so it cannot be separated into two different calls (without some memory)! + // Remap [$4000-$5fff] to point to [$10000-$11fff] + memoryRemapBlock(0x40, 0x100); + // Put 0x55, 0xaa into $10000 block1[0] = 0x55; block1[1] = 0xaa; - block2[0] = 0x55; - block2[1] = 0xaa; - //block2[1] = 0xaa; - //block2[2] = block1[1]; - + // Remap [$8000-$9fff] to point to [$10000-$11fff] + memoryRemapBlock(0x80, 0x100); + // Put 0x55, 0xaainto $10002 + block2[2] = 0x55; + block2[3] = 0xaa; + // Remap [$4000-$5fff] and [$8000-$9fff] to both point to [$10000-$11fff] (notice usage of page offsets) + memoryRemap(MEMORYBLOCK_4000|MEMORYBLOCK_8000, 0x0c0, 0x080); + // Put 0x55, 0xaa into $10004 in a convoluted way + block2[4] = block1[2]; + block1[5] = block2[1]; } -// Remap one of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. -// After the remapping the CPU will access the mapped memory whenever it uses instructions that access the mapped block. +// Bit representing 8K block #0 of the 64K addressable memory ($0000-$1fff) +const unsigned char MEMORYBLOCK_0000 = 0b00000001; +// Bit representing 8K block #1 of the 64K addressable memory ($2000-$3fff) +const unsigned char MEMORYBLOCK_2000 = 0b00000010; +// Bit representing 8K block #2 of the 64K addressable memory ($4000-$5fff) +const unsigned char MEMORYBLOCK_4000 = 0b00000100; +// Bit representing 8K block #3 of the 64K addressable memory ($6000-$7fff) +const unsigned char MEMORYBLOCK_6000 = 0b00001000; +// Bit representing 8K block #4 of the 64K addressable memory ($8000-$9fff) +const unsigned char MEMORYBLOCK_8000 = 0b00010000; +// Bit representing 8K block #5 of the 64K addressable memory ($a000-$bfff) +const unsigned char MEMORYBLOCK_A000 = 0b00100000; +// Bit representing 8K block #6 of the 64K addressable memory ($c000-$dfff) +const unsigned char MEMORYBLOCK_C000 = 0b01000000; +// Bit representing 8K block #7 of the 64K addressable memory ($e000-$ffff) +const unsigned char MEMORYBLOCK_E000 = 0b10000000; + +// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block. +// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block +// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000. +// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000. +// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000. +// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000. +// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000. +// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000. +// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000. +// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000. +// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100. +// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000. +// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000. +// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000. +// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000 +// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000. +// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000. +// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000. +void memoryRemap(unsigned char remapBlocks, unsigned int lowerMemoryPageOffset, unsigned int upperMemoryPageOffset) { + char * aVal = 0xfc; + char * xVal = 0xfd; + char * yVal = 0xfe; + char * zVal = 0xff; + *aVal = lowerMemoryPageOffset & 0xf); + *yVal = upperMemoryPageOffset & 0xf); + asm { + lda aVal // lower blocks offset page low + ldx xVal // lower blocks to map + lower blocks offset high nibble + ldy yVal // upper blocks offset page + ldz zVal // upper blocks to map + upper blocks offset page high nibble + map + eom + } +} + +// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. // blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) -// Legal block page addresses are: $00: block $0000-$1fff, $20: block $2000-$3fff, ..., $e0: block $e000-$ffff // memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. // Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. -void memoryBlockRemap(unsigned char blockPage, unsigned int memoryPage) { - // Which block is being remapped? (0-7) - char block = blockPage / $20; +void memoryRemapBlock(unsigned char blockPage, unsigned int memoryPage) { // Find the page offset (the number of pages to offset the block) unsigned int pageOffset = memoryPage-blockPage; - if(block&4) { - // High block (4-7) - char * yVal = 0xfe; - char * zVal = 0xff; - *yVal = pageOffset & 0xf); - asm { - lda #0 // lower blocks offset page low - ldx #0 // lower blocks to map + lower blocks offset page high nibble - ldy yVal // upper blocks offset page - ldz zVal // upper blocks to map + upper blocks offset page high nibble - map - eom - } - } else { - // Low block (0-3) - char * aVal = 0xfe; - char * xVal = 0xff; - *aVal = pageOffset & 0xf); - asm { - lda aVal // lower blocks offset page low - ldx xVal // lower blocks to map + lower blocks offset high nibble - ldy #0 // upper blocks offset page - ldz #0 // upper blocks to map + upper blocks offset page high nibble - map - eom - } - - } - + // Which block is being remapped? (0-7) + char block = blockPage / $20; + char blockBits = 1<$80 + sta.z memoryRemap.upperMemoryPageOffset+1 + ldz #MEMORYBLOCK_4000|MEMORYBLOCK_8000 + lda #<$c0 + sta.z memoryRemap.lowerMemoryPageOffset + lda #>$c0 + sta.z memoryRemap.lowerMemoryPageOffset+1 + jsr memoryRemap + // block2[4] = block1[2] + // Put 0x55, 0xaa into $10004 in a convoluted way + lda block1+2 + sta block2+4 + // block1[5] = block2[1] + lda block2+1 + sta block1+5 + // } + rts +} +// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. +// blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) +// memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. +// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. +// memoryRemapBlock(byte register(X) blockPage) +memoryRemapBlock: { + .label pageOffset = 2 + // pageOffset = memoryPage-blockPage + stx.z $ff + lda #<$100 + sec + sbc.z $ff + sta.z pageOffset + lda #>$100 + sbc #0 + sta.z pageOffset+1 + // block = blockPage / $20 + txa + lsr + lsr + lsr + lsr + lsr + // blockBits = 1<lowerMemoryPageOffset + lda.z lowerMemoryPageOffset+1 + // >lowerMemoryPageOffset & 0xf + and #$f + // (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf) + ora.z __1 + // *xVal = (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf) + sta xVal + // upperMemoryPageOffset + lda.z upperMemoryPageOffset+1 + // >upperMemoryPageOffset & 0xf + and #$f + // (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf) + ora.z __6 + // *zVal = (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf) + sta zVal + // asm + lda aVal + ldx xVal + ldy yVal + ldz zVal + map + eom + // } + rts +} diff --git a/src/test/ref/examples/mega65/memorymap-test.cfg b/src/test/ref/examples/mega65/memorymap-test.cfg new file mode 100644 index 000000000..e89e8aab6 --- /dev/null +++ b/src/test/ref/examples/mega65/memorymap-test.cfg @@ -0,0 +1,63 @@ + +(void()) main() +main: scope:[main] from + [0] phi() + [1] call memoryRemapBlock + to:main::@1 +main::@1: scope:[main] from main + [2] *((const byte*) main::block1) ← (byte) $55 + [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa + [4] call memoryRemapBlock + to:main::@2 +main::@2: scope:[main] from main::@1 + [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 + [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa + [7] call memoryRemap + to:main::@3 +main::@3: scope:[main] from main::@2 + [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) + [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) + to:main::@return +main::@return: scope:[main] from main::@3 + [10] return + to:@return + +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +memoryRemapBlock: scope:[memoryRemapBlock] from main main::@1 + [11] (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) $40 main::@1/(byte) $80 ) + [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 + [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 + [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 + [15] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0 + [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + [18] call memoryRemap + to:memoryRemapBlock::@return +memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock + [19] return + to:@return + +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +memoryRemap: scope:[memoryRemap] from main::@2 memoryRemapBlock + [20] (word) memoryRemap::upperMemoryPageOffset#2 ← phi( main::@2/(byte) $80 memoryRemapBlock/(word) memoryRemap::upperMemoryPageOffset#1 ) + [20] (byte) memoryRemap::remapBlocks#2 ← phi( main::@2/(const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 memoryRemapBlock/(byte) memoryRemap::remapBlocks#1 ) + [20] (word) memoryRemap::lowerMemoryPageOffset#2 ← phi( main::@2/(byte) $c0 memoryRemapBlock/(word) memoryRemap::lowerMemoryPageOffset#1 ) + [21] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2 + [22] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 + [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 + [24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 + [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f + [26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 + [27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 + [28] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2 + [29] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 + [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 + [31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 + [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f + [33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 + [34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 + asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + to:memoryRemap::@return +memoryRemap::@return: scope:[memoryRemap] from memoryRemap + [36] return + to:@return diff --git a/src/test/ref/examples/mega65/memorymap-test.log b/src/test/ref/examples/mega65/memorymap-test.log new file mode 100644 index 000000000..1e7441a81 --- /dev/null +++ b/src/test/ref/examples/mega65/memorymap-test.log @@ -0,0 +1,2275 @@ +Resolved forward reference MEMORYBLOCK_4000 to (const nomodify byte) MEMORYBLOCK_4000 +Resolved forward reference MEMORYBLOCK_8000 to (const nomodify byte) MEMORYBLOCK_8000 +Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from __start + (byte) memoryRemapBlock::blockPage#0 ← (number) $40 + (word) memoryRemapBlock::memoryPage#0 ← (number) $100 + call memoryRemapBlock + to:main::@1 +main::@1: scope:[main] from main + *((const byte*) main::block1 + (number) 0) ← (number) $55 + *((const byte*) main::block1 + (number) 1) ← (number) $aa + (byte) memoryRemapBlock::blockPage#1 ← (number) $80 + (word) memoryRemapBlock::memoryPage#1 ← (number) $100 + call memoryRemapBlock + to:main::@2 +main::@2: scope:[main] from main::@1 + *((const byte*) main::block2 + (number) 2) ← (number) $55 + *((const byte*) main::block2 + (number) 3) ← (number) $aa + (byte~) main::$2 ← (const nomodify byte) MEMORYBLOCK_4000 | (const nomodify byte) MEMORYBLOCK_8000 + (byte) memoryRemap::remapBlocks#0 ← (byte~) main::$2 + (word) memoryRemap::lowerMemoryPageOffset#0 ← (number) $c0 + (word) memoryRemap::upperMemoryPageOffset#0 ← (number) $80 + call memoryRemap + to:main::@3 +main::@3: scope:[main] from main::@2 + *((const byte*) main::block2 + (number) 4) ← *((const byte*) main::block1 + (number) 2) + *((const byte*) main::block1 + (number) 5) ← *((const byte*) main::block2 + (number) 1) + to:main::@return +main::@return: scope:[main] from main::@3 + return + to:@return + +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +memoryRemap: scope:[memoryRemap] from main::@2 memoryRemapBlock + (word) memoryRemap::upperMemoryPageOffset#2 ← phi( main::@2/(word) memoryRemap::upperMemoryPageOffset#0 memoryRemapBlock/(word) memoryRemap::upperMemoryPageOffset#1 ) + (byte) memoryRemap::remapBlocks#2 ← phi( main::@2/(byte) memoryRemap::remapBlocks#0 memoryRemapBlock/(byte) memoryRemap::remapBlocks#1 ) + (word) memoryRemap::lowerMemoryPageOffset#2 ← phi( main::@2/(word) memoryRemap::lowerMemoryPageOffset#0 memoryRemapBlock/(word) memoryRemap::lowerMemoryPageOffset#1 ) + (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2 + *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 + (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (number) 4 + (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 + (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (number) $f + (number~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (number~) memoryRemap::$3 + *((const byte*) memoryRemap::xVal) ← (number~) memoryRemap::$4 + (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2 + *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 + (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (number) $f0 + (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 + (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (number) $f + (number~) memoryRemap::$9 ← (number~) memoryRemap::$6 | (number~) memoryRemap::$8 + *((const byte*) memoryRemap::zVal) ← (number~) memoryRemap::$9 + asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + to:memoryRemap::@return +memoryRemap::@return: scope:[memoryRemap] from memoryRemap + return + to:@return + +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +memoryRemapBlock: scope:[memoryRemapBlock] from main main::@1 + (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) memoryRemapBlock::blockPage#0 main::@1/(byte) memoryRemapBlock::blockPage#1 ) + (word) memoryRemapBlock::memoryPage#2 ← phi( main/(word) memoryRemapBlock::memoryPage#0 main::@1/(word) memoryRemapBlock::memoryPage#1 ) + (word~) memoryRemapBlock::$0 ← (word) memoryRemapBlock::memoryPage#2 - (byte) memoryRemapBlock::blockPage#2 + (word) memoryRemapBlock::pageOffset#0 ← (word~) memoryRemapBlock::$0 + (number~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (number) $20 + (byte) memoryRemapBlock::block#0 ← (number~) memoryRemapBlock::$1 + (number~) memoryRemapBlock::$2 ← (number) 1 << (byte) memoryRemapBlock::block#0 + (byte) memoryRemapBlock::blockBits#0 ← (number~) memoryRemapBlock::$2 + (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0 + (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + call memoryRemap + to:memoryRemapBlock::@1 +memoryRemapBlock::@1: scope:[memoryRemapBlock] from memoryRemapBlock + to:memoryRemapBlock::@return +memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock::@1 + return + to:@return + +(void()) __start() +__start: scope:[__start] from + call main + to:__start::@1 +__start::@1: scope:[__start] from __start + to:__start::@return +__start::@return: scope:[__start] from __start::@1 + return + to:@return + +SYMBOL TABLE SSA +(byte) MEGA65_VICIV::ALPHADELAY +(byte) MEGA65_VICIV::B0PIX +(byte) MEGA65_VICIV::B0_ADDR +(byte) MEGA65_VICIV::B1PIX +(byte) MEGA65_VICIV::B1_ADDR +(byte) MEGA65_VICIV::B2PIX +(byte) MEGA65_VICIV::B2_ADDR +(byte) MEGA65_VICIV::B3PIX +(byte) MEGA65_VICIV::B3_ADDR +(byte) MEGA65_VICIV::B4PIX +(byte) MEGA65_VICIV::B4_ADDR +(byte) MEGA65_VICIV::B5PIX +(byte) MEGA65_VICIV::B5_ADDR +(byte) MEGA65_VICIV::B6PIX +(byte) MEGA65_VICIV::B6_ADDR +(byte) MEGA65_VICIV::B7PIX +(byte) MEGA65_VICIV::B7_ADDR +(byte) MEGA65_VICIV::BBDRPOS_HI +(byte) MEGA65_VICIV::BBDRPOS_LO +(byte) MEGA65_VICIV::BG_COLOR +(byte) MEGA65_VICIV::BG_COLOR1 +(byte) MEGA65_VICIV::BG_COLOR2 +(byte) MEGA65_VICIV::BG_COLOR3 +(byte) MEGA65_VICIV::BORDER_COLOR +(byte) MEGA65_VICIV::BP16ENS +(byte) MEGA65_VICIV::BPCOMP +(byte) MEGA65_VICIV::BPX +(byte) MEGA65_VICIV::BPY +(byte) MEGA65_VICIV::CHARPTR_HILO +(byte) MEGA65_VICIV::CHARPTR_LOHI +(byte) MEGA65_VICIV::CHARPTR_LOLO +(byte) MEGA65_VICIV::CHARSTEP_HI +(byte) MEGA65_VICIV::CHARSTEP_LO +(byte) MEGA65_VICIV::CHRCOUNT +(byte) MEGA65_VICIV::CHRXSCL +(byte) MEGA65_VICIV::CHRYSCL +(byte) MEGA65_VICIV::COLPTR_HI +(byte) MEGA65_VICIV::COLPTR_LO +(byte) MEGA65_VICIV::CONTROL1 +(byte) MEGA65_VICIV::CONTROL2 +(byte) MEGA65_VICIV::CONTROLA +(byte) MEGA65_VICIV::CONTROLB +(byte) MEGA65_VICIV::CONTROLC +(byte) MEGA65_VICIV::DEBUG1 +(byte) MEGA65_VICIV::DEBUGX +(byte) MEGA65_VICIV::DEBUGXY +(byte) MEGA65_VICIV::DEBUGY +(byte) MEGA65_VICIV::FNRASTER_HI +(byte) MEGA65_VICIV::FNRASTER_LO +(byte) MEGA65_VICIV::HPOS +(byte) MEGA65_VICIV::IRQ_ENABLE +(byte) MEGA65_VICIV::IRQ_STATUS +(byte) MEGA65_VICIV::KEY +(byte) MEGA65_VICIV::LIGHTPEN_X +(byte) MEGA65_VICIV::LIGHTPEN_Y +(byte) MEGA65_VICIV::MEMORY +(byte) MEGA65_VICIV::PALSEL +(byte) MEGA65_VICIV::RASLINE0 +(byte) MEGA65_VICIV::RASTER +(byte) MEGA65_VICIV::ROWCOUNT +(byte) MEGA65_VICIV::RSTCMP +(byte) MEGA65_VICIV::RSTCOMP +(byte) MEGA65_VICIV::SBPDEBUG +(byte) MEGA65_VICIV::SCRNPTR_HIHI +(byte) MEGA65_VICIV::SCRNPTR_HILO +(byte) MEGA65_VICIV::SCRNPTR_LOHI +(byte) MEGA65_VICIV::SCRNPTR_LOLO +(byte) MEGA65_VICIV::SIDBDRWD_HI +(byte) MEGA65_VICIV::SIDBDRWD_LO +(byte) MEGA65_VICIV::SPR16EN +(byte) MEGA65_VICIV::SPRALPHAVAL +(byte) MEGA65_VICIV::SPRENALPHA +(byte) MEGA65_VICIV::SPRENV400 +(byte) MEGA65_VICIV::SPRHGHT +(byte) MEGA65_VICIV::SPRHGTEN +(byte) MEGA65_VICIV::SPRITE0_COLOR +(byte) MEGA65_VICIV::SPRITE0_X +(byte) MEGA65_VICIV::SPRITE0_Y +(byte) MEGA65_VICIV::SPRITE1_COLOR +(byte) MEGA65_VICIV::SPRITE1_X +(byte) MEGA65_VICIV::SPRITE1_Y +(byte) MEGA65_VICIV::SPRITE2_COLOR +(byte) MEGA65_VICIV::SPRITE2_X +(byte) MEGA65_VICIV::SPRITE2_Y +(byte) MEGA65_VICIV::SPRITE3_COLOR +(byte) MEGA65_VICIV::SPRITE3_X +(byte) MEGA65_VICIV::SPRITE3_Y +(byte) MEGA65_VICIV::SPRITE4_COLOR +(byte) MEGA65_VICIV::SPRITE4_X +(byte) MEGA65_VICIV::SPRITE4_Y +(byte) MEGA65_VICIV::SPRITE5_COLOR +(byte) MEGA65_VICIV::SPRITE5_X +(byte) MEGA65_VICIV::SPRITE5_Y +(byte) MEGA65_VICIV::SPRITE6_COLOR +(byte) MEGA65_VICIV::SPRITE6_X +(byte) MEGA65_VICIV::SPRITE6_Y +(byte) MEGA65_VICIV::SPRITE7_COLOR +(byte) MEGA65_VICIV::SPRITE7_X +(byte) MEGA65_VICIV::SPRITE7_Y +(byte) MEGA65_VICIV::SPRITES_BG_COLLISION +(byte) MEGA65_VICIV::SPRITES_COLLISION +(byte) MEGA65_VICIV::SPRITES_ENABLE +(byte) MEGA65_VICIV::SPRITES_EXPAND_X +(byte) MEGA65_VICIV::SPRITES_EXPAND_Y +(byte) MEGA65_VICIV::SPRITES_MC +(byte) MEGA65_VICIV::SPRITES_MCOLOR1 +(byte) MEGA65_VICIV::SPRITES_MCOLOR2 +(byte) MEGA65_VICIV::SPRITES_PRIORITY +(byte) MEGA65_VICIV::SPRITES_XMSB +(byte) MEGA65_VICIV::SPRPTRADR_HILO +(byte) MEGA65_VICIV::SPRPTRADR_LOHI +(byte) MEGA65_VICIV::SPRPTRADR_LOLO +(byte) MEGA65_VICIV::SPRX64EN +(byte) MEGA65_VICIV::SPRXSMSBS +(byte) MEGA65_VICIV::SPRYSMSBSM +(byte) MEGA65_VICIV::SRPYMSBS +(byte) MEGA65_VICIV::SYNCPOL +(byte) MEGA65_VICIV::TBDRPOS_HI +(byte) MEGA65_VICIV::TBDRPOS_LO +(byte) MEGA65_VICIV::TEXTXPOS_HI +(byte) MEGA65_VICIV::TEXTXPOS_LO +(byte) MEGA65_VICIV::TEXTYPOS_HI +(byte) MEGA65_VICIV::TEXTYPOS_LO +(byte) MEGA65_VICIV::UNUSED +(byte) MEGA65_VICIV::VPOS +(byte) MEGA65_VICIV::VSYNDEL +(byte) MEGA65_VICIV::XPOS_HI +(byte) MEGA65_VICIV::XPOS_LO +(const nomodify byte) MEMORYBLOCK_4000 = (byte) 4 +(const nomodify byte) MEMORYBLOCK_8000 = (byte) $10 +(byte) MOS4569_VICIII::B0PIX +(byte) MOS4569_VICIII::B0_ADDR +(byte) MOS4569_VICIII::B1PIX +(byte) MOS4569_VICIII::B1_ADDR +(byte) MOS4569_VICIII::B2PIX +(byte) MOS4569_VICIII::B2_ADDR +(byte) MOS4569_VICIII::B3PIX +(byte) MOS4569_VICIII::B3_ADDR +(byte) MOS4569_VICIII::B4PIX +(byte) MOS4569_VICIII::B4_ADDR +(byte) MOS4569_VICIII::B5PIX +(byte) MOS4569_VICIII::B5_ADDR +(byte) MOS4569_VICIII::B6PIX +(byte) MOS4569_VICIII::B6_ADDR +(byte) MOS4569_VICIII::B7PIX +(byte) MOS4569_VICIII::B7_ADDR +(byte) MOS4569_VICIII::BG_COLOR +(byte) MOS4569_VICIII::BG_COLOR1 +(byte) MOS4569_VICIII::BG_COLOR2 +(byte) MOS4569_VICIII::BG_COLOR3 +(byte) MOS4569_VICIII::BORDER_COLOR +(byte) MOS4569_VICIII::BPCOMP +(byte) MOS4569_VICIII::BPX +(byte) MOS4569_VICIII::BPY +(byte) MOS4569_VICIII::CONTROL1 +(byte) MOS4569_VICIII::CONTROL2 +(byte) MOS4569_VICIII::CONTROLA +(byte) MOS4569_VICIII::CONTROLB +(byte) MOS4569_VICIII::HPOS +(byte) MOS4569_VICIII::IRQ_ENABLE +(byte) MOS4569_VICIII::IRQ_STATUS +(byte) MOS4569_VICIII::KEY +(byte) MOS4569_VICIII::LIGHTPEN_X +(byte) MOS4569_VICIII::LIGHTPEN_Y +(byte) MOS4569_VICIII::MEMORY +(byte) MOS4569_VICIII::RASTER +(byte) MOS4569_VICIII::SPRITE0_COLOR +(byte) MOS4569_VICIII::SPRITE0_X +(byte) MOS4569_VICIII::SPRITE0_Y +(byte) MOS4569_VICIII::SPRITE1_COLOR +(byte) MOS4569_VICIII::SPRITE1_X +(byte) MOS4569_VICIII::SPRITE1_Y +(byte) MOS4569_VICIII::SPRITE2_COLOR +(byte) MOS4569_VICIII::SPRITE2_X +(byte) MOS4569_VICIII::SPRITE2_Y +(byte) MOS4569_VICIII::SPRITE3_COLOR +(byte) MOS4569_VICIII::SPRITE3_X +(byte) MOS4569_VICIII::SPRITE3_Y +(byte) MOS4569_VICIII::SPRITE4_COLOR +(byte) MOS4569_VICIII::SPRITE4_X +(byte) MOS4569_VICIII::SPRITE4_Y +(byte) MOS4569_VICIII::SPRITE5_COLOR +(byte) MOS4569_VICIII::SPRITE5_X +(byte) MOS4569_VICIII::SPRITE5_Y +(byte) MOS4569_VICIII::SPRITE6_COLOR +(byte) MOS4569_VICIII::SPRITE6_X +(byte) MOS4569_VICIII::SPRITE6_Y +(byte) MOS4569_VICIII::SPRITE7_COLOR +(byte) MOS4569_VICIII::SPRITE7_X +(byte) MOS4569_VICIII::SPRITE7_Y +(byte) MOS4569_VICIII::SPRITES_BG_COLLISION +(byte) MOS4569_VICIII::SPRITES_COLLISION +(byte) MOS4569_VICIII::SPRITES_ENABLE +(byte) MOS4569_VICIII::SPRITES_EXPAND_X +(byte) MOS4569_VICIII::SPRITES_EXPAND_Y +(byte) MOS4569_VICIII::SPRITES_MC +(byte) MOS4569_VICIII::SPRITES_MCOLOR1 +(byte) MOS4569_VICIII::SPRITES_MCOLOR2 +(byte) MOS4569_VICIII::SPRITES_PRIORITY +(byte) MOS4569_VICIII::SPRITES_XMSB +(byte) MOS4569_VICIII::UNUSED +(byte) MOS4569_VICIII::VPOS +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(void()) __start() +(label) __start::@1 +(label) __start::@return +(void()) main() +(byte~) main::$2 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(const byte*) main::block1 = (byte*)(number) $4000 +(const byte*) main::block2 = (byte*)(number) $8000 +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +(byte~) memoryRemap::$0 +(byte~) memoryRemap::$1 +(byte~) memoryRemap::$2 +(number~) memoryRemap::$3 +(number~) memoryRemap::$4 +(byte~) memoryRemap::$5 +(number~) memoryRemap::$6 +(byte~) memoryRemap::$7 +(number~) memoryRemap::$8 +(number~) memoryRemap::$9 +(label) memoryRemap::@return +(const byte*) memoryRemap::aVal = (byte*)(number) $fc +(word) memoryRemap::lowerMemoryPageOffset +(word) memoryRemap::lowerMemoryPageOffset#0 +(word) memoryRemap::lowerMemoryPageOffset#1 +(word) memoryRemap::lowerMemoryPageOffset#2 +(byte) memoryRemap::remapBlocks +(byte) memoryRemap::remapBlocks#0 +(byte) memoryRemap::remapBlocks#1 +(byte) memoryRemap::remapBlocks#2 +(word) memoryRemap::upperMemoryPageOffset +(word) memoryRemap::upperMemoryPageOffset#0 +(word) memoryRemap::upperMemoryPageOffset#1 +(word) memoryRemap::upperMemoryPageOffset#2 +(const byte*) memoryRemap::xVal = (byte*)(number) $fd +(const byte*) memoryRemap::yVal = (byte*)(number) $fe +(const byte*) memoryRemap::zVal = (byte*)(number) $ff +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +(word~) memoryRemapBlock::$0 +(number~) memoryRemapBlock::$1 +(number~) memoryRemapBlock::$2 +(label) memoryRemapBlock::@1 +(label) memoryRemapBlock::@return +(byte) memoryRemapBlock::block +(byte) memoryRemapBlock::block#0 +(byte) memoryRemapBlock::blockBits +(byte) memoryRemapBlock::blockBits#0 +(byte) memoryRemapBlock::blockPage +(byte) memoryRemapBlock::blockPage#0 +(byte) memoryRemapBlock::blockPage#1 +(byte) memoryRemapBlock::blockPage#2 +(word) memoryRemapBlock::memoryPage +(word) memoryRemapBlock::memoryPage#0 +(word) memoryRemapBlock::memoryPage#1 +(word) memoryRemapBlock::memoryPage#2 +(word) memoryRemapBlock::pageOffset +(word) memoryRemapBlock::pageOffset#0 + +Adding number conversion cast (unumber) $40 in (byte) memoryRemapBlock::blockPage#0 ← (number) $40 +Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#0 ← (number) $100 +Adding number conversion cast (unumber) $55 in *((const byte*) main::block1 + (number) 0) ← (number) $55 +Adding number conversion cast (unumber) 0 in *((const byte*) main::block1 + (number) 0) ← ((unumber)) (number) $55 +Adding number conversion cast (unumber) $aa in *((const byte*) main::block1 + (number) 1) ← (number) $aa +Adding number conversion cast (unumber) 1 in *((const byte*) main::block1 + (number) 1) ← ((unumber)) (number) $aa +Adding number conversion cast (unumber) $80 in (byte) memoryRemapBlock::blockPage#1 ← (number) $80 +Adding number conversion cast (unumber) $100 in (word) memoryRemapBlock::memoryPage#1 ← (number) $100 +Adding number conversion cast (unumber) $55 in *((const byte*) main::block2 + (number) 2) ← (number) $55 +Adding number conversion cast (unumber) 2 in *((const byte*) main::block2 + (number) 2) ← ((unumber)) (number) $55 +Adding number conversion cast (unumber) $aa in *((const byte*) main::block2 + (number) 3) ← (number) $aa +Adding number conversion cast (unumber) 3 in *((const byte*) main::block2 + (number) 3) ← ((unumber)) (number) $aa +Adding number conversion cast (unumber) $c0 in (word) memoryRemap::lowerMemoryPageOffset#0 ← (number) $c0 +Adding number conversion cast (unumber) $80 in (word) memoryRemap::upperMemoryPageOffset#0 ← (number) $80 +Adding number conversion cast (unumber) 2 in *((const byte*) main::block2 + (number) 4) ← *((const byte*) main::block1 + (number) 2) +Adding number conversion cast (unumber) 4 in *((const byte*) main::block2 + (number) 4) ← *((const byte*) main::block1 + (unumber)(number) 2) +Adding number conversion cast (unumber) 1 in *((const byte*) main::block1 + (number) 5) ← *((const byte*) main::block2 + (number) 1) +Adding number conversion cast (unumber) 5 in *((const byte*) main::block1 + (number) 5) ← *((const byte*) main::block2 + (unumber)(number) 1) +Adding number conversion cast (unumber) 4 in (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (number) 4 +Adding number conversion cast (unumber) $f in (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (number) $f +Adding number conversion cast (unumber) memoryRemap::$3 in (number~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (unumber)(number) $f +Adding number conversion cast (unumber) memoryRemap::$4 in (number~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (unumber~) memoryRemap::$3 +Adding number conversion cast (unumber) $f0 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (number) $f0 +Adding number conversion cast (unumber) memoryRemap::$6 in (number~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (unumber)(number) $f0 +Adding number conversion cast (unumber) $f in (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (number) $f +Adding number conversion cast (unumber) memoryRemap::$8 in (number~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (unumber)(number) $f +Adding number conversion cast (unumber) memoryRemap::$9 in (number~) memoryRemap::$9 ← (unumber~) memoryRemap::$6 | (unumber~) memoryRemap::$8 +Adding number conversion cast (unumber) $20 in (number~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (number) $20 +Adding number conversion cast (unumber) memoryRemapBlock::$1 in (number~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (unumber)(number) $20 +Adding number conversion cast (unumber) 1 in (number~) memoryRemapBlock::$2 ← (number) 1 << (byte) memoryRemapBlock::block#0 +Adding number conversion cast (unumber) memoryRemapBlock::$2 in (number~) memoryRemapBlock::$2 ← (unumber)(number) 1 << (byte) memoryRemapBlock::block#0 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte) memoryRemapBlock::blockPage#0 ← (unumber)(number) $40 +Inlining cast (word) memoryRemapBlock::memoryPage#0 ← (unumber)(number) $100 +Inlining cast *((const byte*) main::block1 + (unumber)(number) 0) ← (unumber)(number) $55 +Inlining cast *((const byte*) main::block1 + (unumber)(number) 1) ← (unumber)(number) $aa +Inlining cast (byte) memoryRemapBlock::blockPage#1 ← (unumber)(number) $80 +Inlining cast (word) memoryRemapBlock::memoryPage#1 ← (unumber)(number) $100 +Inlining cast *((const byte*) main::block2 + (unumber)(number) 2) ← (unumber)(number) $55 +Inlining cast *((const byte*) main::block2 + (unumber)(number) 3) ← (unumber)(number) $aa +Inlining cast (word) memoryRemap::lowerMemoryPageOffset#0 ← (unumber)(number) $c0 +Inlining cast (word) memoryRemap::upperMemoryPageOffset#0 ← (unumber)(number) $80 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 16384 +Simplifying constant pointer cast (byte*) 32768 +Simplifying constant pointer cast (byte*) 252 +Simplifying constant pointer cast (byte*) 253 +Simplifying constant pointer cast (byte*) 254 +Simplifying constant pointer cast (byte*) 255 +Simplifying constant integer cast $40 +Simplifying constant integer cast $100 +Simplifying constant integer cast $55 +Simplifying constant integer cast 0 +Simplifying constant integer cast $aa +Simplifying constant integer cast 1 +Simplifying constant integer cast $80 +Simplifying constant integer cast $100 +Simplifying constant integer cast $55 +Simplifying constant integer cast 2 +Simplifying constant integer cast $aa +Simplifying constant integer cast 3 +Simplifying constant integer cast $c0 +Simplifying constant integer cast $80 +Simplifying constant integer cast 2 +Simplifying constant integer cast 4 +Simplifying constant integer cast 1 +Simplifying constant integer cast 5 +Simplifying constant integer cast 4 +Simplifying constant integer cast $f +Simplifying constant integer cast $f0 +Simplifying constant integer cast $f +Simplifying constant integer cast $20 +Simplifying constant integer cast 1 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) $40 +Finalized unsigned number type (word) $100 +Finalized unsigned number type (byte) $55 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $aa +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) $80 +Finalized unsigned number type (word) $100 +Finalized unsigned number type (byte) $55 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) $aa +Finalized unsigned number type (byte) 3 +Finalized unsigned number type (byte) $c0 +Finalized unsigned number type (byte) $80 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) $f +Finalized unsigned number type (byte) $f0 +Finalized unsigned number type (byte) $f +Finalized unsigned number type (byte) $20 +Finalized unsigned number type (byte) 1 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to byte in (unumber~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f +Inferred type updated to byte in (unumber~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 +Inferred type updated to byte in (unumber~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 +Inferred type updated to byte in (unumber~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f +Inferred type updated to byte in (unumber~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 +Inferred type updated to byte in (unumber~) memoryRemapBlock::$1 ← (byte) memoryRemapBlock::blockPage#2 / (byte) $20 +Inferred type updated to byte in (unumber~) memoryRemapBlock::$2 ← (byte) 1 << (byte) memoryRemapBlock::block#0 +Alias memoryRemap::remapBlocks#0 = main::$2 +Alias memoryRemapBlock::pageOffset#0 = memoryRemapBlock::$0 +Alias memoryRemapBlock::block#0 = memoryRemapBlock::$1 +Alias memoryRemapBlock::blockBits#0 = memoryRemapBlock::$2 +Successful SSA optimization Pass2AliasElimination +Constant right-side identified [10] (byte) memoryRemap::remapBlocks#0 ← (const nomodify byte) MEMORYBLOCK_4000 | (const nomodify byte) MEMORYBLOCK_8000 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) memoryRemapBlock::blockPage#0 = $40 +Constant (const word) memoryRemapBlock::memoryPage#0 = $100 +Constant (const byte) memoryRemapBlock::blockPage#1 = $80 +Constant (const word) memoryRemapBlock::memoryPage#1 = $100 +Constant (const byte) memoryRemap::remapBlocks#0 = MEMORYBLOCK_4000|MEMORYBLOCK_8000 +Constant (const word) memoryRemap::lowerMemoryPageOffset#0 = $c0 +Constant (const word) memoryRemap::upperMemoryPageOffset#0 = $80 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero main::block1 in [3] *((const byte*) main::block1 + (byte) 0) ← (byte) $55 +Successful SSA optimization PassNSimplifyExpressionWithZero +Removing unused procedure __start +Removing unused procedure block __start +Removing unused procedure block __start::@1 +Removing unused procedure block __start::@return +Successful SSA optimization PassNEliminateEmptyStart +Rewriting division to use shift [29] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 / (byte) $20 +Successful SSA optimization Pass2MultiplyToShiftRewriting +Inlining constant with var siblings (const byte) memoryRemap::remapBlocks#0 +Inlining constant with var siblings (const word) memoryRemap::lowerMemoryPageOffset#0 +Inlining constant with var siblings (const word) memoryRemap::upperMemoryPageOffset#0 +Inlining constant with var siblings (const byte) memoryRemapBlock::blockPage#0 +Inlining constant with var siblings (const word) memoryRemapBlock::memoryPage#0 +Inlining constant with var siblings (const byte) memoryRemapBlock::blockPage#1 +Inlining constant with var siblings (const word) memoryRemapBlock::memoryPage#1 +Constant inlined memoryRemap::upperMemoryPageOffset#0 = (byte) $80 +Constant inlined memoryRemapBlock::blockPage#1 = (byte) $80 +Constant inlined memoryRemap::remapBlocks#0 = (const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 +Constant inlined memoryRemapBlock::blockPage#0 = (byte) $40 +Constant inlined memoryRemap::lowerMemoryPageOffset#0 = (byte) $c0 +Constant inlined memoryRemapBlock::memoryPage#1 = (word) $100 +Constant inlined memoryRemapBlock::memoryPage#0 = (word) $100 +Successful SSA optimization Pass2ConstantInlining +Consolidated array index constant in *(main::block1+1) +Consolidated array index constant in *(main::block2+2) +Consolidated array index constant in *(main::block2+3) +Consolidated array index constant in *(main::block1+2) +Consolidated array index constant in *(main::block2+4) +Consolidated array index constant in *(main::block2+1) +Consolidated array index constant in *(main::block1+5) +Successful SSA optimization Pass2ConstantAdditionElimination +Identical Phi Values (word) memoryRemapBlock::memoryPage#2 (word) $100 +Successful SSA optimization Pass2IdenticalPhiElimination +Adding NOP phi() at start of main +Adding NOP phi() at start of memoryRemapBlock::@1 +CALL GRAPH +Calls in [main] to memoryRemapBlock:1 memoryRemapBlock:4 memoryRemap:7 +Calls in [memoryRemapBlock] to memoryRemap:21 + +Created 4 initial phi equivalence classes +Coalesced [18] memoryRemap::lowerMemoryPageOffset#3 ← memoryRemap::lowerMemoryPageOffset#1 +Coalesced [19] memoryRemap::remapBlocks#3 ← memoryRemap::remapBlocks#1 +Coalesced [20] memoryRemap::upperMemoryPageOffset#3 ← memoryRemap::upperMemoryPageOffset#1 +Coalesced down to 4 phi equivalence classes +Culled Empty Block (label) memoryRemapBlock::@1 +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] phi() + [1] call memoryRemapBlock + to:main::@1 +main::@1: scope:[main] from main + [2] *((const byte*) main::block1) ← (byte) $55 + [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa + [4] call memoryRemapBlock + to:main::@2 +main::@2: scope:[main] from main::@1 + [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 + [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa + [7] call memoryRemap + to:main::@3 +main::@3: scope:[main] from main::@2 + [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) + [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) + to:main::@return +main::@return: scope:[main] from main::@3 + [10] return + to:@return + +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +memoryRemapBlock: scope:[memoryRemapBlock] from main main::@1 + [11] (byte) memoryRemapBlock::blockPage#2 ← phi( main/(byte) $40 main::@1/(byte) $80 ) + [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 + [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 + [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 + [15] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0 + [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + [18] call memoryRemap + to:memoryRemapBlock::@return +memoryRemapBlock::@return: scope:[memoryRemapBlock] from memoryRemapBlock + [19] return + to:@return + +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +memoryRemap: scope:[memoryRemap] from main::@2 memoryRemapBlock + [20] (word) memoryRemap::upperMemoryPageOffset#2 ← phi( main::@2/(byte) $80 memoryRemapBlock/(word) memoryRemap::upperMemoryPageOffset#1 ) + [20] (byte) memoryRemap::remapBlocks#2 ← phi( main::@2/(const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 memoryRemapBlock/(byte) memoryRemap::remapBlocks#1 ) + [20] (word) memoryRemap::lowerMemoryPageOffset#2 ← phi( main::@2/(byte) $c0 memoryRemapBlock/(word) memoryRemap::lowerMemoryPageOffset#1 ) + [21] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2 + [22] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 + [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 + [24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 + [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f + [26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 + [27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 + [28] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2 + [29] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 + [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 + [31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 + [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f + [33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 + [34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 + asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + to:memoryRemap::@return +memoryRemap::@return: scope:[memoryRemap] from memoryRemap + [36] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte) MEGA65_VICIV::ALPHADELAY +(byte) MEGA65_VICIV::B0PIX +(byte) MEGA65_VICIV::B0_ADDR +(byte) MEGA65_VICIV::B1PIX +(byte) MEGA65_VICIV::B1_ADDR +(byte) MEGA65_VICIV::B2PIX +(byte) MEGA65_VICIV::B2_ADDR +(byte) MEGA65_VICIV::B3PIX +(byte) MEGA65_VICIV::B3_ADDR +(byte) MEGA65_VICIV::B4PIX +(byte) MEGA65_VICIV::B4_ADDR +(byte) MEGA65_VICIV::B5PIX +(byte) MEGA65_VICIV::B5_ADDR +(byte) MEGA65_VICIV::B6PIX +(byte) MEGA65_VICIV::B6_ADDR +(byte) MEGA65_VICIV::B7PIX +(byte) MEGA65_VICIV::B7_ADDR +(byte) MEGA65_VICIV::BBDRPOS_HI +(byte) MEGA65_VICIV::BBDRPOS_LO +(byte) MEGA65_VICIV::BG_COLOR +(byte) MEGA65_VICIV::BG_COLOR1 +(byte) MEGA65_VICIV::BG_COLOR2 +(byte) MEGA65_VICIV::BG_COLOR3 +(byte) MEGA65_VICIV::BORDER_COLOR +(byte) MEGA65_VICIV::BP16ENS +(byte) MEGA65_VICIV::BPCOMP +(byte) MEGA65_VICIV::BPX +(byte) MEGA65_VICIV::BPY +(byte) MEGA65_VICIV::CHARPTR_HILO +(byte) MEGA65_VICIV::CHARPTR_LOHI +(byte) MEGA65_VICIV::CHARPTR_LOLO +(byte) MEGA65_VICIV::CHARSTEP_HI +(byte) MEGA65_VICIV::CHARSTEP_LO +(byte) MEGA65_VICIV::CHRCOUNT +(byte) MEGA65_VICIV::CHRXSCL +(byte) MEGA65_VICIV::CHRYSCL +(byte) MEGA65_VICIV::COLPTR_HI +(byte) MEGA65_VICIV::COLPTR_LO +(byte) MEGA65_VICIV::CONTROL1 +(byte) MEGA65_VICIV::CONTROL2 +(byte) MEGA65_VICIV::CONTROLA +(byte) MEGA65_VICIV::CONTROLB +(byte) MEGA65_VICIV::CONTROLC +(byte) MEGA65_VICIV::DEBUG1 +(byte) MEGA65_VICIV::DEBUGX +(byte) MEGA65_VICIV::DEBUGXY +(byte) MEGA65_VICIV::DEBUGY +(byte) MEGA65_VICIV::FNRASTER_HI +(byte) MEGA65_VICIV::FNRASTER_LO +(byte) MEGA65_VICIV::HPOS +(byte) MEGA65_VICIV::IRQ_ENABLE +(byte) MEGA65_VICIV::IRQ_STATUS +(byte) MEGA65_VICIV::KEY +(byte) MEGA65_VICIV::LIGHTPEN_X +(byte) MEGA65_VICIV::LIGHTPEN_Y +(byte) MEGA65_VICIV::MEMORY +(byte) MEGA65_VICIV::PALSEL +(byte) MEGA65_VICIV::RASLINE0 +(byte) MEGA65_VICIV::RASTER +(byte) MEGA65_VICIV::ROWCOUNT +(byte) MEGA65_VICIV::RSTCMP +(byte) MEGA65_VICIV::RSTCOMP +(byte) MEGA65_VICIV::SBPDEBUG +(byte) MEGA65_VICIV::SCRNPTR_HIHI +(byte) MEGA65_VICIV::SCRNPTR_HILO +(byte) MEGA65_VICIV::SCRNPTR_LOHI +(byte) MEGA65_VICIV::SCRNPTR_LOLO +(byte) MEGA65_VICIV::SIDBDRWD_HI +(byte) MEGA65_VICIV::SIDBDRWD_LO +(byte) MEGA65_VICIV::SPR16EN +(byte) MEGA65_VICIV::SPRALPHAVAL +(byte) MEGA65_VICIV::SPRENALPHA +(byte) MEGA65_VICIV::SPRENV400 +(byte) MEGA65_VICIV::SPRHGHT +(byte) MEGA65_VICIV::SPRHGTEN +(byte) MEGA65_VICIV::SPRITE0_COLOR +(byte) MEGA65_VICIV::SPRITE0_X +(byte) MEGA65_VICIV::SPRITE0_Y +(byte) MEGA65_VICIV::SPRITE1_COLOR +(byte) MEGA65_VICIV::SPRITE1_X +(byte) MEGA65_VICIV::SPRITE1_Y +(byte) MEGA65_VICIV::SPRITE2_COLOR +(byte) MEGA65_VICIV::SPRITE2_X +(byte) MEGA65_VICIV::SPRITE2_Y +(byte) MEGA65_VICIV::SPRITE3_COLOR +(byte) MEGA65_VICIV::SPRITE3_X +(byte) MEGA65_VICIV::SPRITE3_Y +(byte) MEGA65_VICIV::SPRITE4_COLOR +(byte) MEGA65_VICIV::SPRITE4_X +(byte) MEGA65_VICIV::SPRITE4_Y +(byte) MEGA65_VICIV::SPRITE5_COLOR +(byte) MEGA65_VICIV::SPRITE5_X +(byte) MEGA65_VICIV::SPRITE5_Y +(byte) MEGA65_VICIV::SPRITE6_COLOR +(byte) MEGA65_VICIV::SPRITE6_X +(byte) MEGA65_VICIV::SPRITE6_Y +(byte) MEGA65_VICIV::SPRITE7_COLOR +(byte) MEGA65_VICIV::SPRITE7_X +(byte) MEGA65_VICIV::SPRITE7_Y +(byte) MEGA65_VICIV::SPRITES_BG_COLLISION +(byte) MEGA65_VICIV::SPRITES_COLLISION +(byte) MEGA65_VICIV::SPRITES_ENABLE +(byte) MEGA65_VICIV::SPRITES_EXPAND_X +(byte) MEGA65_VICIV::SPRITES_EXPAND_Y +(byte) MEGA65_VICIV::SPRITES_MC +(byte) MEGA65_VICIV::SPRITES_MCOLOR1 +(byte) MEGA65_VICIV::SPRITES_MCOLOR2 +(byte) MEGA65_VICIV::SPRITES_PRIORITY +(byte) MEGA65_VICIV::SPRITES_XMSB +(byte) MEGA65_VICIV::SPRPTRADR_HILO +(byte) MEGA65_VICIV::SPRPTRADR_LOHI +(byte) MEGA65_VICIV::SPRPTRADR_LOLO +(byte) MEGA65_VICIV::SPRX64EN +(byte) MEGA65_VICIV::SPRXSMSBS +(byte) MEGA65_VICIV::SPRYSMSBSM +(byte) MEGA65_VICIV::SRPYMSBS +(byte) MEGA65_VICIV::SYNCPOL +(byte) MEGA65_VICIV::TBDRPOS_HI +(byte) MEGA65_VICIV::TBDRPOS_LO +(byte) MEGA65_VICIV::TEXTXPOS_HI +(byte) MEGA65_VICIV::TEXTXPOS_LO +(byte) MEGA65_VICIV::TEXTYPOS_HI +(byte) MEGA65_VICIV::TEXTYPOS_LO +(byte) MEGA65_VICIV::UNUSED +(byte) MEGA65_VICIV::VPOS +(byte) MEGA65_VICIV::VSYNDEL +(byte) MEGA65_VICIV::XPOS_HI +(byte) MEGA65_VICIV::XPOS_LO +(byte) MOS4569_VICIII::B0PIX +(byte) MOS4569_VICIII::B0_ADDR +(byte) MOS4569_VICIII::B1PIX +(byte) MOS4569_VICIII::B1_ADDR +(byte) MOS4569_VICIII::B2PIX +(byte) MOS4569_VICIII::B2_ADDR +(byte) MOS4569_VICIII::B3PIX +(byte) MOS4569_VICIII::B3_ADDR +(byte) MOS4569_VICIII::B4PIX +(byte) MOS4569_VICIII::B4_ADDR +(byte) MOS4569_VICIII::B5PIX +(byte) MOS4569_VICIII::B5_ADDR +(byte) MOS4569_VICIII::B6PIX +(byte) MOS4569_VICIII::B6_ADDR +(byte) MOS4569_VICIII::B7PIX +(byte) MOS4569_VICIII::B7_ADDR +(byte) MOS4569_VICIII::BG_COLOR +(byte) MOS4569_VICIII::BG_COLOR1 +(byte) MOS4569_VICIII::BG_COLOR2 +(byte) MOS4569_VICIII::BG_COLOR3 +(byte) MOS4569_VICIII::BORDER_COLOR +(byte) MOS4569_VICIII::BPCOMP +(byte) MOS4569_VICIII::BPX +(byte) MOS4569_VICIII::BPY +(byte) MOS4569_VICIII::CONTROL1 +(byte) MOS4569_VICIII::CONTROL2 +(byte) MOS4569_VICIII::CONTROLA +(byte) MOS4569_VICIII::CONTROLB +(byte) MOS4569_VICIII::HPOS +(byte) MOS4569_VICIII::IRQ_ENABLE +(byte) MOS4569_VICIII::IRQ_STATUS +(byte) MOS4569_VICIII::KEY +(byte) MOS4569_VICIII::LIGHTPEN_X +(byte) MOS4569_VICIII::LIGHTPEN_Y +(byte) MOS4569_VICIII::MEMORY +(byte) MOS4569_VICIII::RASTER +(byte) MOS4569_VICIII::SPRITE0_COLOR +(byte) MOS4569_VICIII::SPRITE0_X +(byte) MOS4569_VICIII::SPRITE0_Y +(byte) MOS4569_VICIII::SPRITE1_COLOR +(byte) MOS4569_VICIII::SPRITE1_X +(byte) MOS4569_VICIII::SPRITE1_Y +(byte) MOS4569_VICIII::SPRITE2_COLOR +(byte) MOS4569_VICIII::SPRITE2_X +(byte) MOS4569_VICIII::SPRITE2_Y +(byte) MOS4569_VICIII::SPRITE3_COLOR +(byte) MOS4569_VICIII::SPRITE3_X +(byte) MOS4569_VICIII::SPRITE3_Y +(byte) MOS4569_VICIII::SPRITE4_COLOR +(byte) MOS4569_VICIII::SPRITE4_X +(byte) MOS4569_VICIII::SPRITE4_Y +(byte) MOS4569_VICIII::SPRITE5_COLOR +(byte) MOS4569_VICIII::SPRITE5_X +(byte) MOS4569_VICIII::SPRITE5_Y +(byte) MOS4569_VICIII::SPRITE6_COLOR +(byte) MOS4569_VICIII::SPRITE6_X +(byte) MOS4569_VICIII::SPRITE6_Y +(byte) MOS4569_VICIII::SPRITE7_COLOR +(byte) MOS4569_VICIII::SPRITE7_X +(byte) MOS4569_VICIII::SPRITE7_Y +(byte) MOS4569_VICIII::SPRITES_BG_COLLISION +(byte) MOS4569_VICIII::SPRITES_COLLISION +(byte) MOS4569_VICIII::SPRITES_ENABLE +(byte) MOS4569_VICIII::SPRITES_EXPAND_X +(byte) MOS4569_VICIII::SPRITES_EXPAND_Y +(byte) MOS4569_VICIII::SPRITES_MC +(byte) MOS4569_VICIII::SPRITES_MCOLOR1 +(byte) MOS4569_VICIII::SPRITES_MCOLOR2 +(byte) MOS4569_VICIII::SPRITES_PRIORITY +(byte) MOS4569_VICIII::SPRITES_XMSB +(byte) MOS4569_VICIII::UNUSED +(byte) MOS4569_VICIII::VPOS +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(void()) main() +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +(byte~) memoryRemap::$0 202.0 +(byte~) memoryRemap::$1 67.33333333333333 +(byte~) memoryRemap::$2 202.0 +(byte~) memoryRemap::$3 202.0 +(byte~) memoryRemap::$4 202.0 +(byte~) memoryRemap::$5 202.0 +(byte~) memoryRemap::$6 67.33333333333333 +(byte~) memoryRemap::$7 202.0 +(byte~) memoryRemap::$8 202.0 +(byte~) memoryRemap::$9 202.0 +(word) memoryRemap::lowerMemoryPageOffset +(word) memoryRemap::lowerMemoryPageOffset#1 11.0 +(word) memoryRemap::lowerMemoryPageOffset#2 53.25 +(byte) memoryRemap::remapBlocks +(byte) memoryRemap::remapBlocks#1 7.333333333333333 +(byte) memoryRemap::remapBlocks#2 21.299999999999997 +(word) memoryRemap::upperMemoryPageOffset +(word) memoryRemap::upperMemoryPageOffset#1 22.0 +(word) memoryRemap::upperMemoryPageOffset#2 19.363636363636363 +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +(byte) memoryRemapBlock::block +(byte) memoryRemapBlock::block#0 22.0 +(byte) memoryRemapBlock::blockBits +(byte) memoryRemapBlock::blockBits#0 22.0 +(byte) memoryRemapBlock::blockPage +(byte) memoryRemapBlock::blockPage#2 11.0 +(word) memoryRemapBlock::memoryPage +(word) memoryRemapBlock::pageOffset +(word) memoryRemapBlock::pageOffset#0 6.6000000000000005 + +Initial phi equivalence classes +[ memoryRemapBlock::blockPage#2 ] +[ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] +[ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +[ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +Added variable memoryRemapBlock::pageOffset#0 to live range equivalence class [ memoryRemapBlock::pageOffset#0 ] +Added variable memoryRemapBlock::block#0 to live range equivalence class [ memoryRemapBlock::block#0 ] +Added variable memoryRemapBlock::blockBits#0 to live range equivalence class [ memoryRemapBlock::blockBits#0 ] +Added variable memoryRemap::$0 to live range equivalence class [ memoryRemap::$0 ] +Added variable memoryRemap::$1 to live range equivalence class [ memoryRemap::$1 ] +Added variable memoryRemap::$2 to live range equivalence class [ memoryRemap::$2 ] +Added variable memoryRemap::$3 to live range equivalence class [ memoryRemap::$3 ] +Added variable memoryRemap::$4 to live range equivalence class [ memoryRemap::$4 ] +Added variable memoryRemap::$5 to live range equivalence class [ memoryRemap::$5 ] +Added variable memoryRemap::$6 to live range equivalence class [ memoryRemap::$6 ] +Added variable memoryRemap::$7 to live range equivalence class [ memoryRemap::$7 ] +Added variable memoryRemap::$8 to live range equivalence class [ memoryRemap::$8 ] +Added variable memoryRemap::$9 to live range equivalence class [ memoryRemap::$9 ] +Complete equivalence classes +[ memoryRemapBlock::blockPage#2 ] +[ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] +[ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +[ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +[ memoryRemapBlock::pageOffset#0 ] +[ memoryRemapBlock::block#0 ] +[ memoryRemapBlock::blockBits#0 ] +[ memoryRemap::$0 ] +[ memoryRemap::$1 ] +[ memoryRemap::$2 ] +[ memoryRemap::$3 ] +[ memoryRemap::$4 ] +[ memoryRemap::$5 ] +[ memoryRemap::$6 ] +[ memoryRemap::$7 ] +[ memoryRemap::$8 ] +[ memoryRemap::$9 ] +Allocated zp[1]:2 [ memoryRemapBlock::blockPage#2 ] +Allocated zp[2]:3 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] +Allocated zp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Allocated zp[2]:6 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +Allocated zp[2]:8 [ memoryRemapBlock::pageOffset#0 ] +Allocated zp[1]:10 [ memoryRemapBlock::block#0 ] +Allocated zp[1]:11 [ memoryRemapBlock::blockBits#0 ] +Allocated zp[1]:12 [ memoryRemap::$0 ] +Allocated zp[1]:13 [ memoryRemap::$1 ] +Allocated zp[1]:14 [ memoryRemap::$2 ] +Allocated zp[1]:15 [ memoryRemap::$3 ] +Allocated zp[1]:16 [ memoryRemap::$4 ] +Allocated zp[1]:17 [ memoryRemap::$5 ] +Allocated zp[1]:18 [ memoryRemap::$6 ] +Allocated zp[1]:19 [ memoryRemap::$7 ] +Allocated zp[1]:20 [ memoryRemap::$8 ] +Allocated zp[1]:21 [ memoryRemap::$9 ] + +INITIAL ASM +Target platform is mega65 / MEGA45GS02 + // File Comments +// Test the MAP instruction for remapping memory +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf + // Upstart +.cpu _45gs02 + // MEGA65 platform PRG executable starting in MEGA65 mode. +.file [name="memorymap-test.prg", type="prg", segments="Program"] +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$2001] +.segmentdef Code [start=$2017] +.segmentdef Data [startAfter="Code"] +.segment Basic +.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 +.byte $15, $20, $14, $00, $9e, $20 // 20 SYS +.text toIntString(main) // NNNN +.byte $00, $00, $00 // + // Global Constants & labels + // Bit representing 8K block #2 of the 64K addressable memory ($4000-$5fff) + .const MEMORYBLOCK_4000 = 4 + // Bit representing 8K block #4 of the 64K addressable memory ($8000-$9fff) + .const MEMORYBLOCK_8000 = $10 +.segment Code + // main +main: { + .label block1 = $4000 + .label block2 = $8000 + // [1] call memoryRemapBlock + // Remap [$4000-$5fff] to point to [$10000-$11fff] + // [11] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] + memoryRemapBlock_from_main: + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $40 [phi:main->memoryRemapBlock#0] -- vbuz1=vbuc1 + lda #$40 + sta.z memoryRemapBlock.blockPage + jsr memoryRemapBlock + jmp __b1 + // main::@1 + __b1: + // [2] *((const byte*) main::block1) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaa into $10000 + lda #$55 + sta block1 + // [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block1+1 + // [4] call memoryRemapBlock + // Remap [$8000-$9fff] to point to [$10000-$11fff] + // [11] phi from main::@1 to memoryRemapBlock [phi:main::@1->memoryRemapBlock] + memoryRemapBlock_from___b1: + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $80 [phi:main::@1->memoryRemapBlock#0] -- vbuz1=vbuc1 + lda #$80 + sta.z memoryRemapBlock.blockPage + jsr memoryRemapBlock + jmp __b2 + // main::@2 + __b2: + // [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaainto $10002 + lda #$55 + sta block2+2 + // [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block2+3 + // [7] call memoryRemap + // Remap [$4000-$5fff] and [$8000-$9fff] to both point to [$10000-$11fff] (notice usage of page offsets) + // [20] phi from main::@2 to memoryRemap [phi:main::@2->memoryRemap] + memoryRemap_from___b2: + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (byte) $80 [phi:main::@2->memoryRemap#0] -- vwuz1=vbuc1 + lda #<$80 + sta.z memoryRemap.upperMemoryPageOffset + lda #>$80 + sta.z memoryRemap.upperMemoryPageOffset+1 + // [20] phi (byte) memoryRemap::remapBlocks#2 = (const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 [phi:main::@2->memoryRemap#1] -- vbuz1=vbuc1 + lda #MEMORYBLOCK_4000|MEMORYBLOCK_8000 + sta.z memoryRemap.remapBlocks + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (byte) $c0 [phi:main::@2->memoryRemap#2] -- vwuz1=vbuc1 + lda #<$c0 + sta.z memoryRemap.lowerMemoryPageOffset + lda #>$c0 + sta.z memoryRemap.lowerMemoryPageOffset+1 + jsr memoryRemap + jmp __b3 + // main::@3 + __b3: + // [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) -- _deref_pbuc1=_deref_pbuc2 + // Put 0x55, 0xaa into $10004 in a convoluted way + lda block1+2 + sta block2+4 + // [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 + lda block2+1 + sta block1+5 + jmp __breturn + // main::@return + __breturn: + // [10] return + rts +} + // memoryRemapBlock +// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. +// blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) +// memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. +// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. +// memoryRemapBlock(byte zp(2) blockPage) +memoryRemapBlock: { + .label pageOffset = 8 + .label block = $a + .label blockBits = $b + .label blockPage = 2 + // [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 -- vwuz1=vwuc1_minus_vbuz2 + sec + lda #<$100 + sbc.z blockPage + sta.z pageOffset + lda #>$100 + sbc #0 + sta.z pageOffset+1 + // [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 -- vbuz1=vbuz2_ror_5 + lda.z blockPage + lsr + lsr + lsr + lsr + lsr + sta.z block + // [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 -- vbuz1=vbuc1_rol_vbuz2 + lda #1 + ldy.z block + cpy #0 + beq !e+ + !: + asl + dey + bne !- + !e: + sta.z blockBits + // [15] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0 -- vbuz1=vbuz2 + lda.z blockBits + sta.z memoryRemap.remapBlocks + // [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 -- vwuz1=vwuz2 + lda.z pageOffset + sta.z memoryRemap.lowerMemoryPageOffset + lda.z pageOffset+1 + sta.z memoryRemap.lowerMemoryPageOffset+1 + // [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 -- vwuz1=vwuz2 + lda.z pageOffset + sta.z memoryRemap.upperMemoryPageOffset + lda.z pageOffset+1 + sta.z memoryRemap.upperMemoryPageOffset+1 + // [18] call memoryRemap + // [20] phi from memoryRemapBlock to memoryRemap [phi:memoryRemapBlock->memoryRemap] + memoryRemap_from_memoryRemapBlock: + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (word) memoryRemap::upperMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#0] -- register_copy + // [20] phi (byte) memoryRemap::remapBlocks#2 = (byte) memoryRemap::remapBlocks#1 [phi:memoryRemapBlock->memoryRemap#1] -- register_copy + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (word) memoryRemap::lowerMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#2] -- register_copy + jsr memoryRemap + jmp __breturn + // memoryRemapBlock::@return + __breturn: + // [19] return + rts +} + // memoryRemap +// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block. +// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block +// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000. +// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000. +// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000. +// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000. +// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000. +// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000. +// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000. +// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000. +// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100. +// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000. +// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000. +// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000. +// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000 +// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000. +// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000. +// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000. +// memoryRemap(byte zp(5) remapBlocks, word zp(3) lowerMemoryPageOffset, word zp(6) upperMemoryPageOffset) +memoryRemap: { + .label aVal = $fc + .label xVal = $fd + .label yVal = $fe + .label zVal = $ff + .label __0 = $c + .label __1 = $d + .label __2 = $e + .label __3 = $f + .label __4 = $10 + .label __5 = $11 + .label __6 = $12 + .label __7 = $13 + .label __8 = $14 + .label __9 = $15 + .label remapBlocks = 5 + .label lowerMemoryPageOffset = 3 + .label upperMemoryPageOffset = 6 + // [21] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2 -- vbuz1=_lo_vwuz2 + lda.z lowerMemoryPageOffset + sta.z __0 + // [22] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuz1 + lda.z __0 + sta aVal + // [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 -- vbuz1=vbuz2_rol_4 + lda.z remapBlocks + asl + asl + asl + asl + sta.z __1 + // [24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 -- vbuz1=_hi_vwuz2 + lda.z lowerMemoryPageOffset+1 + sta.z __2 + // [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 + lda #$f + and.z __2 + sta.z __3 + // [26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuz1=vbuz2_bor_vbuz3 + lda.z __1 + ora.z __3 + sta.z __4 + // [27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuz1 + lda.z __4 + sta xVal + // [28] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2 -- vbuz1=_lo_vwuz2 + lda.z upperMemoryPageOffset + sta.z __5 + // [29] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuz1 + lda.z __5 + sta yVal + // [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 -- vbuz1=vbuz2_band_vbuc1 + lda #$f0 + and.z remapBlocks + sta.z __6 + // [31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 -- vbuz1=_hi_vwuz2 + lda.z upperMemoryPageOffset+1 + sta.z __7 + // [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuz1=vbuz2_band_vbuc1 + lda #$f + and.z __7 + sta.z __8 + // [33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuz1=vbuz2_bor_vbuz3 + lda.z __6 + ora.z __8 + sta.z __9 + // [34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuz1 + lda.z __9 + sta zVal + // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + lda aVal + ldx xVal + ldy yVal + ldz zVal + map + eom + jmp __breturn + // memoryRemap::@return + __breturn: + // [36] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [2] *((const byte*) main::block1) ← (byte) $55 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa [ ] ( [ ] { } ) always clobbers reg byte a +Statement [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) [ ] ( [ ] { } ) always clobbers reg byte a +Statement [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) [ ] ( [ ] { } ) always clobbers reg byte a +Statement [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:2 [ memoryRemapBlock::blockPage#2 ] +Statement [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Statement [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] ( memoryRemapBlock:1 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] ( memoryRemap:7 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:7 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:13 [ memoryRemap::$1 ] +Statement [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] ( memoryRemap:7 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:7 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::$6 memoryRemap::$8 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::$6 memoryRemap::$8 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp[1]:18 [ memoryRemap::$6 ] +Statement asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } always clobbers reg byte a reg byte x reg byte y reg byte z +Statement [2] *((const byte*) main::block1) ← (byte) $55 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa [ ] ( [ ] { } ) always clobbers reg byte a +Statement [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa [ ] ( [ ] { } ) always clobbers reg byte a +Statement [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) [ ] ( [ ] { } ) always clobbers reg byte a +Statement [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) [ ] ( [ ] { } ) always clobbers reg byte a +Statement [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::blockPage#2 memoryRemapBlock::pageOffset#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::block#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemapBlock::blockBits#0 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] ( memoryRemapBlock:1 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemapBlock::pageOffset#0 memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] ( memoryRemapBlock:1 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4 [ memoryRemap::remapBlocks#1 memoryRemap::lowerMemoryPageOffset#1 memoryRemap::upperMemoryPageOffset#1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] ( memoryRemap:7 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] ( memoryRemap:7 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::remapBlocks#2 memoryRemap::upperMemoryPageOffset#2 memoryRemap::$1 memoryRemap::$3 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] ( memoryRemap:7 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::$6 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f [ memoryRemap::$6 memoryRemap::$8 ] ( memoryRemap:7 [ memoryRemap::$6 memoryRemap::$8 ] { } memoryRemapBlock:1::memoryRemap:18 [ memoryRemap::$6 memoryRemap::$8 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } memoryRemapBlock:4::memoryRemap:18 [ memoryRemap::$6 memoryRemap::$8 ] { { memoryRemap::remapBlocks#1 = memoryRemap::remapBlocks#2 memoryRemapBlock::blockBits#0 } { memoryRemap::upperMemoryPageOffset#1 = memoryRemap::upperMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 } } ) always clobbers reg byte a +Statement asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } always clobbers reg byte a reg byte x reg byte y reg byte z +Potential registers zp[1]:2 [ memoryRemapBlock::blockPage#2 ] : zp[1]:2 , reg byte x , reg byte y , reg byte z , +Potential registers zp[2]:3 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] : zp[2]:3 , +Potential registers zp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] : zp[1]:5 , reg byte x , reg byte y , reg byte z , +Potential registers zp[2]:6 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] : zp[2]:6 , +Potential registers zp[2]:8 [ memoryRemapBlock::pageOffset#0 ] : zp[2]:8 , +Potential registers zp[1]:10 [ memoryRemapBlock::block#0 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:11 [ memoryRemapBlock::blockBits#0 ] : zp[1]:11 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:12 [ memoryRemap::$0 ] : zp[1]:12 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:13 [ memoryRemap::$1 ] : zp[1]:13 , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:14 [ memoryRemap::$2 ] : zp[1]:14 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:15 [ memoryRemap::$3 ] : zp[1]:15 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:16 [ memoryRemap::$4 ] : zp[1]:16 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:17 [ memoryRemap::$5 ] : zp[1]:17 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:18 [ memoryRemap::$6 ] : zp[1]:18 , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:19 [ memoryRemap::$7 ] : zp[1]:19 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:20 [ memoryRemap::$8 ] : zp[1]:20 , reg byte a , reg byte x , reg byte y , reg byte z , +Potential registers zp[1]:21 [ memoryRemap::$9 ] : zp[1]:21 , reg byte a , reg byte x , reg byte y , reg byte z , + +REGISTER UPLIFT SCOPES +Uplift Scope [memoryRemap] 202: zp[1]:12 [ memoryRemap::$0 ] 202: zp[1]:14 [ memoryRemap::$2 ] 202: zp[1]:15 [ memoryRemap::$3 ] 202: zp[1]:16 [ memoryRemap::$4 ] 202: zp[1]:17 [ memoryRemap::$5 ] 202: zp[1]:19 [ memoryRemap::$7 ] 202: zp[1]:20 [ memoryRemap::$8 ] 202: zp[1]:21 [ memoryRemap::$9 ] 67.33: zp[1]:13 [ memoryRemap::$1 ] 67.33: zp[1]:18 [ memoryRemap::$6 ] 64.25: zp[2]:3 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] 41.36: zp[2]:6 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] 28.63: zp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Uplift Scope [memoryRemapBlock] 22: zp[1]:10 [ memoryRemapBlock::block#0 ] 22: zp[1]:11 [ memoryRemapBlock::blockBits#0 ] 11: zp[1]:2 [ memoryRemapBlock::blockPage#2 ] 6.6: zp[2]:8 [ memoryRemapBlock::pageOffset#0 ] +Uplift Scope [MOS6526_CIA] +Uplift Scope [MOS6569_VICII] +Uplift Scope [MOS6581_SID] +Uplift Scope [MOS4569_VICIII] +Uplift Scope [MEGA65_VICIV] +Uplift Scope [main] +Uplift Scope [] + +Uplifting [memoryRemap] best 326 combination reg byte a [ memoryRemap::$0 ] reg byte a [ memoryRemap::$2 ] reg byte a [ memoryRemap::$3 ] zp[1]:16 [ memoryRemap::$4 ] zp[1]:17 [ memoryRemap::$5 ] zp[1]:19 [ memoryRemap::$7 ] zp[1]:20 [ memoryRemap::$8 ] zp[1]:21 [ memoryRemap::$9 ] zp[1]:13 [ memoryRemap::$1 ] zp[1]:18 [ memoryRemap::$6 ] zp[2]:3 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] zp[2]:6 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] zp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Limited combination testing to 100 combinations of 25000000 possible. +Uplifting [memoryRemapBlock] best 312 combination reg byte a [ memoryRemapBlock::block#0 ] reg byte a [ memoryRemapBlock::blockBits#0 ] reg byte x [ memoryRemapBlock::blockPage#2 ] zp[2]:8 [ memoryRemapBlock::pageOffset#0 ] +Uplifting [MOS6526_CIA] best 312 combination +Uplifting [MOS6569_VICII] best 312 combination +Uplifting [MOS6581_SID] best 312 combination +Uplifting [MOS4569_VICIII] best 312 combination +Uplifting [MEGA65_VICIV] best 312 combination +Uplifting [main] best 312 combination +Uplifting [] best 312 combination +Attempting to uplift remaining variables inzp[1]:16 [ memoryRemap::$4 ] +Uplifting [memoryRemap] best 306 combination reg byte a [ memoryRemap::$4 ] +Attempting to uplift remaining variables inzp[1]:17 [ memoryRemap::$5 ] +Uplifting [memoryRemap] best 300 combination reg byte a [ memoryRemap::$5 ] +Attempting to uplift remaining variables inzp[1]:19 [ memoryRemap::$7 ] +Uplifting [memoryRemap] best 294 combination reg byte a [ memoryRemap::$7 ] +Attempting to uplift remaining variables inzp[1]:20 [ memoryRemap::$8 ] +Uplifting [memoryRemap] best 288 combination reg byte a [ memoryRemap::$8 ] +Attempting to uplift remaining variables inzp[1]:21 [ memoryRemap::$9 ] +Uplifting [memoryRemap] best 282 combination reg byte a [ memoryRemap::$9 ] +Attempting to uplift remaining variables inzp[1]:13 [ memoryRemap::$1 ] +Uplifting [memoryRemap] best 282 combination zp[1]:13 [ memoryRemap::$1 ] +Attempting to uplift remaining variables inzp[1]:18 [ memoryRemap::$6 ] +Uplifting [memoryRemap] best 282 combination zp[1]:18 [ memoryRemap::$6 ] +Attempting to uplift remaining variables inzp[1]:5 [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Uplifting [memoryRemap] best 273 combination reg byte z [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +Coalescing zero page register [ zp[2]:3 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 ] ] with [ zp[2]:8 [ memoryRemapBlock::pageOffset#0 ] ] - score: 1 +Allocated (was zp[2]:3) zp[2]:2 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 ] +Allocated (was zp[2]:6) zp[2]:4 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +Allocated (was zp[1]:13) zp[1]:6 [ memoryRemap::$1 ] +Allocated (was zp[1]:18) zp[1]:7 [ memoryRemap::$6 ] + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test the MAP instruction for remapping memory +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf + // Upstart +.cpu _45gs02 + // MEGA65 platform PRG executable starting in MEGA65 mode. +.file [name="memorymap-test.prg", type="prg", segments="Program"] +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$2001] +.segmentdef Code [start=$2017] +.segmentdef Data [startAfter="Code"] +.segment Basic +.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 +.byte $15, $20, $14, $00, $9e, $20 // 20 SYS +.text toIntString(main) // NNNN +.byte $00, $00, $00 // + // Global Constants & labels + // Bit representing 8K block #2 of the 64K addressable memory ($4000-$5fff) + .const MEMORYBLOCK_4000 = 4 + // Bit representing 8K block #4 of the 64K addressable memory ($8000-$9fff) + .const MEMORYBLOCK_8000 = $10 +.segment Code + // main +main: { + .label block1 = $4000 + .label block2 = $8000 + // [1] call memoryRemapBlock + // Remap [$4000-$5fff] to point to [$10000-$11fff] + // [11] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] + memoryRemapBlock_from_main: + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $40 [phi:main->memoryRemapBlock#0] -- vbuxx=vbuc1 + ldx #$40 + jsr memoryRemapBlock + jmp __b1 + // main::@1 + __b1: + // [2] *((const byte*) main::block1) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaa into $10000 + lda #$55 + sta block1 + // [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block1+1 + // [4] call memoryRemapBlock + // Remap [$8000-$9fff] to point to [$10000-$11fff] + // [11] phi from main::@1 to memoryRemapBlock [phi:main::@1->memoryRemapBlock] + memoryRemapBlock_from___b1: + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $80 [phi:main::@1->memoryRemapBlock#0] -- vbuxx=vbuc1 + ldx #$80 + jsr memoryRemapBlock + jmp __b2 + // main::@2 + __b2: + // [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaainto $10002 + lda #$55 + sta block2+2 + // [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block2+3 + // [7] call memoryRemap + // Remap [$4000-$5fff] and [$8000-$9fff] to both point to [$10000-$11fff] (notice usage of page offsets) + // [20] phi from main::@2 to memoryRemap [phi:main::@2->memoryRemap] + memoryRemap_from___b2: + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (byte) $80 [phi:main::@2->memoryRemap#0] -- vwuz1=vbuc1 + lda #<$80 + sta.z memoryRemap.upperMemoryPageOffset + lda #>$80 + sta.z memoryRemap.upperMemoryPageOffset+1 + // [20] phi (byte) memoryRemap::remapBlocks#2 = (const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 [phi:main::@2->memoryRemap#1] -- vbuzz=vbuc1 + ldz #MEMORYBLOCK_4000|MEMORYBLOCK_8000 + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (byte) $c0 [phi:main::@2->memoryRemap#2] -- vwuz1=vbuc1 + lda #<$c0 + sta.z memoryRemap.lowerMemoryPageOffset + lda #>$c0 + sta.z memoryRemap.lowerMemoryPageOffset+1 + jsr memoryRemap + jmp __b3 + // main::@3 + __b3: + // [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) -- _deref_pbuc1=_deref_pbuc2 + // Put 0x55, 0xaa into $10004 in a convoluted way + lda block1+2 + sta block2+4 + // [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 + lda block2+1 + sta block1+5 + jmp __breturn + // main::@return + __breturn: + // [10] return + rts +} + // memoryRemapBlock +// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. +// blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) +// memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. +// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. +// memoryRemapBlock(byte register(X) blockPage) +memoryRemapBlock: { + .label pageOffset = 2 + // [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 -- vwuz1=vwuc1_minus_vbuxx + stx.z $ff + lda #<$100 + sec + sbc.z $ff + sta.z pageOffset + lda #>$100 + sbc #0 + sta.z pageOffset+1 + // [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 -- vbuaa=vbuxx_ror_5 + txa + lsr + lsr + lsr + lsr + lsr + // [14] (byte) memoryRemapBlock::blockBits#0 ← (byte) 1 << (byte) memoryRemapBlock::block#0 -- vbuaa=vbuc1_rol_vbuaa + tay + lda #1 + cpy #0 + beq !e+ + !: + asl + dey + bne !- + !e: + // [15] (byte) memoryRemap::remapBlocks#1 ← (byte) memoryRemapBlock::blockBits#0 -- vbuzz=vbuaa + taz + // [16] (word) memoryRemap::lowerMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 + // [17] (word) memoryRemap::upperMemoryPageOffset#1 ← (word) memoryRemapBlock::pageOffset#0 -- vwuz1=vwuz2 + lda.z pageOffset + sta.z memoryRemap.upperMemoryPageOffset + lda.z pageOffset+1 + sta.z memoryRemap.upperMemoryPageOffset+1 + // [18] call memoryRemap + // [20] phi from memoryRemapBlock to memoryRemap [phi:memoryRemapBlock->memoryRemap] + memoryRemap_from_memoryRemapBlock: + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (word) memoryRemap::upperMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#0] -- register_copy + // [20] phi (byte) memoryRemap::remapBlocks#2 = (byte) memoryRemap::remapBlocks#1 [phi:memoryRemapBlock->memoryRemap#1] -- register_copy + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (word) memoryRemap::lowerMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#2] -- register_copy + jsr memoryRemap + jmp __breturn + // memoryRemapBlock::@return + __breturn: + // [19] return + rts +} + // memoryRemap +// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block. +// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block +// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000. +// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000. +// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000. +// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000. +// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000. +// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000. +// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000. +// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000. +// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100. +// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000. +// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000. +// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000. +// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000 +// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000. +// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000. +// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000. +// memoryRemap(byte register(Z) remapBlocks, word zp(2) lowerMemoryPageOffset, word zp(4) upperMemoryPageOffset) +memoryRemap: { + .label aVal = $fc + .label xVal = $fd + .label yVal = $fe + .label zVal = $ff + .label __1 = 6 + .label __6 = 7 + .label lowerMemoryPageOffset = 2 + .label upperMemoryPageOffset = 4 + // [21] (byte~) memoryRemap::$0 ← < (word) memoryRemap::lowerMemoryPageOffset#2 -- vbuaa=_lo_vwuz1 + lda.z lowerMemoryPageOffset + // [22] *((const byte*) memoryRemap::aVal) ← (byte~) memoryRemap::$0 -- _deref_pbuc1=vbuaa + sta aVal + // [23] (byte~) memoryRemap::$1 ← (byte) memoryRemap::remapBlocks#2 << (byte) 4 -- vbuz1=vbuzz_rol_4 + tza + asl + asl + asl + asl + sta.z __1 + // [24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 -- vbuaa=_hi_vwuz1 + lda.z lowerMemoryPageOffset+1 + // [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + and #$f + // [26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa + ora.z __1 + // [27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa + sta xVal + // [28] (byte~) memoryRemap::$5 ← < (word) memoryRemap::upperMemoryPageOffset#2 -- vbuaa=_lo_vwuz1 + lda.z upperMemoryPageOffset + // [29] *((const byte*) memoryRemap::yVal) ← (byte~) memoryRemap::$5 -- _deref_pbuc1=vbuaa + sta yVal + // [30] (byte~) memoryRemap::$6 ← (byte) memoryRemap::remapBlocks#2 & (byte) $f0 -- vbuz1=vbuzz_band_vbuc1 + tza + and #$f0 + sta.z __6 + // [31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 -- vbuaa=_hi_vwuz1 + lda.z upperMemoryPageOffset+1 + // [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + and #$f + // [33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa + ora.z __6 + // [34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa + sta zVal + // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + lda aVal + ldx xVal + ldy yVal + ldz zVal + map + eom + jmp __breturn + // memoryRemap::@return + __breturn: + // [36] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __b2 +Removing instruction jmp __b3 +Removing instruction jmp __breturn +Removing instruction jmp __breturn +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction memoryRemapBlock_from_main: +Removing instruction __b1: +Removing instruction memoryRemapBlock_from___b1: +Removing instruction __b2: +Removing instruction memoryRemap_from___b2: +Removing instruction __b3: +Removing instruction __breturn: +Removing instruction memoryRemap_from_memoryRemapBlock: +Removing instruction __breturn: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(byte) MEGA65_VICIV::ALPHADELAY +(byte) MEGA65_VICIV::B0PIX +(byte) MEGA65_VICIV::B0_ADDR +(byte) MEGA65_VICIV::B1PIX +(byte) MEGA65_VICIV::B1_ADDR +(byte) MEGA65_VICIV::B2PIX +(byte) MEGA65_VICIV::B2_ADDR +(byte) MEGA65_VICIV::B3PIX +(byte) MEGA65_VICIV::B3_ADDR +(byte) MEGA65_VICIV::B4PIX +(byte) MEGA65_VICIV::B4_ADDR +(byte) MEGA65_VICIV::B5PIX +(byte) MEGA65_VICIV::B5_ADDR +(byte) MEGA65_VICIV::B6PIX +(byte) MEGA65_VICIV::B6_ADDR +(byte) MEGA65_VICIV::B7PIX +(byte) MEGA65_VICIV::B7_ADDR +(byte) MEGA65_VICIV::BBDRPOS_HI +(byte) MEGA65_VICIV::BBDRPOS_LO +(byte) MEGA65_VICIV::BG_COLOR +(byte) MEGA65_VICIV::BG_COLOR1 +(byte) MEGA65_VICIV::BG_COLOR2 +(byte) MEGA65_VICIV::BG_COLOR3 +(byte) MEGA65_VICIV::BORDER_COLOR +(byte) MEGA65_VICIV::BP16ENS +(byte) MEGA65_VICIV::BPCOMP +(byte) MEGA65_VICIV::BPX +(byte) MEGA65_VICIV::BPY +(byte) MEGA65_VICIV::CHARPTR_HILO +(byte) MEGA65_VICIV::CHARPTR_LOHI +(byte) MEGA65_VICIV::CHARPTR_LOLO +(byte) MEGA65_VICIV::CHARSTEP_HI +(byte) MEGA65_VICIV::CHARSTEP_LO +(byte) MEGA65_VICIV::CHRCOUNT +(byte) MEGA65_VICIV::CHRXSCL +(byte) MEGA65_VICIV::CHRYSCL +(byte) MEGA65_VICIV::COLPTR_HI +(byte) MEGA65_VICIV::COLPTR_LO +(byte) MEGA65_VICIV::CONTROL1 +(byte) MEGA65_VICIV::CONTROL2 +(byte) MEGA65_VICIV::CONTROLA +(byte) MEGA65_VICIV::CONTROLB +(byte) MEGA65_VICIV::CONTROLC +(byte) MEGA65_VICIV::DEBUG1 +(byte) MEGA65_VICIV::DEBUGX +(byte) MEGA65_VICIV::DEBUGXY +(byte) MEGA65_VICIV::DEBUGY +(byte) MEGA65_VICIV::FNRASTER_HI +(byte) MEGA65_VICIV::FNRASTER_LO +(byte) MEGA65_VICIV::HPOS +(byte) MEGA65_VICIV::IRQ_ENABLE +(byte) MEGA65_VICIV::IRQ_STATUS +(byte) MEGA65_VICIV::KEY +(byte) MEGA65_VICIV::LIGHTPEN_X +(byte) MEGA65_VICIV::LIGHTPEN_Y +(byte) MEGA65_VICIV::MEMORY +(byte) MEGA65_VICIV::PALSEL +(byte) MEGA65_VICIV::RASLINE0 +(byte) MEGA65_VICIV::RASTER +(byte) MEGA65_VICIV::ROWCOUNT +(byte) MEGA65_VICIV::RSTCMP +(byte) MEGA65_VICIV::RSTCOMP +(byte) MEGA65_VICIV::SBPDEBUG +(byte) MEGA65_VICIV::SCRNPTR_HIHI +(byte) MEGA65_VICIV::SCRNPTR_HILO +(byte) MEGA65_VICIV::SCRNPTR_LOHI +(byte) MEGA65_VICIV::SCRNPTR_LOLO +(byte) MEGA65_VICIV::SIDBDRWD_HI +(byte) MEGA65_VICIV::SIDBDRWD_LO +(byte) MEGA65_VICIV::SPR16EN +(byte) MEGA65_VICIV::SPRALPHAVAL +(byte) MEGA65_VICIV::SPRENALPHA +(byte) MEGA65_VICIV::SPRENV400 +(byte) MEGA65_VICIV::SPRHGHT +(byte) MEGA65_VICIV::SPRHGTEN +(byte) MEGA65_VICIV::SPRITE0_COLOR +(byte) MEGA65_VICIV::SPRITE0_X +(byte) MEGA65_VICIV::SPRITE0_Y +(byte) MEGA65_VICIV::SPRITE1_COLOR +(byte) MEGA65_VICIV::SPRITE1_X +(byte) MEGA65_VICIV::SPRITE1_Y +(byte) MEGA65_VICIV::SPRITE2_COLOR +(byte) MEGA65_VICIV::SPRITE2_X +(byte) MEGA65_VICIV::SPRITE2_Y +(byte) MEGA65_VICIV::SPRITE3_COLOR +(byte) MEGA65_VICIV::SPRITE3_X +(byte) MEGA65_VICIV::SPRITE3_Y +(byte) MEGA65_VICIV::SPRITE4_COLOR +(byte) MEGA65_VICIV::SPRITE4_X +(byte) MEGA65_VICIV::SPRITE4_Y +(byte) MEGA65_VICIV::SPRITE5_COLOR +(byte) MEGA65_VICIV::SPRITE5_X +(byte) MEGA65_VICIV::SPRITE5_Y +(byte) MEGA65_VICIV::SPRITE6_COLOR +(byte) MEGA65_VICIV::SPRITE6_X +(byte) MEGA65_VICIV::SPRITE6_Y +(byte) MEGA65_VICIV::SPRITE7_COLOR +(byte) MEGA65_VICIV::SPRITE7_X +(byte) MEGA65_VICIV::SPRITE7_Y +(byte) MEGA65_VICIV::SPRITES_BG_COLLISION +(byte) MEGA65_VICIV::SPRITES_COLLISION +(byte) MEGA65_VICIV::SPRITES_ENABLE +(byte) MEGA65_VICIV::SPRITES_EXPAND_X +(byte) MEGA65_VICIV::SPRITES_EXPAND_Y +(byte) MEGA65_VICIV::SPRITES_MC +(byte) MEGA65_VICIV::SPRITES_MCOLOR1 +(byte) MEGA65_VICIV::SPRITES_MCOLOR2 +(byte) MEGA65_VICIV::SPRITES_PRIORITY +(byte) MEGA65_VICIV::SPRITES_XMSB +(byte) MEGA65_VICIV::SPRPTRADR_HILO +(byte) MEGA65_VICIV::SPRPTRADR_LOHI +(byte) MEGA65_VICIV::SPRPTRADR_LOLO +(byte) MEGA65_VICIV::SPRX64EN +(byte) MEGA65_VICIV::SPRXSMSBS +(byte) MEGA65_VICIV::SPRYSMSBSM +(byte) MEGA65_VICIV::SRPYMSBS +(byte) MEGA65_VICIV::SYNCPOL +(byte) MEGA65_VICIV::TBDRPOS_HI +(byte) MEGA65_VICIV::TBDRPOS_LO +(byte) MEGA65_VICIV::TEXTXPOS_HI +(byte) MEGA65_VICIV::TEXTXPOS_LO +(byte) MEGA65_VICIV::TEXTYPOS_HI +(byte) MEGA65_VICIV::TEXTYPOS_LO +(byte) MEGA65_VICIV::UNUSED +(byte) MEGA65_VICIV::VPOS +(byte) MEGA65_VICIV::VSYNDEL +(byte) MEGA65_VICIV::XPOS_HI +(byte) MEGA65_VICIV::XPOS_LO +(const nomodify byte) MEMORYBLOCK_4000 = (byte) 4 +(const nomodify byte) MEMORYBLOCK_8000 = (byte) $10 +(byte) MOS4569_VICIII::B0PIX +(byte) MOS4569_VICIII::B0_ADDR +(byte) MOS4569_VICIII::B1PIX +(byte) MOS4569_VICIII::B1_ADDR +(byte) MOS4569_VICIII::B2PIX +(byte) MOS4569_VICIII::B2_ADDR +(byte) MOS4569_VICIII::B3PIX +(byte) MOS4569_VICIII::B3_ADDR +(byte) MOS4569_VICIII::B4PIX +(byte) MOS4569_VICIII::B4_ADDR +(byte) MOS4569_VICIII::B5PIX +(byte) MOS4569_VICIII::B5_ADDR +(byte) MOS4569_VICIII::B6PIX +(byte) MOS4569_VICIII::B6_ADDR +(byte) MOS4569_VICIII::B7PIX +(byte) MOS4569_VICIII::B7_ADDR +(byte) MOS4569_VICIII::BG_COLOR +(byte) MOS4569_VICIII::BG_COLOR1 +(byte) MOS4569_VICIII::BG_COLOR2 +(byte) MOS4569_VICIII::BG_COLOR3 +(byte) MOS4569_VICIII::BORDER_COLOR +(byte) MOS4569_VICIII::BPCOMP +(byte) MOS4569_VICIII::BPX +(byte) MOS4569_VICIII::BPY +(byte) MOS4569_VICIII::CONTROL1 +(byte) MOS4569_VICIII::CONTROL2 +(byte) MOS4569_VICIII::CONTROLA +(byte) MOS4569_VICIII::CONTROLB +(byte) MOS4569_VICIII::HPOS +(byte) MOS4569_VICIII::IRQ_ENABLE +(byte) MOS4569_VICIII::IRQ_STATUS +(byte) MOS4569_VICIII::KEY +(byte) MOS4569_VICIII::LIGHTPEN_X +(byte) MOS4569_VICIII::LIGHTPEN_Y +(byte) MOS4569_VICIII::MEMORY +(byte) MOS4569_VICIII::RASTER +(byte) MOS4569_VICIII::SPRITE0_COLOR +(byte) MOS4569_VICIII::SPRITE0_X +(byte) MOS4569_VICIII::SPRITE0_Y +(byte) MOS4569_VICIII::SPRITE1_COLOR +(byte) MOS4569_VICIII::SPRITE1_X +(byte) MOS4569_VICIII::SPRITE1_Y +(byte) MOS4569_VICIII::SPRITE2_COLOR +(byte) MOS4569_VICIII::SPRITE2_X +(byte) MOS4569_VICIII::SPRITE2_Y +(byte) MOS4569_VICIII::SPRITE3_COLOR +(byte) MOS4569_VICIII::SPRITE3_X +(byte) MOS4569_VICIII::SPRITE3_Y +(byte) MOS4569_VICIII::SPRITE4_COLOR +(byte) MOS4569_VICIII::SPRITE4_X +(byte) MOS4569_VICIII::SPRITE4_Y +(byte) MOS4569_VICIII::SPRITE5_COLOR +(byte) MOS4569_VICIII::SPRITE5_X +(byte) MOS4569_VICIII::SPRITE5_Y +(byte) MOS4569_VICIII::SPRITE6_COLOR +(byte) MOS4569_VICIII::SPRITE6_X +(byte) MOS4569_VICIII::SPRITE6_Y +(byte) MOS4569_VICIII::SPRITE7_COLOR +(byte) MOS4569_VICIII::SPRITE7_X +(byte) MOS4569_VICIII::SPRITE7_Y +(byte) MOS4569_VICIII::SPRITES_BG_COLLISION +(byte) MOS4569_VICIII::SPRITES_COLLISION +(byte) MOS4569_VICIII::SPRITES_ENABLE +(byte) MOS4569_VICIII::SPRITES_EXPAND_X +(byte) MOS4569_VICIII::SPRITES_EXPAND_Y +(byte) MOS4569_VICIII::SPRITES_MC +(byte) MOS4569_VICIII::SPRITES_MCOLOR1 +(byte) MOS4569_VICIII::SPRITES_MCOLOR2 +(byte) MOS4569_VICIII::SPRITES_PRIORITY +(byte) MOS4569_VICIII::SPRITES_XMSB +(byte) MOS4569_VICIII::UNUSED +(byte) MOS4569_VICIII::VPOS +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(const byte*) main::block1 = (byte*) 16384 +(const byte*) main::block2 = (byte*) 32768 +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +(byte~) memoryRemap::$0 reg byte a 202.0 +(byte~) memoryRemap::$1 zp[1]:6 67.33333333333333 +(byte~) memoryRemap::$2 reg byte a 202.0 +(byte~) memoryRemap::$3 reg byte a 202.0 +(byte~) memoryRemap::$4 reg byte a 202.0 +(byte~) memoryRemap::$5 reg byte a 202.0 +(byte~) memoryRemap::$6 zp[1]:7 67.33333333333333 +(byte~) memoryRemap::$7 reg byte a 202.0 +(byte~) memoryRemap::$8 reg byte a 202.0 +(byte~) memoryRemap::$9 reg byte a 202.0 +(label) memoryRemap::@return +(const byte*) memoryRemap::aVal = (byte*) 252 +(word) memoryRemap::lowerMemoryPageOffset +(word) memoryRemap::lowerMemoryPageOffset#1 lowerMemoryPageOffset zp[2]:2 11.0 +(word) memoryRemap::lowerMemoryPageOffset#2 lowerMemoryPageOffset zp[2]:2 53.25 +(byte) memoryRemap::remapBlocks +(byte) memoryRemap::remapBlocks#1 reg byte z 7.333333333333333 +(byte) memoryRemap::remapBlocks#2 reg byte z 21.299999999999997 +(word) memoryRemap::upperMemoryPageOffset +(word) memoryRemap::upperMemoryPageOffset#1 upperMemoryPageOffset zp[2]:4 22.0 +(word) memoryRemap::upperMemoryPageOffset#2 upperMemoryPageOffset zp[2]:4 19.363636363636363 +(const byte*) memoryRemap::xVal = (byte*) 253 +(const byte*) memoryRemap::yVal = (byte*) 254 +(const byte*) memoryRemap::zVal = (byte*) 255 +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +(label) memoryRemapBlock::@return +(byte) memoryRemapBlock::block +(byte) memoryRemapBlock::block#0 reg byte a 22.0 +(byte) memoryRemapBlock::blockBits +(byte) memoryRemapBlock::blockBits#0 reg byte a 22.0 +(byte) memoryRemapBlock::blockPage +(byte) memoryRemapBlock::blockPage#2 reg byte x 11.0 +(word) memoryRemapBlock::memoryPage +(word) memoryRemapBlock::pageOffset +(word) memoryRemapBlock::pageOffset#0 pageOffset zp[2]:2 6.6000000000000005 + +reg byte x [ memoryRemapBlock::blockPage#2 ] +zp[2]:2 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 ] +reg byte z [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +zp[2]:4 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +reg byte a [ memoryRemapBlock::block#0 ] +reg byte a [ memoryRemapBlock::blockBits#0 ] +reg byte a [ memoryRemap::$0 ] +zp[1]:6 [ memoryRemap::$1 ] +reg byte a [ memoryRemap::$2 ] +reg byte a [ memoryRemap::$3 ] +reg byte a [ memoryRemap::$4 ] +reg byte a [ memoryRemap::$5 ] +zp[1]:7 [ memoryRemap::$6 ] +reg byte a [ memoryRemap::$7 ] +reg byte a [ memoryRemap::$8 ] +reg byte a [ memoryRemap::$9 ] + + +FINAL ASSEMBLER +Score: 243 + + // File Comments +// Test the MAP instruction for remapping memory +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf + // Upstart +.cpu _45gs02 + // MEGA65 platform PRG executable starting in MEGA65 mode. +.file [name="memorymap-test.prg", type="prg", segments="Program"] +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$2001] +.segmentdef Code [start=$2017] +.segmentdef Data [startAfter="Code"] +.segment Basic +.byte $0a, $20, $0a, $00, $fe, $02, $20, $30, $00 // 10 BANK 0 +.byte $15, $20, $14, $00, $9e, $20 // 20 SYS +.text toIntString(main) // NNNN +.byte $00, $00, $00 // + // Global Constants & labels + // Bit representing 8K block #2 of the 64K addressable memory ($4000-$5fff) + .const MEMORYBLOCK_4000 = 4 + // Bit representing 8K block #4 of the 64K addressable memory ($8000-$9fff) + .const MEMORYBLOCK_8000 = $10 +.segment Code + // main +main: { + .label block1 = $4000 + .label block2 = $8000 + // memoryRemapBlock(0x40, 0x100) + // [1] call memoryRemapBlock + // Remap [$4000-$5fff] to point to [$10000-$11fff] + // [11] phi from main to memoryRemapBlock [phi:main->memoryRemapBlock] + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $40 [phi:main->memoryRemapBlock#0] -- vbuxx=vbuc1 + ldx #$40 + jsr memoryRemapBlock + // main::@1 + // block1[0] = 0x55 + // [2] *((const byte*) main::block1) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaa into $10000 + lda #$55 + sta block1 + // block1[1] = 0xaa + // [3] *((const byte*) main::block1+(byte) 1) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block1+1 + // memoryRemapBlock(0x80, 0x100) + // [4] call memoryRemapBlock + // Remap [$8000-$9fff] to point to [$10000-$11fff] + // [11] phi from main::@1 to memoryRemapBlock [phi:main::@1->memoryRemapBlock] + // [11] phi (byte) memoryRemapBlock::blockPage#2 = (byte) $80 [phi:main::@1->memoryRemapBlock#0] -- vbuxx=vbuc1 + ldx #$80 + jsr memoryRemapBlock + // main::@2 + // block2[2] = 0x55 + // [5] *((const byte*) main::block2+(byte) 2) ← (byte) $55 -- _deref_pbuc1=vbuc2 + // Put 0x55, 0xaainto $10002 + lda #$55 + sta block2+2 + // block2[3] = 0xaa + // [6] *((const byte*) main::block2+(byte) 3) ← (byte) $aa -- _deref_pbuc1=vbuc2 + lda #$aa + sta block2+3 + // memoryRemap(MEMORYBLOCK_4000|MEMORYBLOCK_8000, 0x0c0, 0x080) + // [7] call memoryRemap + // Remap [$4000-$5fff] and [$8000-$9fff] to both point to [$10000-$11fff] (notice usage of page offsets) + // [20] phi from main::@2 to memoryRemap [phi:main::@2->memoryRemap] + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (byte) $80 [phi:main::@2->memoryRemap#0] -- vwuz1=vbuc1 + lda #<$80 + sta.z memoryRemap.upperMemoryPageOffset + lda #>$80 + sta.z memoryRemap.upperMemoryPageOffset+1 + // [20] phi (byte) memoryRemap::remapBlocks#2 = (const nomodify byte) MEMORYBLOCK_4000|(const nomodify byte) MEMORYBLOCK_8000 [phi:main::@2->memoryRemap#1] -- vbuzz=vbuc1 + ldz #MEMORYBLOCK_4000|MEMORYBLOCK_8000 + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (byte) $c0 [phi:main::@2->memoryRemap#2] -- vwuz1=vbuc1 + lda #<$c0 + sta.z memoryRemap.lowerMemoryPageOffset + lda #>$c0 + sta.z memoryRemap.lowerMemoryPageOffset+1 + jsr memoryRemap + // main::@3 + // block2[4] = block1[2] + // [8] *((const byte*) main::block2+(byte) 4) ← *((const byte*) main::block1+(byte) 2) -- _deref_pbuc1=_deref_pbuc2 + // Put 0x55, 0xaa into $10004 in a convoluted way + lda block1+2 + sta block2+4 + // block1[5] = block2[1] + // [9] *((const byte*) main::block1+(byte) 5) ← *((const byte*) main::block2+(byte) 1) -- _deref_pbuc1=_deref_pbuc2 + lda block2+1 + sta block1+5 + // main::@return + // } + // [10] return + rts +} + // memoryRemapBlock +// Remap a single 8K memory block in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// All the other 8K memory blocks will not be mapped and will point to their own address in the lowest 64K of the MEGA65 memory. +// blockPage: Page address of the 8K memory block to remap (ie. the block that is remapped is $100 * the passed page address.) +// memoryPage: Page address of the memory that the block should point to in the 1MB memory space of the MEGA65. +// Ie. the memory that will be pointed to is $100 * the passed page address. Only the lower 12bits of the passed value is used. +// memoryRemapBlock(byte register(X) blockPage) +memoryRemapBlock: { + .label pageOffset = 2 + // pageOffset = memoryPage-blockPage + // [12] (word) memoryRemapBlock::pageOffset#0 ← (word) $100 - (byte) memoryRemapBlock::blockPage#2 -- vwuz1=vwuc1_minus_vbuxx + stx.z $ff + lda #<$100 + sec + sbc.z $ff + sta.z pageOffset + lda #>$100 + sbc #0 + sta.z pageOffset+1 + // block = blockPage / $20 + // [13] (byte) memoryRemapBlock::block#0 ← (byte) memoryRemapBlock::blockPage#2 >> (byte) 5 -- vbuaa=vbuxx_ror_5 + txa + lsr + lsr + lsr + lsr + lsr + // blockBits = 1<memoryRemap] + // [20] phi (word) memoryRemap::upperMemoryPageOffset#2 = (word) memoryRemap::upperMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#0] -- register_copy + // [20] phi (byte) memoryRemap::remapBlocks#2 = (byte) memoryRemap::remapBlocks#1 [phi:memoryRemapBlock->memoryRemap#1] -- register_copy + // [20] phi (word) memoryRemap::lowerMemoryPageOffset#2 = (word) memoryRemap::lowerMemoryPageOffset#1 [phi:memoryRemapBlock->memoryRemap#2] -- register_copy + jsr memoryRemap + // memoryRemapBlock::@return + // } + // [19] return + rts +} + // memoryRemap +// Remap some of the eight 8K memory blocks in the 64K address space of the 6502 to point somewhere else in the first 1MB memory space of the MEGA65. +// After the remapping the CPU will access the mapped memory whenever it uses instructions that access a remapped block. +// remapBlocks: Indicates which 8K blocks of the 6502 address space to remap. Each bit represents one 8K block +// - bit 0 Memory block $0000-$1fff. Use constant MEMORYBLOCK_0000. +// - bit 1 Memory block $2000-$3fff. Use constant MEMORYBLOCK_2000. +// - bit 2 Memory block $4000-$5fff. Use constant MEMORYBLOCK_4000. +// - bit 3 Memory block $6000-$7fff. Use constant MEMORYBLOCK_6000. +// - bit 4 Memory block $8000-$9fff. Use constant MEMORYBLOCK_8000. +// - bit 5 Memory block $a000-$bfff. Use constant MEMORYBLOCK_A000. +// - bit 6 Memory block $c000-$dfff. Use constant MEMORYBLOCK_C000. +// - bit 7 Memory block $e000-$ffff. Use constant MEMORYBLOCK_E000. +// lowerMemoryPageOffset: Offset that will be added to any remapped blocks in the lower 32K of memory (block 0-3). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 0 ($0000-$1fff) is remapped it will point to lowerMemoryPageOffset*$100. +// - If block 1 ($2000-$3fff) is remapped it will point to lowerMemoryPageOffset*$100 + $2000. +// - If block 2 ($4000-$5fff) is remapped it will point to lowerMemoryPageOffset*$100 + $4000. +// - If block 3 ($6000-$7fff) is remapped it will point to lowerMemoryPageOffset*$100 + $6000. +// upperMemoryPageOffset: Offset that will be added to any remapped blocks in the upper 32K of memory (block 4-7). +// The offset is a page offset (meaning it is multiplied by 0x100). Only the lower 12bits of the passed value is used. +// - If block 4 ($8000-$9fff) is remapped it will point to upperMemoryPageOffset*$100 + $8000 +// - If block 5 ($a000-$bfff) is remapped it will point to upperMemoryPageOffset*$100 + $a000. +// - If block 6 ($c000-$dfff) is remapped it will point to upperMemoryPageOffset*$100 + $c000. +// - If block 7 ($e000-$ffff) is remapped it will point to upperMemoryPageOffset*$100 + $e000. +// memoryRemap(byte register(Z) remapBlocks, word zp(2) lowerMemoryPageOffset, word zp(4) upperMemoryPageOffset) +memoryRemap: { + .label aVal = $fc + .label xVal = $fd + .label yVal = $fe + .label zVal = $ff + .label __1 = 6 + .label __6 = 7 + .label lowerMemoryPageOffset = 2 + .label upperMemoryPageOffset = 4 + // lowerMemoryPageOffset + // [24] (byte~) memoryRemap::$2 ← > (word) memoryRemap::lowerMemoryPageOffset#2 -- vbuaa=_hi_vwuz1 + lda.z lowerMemoryPageOffset+1 + // >lowerMemoryPageOffset & 0xf + // [25] (byte~) memoryRemap::$3 ← (byte~) memoryRemap::$2 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + and #$f + // (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf) + // [26] (byte~) memoryRemap::$4 ← (byte~) memoryRemap::$1 | (byte~) memoryRemap::$3 -- vbuaa=vbuz1_bor_vbuaa + ora.z __1 + // *xVal = (remapBlocks << 4) | (>lowerMemoryPageOffset & 0xf) + // [27] *((const byte*) memoryRemap::xVal) ← (byte~) memoryRemap::$4 -- _deref_pbuc1=vbuaa + sta xVal + // upperMemoryPageOffset + // [31] (byte~) memoryRemap::$7 ← > (word) memoryRemap::upperMemoryPageOffset#2 -- vbuaa=_hi_vwuz1 + lda.z upperMemoryPageOffset+1 + // >upperMemoryPageOffset & 0xf + // [32] (byte~) memoryRemap::$8 ← (byte~) memoryRemap::$7 & (byte) $f -- vbuaa=vbuaa_band_vbuc1 + and #$f + // (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf) + // [33] (byte~) memoryRemap::$9 ← (byte~) memoryRemap::$6 | (byte~) memoryRemap::$8 -- vbuaa=vbuz1_bor_vbuaa + ora.z __6 + // *zVal = (remapBlocks & 0xf0) | (>upperMemoryPageOffset & 0xf) + // [34] *((const byte*) memoryRemap::zVal) ← (byte~) memoryRemap::$9 -- _deref_pbuc1=vbuaa + sta zVal + // asm + // asm { ldaaVal ldxxVal ldyyVal ldzzVal map eom } + lda aVal + ldx xVal + ldy yVal + ldz zVal + map + eom + // memoryRemap::@return + // } + // [36] return + rts +} + // File Data + diff --git a/src/test/ref/examples/mega65/memorymap-test.sym b/src/test/ref/examples/mega65/memorymap-test.sym new file mode 100644 index 000000000..7426e631e --- /dev/null +++ b/src/test/ref/examples/mega65/memorymap-test.sym @@ -0,0 +1,346 @@ +(byte) MEGA65_VICIV::ALPHADELAY +(byte) MEGA65_VICIV::B0PIX +(byte) MEGA65_VICIV::B0_ADDR +(byte) MEGA65_VICIV::B1PIX +(byte) MEGA65_VICIV::B1_ADDR +(byte) MEGA65_VICIV::B2PIX +(byte) MEGA65_VICIV::B2_ADDR +(byte) MEGA65_VICIV::B3PIX +(byte) MEGA65_VICIV::B3_ADDR +(byte) MEGA65_VICIV::B4PIX +(byte) MEGA65_VICIV::B4_ADDR +(byte) MEGA65_VICIV::B5PIX +(byte) MEGA65_VICIV::B5_ADDR +(byte) MEGA65_VICIV::B6PIX +(byte) MEGA65_VICIV::B6_ADDR +(byte) MEGA65_VICIV::B7PIX +(byte) MEGA65_VICIV::B7_ADDR +(byte) MEGA65_VICIV::BBDRPOS_HI +(byte) MEGA65_VICIV::BBDRPOS_LO +(byte) MEGA65_VICIV::BG_COLOR +(byte) MEGA65_VICIV::BG_COLOR1 +(byte) MEGA65_VICIV::BG_COLOR2 +(byte) MEGA65_VICIV::BG_COLOR3 +(byte) MEGA65_VICIV::BORDER_COLOR +(byte) MEGA65_VICIV::BP16ENS +(byte) MEGA65_VICIV::BPCOMP +(byte) MEGA65_VICIV::BPX +(byte) MEGA65_VICIV::BPY +(byte) MEGA65_VICIV::CHARPTR_HILO +(byte) MEGA65_VICIV::CHARPTR_LOHI +(byte) MEGA65_VICIV::CHARPTR_LOLO +(byte) MEGA65_VICIV::CHARSTEP_HI +(byte) MEGA65_VICIV::CHARSTEP_LO +(byte) MEGA65_VICIV::CHRCOUNT +(byte) MEGA65_VICIV::CHRXSCL +(byte) MEGA65_VICIV::CHRYSCL +(byte) MEGA65_VICIV::COLPTR_HI +(byte) MEGA65_VICIV::COLPTR_LO +(byte) MEGA65_VICIV::CONTROL1 +(byte) MEGA65_VICIV::CONTROL2 +(byte) MEGA65_VICIV::CONTROLA +(byte) MEGA65_VICIV::CONTROLB +(byte) MEGA65_VICIV::CONTROLC +(byte) MEGA65_VICIV::DEBUG1 +(byte) MEGA65_VICIV::DEBUGX +(byte) MEGA65_VICIV::DEBUGXY +(byte) MEGA65_VICIV::DEBUGY +(byte) MEGA65_VICIV::FNRASTER_HI +(byte) MEGA65_VICIV::FNRASTER_LO +(byte) MEGA65_VICIV::HPOS +(byte) MEGA65_VICIV::IRQ_ENABLE +(byte) MEGA65_VICIV::IRQ_STATUS +(byte) MEGA65_VICIV::KEY +(byte) MEGA65_VICIV::LIGHTPEN_X +(byte) MEGA65_VICIV::LIGHTPEN_Y +(byte) MEGA65_VICIV::MEMORY +(byte) MEGA65_VICIV::PALSEL +(byte) MEGA65_VICIV::RASLINE0 +(byte) MEGA65_VICIV::RASTER +(byte) MEGA65_VICIV::ROWCOUNT +(byte) MEGA65_VICIV::RSTCMP +(byte) MEGA65_VICIV::RSTCOMP +(byte) MEGA65_VICIV::SBPDEBUG +(byte) MEGA65_VICIV::SCRNPTR_HIHI +(byte) MEGA65_VICIV::SCRNPTR_HILO +(byte) MEGA65_VICIV::SCRNPTR_LOHI +(byte) MEGA65_VICIV::SCRNPTR_LOLO +(byte) MEGA65_VICIV::SIDBDRWD_HI +(byte) MEGA65_VICIV::SIDBDRWD_LO +(byte) MEGA65_VICIV::SPR16EN +(byte) MEGA65_VICIV::SPRALPHAVAL +(byte) MEGA65_VICIV::SPRENALPHA +(byte) MEGA65_VICIV::SPRENV400 +(byte) MEGA65_VICIV::SPRHGHT +(byte) MEGA65_VICIV::SPRHGTEN +(byte) MEGA65_VICIV::SPRITE0_COLOR +(byte) MEGA65_VICIV::SPRITE0_X +(byte) MEGA65_VICIV::SPRITE0_Y +(byte) MEGA65_VICIV::SPRITE1_COLOR +(byte) MEGA65_VICIV::SPRITE1_X +(byte) MEGA65_VICIV::SPRITE1_Y +(byte) MEGA65_VICIV::SPRITE2_COLOR +(byte) MEGA65_VICIV::SPRITE2_X +(byte) MEGA65_VICIV::SPRITE2_Y +(byte) MEGA65_VICIV::SPRITE3_COLOR +(byte) MEGA65_VICIV::SPRITE3_X +(byte) MEGA65_VICIV::SPRITE3_Y +(byte) MEGA65_VICIV::SPRITE4_COLOR +(byte) MEGA65_VICIV::SPRITE4_X +(byte) MEGA65_VICIV::SPRITE4_Y +(byte) MEGA65_VICIV::SPRITE5_COLOR +(byte) MEGA65_VICIV::SPRITE5_X +(byte) MEGA65_VICIV::SPRITE5_Y +(byte) MEGA65_VICIV::SPRITE6_COLOR +(byte) MEGA65_VICIV::SPRITE6_X +(byte) MEGA65_VICIV::SPRITE6_Y +(byte) MEGA65_VICIV::SPRITE7_COLOR +(byte) MEGA65_VICIV::SPRITE7_X +(byte) MEGA65_VICIV::SPRITE7_Y +(byte) MEGA65_VICIV::SPRITES_BG_COLLISION +(byte) MEGA65_VICIV::SPRITES_COLLISION +(byte) MEGA65_VICIV::SPRITES_ENABLE +(byte) MEGA65_VICIV::SPRITES_EXPAND_X +(byte) MEGA65_VICIV::SPRITES_EXPAND_Y +(byte) MEGA65_VICIV::SPRITES_MC +(byte) MEGA65_VICIV::SPRITES_MCOLOR1 +(byte) MEGA65_VICIV::SPRITES_MCOLOR2 +(byte) MEGA65_VICIV::SPRITES_PRIORITY +(byte) MEGA65_VICIV::SPRITES_XMSB +(byte) MEGA65_VICIV::SPRPTRADR_HILO +(byte) MEGA65_VICIV::SPRPTRADR_LOHI +(byte) MEGA65_VICIV::SPRPTRADR_LOLO +(byte) MEGA65_VICIV::SPRX64EN +(byte) MEGA65_VICIV::SPRXSMSBS +(byte) MEGA65_VICIV::SPRYSMSBSM +(byte) MEGA65_VICIV::SRPYMSBS +(byte) MEGA65_VICIV::SYNCPOL +(byte) MEGA65_VICIV::TBDRPOS_HI +(byte) MEGA65_VICIV::TBDRPOS_LO +(byte) MEGA65_VICIV::TEXTXPOS_HI +(byte) MEGA65_VICIV::TEXTXPOS_LO +(byte) MEGA65_VICIV::TEXTYPOS_HI +(byte) MEGA65_VICIV::TEXTYPOS_LO +(byte) MEGA65_VICIV::UNUSED +(byte) MEGA65_VICIV::VPOS +(byte) MEGA65_VICIV::VSYNDEL +(byte) MEGA65_VICIV::XPOS_HI +(byte) MEGA65_VICIV::XPOS_LO +(const nomodify byte) MEMORYBLOCK_4000 = (byte) 4 +(const nomodify byte) MEMORYBLOCK_8000 = (byte) $10 +(byte) MOS4569_VICIII::B0PIX +(byte) MOS4569_VICIII::B0_ADDR +(byte) MOS4569_VICIII::B1PIX +(byte) MOS4569_VICIII::B1_ADDR +(byte) MOS4569_VICIII::B2PIX +(byte) MOS4569_VICIII::B2_ADDR +(byte) MOS4569_VICIII::B3PIX +(byte) MOS4569_VICIII::B3_ADDR +(byte) MOS4569_VICIII::B4PIX +(byte) MOS4569_VICIII::B4_ADDR +(byte) MOS4569_VICIII::B5PIX +(byte) MOS4569_VICIII::B5_ADDR +(byte) MOS4569_VICIII::B6PIX +(byte) MOS4569_VICIII::B6_ADDR +(byte) MOS4569_VICIII::B7PIX +(byte) MOS4569_VICIII::B7_ADDR +(byte) MOS4569_VICIII::BG_COLOR +(byte) MOS4569_VICIII::BG_COLOR1 +(byte) MOS4569_VICIII::BG_COLOR2 +(byte) MOS4569_VICIII::BG_COLOR3 +(byte) MOS4569_VICIII::BORDER_COLOR +(byte) MOS4569_VICIII::BPCOMP +(byte) MOS4569_VICIII::BPX +(byte) MOS4569_VICIII::BPY +(byte) MOS4569_VICIII::CONTROL1 +(byte) MOS4569_VICIII::CONTROL2 +(byte) MOS4569_VICIII::CONTROLA +(byte) MOS4569_VICIII::CONTROLB +(byte) MOS4569_VICIII::HPOS +(byte) MOS4569_VICIII::IRQ_ENABLE +(byte) MOS4569_VICIII::IRQ_STATUS +(byte) MOS4569_VICIII::KEY +(byte) MOS4569_VICIII::LIGHTPEN_X +(byte) MOS4569_VICIII::LIGHTPEN_Y +(byte) MOS4569_VICIII::MEMORY +(byte) MOS4569_VICIII::RASTER +(byte) MOS4569_VICIII::SPRITE0_COLOR +(byte) MOS4569_VICIII::SPRITE0_X +(byte) MOS4569_VICIII::SPRITE0_Y +(byte) MOS4569_VICIII::SPRITE1_COLOR +(byte) MOS4569_VICIII::SPRITE1_X +(byte) MOS4569_VICIII::SPRITE1_Y +(byte) MOS4569_VICIII::SPRITE2_COLOR +(byte) MOS4569_VICIII::SPRITE2_X +(byte) MOS4569_VICIII::SPRITE2_Y +(byte) MOS4569_VICIII::SPRITE3_COLOR +(byte) MOS4569_VICIII::SPRITE3_X +(byte) MOS4569_VICIII::SPRITE3_Y +(byte) MOS4569_VICIII::SPRITE4_COLOR +(byte) MOS4569_VICIII::SPRITE4_X +(byte) MOS4569_VICIII::SPRITE4_Y +(byte) MOS4569_VICIII::SPRITE5_COLOR +(byte) MOS4569_VICIII::SPRITE5_X +(byte) MOS4569_VICIII::SPRITE5_Y +(byte) MOS4569_VICIII::SPRITE6_COLOR +(byte) MOS4569_VICIII::SPRITE6_X +(byte) MOS4569_VICIII::SPRITE6_Y +(byte) MOS4569_VICIII::SPRITE7_COLOR +(byte) MOS4569_VICIII::SPRITE7_X +(byte) MOS4569_VICIII::SPRITE7_Y +(byte) MOS4569_VICIII::SPRITES_BG_COLLISION +(byte) MOS4569_VICIII::SPRITES_COLLISION +(byte) MOS4569_VICIII::SPRITES_ENABLE +(byte) MOS4569_VICIII::SPRITES_EXPAND_X +(byte) MOS4569_VICIII::SPRITES_EXPAND_Y +(byte) MOS4569_VICIII::SPRITES_MC +(byte) MOS4569_VICIII::SPRITES_MCOLOR1 +(byte) MOS4569_VICIII::SPRITES_MCOLOR2 +(byte) MOS4569_VICIII::SPRITES_PRIORITY +(byte) MOS4569_VICIII::SPRITES_XMSB +(byte) MOS4569_VICIII::UNUSED +(byte) MOS4569_VICIII::VPOS +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(const byte*) main::block1 = (byte*) 16384 +(const byte*) main::block2 = (byte*) 32768 +(void()) memoryRemap((byte) memoryRemap::remapBlocks , (word) memoryRemap::lowerMemoryPageOffset , (word) memoryRemap::upperMemoryPageOffset) +(byte~) memoryRemap::$0 reg byte a 202.0 +(byte~) memoryRemap::$1 zp[1]:6 67.33333333333333 +(byte~) memoryRemap::$2 reg byte a 202.0 +(byte~) memoryRemap::$3 reg byte a 202.0 +(byte~) memoryRemap::$4 reg byte a 202.0 +(byte~) memoryRemap::$5 reg byte a 202.0 +(byte~) memoryRemap::$6 zp[1]:7 67.33333333333333 +(byte~) memoryRemap::$7 reg byte a 202.0 +(byte~) memoryRemap::$8 reg byte a 202.0 +(byte~) memoryRemap::$9 reg byte a 202.0 +(label) memoryRemap::@return +(const byte*) memoryRemap::aVal = (byte*) 252 +(word) memoryRemap::lowerMemoryPageOffset +(word) memoryRemap::lowerMemoryPageOffset#1 lowerMemoryPageOffset zp[2]:2 11.0 +(word) memoryRemap::lowerMemoryPageOffset#2 lowerMemoryPageOffset zp[2]:2 53.25 +(byte) memoryRemap::remapBlocks +(byte) memoryRemap::remapBlocks#1 reg byte z 7.333333333333333 +(byte) memoryRemap::remapBlocks#2 reg byte z 21.299999999999997 +(word) memoryRemap::upperMemoryPageOffset +(word) memoryRemap::upperMemoryPageOffset#1 upperMemoryPageOffset zp[2]:4 22.0 +(word) memoryRemap::upperMemoryPageOffset#2 upperMemoryPageOffset zp[2]:4 19.363636363636363 +(const byte*) memoryRemap::xVal = (byte*) 253 +(const byte*) memoryRemap::yVal = (byte*) 254 +(const byte*) memoryRemap::zVal = (byte*) 255 +(void()) memoryRemapBlock((byte) memoryRemapBlock::blockPage , (word) memoryRemapBlock::memoryPage) +(label) memoryRemapBlock::@return +(byte) memoryRemapBlock::block +(byte) memoryRemapBlock::block#0 reg byte a 22.0 +(byte) memoryRemapBlock::blockBits +(byte) memoryRemapBlock::blockBits#0 reg byte a 22.0 +(byte) memoryRemapBlock::blockPage +(byte) memoryRemapBlock::blockPage#2 reg byte x 11.0 +(word) memoryRemapBlock::memoryPage +(word) memoryRemapBlock::pageOffset +(word) memoryRemapBlock::pageOffset#0 pageOffset zp[2]:2 6.6000000000000005 + +reg byte x [ memoryRemapBlock::blockPage#2 ] +zp[2]:2 [ memoryRemap::lowerMemoryPageOffset#2 memoryRemap::lowerMemoryPageOffset#1 memoryRemapBlock::pageOffset#0 ] +reg byte z [ memoryRemap::remapBlocks#2 memoryRemap::remapBlocks#1 ] +zp[2]:4 [ memoryRemap::upperMemoryPageOffset#2 memoryRemap::upperMemoryPageOffset#1 ] +reg byte a [ memoryRemapBlock::block#0 ] +reg byte a [ memoryRemapBlock::blockBits#0 ] +reg byte a [ memoryRemap::$0 ] +zp[1]:6 [ memoryRemap::$1 ] +reg byte a [ memoryRemap::$2 ] +reg byte a [ memoryRemap::$3 ] +reg byte a [ memoryRemap::$4 ] +reg byte a [ memoryRemap::$5 ] +zp[1]:7 [ memoryRemap::$6 ] +reg byte a [ memoryRemap::$7 ] +reg byte a [ memoryRemap::$8 ] +reg byte a [ memoryRemap::$9 ] diff --git a/src/test/ref/examples/mega65/raster65.asm b/src/test/ref/examples/mega65/raster65.asm index 933be3b08..4575838f3 100644 --- a/src/test/ref/examples/mega65/raster65.asm +++ b/src/test/ref/examples/mega65/raster65.asm @@ -1,7 +1,10 @@ -// Raster65 Demo Implementation in C -// Based on RASTER65 assembler demo made by DEFT in 2015 +// Raster65 Demo re-implementation in C by Jesper Gravgaard +// Based on RASTER65 assembler demo made in 2015 and updated in 2020 by DEFT // https://mega.scryptos.com/sharefolder/MEGA/MEGA65+filehost // https://www.forum64.de/index.php?thread/104591-xemu-vic-iv-implementation-update/&postID=1560511#post1560511 +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .cpu _45gs02 // MEGA65 platform executable starting in C64 mode. .file [name="raster65.prg", type="prg", segments="Program"] @@ -215,7 +218,7 @@ irq: { ldy #0 lda (scroll_ptr),y inw.z scroll_ptr - // if(nxt==0) + // if(nxt == 0) cmp #0 bne __b39 // scroll_ptr = SCROLL_TEXT diff --git a/src/test/ref/examples/mega65/raster65.log b/src/test/ref/examples/mega65/raster65.log index 301c35a1b..28edc663d 100644 --- a/src/test/ref/examples/mega65/raster65.log +++ b/src/test/ref/examples/mega65/raster65.log @@ -2398,10 +2398,13 @@ Allocated zp[1]:38 [ irq::raster#0 ] INITIAL ASM Target platform is mega65_c64 / MEGA45GS02 // File Comments -// Raster65 Demo Implementation in C -// Based on RASTER65 assembler demo made by DEFT in 2015 +// Raster65 Demo re-implementation in C by Jesper Gravgaard +// Based on RASTER65 assembler demo made in 2015 and updated in 2020 by DEFT // https://mega.scryptos.com/sharefolder/MEGA/MEGA65+filehost // https://www.forum64.de/index.php?thread/104591-xemu-vic-iv-implementation-update/&postID=1560511#post1560511 +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform executable starting in C64 mode. @@ -3615,10 +3618,13 @@ Allocated (was zp[1]:28) zp[1]:11 [ greet_idx ] ASSEMBLER BEFORE OPTIMIZATION // File Comments -// Raster65 Demo Implementation in C -// Based on RASTER65 assembler demo made by DEFT in 2015 +// Raster65 Demo re-implementation in C by Jesper Gravgaard +// Based on RASTER65 assembler demo made in 2015 and updated in 2020 by DEFT // https://mega.scryptos.com/sharefolder/MEGA/MEGA65+filehost // https://www.forum64.de/index.php?thread/104591-xemu-vic-iv-implementation-update/&postID=1560511#post1560511 +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform executable starting in C64 mode. @@ -4580,9 +4586,9 @@ Removing instruction jmp __b5 Succesful ASM optimization Pass5NextJumpElimination Removing instruction ldy #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Fixing long branch [135] bne __b2 to beq -Fixing long branch [145] bcc __b17 to bcs -Fixing long branch [152] bne __b19 to beq +Fixing long branch [138] bne __b2 to beq +Fixing long branch [148] bcc __b17 to bcs +Fixing long branch [155] bne __b19 to beq FINAL SYMBOL TABLE (const nomodify struct MOS6526_CIA*) CIA1 = (struct MOS6526_CIA*) 56320 @@ -5121,10 +5127,13 @@ FINAL ASSEMBLER Score: 9963 // File Comments -// Raster65 Demo Implementation in C -// Based on RASTER65 assembler demo made by DEFT in 2015 +// Raster65 Demo re-implementation in C by Jesper Gravgaard +// Based on RASTER65 assembler demo made in 2015 and updated in 2020 by DEFT // https://mega.scryptos.com/sharefolder/MEGA/MEGA65+filehost // https://www.forum64.de/index.php?thread/104591-xemu-vic-iv-implementation-update/&postID=1560511#post1560511 +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform executable starting in C64 mode. @@ -5406,7 +5415,7 @@ irq: { lda (scroll_ptr),y // [36] (volatile byte*) scroll_ptr ← ++ (volatile byte*) scroll_ptr -- pbuz1=_inc_pbuz1 inw.z scroll_ptr - // if(nxt==0) + // if(nxt == 0) // [37] if((byte) irq::nxt#0!=(byte) 0) goto irq::@39 -- vbuaa_neq_0_then_la1 cmp #0 bne __b39 diff --git a/src/test/ref/examples/mega65/test-vic4.asm b/src/test/ref/examples/mega65/test-vic4.asm index 96e3c9771..40c1ff2ab 100644 --- a/src/test/ref/examples/mega65/test-vic4.asm +++ b/src/test/ref/examples/mega65/test-vic4.asm @@ -1,4 +1,7 @@ // Hello World for MEGA 65 - putting chars directly to the screen +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf .cpu _45gs02 // MEGA65 platform PRG executable starting in MEGA65 mode. .file [name="test-vic4.prg", type="prg", segments="Program"] diff --git a/src/test/ref/examples/mega65/test-vic4.log b/src/test/ref/examples/mega65/test-vic4.log index b440cceaa..c91149cd3 100644 --- a/src/test/ref/examples/mega65/test-vic4.log +++ b/src/test/ref/examples/mega65/test-vic4.log @@ -755,6 +755,9 @@ INITIAL ASM Target platform is mega65 / MEGA45GS02 // File Comments // Hello World for MEGA 65 - putting chars directly to the screen +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform PRG executable starting in MEGA65 mode. @@ -912,6 +915,9 @@ Uplifting [] best 1050 combination ASSEMBLER BEFORE OPTIMIZATION // File Comments // Hello World for MEGA 65 - putting chars directly to the screen +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform PRG executable starting in MEGA65 mode. @@ -1359,6 +1365,9 @@ Score: 960 // File Comments // Hello World for MEGA 65 - putting chars directly to the screen +// MEGA65 Registers and Constants +// The MOS 6526 Complex Interface Adapter (CIA) +// http://archive.6502.org/datasheets/mos_6526_cia_recreated.pdf // Upstart .cpu _45gs02 // MEGA65 platform PRG executable starting in MEGA65 mode.