diff --git a/src/main/java/dk/camelot64/kickc/asm/AsmProgramStaticRegisterValues.java b/src/main/java/dk/camelot64/kickc/asm/AsmProgramStaticRegisterValues.java index c00928166..5e87fe9db 100644 --- a/src/main/java/dk/camelot64/kickc/asm/AsmProgramStaticRegisterValues.java +++ b/src/main/java/dk/camelot64/kickc/asm/AsmProgramStaticRegisterValues.java @@ -107,6 +107,22 @@ public class AsmProgramStaticRegisterValues { if (instructionType.getMnemnonic().equals("sty") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) { current.setyMem(instruction.getParameter()); } + if (instructionType.getMnemnonic().equals("txa")) { + current.setA(current.getX()); + current.setaMem(current.getxMem()); + } + if (instructionType.getMnemnonic().equals("tax")) { + current.setX(current.getA()); + current.setxMem(current.getaMem()); + } + if (instructionType.getMnemnonic().equals("tya")) { + current.setA(current.getY()); + current.setaMem(current.getyMem()); + } + if (instructionType.getMnemnonic().equals("tay")) { + current.setY(current.getA()); + current.setyMem(current.getaMem()); + } if (instructionType.getMnemnonic().equals("sec")) { current.setC(Boolean.TRUE); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java b/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java index 567907b7d..0889ed948 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass5UnnecesaryLoadElimination.java @@ -36,6 +36,14 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization { AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction); if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) { modified = remove(lineIt); + } else if (instructionValues.getX() != null && instructionValues.getX().equals(immValue)) { + getLog().append("Replacing instruction "+instruction+" with TXA"); + instruction.setType(AsmInstructionSet.getInstructionType("txa", AsmAddressingMode.NON, null, false)); + instruction.setParameter(null); + } else if (instructionValues.getY() != null && instructionValues.getY().equals(immValue)) { + getLog().append("Replacing instruction "+instruction+" with TYA"); + instruction.setType(AsmInstructionSet.getInstructionType("tya", AsmAddressingMode.NON, null, false)); + instruction.setParameter(null); } } if (instructionType.getMnemnonic().equals("lda") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) { @@ -58,6 +66,10 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization { AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction); if (instructionValues.getX() != null && instructionValues.getX().equals(immValue)) { modified = remove(lineIt); + } else if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) { + getLog().append("Replacing instruction "+instruction+" with TAX"); + instruction.setType(AsmInstructionSet.getInstructionType("tax", AsmAddressingMode.NON, null, false)); + instruction.setParameter(null); } } if (instructionType.getMnemnonic().equals("ldx") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) { @@ -76,6 +88,10 @@ public class Pass5UnnecesaryLoadElimination extends Pass5AsmOptimization { AsmProgramStaticRegisterValues.AsmRegisterValues instructionValues = staticValues.getValues(instruction); if (instructionValues.getY() != null && instructionValues.getY().equals(immValue)) { modified = remove(lineIt); + } else if (instructionValues.getA() != null && instructionValues.getA().equals(immValue)) { + getLog().append("Replacing instruction "+instruction+" with TAY"); + instruction.setType(AsmInstructionSet.getInstructionType("tay", AsmAddressingMode.NON, null, false)); + instruction.setParameter(null); } } if (instructionType.getMnemnonic().equals("ldy") && (instructionType.getAddressingMode().equals(AsmAddressingMode.ZP)||instructionType.getAddressingMode().equals(AsmAddressingMode.ABS))) { diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm index 6a29d5566..65db375f5 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.asm @@ -395,7 +395,7 @@ init_plot_tables: { lda #0 sta yoffs sta yoffs+1 - ldx #0 + tax b3: txa and #7 @@ -433,7 +433,7 @@ init_screen: { sta b+1 b1: ldy #0 - lda #0 + tya sta (b),y inc b bne !+ diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log index 9a1535c29..f414f7838 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-bresenham.log @@ -18346,6 +18346,8 @@ Removing instruction lda yd Removing instruction lda yd Removing instruction ldy #0 Removing instruction lda #0 +Replacing instruction ldx #0 with TAX +Replacing instruction lda #0 with TYA Succesful ASM optimization Pass5UnnecesaryLoadElimination ASSEMBLER //SEG0 Basic Upstart @@ -19138,7 +19140,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG317 [171] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG318 [171] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] b3_from_b4: @@ -19217,7 +19219,7 @@ init_screen: { b1: //SEG348 [187] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG349 [188] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -20080,7 +20082,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG317 [171] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG318 [171] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG319 [171] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy @@ -20154,7 +20156,7 @@ init_screen: { b1: //SEG348 [187] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG349 [188] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -20978,7 +20980,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG317 [171] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG318 [171] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG319 [171] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy @@ -21049,7 +21051,7 @@ init_screen: { b1: //SEG348 [187] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG349 [188] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -21825,7 +21827,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG317 [171] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax //SEG318 [171] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG319 [171] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy //SEG320 [171] phi (byte) init_plot_tables::y#2 = (byte) init_plot_tables::y#1 [phi:init_plot_tables::@4->init_plot_tables::@3#1] -- register_copy @@ -21894,7 +21896,7 @@ init_screen: { b1: //SEG348 [187] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG349 [188] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -23017,7 +23019,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG317 [171] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax //SEG318 [171] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG319 [171] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy //SEG320 [171] phi (byte) init_plot_tables::y#2 = (byte) init_plot_tables::y#1 [phi:init_plot_tables::@4->init_plot_tables::@3#1] -- register_copy @@ -23086,7 +23088,7 @@ init_screen: { b1: //SEG348 [187] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG349 [188] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm index bea04b769..806ecc276 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.asm @@ -122,7 +122,7 @@ init_plot_tables: { lda #0 sta yoffs sta yoffs+1 - ldx #0 + tax b3: txa and #7 @@ -160,7 +160,7 @@ init_screen: { sta b+1 b1: ldy #0 - lda #0 + tya sta (b),y inc b bne !+ diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log index 393275f6c..f843e70d3 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/bitmap-plotter.log @@ -6913,6 +6913,8 @@ init_screen: { Removing instruction lda #0 Removing instruction ldy #0 Removing instruction lda #0 +Replacing instruction ldx #0 with TAX +Replacing instruction lda #0 with TYA Succesful ASM optimization Pass5UnnecesaryLoadElimination ASSEMBLER //SEG0 Basic Upstart @@ -7141,7 +7143,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG79 [47] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG80 [47] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] b3_from_b4: @@ -7220,7 +7222,7 @@ init_screen: { b1: //SEG110 [63] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG111 [64] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -7511,7 +7513,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG79 [47] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG80 [47] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG81 [47] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy @@ -7585,7 +7587,7 @@ init_screen: { b1: //SEG110 [63] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG111 [64] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -7862,7 +7864,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG79 [47] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax jmp b3 //SEG80 [47] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG81 [47] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy @@ -7933,7 +7935,7 @@ init_screen: { b1: //SEG110 [63] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG111 [64] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -8191,7 +8193,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG79 [47] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax //SEG80 [47] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG81 [47] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy //SEG82 [47] phi (byte) init_plot_tables::y#2 = (byte) init_plot_tables::y#1 [phi:init_plot_tables::@4->init_plot_tables::@3#1] -- register_copy @@ -8260,7 +8262,7 @@ init_screen: { b1: //SEG110 [63] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG111 [64] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b @@ -8659,7 +8661,7 @@ init_plot_tables: { sta yoffs sta yoffs+1 //SEG79 [47] phi (byte) init_plot_tables::y#2 = (byte) 0 [phi:init_plot_tables::@2->init_plot_tables::@3#1] -- xby=coby1 - ldx #0 + tax //SEG80 [47] phi from init_plot_tables::@4 to init_plot_tables::@3 [phi:init_plot_tables::@4->init_plot_tables::@3] //SEG81 [47] phi (byte*) init_plot_tables::yoffs#2 = (byte*) init_plot_tables::yoffs#4 [phi:init_plot_tables::@4->init_plot_tables::@3#0] -- register_copy //SEG82 [47] phi (byte) init_plot_tables::y#2 = (byte) init_plot_tables::y#1 [phi:init_plot_tables::@4->init_plot_tables::@3#1] -- register_copy @@ -8728,7 +8730,7 @@ init_screen: { b1: //SEG110 [63] *((byte*) init_screen::b#2) ← (byte) 0 [ init_screen::b#2 ] ( main:0::init_screen:5 [ init_screen::b#2 ] ) -- _deref_zpptrby1=coby1 ldy #0 - lda #0 + tya sta (b),y //SEG111 [64] (byte*) init_screen::b#1 ← ++ (byte*) init_screen::b#2 [ init_screen::b#1 ] ( main:0::init_screen:5 [ init_screen::b#1 ] ) -- zpptrby1=_inc_zpptrby1 inc b diff --git a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm index 2034c803d..a10d8ff30 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/bresenhamarr.asm @@ -14,10 +14,10 @@ main: { lda #0 sta y ldy #yd/2 - ldx #0 + tax lda #0+0*$28 sta idx - lda #0 + txa sta idx+1 b1: lda #main::@1#1] -- yby=coby1 ldy #yd/2 //SEG11 [2] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#2] -- xby=coby1 - ldx #0 + tax //SEG12 [2] phi (word) main::idx#3 = (byte) 0+(byte) 0*(byte) 40 [phi:main->main::@1#3] -- zpwo1=coby1 lda #0+0*$28 sta idx - lda #0 + txa sta idx+1 jmp b1 //SEG13 [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] @@ -1911,11 +1913,11 @@ main: { //SEG10 [2] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- yby=coby1 ldy #yd/2 //SEG11 [2] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#2] -- xby=coby1 - ldx #0 + tax //SEG12 [2] phi (word) main::idx#3 = (byte) 0+(byte) 0*(byte) 40 [phi:main->main::@1#3] -- zpwo1=coby1 lda #0+0*$28 sta idx - lda #0 + txa sta idx+1 jmp b1 //SEG13 [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] @@ -2012,11 +2014,11 @@ main: { //SEG10 [2] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- yby=coby1 ldy #yd/2 //SEG11 [2] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#2] -- xby=coby1 - ldx #0 + tax //SEG12 [2] phi (word) main::idx#3 = (byte) 0+(byte) 0*(byte) 40 [phi:main->main::@1#3] -- zpwo1=coby1 lda #0+0*$28 sta idx - lda #0 + txa sta idx+1 //SEG13 [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] //SEG14 [2] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy @@ -2156,11 +2158,11 @@ main: { //SEG10 [2] phi (byte) main::e#3 = (const byte) main::yd#0/(byte) 2 [phi:main->main::@1#1] -- yby=coby1 ldy #yd/2 //SEG11 [2] phi (byte) main::x#2 = (byte) 0 [phi:main->main::@1#2] -- xby=coby1 - ldx #0 + tax //SEG12 [2] phi (word) main::idx#3 = (byte) 0+(byte) 0*(byte) 40 [phi:main->main::@1#3] -- zpwo1=coby1 lda #0+0*$28 sta idx - lda #0 + txa sta idx+1 //SEG13 [2] phi from main::@2 to main::@1 [phi:main::@2->main::@1] //SEG14 [2] phi (byte) main::y#2 = (byte) main::y#4 [phi:main::@2->main::@1#0] -- register_copy diff --git a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.asm b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.asm index 5c17fe197..d9ce07037 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.asm @@ -7,8 +7,8 @@ main: { lda #0 sta cnt3 - ldy #0 - ldx #0 + tay + tax jsr inccnt sta SCREEN+0 inx diff --git a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log index 56722e745..15bd4b075 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/modglobal.log @@ -1150,6 +1150,8 @@ inccnt: { rts } +Replacing instruction ldy #0 with TAY +Replacing instruction ldx #0 with TAX Removing instruction bbegin: Removing instruction main_from_b2: Succesful ASM optimization Pass5RedundantLabelElimination @@ -1178,9 +1180,9 @@ main: { lda #0 sta cnt3 //SEG11 [10] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- yby=coby1 - ldy #0 + tay //SEG12 [10] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- xby=coby1 - ldx #0 + tax jsr inccnt //SEG13 main::@1 b1: @@ -1255,9 +1257,9 @@ main: { lda #0 sta cnt3 //SEG11 [10] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- yby=coby1 - ldy #0 + tay //SEG12 [10] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- xby=coby1 - ldx #0 + tax jsr inccnt //SEG13 main::@1 //SEG14 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] ( main:0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] ) @@ -1353,9 +1355,9 @@ main: { lda #0 sta cnt3 //SEG11 [10] phi (byte) cnt2#10 = (byte) 0 [phi:main->inccnt#1] -- yby=coby1 - ldy #0 + tay //SEG12 [10] phi (byte) cnt#11 = (byte) 0 [phi:main->inccnt#2] -- xby=coby1 - ldx #0 + tax jsr inccnt //SEG13 main::@1 //SEG14 [3] (byte~) main::$0 ← (byte) inccnt::return#0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] ( main:0 [ main::$0 cnt#1 cnt2#1 cnt3#1 ] ) diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm index 036d88c9e..08cd2eb27 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.asm @@ -73,7 +73,7 @@ lvalue: { sta SCREEN lda #2 sta SCREEN+1 - ldx #2 + tax b1: cpx #$a bcc b2 diff --git a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log index 191a76d76..d4204c4af 100644 --- a/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log +++ b/src/main/java/dk/camelot64/kickc/test/ref/ptrtest.log @@ -3054,6 +3054,7 @@ lvalue: { jmp b1 } +Replacing instruction ldx #2 with TAX FINAL SYMBOL TABLE (label) @5 (label) @begin @@ -3264,7 +3265,7 @@ lvalue: { sta SCREEN+1 //SEG66 [30] phi from lvalue to lvalue::@1 [phi:lvalue->lvalue::@1] //SEG67 [30] phi (byte) lvalue::i#2 = (byte) 2 [phi:lvalue->lvalue::@1#0] -- xby=coby1 - ldx #2 + tax //SEG68 lvalue::@1 b1: //SEG69 [31] if((byte) lvalue::i#2<(byte) 10) goto lvalue::@2 [ lvalue::i#2 ] ( main:0::lvalue:2 [ lvalue::i#2 ] ) -- xby_lt_coby1_then_la1