diff --git a/src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuc1.asm b/src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuyy.asm similarity index 85% rename from src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuc1.asm rename to src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuyy.asm index 0649e2556..e02a6901c 100644 --- a/src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuc1.asm +++ b/src/main/fragment/mos6502-common/pssz1=pptz1_derefidx_vbuyy.asm @@ -1,4 +1,3 @@ -ldy #{c1} lda ({z1}),y pha iny diff --git a/src/main/fragment/mos6502-common/vwsz1=_deref_pwsz1.asm b/src/main/fragment/mos6502-common/vwsz1=_deref_pwsz1.asm index 93a8b3b23..94fcb2f49 100644 --- a/src/main/fragment/mos6502-common/vwsz1=_deref_pwsz1.asm +++ b/src/main/fragment/mos6502-common/vwsz1=_deref_pwsz1.asm @@ -1,7 +1,8 @@ ldy #0 lda ({z1}),y -tax +pha iny lda ({z1}),y -stx {z1} -sta {z1}+1 \ No newline at end of file +sta {z1}+1 +pla +sta {z1} diff --git a/src/main/fragment/mos6502-common/vwuz1=_deref_pwuz1.asm b/src/main/fragment/mos6502-common/vwuz1=_deref_pwuz1.asm index 7e9202dc9..94fcb2f49 100644 --- a/src/main/fragment/mos6502-common/vwuz1=_deref_pwuz1.asm +++ b/src/main/fragment/mos6502-common/vwuz1=_deref_pwuz1.asm @@ -1,7 +1,8 @@ ldy #0 lda ({z1}),y -tax +pha iny lda ({z1}),y sta {z1}+1 -stx {z1} +pla +sta {z1} diff --git a/src/main/fragment/mos6502-selfmod/_deref_(_deref_pptz1)=pbuc1_derefidx_vbuxx.asm b/src/main/fragment/mos6502-selfmod/_deref_(_deref_pptz1)=pbuc1_derefidx_vbuxx.asm deleted file mode 100644 index 1d22175ee..000000000 --- a/src/main/fragment/mos6502-selfmod/_deref_(_deref_pptz1)=pbuc1_derefidx_vbuxx.asm +++ /dev/null @@ -1,5 +0,0 @@ -ldy #0 -lda {z1} -sta !+ +1 -lda {c1},x -!: sta ($ff),y diff --git a/src/main/fragment/mos6502-undoc/vbum1=vbuaa_band_vbuxx.asm b/src/main/fragment/mos6502-undoc/vbum1=vbuaa_band_vbuxx.asm new file mode 100644 index 000000000..6bcf679c2 --- /dev/null +++ b/src/main/fragment/mos6502-undoc/vbum1=vbuaa_band_vbuxx.asm @@ -0,0 +1 @@ +sax {m1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-undoc/vbuxx=vbuz1_minus_vbuc1.asm b/src/main/fragment/mos6502-undoc/vbuxx=vbum1_minus_vbuc1.asm similarity index 50% rename from src/main/fragment/mos6502-undoc/vbuxx=vbuz1_minus_vbuc1.asm rename to src/main/fragment/mos6502-undoc/vbuxx=vbum1_minus_vbuc1.asm index b374558ae..e6e76f0a5 100644 --- a/src/main/fragment/mos6502-undoc/vbuxx=vbuz1_minus_vbuc1.asm +++ b/src/main/fragment/mos6502-undoc/vbuxx=vbum1_minus_vbuc1.asm @@ -1,2 +1,2 @@ -lax {z1} +lax {m1} axs #{c1} \ No newline at end of file diff --git a/src/main/fragment/mos6502-undoc/vbuxx=vbuz1_plus_vbuc1.asm b/src/main/fragment/mos6502-undoc/vbuxx=vbum1_plus_vbuc1.asm similarity index 57% rename from src/main/fragment/mos6502-undoc/vbuxx=vbuz1_plus_vbuc1.asm rename to src/main/fragment/mos6502-undoc/vbuxx=vbum1_plus_vbuc1.asm index 7bb35ab69..8c5c9ab24 100644 --- a/src/main/fragment/mos6502-undoc/vbuxx=vbuz1_plus_vbuc1.asm +++ b/src/main/fragment/mos6502-undoc/vbuxx=vbum1_plus_vbuc1.asm @@ -1,2 +1,2 @@ -lax {z1} +lax {m1} axs #-[{c1}] \ No newline at end of file diff --git a/src/main/fragment/mos6502-undoc/vbuz1=vbuaa_band_vbuxx.asm b/src/main/fragment/mos6502-undoc/vbuz1=vbuaa_band_vbuxx.asm deleted file mode 100644 index 124679d63..000000000 --- a/src/main/fragment/mos6502-undoc/vbuz1=vbuaa_band_vbuxx.asm +++ /dev/null @@ -1 +0,0 @@ -sax {z1} \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java b/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java index dafdf32ad..e5158502f 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Scope.java @@ -347,7 +347,7 @@ public abstract class Scope implements Symbol, Serializable { if(asmName != null) { res.append(" " + asmName); } - if(SymbolVariable.StorageStrategy.MEMORY.equals(symVar.getStorageStrategy())) { + if(symVar.isStorageMemory()) { res.append(" memory"); } Registers.Register declRegister = symVar.getDeclaredRegister(); diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/SymbolVariable.java b/src/main/java/dk/camelot64/kickc/model/symbols/SymbolVariable.java index b6b523f19..dd0584148 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/SymbolVariable.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/SymbolVariable.java @@ -202,7 +202,7 @@ public abstract class SymbolVariable implements Symbol { } public boolean isVolatile() { - return declaredVolatile || inferedVolatile || StorageStrategy.MEMORY.equals(getStorageStrategy()); + return declaredVolatile || inferedVolatile || isStorageMemory(); } public boolean isDeclaredExport() { diff --git a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java index 737a3d0c4..07950db4b 100644 --- a/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java +++ b/src/main/java/dk/camelot64/kickc/model/symbols/Variable.java @@ -27,7 +27,7 @@ public class Variable extends SymbolVariable { public Variable(String name, Scope scope, SymbolType type, String dataSegment, StorageStrategy storageStrategy) { super(name, scope, type, storageStrategy, dataSegment); - if(StorageStrategy.PHI_MASTER.equals(storageStrategy)) + if(isStoragePhiMaster()) this.nextPhiVersionNumber = 0; } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java b/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java index a5a916525..58c3d49f5 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1UnwindStructValues.java @@ -220,10 +220,8 @@ public class Pass1UnwindStructValues extends Pass1Base { memberVariable.setInferedVolatile(variable.isInferedVolatile()); memberVariable.setDeclaredConstant(variable.isDeclaredConstant()); memberVariable.setDeclaredExport(variable.isDeclaredExport()); - if(variable.getStorageStrategy().equals(SymbolVariable.StorageStrategy.MEMORY)) { - if(member.getStorageStrategy().equals(SymbolVariable.StorageStrategy.PHI_MASTER)) - memberVariable.setStorageStrategy(SymbolVariable.StorageStrategy.MEMORY); - } + if(variable.isStorageMemory() && member.isStoragePhiMaster()) + memberVariable.setStorageStrategy(SymbolVariable.StorageStrategy.MEMORY); variableUnwinding.setMemberUnwinding(member.getLocalName(), memberVariable.getRef()); getLog().append("Created struct value member variable " + memberVariable.toString(getProgram())); } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass2AssertRValues.java b/src/main/java/dk/camelot64/kickc/passes/Pass2AssertRValues.java index 970a55b81..78c12aba7 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass2AssertRValues.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass2AssertRValues.java @@ -31,7 +31,7 @@ public class Pass2AssertRValues extends Pass2SsaAssertion { if(rValue instanceof VariableRef) { VariableRef variableRef = (VariableRef) rValue; Variable variable = getScope().getVariable(variableRef); - if(variable.getStorageStrategy().equals(SymbolVariable.StorageStrategy.PHI_MASTER)) { + if(variable.isStoragePhiMaster()) { throw new CompileError("No unversioned variable references allowed "+currentStmt.toString(getProgram(), false), currentStmt.getSource()); } } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index 123026e51..16bb9c9d8 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -465,7 +465,7 @@ public class Pass4CodeGeneration { // Add all memory variables Collection scopeVariables = scope.getAllVariables(false); for(Variable variable : scopeVariables) { - if(variable.getStorageStrategy().equals(SymbolVariable.StorageStrategy.MEMORY)) { + if(variable.isStorageMemory()) { // Skip if already added String asmName = variable.getAsmName() == null ? variable.getLocalName() : variable.getAsmName(); if(added.contains(asmName)) { diff --git a/src/test/ref/bitmap-plot-1.asm b/src/test/ref/bitmap-plot-1.asm index 0b1479caf..8b4248413 100644 --- a/src/test/ref/bitmap-plot-1.asm +++ b/src/test/ref/bitmap-plot-1.asm @@ -98,11 +98,12 @@ main: { sta.z __27+1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x lda #<$a0 sta.z mul16s.a lda #>$a0 @@ -146,11 +147,12 @@ main: { sta.z __28+1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y lda #<$64 sta.z mul16s.a lda #>$64 diff --git a/src/test/ref/bitmap-plot-1.log b/src/test/ref/bitmap-plot-1.log index f43fa8c99..5275177d5 100644 --- a/src/test/ref/bitmap-plot-1.log +++ b/src/test/ref/bitmap-plot-1.log @@ -6574,11 +6574,12 @@ main: { // [18] (signed word) main::cos_x#0 ← *((signed word*~) main::$27) -- vwsz1=_deref_pwsz1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x // [19] (signed word) mul16s::b#1 ← (signed word) main::cos_x#0 // [20] call mul16s // [54] phi from main::@2 to mul16s [phi:main::@2->mul16s] @@ -6639,11 +6640,12 @@ main: { // [28] (signed word) main::sin_y#0 ← *((signed word*~) main::$28) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y // [29] (signed word) mul16s::b#2 ← (signed word) main::sin_y#0 // [30] call mul16s // [54] phi from main::@9 to mul16s [phi:main::@9->mul16s] @@ -8621,7 +8623,7 @@ reg byte a [ divr16u::$2 ] FINAL ASSEMBLER -Score: 20291 +Score: 20391 // File Comments // Tests the simple bitmap plotter - and counts plots per frame in an IRQ @@ -8769,11 +8771,12 @@ main: { // [18] (signed word) main::cos_x#0 ← *((signed word*~) main::$27) -- vwsz1=_deref_pwsz1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x // mul16s(160, cos_x) // [19] (signed word) mul16s::b#1 ← (signed word) main::cos_x#0 // [20] call mul16s @@ -8838,11 +8841,12 @@ main: { // [28] (signed word) main::sin_y#0 ← *((signed word*~) main::$28) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y // mul16s(100, sin_y) // [29] (signed word) mul16s::b#2 ← (signed word) main::sin_y#0 // [30] call mul16s diff --git a/src/test/ref/bitmap-plot-2.asm b/src/test/ref/bitmap-plot-2.asm index ee296c47e..a5407af22 100644 --- a/src/test/ref/bitmap-plot-2.asm +++ b/src/test/ref/bitmap-plot-2.asm @@ -107,11 +107,12 @@ main: { sta.z __36+1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x jsr mul16s lda.z xpos+2 sta.z __10 @@ -147,11 +148,12 @@ main: { sta.z __37+1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y jsr mul16s lda.z ypos+2 sta.z __16 diff --git a/src/test/ref/bitmap-plot-2.log b/src/test/ref/bitmap-plot-2.log index 48d29604d..4bd6ad71e 100644 --- a/src/test/ref/bitmap-plot-2.log +++ b/src/test/ref/bitmap-plot-2.log @@ -6897,11 +6897,12 @@ main: { // [18] (signed word) main::cos_x#0 ← *((signed word*~) main::$36) -- vwsz1=_deref_pwsz1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x // [19] (signed word) mul16s::a#1 ← (signed word) main::r#10 // [20] (signed word) mul16s::b#1 ← (signed word) main::cos_x#0 // [21] call mul16s @@ -6955,11 +6956,12 @@ main: { // [29] (signed word) main::sin_y#0 ← *((signed word*~) main::$37) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y // [30] (signed word) mul16s::a#2 ← (signed word) main::r#10 // [31] (signed word) mul16s::b#2 ← (signed word) main::sin_y#0 // [32] call mul16s @@ -9024,7 +9026,7 @@ reg byte a [ divr16u::$2 ] FINAL ASSEMBLER -Score: 20476 +Score: 20576 // File Comments // Tests the simple bitmap plotter - and counts plots per frame in an IRQ @@ -9183,11 +9185,12 @@ main: { // [18] (signed word) main::cos_x#0 ← *((signed word*~) main::$36) -- vwsz1=_deref_pwsz1 ldy #0 lda (cos_x),y - tax + pha iny lda (cos_x),y - stx.z cos_x sta.z cos_x+1 + pla + sta.z cos_x // mul16s(r, cos_x) // [19] (signed word) mul16s::a#1 ← (signed word) main::r#10 // [20] (signed word) mul16s::b#1 ← (signed word) main::cos_x#0 @@ -9245,11 +9248,12 @@ main: { // [29] (signed word) main::sin_y#0 ← *((signed word*~) main::$37) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_y),y - tax + pha iny lda (sin_y),y - stx.z sin_y sta.z sin_y+1 + pla + sta.z sin_y // mul16s(r, sin_y) // [30] (signed word) mul16s::a#2 ← (signed word) main::r#10 // [31] (signed word) mul16s::b#2 ← (signed word) main::sin_y#0 diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.asm b/src/test/ref/examples/scrolllogo/scrolllogo.asm index fdb6e5185..986260c28 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.asm +++ b/src/test/ref/examples/scrolllogo/scrolllogo.asm @@ -93,11 +93,12 @@ loop: { sta.z __2+1 ldy #0 lda (xpos),y - tax + pha iny lda (xpos),y - stx.z xpos sta.z xpos+1 + pla + sta.z xpos jsr render_logo inc.z xsin_idx bne !+ diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.log b/src/test/ref/examples/scrolllogo/scrolllogo.log index 93ba1c177..def6f7956 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.log +++ b/src/test/ref/examples/scrolllogo/scrolllogo.log @@ -6629,11 +6629,12 @@ loop: { // [31] (signed word) loop::xpos#0 ← *((signed word*~) loop::$2) -- vwsz1=_deref_pwsz1 ldy #0 lda (xpos),y - tax + pha iny lda (xpos),y - stx.z xpos sta.z xpos+1 + pla + sta.z xpos // [32] (signed word) render_logo::xpos#0 ← (signed word) loop::xpos#0 // [33] call render_logo jsr render_logo @@ -8508,7 +8509,7 @@ zp ZP_WORD:35 [ memset::end#0 sin16s_gen2::i#2 sin16s_gen2::i#1 xsin_idx#11 xsin FINAL ASSEMBLER -Score: 46394 +Score: 46444 // File Comments // Upstart @@ -8685,11 +8686,12 @@ loop: { // [31] (signed word) loop::xpos#0 ← *((signed word*~) loop::$2) -- vwsz1=_deref_pwsz1 ldy #0 lda (xpos),y - tax + pha iny lda (xpos),y - stx.z xpos sta.z xpos+1 + pla + sta.z xpos // render_logo(xpos) // [32] (signed word) render_logo::xpos#0 ← (signed word) loop::xpos#0 // [33] call render_logo diff --git a/src/test/ref/examples/sinplotter/sine-plotter.asm b/src/test/ref/examples/sinplotter/sine-plotter.asm index fca1b6dea..c80ea62d6 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.asm +++ b/src/test/ref/examples/sinplotter/sine-plotter.asm @@ -102,11 +102,12 @@ render_sine: { sta.z __1+1 ldy #0 lda (sin_val),y - tax + pha iny lda (sin_val),y - stx.z sin_val sta.z sin_val+1 + pla + sta.z sin_val jsr wrap_y tax jsr bitmap_plot @@ -125,11 +126,12 @@ render_sine: { sta.z __4+1 ldy #0 lda (sin2_val),y - tax + pha iny lda (sin2_val),y - stx.z sin2_val sta.z sin2_val+1 + pla + sta.z sin2_val lda.z wrap_y.y clc adc #<$a diff --git a/src/test/ref/examples/sinplotter/sine-plotter.log b/src/test/ref/examples/sinplotter/sine-plotter.log index 3c0f7bc5e..344abe8bc 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.log +++ b/src/test/ref/examples/sinplotter/sine-plotter.log @@ -6334,11 +6334,12 @@ render_sine: { // [28] (signed word) render_sine::sin_val#0 ← *((signed word*~) render_sine::$1) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_val),y - tax + pha iny lda (sin_val),y - stx.z sin_val sta.z sin_val+1 + pla + sta.z sin_val // [29] (signed word) wrap_y::y#0 ← (signed word) render_sine::sin_val#0 // [30] call wrap_y // [58] phi from render_sine::@2 to wrap_y [phi:render_sine::@2->wrap_y] @@ -6380,11 +6381,12 @@ render_sine: { // [38] (signed word) render_sine::sin2_val#0 ← *((signed word*~) render_sine::$4) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin2_val),y - tax + pha iny lda (sin2_val),y - stx.z sin2_val sta.z sin2_val+1 + pla + sta.z sin2_val // [39] (signed word) wrap_y::y#1 ← (signed word) render_sine::sin2_val#0 + (signed byte) $a -- vwsz1=vwsz1_plus_vbsc1 lda.z wrap_y.y clc @@ -8256,7 +8258,7 @@ reg byte a [ bitmap_init::$6 ] FINAL ASSEMBLER -Score: 24649 +Score: 24749 // File Comments // Generate a big sinus and plot it on a bitmap @@ -8433,11 +8435,12 @@ render_sine: { // [28] (signed word) render_sine::sin_val#0 ← *((signed word*~) render_sine::$1) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin_val),y - tax + pha iny lda (sin_val),y - stx.z sin_val sta.z sin_val+1 + pla + sta.z sin_val // wrap_y(sin_val) // [29] (signed word) wrap_y::y#0 ← (signed word) render_sine::sin_val#0 // [30] call wrap_y @@ -8479,11 +8482,12 @@ render_sine: { // [38] (signed word) render_sine::sin2_val#0 ← *((signed word*~) render_sine::$4) -- vwsz1=_deref_pwsz1 ldy #0 lda (sin2_val),y - tax + pha iny lda (sin2_val),y - stx.z sin2_val sta.z sin2_val+1 + pla + sta.z sin2_val // wrap_y(sin2_val+10) // [39] (signed word) wrap_y::y#1 ← (signed word) render_sine::sin2_val#0 + (signed byte) $a -- vwsz1=vwsz1_plus_vbsc1 lda.z wrap_y.y diff --git a/src/test/ref/sinusgen8b.asm b/src/test/ref/sinusgen8b.asm index c361ccf98..eee38a2b1 100644 --- a/src/test/ref/sinusgen8b.asm +++ b/src/test/ref/sinusgen8b.asm @@ -23,7 +23,7 @@ main: { .label __4 = $18 .label __11 = $18 .label sb = $17 - .label sw = $20 + .label sw = $18 jsr sin8s_gen jsr sin16s_gen jsr print_cls @@ -49,11 +49,14 @@ main: { adc #>sintabw sta.z __4+1 ldy #0 - lda (__4),y - sta.z sw + lda (sw),y + pha iny - lda (__4),y + lda (sw),y sta.z sw+1 + pla + sta.z sw + lda.z sw+1 eor #$ff sec adc.z sb @@ -265,14 +268,14 @@ sin16s: { .label __4 = 6 .label x = 6 .label return = $18 - .label x1 = $20 + .label x1 = $1e .label x2 = $10 .label x3 = $10 - .label x3_6 = $1e + .label x3_6 = $20 .label usinx = $18 .label x4 = $10 - .label x5 = $1e - .label x5_128 = $1e + .label x5 = $20 + .label x5_128 = $20 .label sinx = $18 .label isUpper = $14 lda.z x+3 @@ -442,7 +445,7 @@ mulu16_sel: { .label __1 = 6 .label v1 = $10 .label v2 = $12 - .label return = $1e + .label return = $20 .label return_1 = $10 .label return_10 = $10 lda.z v1 @@ -467,9 +470,9 @@ mulu16_sel: { rts } // Perform binary multiplication of two unsigned 16-bit words into a 32-bit unsigned double word -// mul16u(word zeropage($1e) a, word zeropage($12) b) +// mul16u(word zeropage($20) a, word zeropage($12) b) mul16u: { - .label a = $1e + .label a = $20 .label mb = $a .label res = 6 .label b = $12 @@ -612,7 +615,7 @@ divr16u: { sin8s_gen: { .label step = $10 .label sintab = $18 - .label x = $1e + .label x = $20 .label i = $12 jsr div16u lda #sin8s_gen] sin8s_gen_from_main: @@ -6420,13 +6420,15 @@ main: { lda.z __4+1 adc #>sintabw sta.z __4+1 - // [15] (signed word) main::sw#0 ← *((signed word*~) main::$4) -- vwsz1=_deref_pwsz2 + // [15] (signed word) main::sw#0 ← *((signed word*~) main::$4) -- vwsz1=_deref_pwsz1 ldy #0 - lda (__4),y - sta.z sw + lda (sw),y + pha iny - lda (__4),y + lda (sw),y sta.z sw+1 + pla + sta.z sw // [16] (byte~) main::$6 ← > (signed word) main::sw#0 -- vbuaa=_hi_vwsz1 lda.z sw+1 // [17] (signed byte) main::sd#0 ← (signed byte) main::sb#0 - (signed byte)(byte~) main::$6 -- vbsaa=vbsz1_minus_vbsaa @@ -6814,14 +6816,14 @@ sin16s: { .label __4 = 6 .label x = 6 .label return = $18 - .label x1 = $20 + .label x1 = $1e .label x2 = $10 .label x3 = $10 - .label x3_6 = $1e + .label x3_6 = $20 .label usinx = $18 .label x4 = $10 - .label x5 = $1e - .label x5_128 = $1e + .label x5 = $20 + .label x5_128 = $20 .label sinx = $18 .label isUpper = $14 // [77] if((dword) sin16s::x#0<(const dword) PI_u4f28) goto sin16s::@1 -- vduz1_lt_vduc1_then_la1 @@ -7105,7 +7107,7 @@ mulu16_sel: { .label __1 = 6 .label v1 = $10 .label v2 = $12 - .label return = $1e + .label return = $20 .label return_1 = $10 .label return_10 = $10 // [118] (word) mul16u::a#1 ← (word) mulu16_sel::v1#5 -- vwuz1=vwuz2 @@ -7147,9 +7149,9 @@ mulu16_sel: { } // mul16u // Perform binary multiplication of two unsigned 16-bit words into a 32-bit unsigned double word -// mul16u(word zeropage($1e) a, word zeropage($12) b) +// mul16u(word zeropage($20) a, word zeropage($12) b) mul16u: { - .label a = $1e + .label a = $20 .label mb = $a .label res = 6 .label b = $12 @@ -7411,7 +7413,7 @@ divr16u: { sin8s_gen: { .label step = $10 .label sintab = $18 - .label x = $1e + .label x = $20 .label i = $12 // [165] call div16u // [241] phi from sin8s_gen to div16u [phi:sin8s_gen->div16u] @@ -7776,7 +7778,7 @@ mulu8_sel: { // Perform binary multiplication of two unsigned 8-bit bytes into a 16-bit unsigned word // mul8u(byte register(X) a, byte register(A) b) mul8u: { - .label mb = $20 + .label mb = $1e .label res = $15 .label return = $15 // [232] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1] @@ -7958,7 +7960,6 @@ Removing instruction jmp __b3 Removing instruction jmp __b1 Removing instruction jmp __breturn Succesful ASM optimization Pass5NextJumpElimination -Removing instruction lda.z sw+1 Removing instruction ldy #0 Removing instruction lda #0 Removing instruction lda #<0 @@ -8244,7 +8245,7 @@ FINAL SYMBOL TABLE (const signed word[$c0]) main::sintabw sintabw = { fill( $c0, 0) } (const string) main::str str = (string) " " (signed word) main::sw -(signed word) main::sw#0 sw zp ZP_WORD:32 22.0 +(signed word) main::sw#0 sw zp ZP_WORD:24 22.0 (const word) main::wavelength wavelength = (byte) $c0 (void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num) (label) memset::@1 @@ -8270,9 +8271,9 @@ FINAL SYMBOL TABLE (label) mul16u::@4 (label) mul16u::@return (word) mul16u::a -(word) mul16u::a#0 a zp ZP_WORD:30 101.0 -(word) mul16u::a#1 a zp ZP_WORD:30 1.3333333333333333 -(word) mul16u::a#2 a zp ZP_WORD:30 67.66666666666666 +(word) mul16u::a#0 a zp ZP_WORD:32 101.0 +(word) mul16u::a#1 a zp ZP_WORD:32 1.3333333333333333 +(word) mul16u::a#2 a zp ZP_WORD:32 67.66666666666666 (word) mul16u::b (word) mul16u::b#0 b zp ZP_WORD:18 2.0 (dword) mul16u::mb @@ -8298,8 +8299,8 @@ FINAL SYMBOL TABLE (byte) mul8u::b (byte) mul8u::b#0 reg byte a 2.0 (word) mul8u::mb -(word) mul8u::mb#1 mb zp ZP_WORD:32 202.0 -(word) mul8u::mb#2 mb zp ZP_WORD:32 43.57142857142858 +(word) mul8u::mb#1 mb zp ZP_WORD:30 202.0 +(word) mul8u::mb#2 mb zp ZP_WORD:30 43.57142857142858 (word) mul8u::res (word) mul8u::res#1 res zp ZP_WORD:21 202.0 (word) mul8u::res#2 res zp ZP_WORD:21 50.83333333333333 @@ -8312,12 +8313,12 @@ FINAL SYMBOL TABLE (label) mulu16_sel::@1 (label) mulu16_sel::@return (word) mulu16_sel::return -(word) mulu16_sel::return#0 return zp ZP_WORD:30 4.0 +(word) mulu16_sel::return#0 return zp ZP_WORD:32 4.0 (word) mulu16_sel::return#1 return#1 zp ZP_WORD:16 4.0 (word) mulu16_sel::return#10 return#10 zp ZP_WORD:16 4.0 -(word) mulu16_sel::return#11 return zp ZP_WORD:30 4.0 -(word) mulu16_sel::return#12 return zp ZP_WORD:30 1.714285714285714 -(word) mulu16_sel::return#2 return zp ZP_WORD:30 4.0 +(word) mulu16_sel::return#11 return zp ZP_WORD:32 4.0 +(word) mulu16_sel::return#12 return zp ZP_WORD:32 1.714285714285714 +(word) mulu16_sel::return#2 return zp ZP_WORD:32 4.0 (byte) mulu16_sel::select (byte) mulu16_sel::select#5 reg byte x 0.3333333333333333 (word) mulu16_sel::v1 @@ -8437,19 +8438,19 @@ FINAL SYMBOL TABLE (dword) sin16s::x#4 x zp ZP_DWORD:6 5.0 (dword) sin16s::x#6 x zp ZP_DWORD:6 6.0 (word) sin16s::x1 -(word) sin16s::x1#0 x1 zp ZP_WORD:32 0.6363636363636365 +(word) sin16s::x1#0 x1 zp ZP_WORD:30 0.6363636363636365 (word) sin16s::x2 (word) sin16s::x2#0 x2 zp ZP_WORD:16 4.0 (word) sin16s::x3 (word) sin16s::x3#0 x3 zp ZP_WORD:16 1.0 (word) sin16s::x3_6 -(word) sin16s::x3_6#0 x3_6 zp ZP_WORD:30 4.0 +(word) sin16s::x3_6#0 x3_6 zp ZP_WORD:32 4.0 (word) sin16s::x4 (word) sin16s::x4#0 x4 zp ZP_WORD:16 4.0 (word) sin16s::x5 -(word) sin16s::x5#0 x5 zp ZP_WORD:30 4.0 +(word) sin16s::x5#0 x5 zp ZP_WORD:32 4.0 (word) sin16s::x5_128 -(word) sin16s::x5_128#0 x5_128 zp ZP_WORD:30 4.0 +(word) sin16s::x5_128#0 x5_128 zp ZP_WORD:32 4.0 (void()) sin16s_gen((signed word*) sin16s_gen::sintab , (word) sin16s_gen::wavelength) (signed word~) sin16s_gen::$2 $2 zp ZP_WORD:24 22.0 (label) sin16s_gen::@1 @@ -8537,8 +8538,8 @@ FINAL SYMBOL TABLE (word) sin8s_gen::step#0 step zp ZP_WORD:16 1.1818181818181819 (word) sin8s_gen::wavelength (word) sin8s_gen::x -(word) sin8s_gen::x#1 x zp ZP_WORD:30 11.0 -(word) sin8s_gen::x#2 x zp ZP_WORD:30 4.125 +(word) sin8s_gen::x#1 x zp ZP_WORD:32 11.0 +(word) sin8s_gen::x#2 x zp ZP_WORD:32 4.125 reg byte x [ main::i#2 main::i#1 ] reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ] @@ -8559,15 +8560,15 @@ reg byte x [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] zp ZP_WORD:21 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 mulu8_sel::$0 mulu8_sel::$1 sin8s::x#6 sin8s::x#4 sin8s::x#0 sin8s::x#1 sin8s::x#2 sin8s::$4 sin16s_gen::i#2 sin16s_gen::i#1 print_char_cursor#28 print_char_cursor#42 print_char_cursor#19 print_char_cursor#10 print_char_cursor#1 ] reg byte a [ mul8u::b#0 ] zp ZP_BYTE:23 [ main::sb#0 sin8s::isUpper#10 ] -zp ZP_WORD:24 [ main::$3 main::$11 main::$4 sin8s_gen::sintab#2 sin8s_gen::sintab#0 divr16u::dividend#4 divr16u::dividend#6 divr16u::dividend#0 sin16s::return#1 sin16s::return#5 sin16s::sinx#1 sin16s::usinx#1 sin16s::return#0 sin16s_gen::$2 sin16s::usinx#0 ] +zp ZP_WORD:24 [ main::$3 main::$11 main::$4 main::sw#0 sin8s_gen::sintab#2 sin8s_gen::sintab#0 divr16u::dividend#4 divr16u::dividend#6 divr16u::dividend#0 sin16s::return#1 sin16s::return#5 sin16s::sinx#1 sin16s::usinx#1 sin16s::return#0 sin16s_gen::$2 sin16s::usinx#0 ] reg byte a [ main::$6 ] reg byte a [ main::sd#0 ] reg byte a [ print_byte::$0 ] reg byte a [ print_byte::$2 ] zp ZP_DWORD:26 [ div32u16u::return#2 sin16s_gen::step#0 div32u16u::return#0 ] -zp ZP_WORD:30 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 sin8s_gen::x#2 sin8s_gen::x#1 mul16u::a#2 mul16u::a#1 mul16u::a#0 ] +zp ZP_WORD:30 [ sin16s::x1#0 mul8u::mb#2 mul8u::mb#1 ] reg byte a [ mul16u::$1 ] -zp ZP_WORD:32 [ div32u16u::quotient_hi#0 sin16s::x1#0 main::sw#0 mul8u::mb#2 mul8u::mb#1 ] +zp ZP_WORD:32 [ div32u16u::quotient_hi#0 mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 sin8s_gen::x#2 sin8s_gen::x#1 mul16u::a#2 mul16u::a#1 mul16u::a#0 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte a [ sin8s::return#0 ] @@ -8590,7 +8591,7 @@ reg byte a [ mul8u::$1 ] FINAL ASSEMBLER -Score: 31936 +Score: 32036 // File Comments // Upstart @@ -8628,7 +8629,7 @@ main: { .label __4 = $18 .label __11 = $18 .label sb = $17 - .label sw = $20 + .label sw = $18 // sin8s_gen(sintabb, wavelength) // [5] call sin8s_gen // [164] phi from main to sin8s_gen [phi:main->sin8s_gen] @@ -8681,15 +8682,18 @@ main: { adc #>sintabw sta.z __4+1 // sw = *(sintabw+(word)i) - // [15] (signed word) main::sw#0 ← *((signed word*~) main::$4) -- vwsz1=_deref_pwsz2 + // [15] (signed word) main::sw#0 ← *((signed word*~) main::$4) -- vwsz1=_deref_pwsz1 ldy #0 - lda (__4),y - sta.z sw + lda (sw),y + pha iny - lda (__4),y + lda (sw),y sta.z sw+1 + pla + sta.z sw // >sw // [16] (byte~) main::$6 ← > (signed word) main::sw#0 -- vbuaa=_hi_vwsz1 + lda.z sw+1 // sd = sb-(signed byte)>sw // [17] (signed byte) main::sd#0 ← (signed byte) main::sb#0 - (signed byte)(byte~) main::$6 -- vbsaa=vbsz1_minus_vbsaa eor #$ff @@ -9057,14 +9061,14 @@ sin16s: { .label __4 = 6 .label x = 6 .label return = $18 - .label x1 = $20 + .label x1 = $1e .label x2 = $10 .label x3 = $10 - .label x3_6 = $1e + .label x3_6 = $20 .label usinx = $18 .label x4 = $10 - .label x5 = $1e - .label x5_128 = $1e + .label x5 = $20 + .label x5_128 = $20 .label sinx = $18 .label isUpper = $14 // if(x >= PI_u4f28 ) @@ -9342,7 +9346,7 @@ mulu16_sel: { .label __1 = 6 .label v1 = $10 .label v2 = $12 - .label return = $1e + .label return = $20 .label return_1 = $10 .label return_10 = $10 // mul16u(v1, v2) @@ -9384,9 +9388,9 @@ mulu16_sel: { } // mul16u // Perform binary multiplication of two unsigned 16-bit words into a 32-bit unsigned double word -// mul16u(word zeropage($1e) a, word zeropage($12) b) +// mul16u(word zeropage($20) a, word zeropage($12) b) mul16u: { - .label a = $1e + .label a = $20 .label mb = $a .label res = 6 .label b = $12 @@ -9636,7 +9640,7 @@ divr16u: { sin8s_gen: { .label step = $10 .label sintab = $18 - .label x = $1e + .label x = $20 .label i = $12 // div16u(PI2_u4f12, wavelength) // [165] call div16u @@ -9990,7 +9994,7 @@ mulu8_sel: { // Perform binary multiplication of two unsigned 8-bit bytes into a 16-bit unsigned word // mul8u(byte register(X) a, byte register(A) b) mul8u: { - .label mb = $20 + .label mb = $1e .label res = $15 .label return = $15 // [232] phi from mul8u to mul8u::@1 [phi:mul8u->mul8u::@1] diff --git a/src/test/ref/sinusgen8b.sym b/src/test/ref/sinusgen8b.sym index 74234df90..877de2398 100644 --- a/src/test/ref/sinusgen8b.sym +++ b/src/test/ref/sinusgen8b.sym @@ -92,7 +92,7 @@ (const signed word[$c0]) main::sintabw sintabw = { fill( $c0, 0) } (const string) main::str str = (string) " " (signed word) main::sw -(signed word) main::sw#0 sw zp ZP_WORD:32 22.0 +(signed word) main::sw#0 sw zp ZP_WORD:24 22.0 (const word) main::wavelength wavelength = (byte) $c0 (void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num) (label) memset::@1 @@ -118,9 +118,9 @@ (label) mul16u::@4 (label) mul16u::@return (word) mul16u::a -(word) mul16u::a#0 a zp ZP_WORD:30 101.0 -(word) mul16u::a#1 a zp ZP_WORD:30 1.3333333333333333 -(word) mul16u::a#2 a zp ZP_WORD:30 67.66666666666666 +(word) mul16u::a#0 a zp ZP_WORD:32 101.0 +(word) mul16u::a#1 a zp ZP_WORD:32 1.3333333333333333 +(word) mul16u::a#2 a zp ZP_WORD:32 67.66666666666666 (word) mul16u::b (word) mul16u::b#0 b zp ZP_WORD:18 2.0 (dword) mul16u::mb @@ -146,8 +146,8 @@ (byte) mul8u::b (byte) mul8u::b#0 reg byte a 2.0 (word) mul8u::mb -(word) mul8u::mb#1 mb zp ZP_WORD:32 202.0 -(word) mul8u::mb#2 mb zp ZP_WORD:32 43.57142857142858 +(word) mul8u::mb#1 mb zp ZP_WORD:30 202.0 +(word) mul8u::mb#2 mb zp ZP_WORD:30 43.57142857142858 (word) mul8u::res (word) mul8u::res#1 res zp ZP_WORD:21 202.0 (word) mul8u::res#2 res zp ZP_WORD:21 50.83333333333333 @@ -160,12 +160,12 @@ (label) mulu16_sel::@1 (label) mulu16_sel::@return (word) mulu16_sel::return -(word) mulu16_sel::return#0 return zp ZP_WORD:30 4.0 +(word) mulu16_sel::return#0 return zp ZP_WORD:32 4.0 (word) mulu16_sel::return#1 return#1 zp ZP_WORD:16 4.0 (word) mulu16_sel::return#10 return#10 zp ZP_WORD:16 4.0 -(word) mulu16_sel::return#11 return zp ZP_WORD:30 4.0 -(word) mulu16_sel::return#12 return zp ZP_WORD:30 1.714285714285714 -(word) mulu16_sel::return#2 return zp ZP_WORD:30 4.0 +(word) mulu16_sel::return#11 return zp ZP_WORD:32 4.0 +(word) mulu16_sel::return#12 return zp ZP_WORD:32 1.714285714285714 +(word) mulu16_sel::return#2 return zp ZP_WORD:32 4.0 (byte) mulu16_sel::select (byte) mulu16_sel::select#5 reg byte x 0.3333333333333333 (word) mulu16_sel::v1 @@ -285,19 +285,19 @@ (dword) sin16s::x#4 x zp ZP_DWORD:6 5.0 (dword) sin16s::x#6 x zp ZP_DWORD:6 6.0 (word) sin16s::x1 -(word) sin16s::x1#0 x1 zp ZP_WORD:32 0.6363636363636365 +(word) sin16s::x1#0 x1 zp ZP_WORD:30 0.6363636363636365 (word) sin16s::x2 (word) sin16s::x2#0 x2 zp ZP_WORD:16 4.0 (word) sin16s::x3 (word) sin16s::x3#0 x3 zp ZP_WORD:16 1.0 (word) sin16s::x3_6 -(word) sin16s::x3_6#0 x3_6 zp ZP_WORD:30 4.0 +(word) sin16s::x3_6#0 x3_6 zp ZP_WORD:32 4.0 (word) sin16s::x4 (word) sin16s::x4#0 x4 zp ZP_WORD:16 4.0 (word) sin16s::x5 -(word) sin16s::x5#0 x5 zp ZP_WORD:30 4.0 +(word) sin16s::x5#0 x5 zp ZP_WORD:32 4.0 (word) sin16s::x5_128 -(word) sin16s::x5_128#0 x5_128 zp ZP_WORD:30 4.0 +(word) sin16s::x5_128#0 x5_128 zp ZP_WORD:32 4.0 (void()) sin16s_gen((signed word*) sin16s_gen::sintab , (word) sin16s_gen::wavelength) (signed word~) sin16s_gen::$2 $2 zp ZP_WORD:24 22.0 (label) sin16s_gen::@1 @@ -385,8 +385,8 @@ (word) sin8s_gen::step#0 step zp ZP_WORD:16 1.1818181818181819 (word) sin8s_gen::wavelength (word) sin8s_gen::x -(word) sin8s_gen::x#1 x zp ZP_WORD:30 11.0 -(word) sin8s_gen::x#2 x zp ZP_WORD:30 4.125 +(word) sin8s_gen::x#1 x zp ZP_WORD:32 11.0 +(word) sin8s_gen::x#2 x zp ZP_WORD:32 4.125 reg byte x [ main::i#2 main::i#1 ] reg byte a [ print_char::ch#4 print_char::ch#2 print_char::ch#3 ] @@ -407,15 +407,15 @@ reg byte x [ mul8u::a#2 mul8u::a#1 mul8u::a#0 ] zp ZP_WORD:21 [ mul8u::res#2 mul8u::res#6 mul8u::res#1 mul8u::return#2 mulu8_sel::$0 mulu8_sel::$1 sin8s::x#6 sin8s::x#4 sin8s::x#0 sin8s::x#1 sin8s::x#2 sin8s::$4 sin16s_gen::i#2 sin16s_gen::i#1 print_char_cursor#28 print_char_cursor#42 print_char_cursor#19 print_char_cursor#10 print_char_cursor#1 ] reg byte a [ mul8u::b#0 ] zp ZP_BYTE:23 [ main::sb#0 sin8s::isUpper#10 ] -zp ZP_WORD:24 [ main::$3 main::$11 main::$4 sin8s_gen::sintab#2 sin8s_gen::sintab#0 divr16u::dividend#4 divr16u::dividend#6 divr16u::dividend#0 sin16s::return#1 sin16s::return#5 sin16s::sinx#1 sin16s::usinx#1 sin16s::return#0 sin16s_gen::$2 sin16s::usinx#0 ] +zp ZP_WORD:24 [ main::$3 main::$11 main::$4 main::sw#0 sin8s_gen::sintab#2 sin8s_gen::sintab#0 divr16u::dividend#4 divr16u::dividend#6 divr16u::dividend#0 sin16s::return#1 sin16s::return#5 sin16s::sinx#1 sin16s::usinx#1 sin16s::return#0 sin16s_gen::$2 sin16s::usinx#0 ] reg byte a [ main::$6 ] reg byte a [ main::sd#0 ] reg byte a [ print_byte::$0 ] reg byte a [ print_byte::$2 ] zp ZP_DWORD:26 [ div32u16u::return#2 sin16s_gen::step#0 div32u16u::return#0 ] -zp ZP_WORD:30 [ mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 sin8s_gen::x#2 sin8s_gen::x#1 mul16u::a#2 mul16u::a#1 mul16u::a#0 ] +zp ZP_WORD:30 [ sin16s::x1#0 mul8u::mb#2 mul8u::mb#1 ] reg byte a [ mul16u::$1 ] -zp ZP_WORD:32 [ div32u16u::quotient_hi#0 sin16s::x1#0 main::sw#0 mul8u::mb#2 mul8u::mb#1 ] +zp ZP_WORD:32 [ div32u16u::quotient_hi#0 mulu16_sel::return#0 mulu16_sel::return#12 mulu16_sel::return#2 sin16s::x3_6#0 mulu16_sel::return#11 sin16s::x5#0 sin16s::x5_128#0 sin8s_gen::x#2 sin8s_gen::x#1 mul16u::a#2 mul16u::a#1 mul16u::a#0 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte a [ sin8s::return#0 ]