diff --git a/src/main/fragment/mos6502-common/_deref_pvom1=pvom1_derefidx_vbuyy_memcpy_vbuxx.asm b/src/main/fragment/mos6502-common/_deref_pvom1=pvom1_derefidx_vbuyy_memcpy_vbuxx.asm new file mode 100644 index 000000000..b300fcf6b --- /dev/null +++ b/src/main/fragment/mos6502-common/_deref_pvom1=pvom1_derefidx_vbuyy_memcpy_vbuxx.asm @@ -0,0 +1,17 @@ +lda {m1} +sta $fc +clc +sty $fe +adc $fe +sta $fe +lda {m1}+1 +sta $fd +adc #00 +sta $ff +ldy #0 +!: +lda ($fe),y +sta ($fc),y +iny +dex +bne !- \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuxx=vdsc2.asm b/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuxx=vdsc2.asm index 5286b2e77..a224a20a2 100644 --- a/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuxx=vdsc2.asm +++ b/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuxx=vdsc2.asm @@ -2,7 +2,7 @@ lda #<{c2} sta {c1},x lda #>{c2} sta {c1}+1,x -lda #<{c2}>>16 +lda #<{c2}>>$10 sta {c1}+2,x -lda #>{c2}>>16 +lda #>{c2}>>$10 sta {c1}+3,x \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuyy=vdsc2.asm b/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuyy=vdsc2.asm index bb7de7902..8f7b562be 100644 --- a/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuyy=vdsc2.asm +++ b/src/main/fragment/mos6502-common/pdsc1_derefidx_vbuyy=vdsc2.asm @@ -2,7 +2,7 @@ lda #<{c2} sta {c1},y lda #>{c2} sta {c1}+1,y -lda #<{c2}>>16 +lda #<{c2}>>$10 sta {c1}+2,y -lda #>{c2}>>16 +lda #>{c2}>>$10 sta {c1}+3,y \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/pdsm1_derefidx_vbuyy=vdsc2.asm b/src/main/fragment/mos6502-common/pdsm1_derefidx_vbuyy=vdsc2.asm index 25d744686..9fbe5ab8a 100644 --- a/src/main/fragment/mos6502-common/pdsm1_derefidx_vbuyy=vdsc2.asm +++ b/src/main/fragment/mos6502-common/pdsm1_derefidx_vbuyy=vdsc2.asm @@ -8,8 +8,8 @@ iny lda #>{c2} sta ($fe),y iny -lda #<{c2}>>16 +lda #<{c2}>>$10 sta ($fe),y iny -lda #>{c2}>>16 +lda #>{c2}>>$10 sta ($fe),y \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/pwuz1_derefidx_vbuyy_lt_vdum2_then_la1.asm b/src/main/fragment/mos6502-common/pwuz1_derefidx_vbuyy_lt_vdum2_then_la1.asm new file mode 100644 index 000000000..ef8dccaf2 --- /dev/null +++ b/src/main/fragment/mos6502-common/pwuz1_derefidx_vbuyy_lt_vdum2_then_la1.asm @@ -0,0 +1,13 @@ +lda {m2} +ora {m2}+1 +bne {la1} +iny +lda ({z1}),y +cmp {m2}+1 +bcc {la1} +bne !+ +dey +lda ({z1}),y +cmp {m2} +bcc {la1} +!: \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuaa=vdsm1.asm b/src/main/fragment/mos6502-common/vbuaa=vdsm1.asm new file mode 100644 index 000000000..33194a2c1 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuaa=vdsm1.asm @@ -0,0 +1 @@ +lda {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuaa=vdum1.asm b/src/main/fragment/mos6502-common/vbuaa=vdum1.asm new file mode 100644 index 000000000..33194a2c1 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuaa=vdum1.asm @@ -0,0 +1 @@ +lda {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuaa=vwuc1.asm b/src/main/fragment/mos6502-common/vbuaa=vwuc1.asm new file mode 100644 index 000000000..01f77a8e6 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuaa=vwuc1.asm @@ -0,0 +1 @@ +lda #<{c1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuaa=vwum1.asm b/src/main/fragment/mos6502-common/vbuaa=vwum1.asm new file mode 100644 index 000000000..33194a2c1 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuaa=vwum1.asm @@ -0,0 +1 @@ +lda {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuxx=vdsm1.asm b/src/main/fragment/mos6502-common/vbuxx=vdsm1.asm new file mode 100644 index 000000000..499199726 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuxx=vdsm1.asm @@ -0,0 +1 @@ +ldx {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuxx=vdum1.asm b/src/main/fragment/mos6502-common/vbuxx=vdum1.asm new file mode 100644 index 000000000..499199726 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuxx=vdum1.asm @@ -0,0 +1 @@ +ldx {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuxx=vwuc1.asm b/src/main/fragment/mos6502-common/vbuxx=vwuc1.asm new file mode 100644 index 000000000..29fafadb2 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuxx=vwuc1.asm @@ -0,0 +1 @@ +ldx #<{c1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuxx=vwum1.asm b/src/main/fragment/mos6502-common/vbuxx=vwum1.asm new file mode 100644 index 000000000..499199726 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuxx=vwum1.asm @@ -0,0 +1 @@ +ldx {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuyy=vdsm1.asm b/src/main/fragment/mos6502-common/vbuyy=vdsm1.asm new file mode 100644 index 000000000..0f004cb1f --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuyy=vdsm1.asm @@ -0,0 +1 @@ +ldy {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuyy=vdum1.asm b/src/main/fragment/mos6502-common/vbuyy=vdum1.asm new file mode 100644 index 000000000..0f004cb1f --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuyy=vdum1.asm @@ -0,0 +1 @@ +ldy {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuyy=vwuc1.asm b/src/main/fragment/mos6502-common/vbuyy=vwuc1.asm new file mode 100644 index 000000000..8f31af013 --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuyy=vwuc1.asm @@ -0,0 +1 @@ +ldy #<{c1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vbuyy=vwum1.asm b/src/main/fragment/mos6502-common/vbuyy=vwum1.asm new file mode 100644 index 000000000..0f004cb1f --- /dev/null +++ b/src/main/fragment/mos6502-common/vbuyy=vwum1.asm @@ -0,0 +1 @@ +ldy {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vdsm1=pdsm2_derefidx_vbuyy_plus_vdsc1.asm b/src/main/fragment/mos6502-common/vdsm1=pdsm2_derefidx_vbuyy_plus_vdsc1.asm index ef6180389..0685aa992 100644 --- a/src/main/fragment/mos6502-common/vdsm1=pdsm2_derefidx_vbuyy_plus_vdsc1.asm +++ b/src/main/fragment/mos6502-common/vdsm1=pdsm2_derefidx_vbuyy_plus_vdsc1.asm @@ -12,9 +12,9 @@ adc #>{c1} sta {m1}+1 iny lda ($fe),y -adc #<{c1}>>16 +adc #<{c1}>>$10 sta {m1}+2 iny lda ($fe),y -adc #>{c1}>>16 +adc #>{c1}>>$10 sta {m1}+3 \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vdum1=vdum1_minus_pduz2_derefidx_vbuyy.asm b/src/main/fragment/mos6502-common/vdum1=vdum1_minus_pduz2_derefidx_vbuyy.asm new file mode 100644 index 000000000..97b6d9336 --- /dev/null +++ b/src/main/fragment/mos6502-common/vdum1=vdum1_minus_pduz2_derefidx_vbuyy.asm @@ -0,0 +1,16 @@ +lda {m1} +sec +sbc ({z2}),y +sta {m1} +iny +lda {m1}+1 +sbc ({z2}),y +sta {m1}+1 +iny +lda {m1}+2 +sbc ({z2}),y +sta {m1}+2 +iny +lda {m1}+3 +sbc ({z2}),y +sta {m1}+3 \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vdum1=vdum1_minus_vwum2.asm b/src/main/fragment/mos6502-common/vdum1=vdum1_minus_vwum2.asm new file mode 100644 index 000000000..b92448ad8 --- /dev/null +++ b/src/main/fragment/mos6502-common/vdum1=vdum1_minus_vwum2.asm @@ -0,0 +1,13 @@ +lda {m1} +sec +sbc {m2} +sta {m1} +lda {m1}+1 +sbc {m2}+1 +sta {m1}+1 +lda {m1}+2 +sbc #0 +sta {m1}+2 +lda {m1}+3 +sbc #0 +sta {m1}+3 \ No newline at end of file diff --git a/src/main/fragment/mos6502-common/vdum1_eq_vdsc1_then_la1.asm b/src/main/fragment/mos6502-common/vdum1_eq_vdsc1_then_la1.asm new file mode 100644 index 000000000..530c9c616 --- /dev/null +++ b/src/main/fragment/mos6502-common/vdum1_eq_vdsc1_then_la1.asm @@ -0,0 +1,13 @@ +lda {m1}+3 +cmp #>{c1}>>$10 +bne !+ +lda {m1}+2 +cmp #<{c1}>>$10 +bne !+ +lda {m1}+1 +cmp #>{c1} +bne !+ +lda {m1} +cmp #<{c1} +beq {la1} +!: \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java index c7a77c29f..97c9fa810 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java @@ -751,12 +751,18 @@ class AsmFragmentTemplateSynthesisRule { synths.add(new AsmFragmentTemplateSynthesisRule("(.*)z2(.*)z1(.*)", twoZM1 + "|" + twoZM2, null, "$1z1$2z2$3", null, mapZM2Swap, false)); // Correct wrong ordered Z2/Z1 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m2(.*)m1(.*)", twoZM1 + "|" + twoZM2, null, "$1m1$2m2$3", null, mapZM2Swap, false)); + // Correct wrong ordered M2/Z1 + synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m2(.*)z1(.*)", twoZM1 + "|" + twoZM2, null, "$1m1$2z2$3", null, mapZM2Swap, false)); + // Correct wrong ordered Z2/M1 + synths.add(new AsmFragmentTemplateSynthesisRule("(.*)z2(.*)m1(.*)", twoZM1 + "|" + twoZM2, null, "$1z1$2m2$3", null, mapZM2Swap, false)); // Correct wrong ordered Z3/Z2 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m3(.*)m2(.*)", twoZM2 + "|" + twoZM3, null, "$1m2$2m3$3", null, mapZM3Swap, false)); // Correct wrong ordered Z4/Z3 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m4(.*)m3(.*)", twoZM3 + "|" + twoZM4, null, "$1m3$2m4$3", null, mapZM4Swap, false)); - // Correct wrong ordered Z2/Z1 + // Correct wrong ordered M2/M2/M1 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m2(.*)m2(.*)m1(.*)", twoZM1 + "|" + threeZM2, null, "$1m1$2m1$3m2$4", null, mapZM2Swap, false)); + // Correct wrong ordered M2/M2/Z1 + synths.add(new AsmFragmentTemplateSynthesisRule("(.*)m2(.*)m2(.*)z1(.*)", twoZM1 + "|" + threeZM2, null, "$1m1$2m1$3z2$4", null, mapZM2Swap, false)); // Correct wrong ordered C2/C1 synths.add(new AsmFragmentTemplateSynthesisRule("(.*)c2(.*)c1(.*)", twoC1 + "|" + twoC2, null, "$1c1$2c2$3", null, mapC2Swap, false)); diff --git a/src/main/kc/include/mega65-dma.h b/src/main/kc/include/mega65-dma.h index 906f5dfaa..d6043e5fd 100644 --- a/src/main/kc/include/mega65-dma.h +++ b/src/main/kc/include/mega65-dma.h @@ -11,9 +11,9 @@ void memcpy_dma(void* dest, void* src, unsigned int num); /// Copy a memory block anywhere in first 4MB memory space using MEGA65 DMagic DMA /// Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. -/// @param dest_bank The 64KB bank for the destination (0-63) +/// @param dest_bank The 64KB bank for the destination (0-127) /// @param dest The destination address (within the MB and bank) -/// @param src_bank The 64KB bank for the source (0-63) +/// @param src_bank The 64KB bank for the source (0-127) /// @param src The source address (within the MB and bank) /// @param num The number of bytes to copy void memcpy_dma4(char dest_bank, void* dest, char src_bank, void* src, unsigned int num); diff --git a/src/main/kc/lib/mega65-dma.c b/src/main/kc/lib/mega65-dma.c index 265d6ba00..5ac42738b 100644 --- a/src/main/kc/lib/mega65-dma.c +++ b/src/main/kc/lib/mega65-dma.c @@ -39,9 +39,9 @@ struct DMA_LIST_F018B memcpy_dma_command = { // Copy a memory block anywhere in first 4MB memory space using MEGA65 DMagic DMA // Copies the values of num bytes from the location pointed to by source directly to the memory block pointed to by destination. -// - dest_bank The 64KB bank for the destination (0-63) +// - dest_bank The 64KB bank for the destination (0-127) // - dest The destination address (within the MB and bank) -// - src_bank The 64KB bank for the source (0-63) +// - src_bank The 64KB bank for the source (0-127) // - src The source address (within the MB and bank) // - num The number of bytes to copy void memcpy_dma4(char dest_bank, void* dest, char src_bank, void* src, unsigned int num) {