From e5893733747a49ccee718514428526fe7955b6fb Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 1 May 2018 22:37:28 +0200 Subject: [PATCH] Added support for multi-level function inlining containing value-lists. --- .../kickc/model/statements/StatementCall.java | 16 - .../passes/Pass1ProcedureCallParameters.java | 1 - .../Pass1ProcedureCallsReturnValue.java | 1 - .../kickc/passes/Pass1ProcedureInline.java | 8 + .../dk/camelot64/kickc/test/TestPrograms.java | 5 + .../kickc/test/kc/inline-function-level2.kc | 26 + .../kickc/test/ref/inline-function-level2.asm | 115 ++ .../kickc/test/ref/inline-function-level2.cfg | 59 + .../kickc/test/ref/inline-function-level2.log | 1602 +++++++++++++++++ .../kickc/test/ref/inline-function-level2.sym | 72 + 10 files changed, 1887 insertions(+), 18 deletions(-) create mode 100644 src/test/java/dk/camelot64/kickc/test/kc/inline-function-level2.kc create mode 100644 src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.asm create mode 100644 src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.cfg create mode 100644 src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.log create mode 100644 src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.sym diff --git a/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java b/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java index 73570056e..180e587ba 100644 --- a/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java +++ b/src/main/java/dk/camelot64/kickc/model/statements/StatementCall.java @@ -21,14 +21,12 @@ public class StatementCall extends StatementBase implements StatementLValue { private String procedureName; private ProcedureRef procedure; private List parameters; - private boolean parametersByAssignment; public StatementCall(LValue lValue, String procedureName, List parameters) { super(null); this.lValue = lValue; this.procedureName = procedureName; this.parameters = parameters; - this.parametersByAssignment = false; } public LValue getlValue() { @@ -67,17 +65,8 @@ public class StatementCall extends StatementBase implements StatementLValue { return parameters.get(idx); } - public boolean isParametersByAssignment() { - return parametersByAssignment; - } - - public void setParametersByAssignment(boolean parametersByAssignment) { - this.parametersByAssignment = parametersByAssignment; - } - public void clearParameters() { this.parameters = null; - this.parametersByAssignment = true; } @Override @@ -99,9 +88,6 @@ public class StatementCall extends StatementBase implements StatementLValue { res.append(parameter.toString(program) + " "); } } - if(parametersByAssignment) { - res.append("param-assignment"); - } if(aliveInfo) { res.append(super.aliveString(program)); } @@ -116,7 +102,6 @@ public class StatementCall extends StatementBase implements StatementLValue { StatementCall that = (StatementCall) o; - if(parametersByAssignment != that.parametersByAssignment) return false; if(lValue != null ? !lValue.equals(that.lValue) : that.lValue != null) return false; if(!procedureName.equals(that.procedureName)) return false; if(procedure != null ? !procedure.equals(that.procedure) : that.procedure != null) return false; @@ -130,7 +115,6 @@ public class StatementCall extends StatementBase implements StatementLValue { result = 31 * result + procedureName.hashCode(); result = 31 * result + (procedure != null ? procedure.hashCode() : 0); result = 31 * result + (parameters != null ? parameters.hashCode() : 0); - result = 31 * result + (parametersByAssignment ? 1 : 0); return result; } } diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java index 555a68b0a..bd364388d 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallParameters.java @@ -52,7 +52,6 @@ public class Pass1ProcedureCallParameters extends ControlFlowGraphCopyVisitor { procReturnVarRef = procReturnVar.getRef(); } StatementCall copyCall = new StatementCall(procReturnVarRef, procedureName, null); - copyCall.setParametersByAssignment(true); copyCall.setProcedure(procedureRef); addStatementToCurrentBlock(copyCall); getCurrentBlock().setCallSuccessor(procedure.getLabel().getRef()); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallsReturnValue.java b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallsReturnValue.java index ffc5a3ab0..3ce4b7a6e 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallsReturnValue.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureCallsReturnValue.java @@ -33,7 +33,6 @@ public class Pass1ProcedureCallsReturnValue extends ControlFlowGraphCopyVisitor Procedure procedure = program.getScope().getProcedure(procedureRef); String procedureName = origCall.getProcedureName(); StatementCall copyCall = new StatementCall(null, procedureName, null); - copyCall.setParametersByAssignment(true); copyCall.setProcedure(procedureRef); addStatementToCurrentBlock(copyCall); getCurrentBlock().setCallSuccessor(procedure.getLabel().getRef()); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureInline.java b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureInline.java index 9683c673c..4065f1dd9 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureInline.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1ProcedureInline.java @@ -8,6 +8,7 @@ import dk.camelot64.kickc.model.symbols.*; import dk.camelot64.kickc.model.types.SymbolType; import dk.camelot64.kickc.model.values.*; +import java.util.ArrayList; import java.util.List; import java.util.ListIterator; @@ -165,6 +166,11 @@ public class Pass1ProcedureInline extends Pass1Base { if(procStatement instanceof StatementAssignment) { StatementAssignment procAssignment = (StatementAssignment) procStatement; inlinedStatement = new StatementAssignment(procAssignment.getlValue(), procAssignment.getrValue1(), procAssignment.getOperator(), procAssignment.getrValue2()); + } else if(procStatement instanceof StatementCall) { + StatementCall procCall = (StatementCall) procStatement; + StatementCall inlinedCall = new StatementCall(procCall.getlValue(), procCall.getProcedureName(), new ArrayList<>(procCall.getParameters())); + inlinedCall.setProcedure(procCall.getProcedure()); + inlinedStatement = inlinedCall; } else if(procStatement instanceof StatementConditionalJump) { StatementConditionalJump procConditional = (StatementConditionalJump) procStatement; LabelRef procDestinationRef = procConditional.getDestination(); @@ -223,6 +229,8 @@ public class Pass1ProcedureInline extends Pass1Base { replaceable.set(new PointerDereferenceIndexed(((PointerDereferenceIndexed) rValue).getPointer(), ((PointerDereferenceIndexed) rValue).getIndex())); } else if(rValue instanceof CastValue) { replaceable.set(new CastValue(((CastValue) rValue).getToType(), ((CastValue) rValue).getValue())); + } else if(rValue instanceof ValueList) { + replaceable.set(new ValueList(new ArrayList<>(((ValueList) rValue).getList()))); } } } diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 5befa4a52..0ecce332e 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -44,6 +44,11 @@ public class TestPrograms { AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false); } + @Test + public void testInlineFunctionLevel2() throws IOException, URISyntaxException { + compileAndCompare("inline-function-level2"); + } + @Test public void testInlineFunctionPrint() throws IOException, URISyntaxException { compileAndCompare("inline-function-print"); diff --git a/src/test/java/dk/camelot64/kickc/test/kc/inline-function-level2.kc b/src/test/java/dk/camelot64/kickc/test/kc/inline-function-level2.kc new file mode 100644 index 000000000..6c064b38d --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/kc/inline-function-level2.kc @@ -0,0 +1,26 @@ +// Inline functions in two levels + +void main() { + for(byte* sc = $400;sc<$400+1000;sc++) *sc = ' '; + line(2, $40, 10, '*'); + line(4, $80, 15, '.'); +} + +byte* cur_line = $400; + +inline void line(byte xpos, byte xadd, byte ysize, byte ch) { + cur_line = $400; + word pos = {xpos, 0}; + for( byte i=0;ipos, ch); + pos += xadd; + cur_line += 40; + } +} + +inline void plot(byte xpos, byte ch) { + *(cur_line+xpos) = ch; +} + + + diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.asm b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.asm new file mode 100644 index 000000000..d510006dc --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.asm @@ -0,0 +1,115 @@ +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label cur_line = 4 + jsr main +main: { + .const line1_xpos = 2 + .const line1_xadd = $40 + .const line1_ysize = $a + .const line1_ch = '*' + .const line2_xpos = 4 + .const line2_xadd = $80 + .const line2_ysize = $f + .const line2_ch = '.' + .label sc = 2 + .label plot1__0 = 6 + .label line1_pos = 2 + .label plot2__0 = 6 + .label line2_pos = 2 + lda #<$400 + sta sc + lda #>$400 + sta sc+1 + b1: + lda #' ' + ldy #0 + sta (sc),y + inc sc + bne !+ + inc sc+1 + !: + lda sc+1 + cmp #>$400+$3e8 + bcc b1 + bne !+ + lda sc + cmp #<$400+$3e8 + bcc b1 + !: + ldx #0 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + lda #line1_xpos*$100+0 + sta line1_pos+1 + b2: + lda line1_pos+1 + clc + adc cur_line + sta plot1__0 + lda #0 + adc cur_line+1 + sta plot1__0+1 + lda #line1_ch + ldy #0 + sta (plot1__0),y + clc + lda line1_pos + adc #line1_xadd + sta line1_pos+1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + inx + cpx #line1_ysize + bcc b2 + ldx #0 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + lda #line2_xpos*$100+0 + sta line2_pos+1 + b3: + lda line2_pos+1 + clc + adc cur_line + sta plot2__0 + lda #0 + adc cur_line+1 + sta plot2__0+1 + lda #line2_ch + ldy #0 + sta (plot2__0),y + clc + lda line2_pos + adc #line2_xadd + sta line2_pos+1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + inx + cpx #line2_ysize + bcc b3 + rts +} diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.cfg b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.cfg new file mode 100644 index 000000000..e80a7a1ba --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.cfg @@ -0,0 +1,59 @@ +@begin: scope:[] from + [0] phi() [ ] ( ) + to:@3 +@3: scope:[] from @begin + [1] phi() [ ] ( ) + [2] call main [ ] ( ) + to:@end +@end: scope:[] from @3 + [3] phi() [ ] ( ) +main: scope:[main] from @3 + [4] phi() [ ] ( main:2 [ ] ) + to:main::@1 +main::@1: scope:[main] from main main::@1 + [5] (byte*) main::sc#2 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@1/(byte*) main::sc#1 ) [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) + [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) + [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) + [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) + to:main::line1 +main::line1: scope:[main] from main::@1 + [9] phi() [ ] ( main:2 [ ] ) + to:main::line1_@1 +main::line1_@1: scope:[main] from main::@4 main::line1 main::line1_@1 + [10] (byte) main::line1_i#2 ← phi( main::@4/(byte) main::line1_i#1 main::line1/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [10] (byte*) cur_line#13 ← phi( main::@4/(byte*) cur_line#1 main::line1/((byte*))(word/signed word/dword/signed dword) 1024 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [10] (word) main::line1_pos#2 ← phi( main::@4/(word) main::line1_pos#1 main::line1/(const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) + to:main::plot1 +main::plot1: scope:[main] from main::line1_@1 + [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) + [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + to:main::@4 +main::@4: scope:[main] from main::plot1 + [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) + [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) + [16] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) + [17] if((byte) main::line1_i#1<(const byte) main::line1_ysize#0) goto main::line1_@1 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) + to:main::line2 +main::line2: scope:[main] from main::@4 + [18] phi() [ ] ( main:2 [ ] ) + to:main::line2_@1 +main::line2_@1: scope:[main] from main::@6 main::line2 main::line2_@1 + [19] (byte) main::line2_i#2 ← phi( main::@6/(byte) main::line2_i#1 main::line2/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [19] (byte*) cur_line#10 ← phi( main::@6/(byte*) cur_line#11 main::line2/((byte*))(word/signed word/dword/signed dword) 1024 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [19] (word) main::line2_pos#2 ← phi( main::@6/(word) main::line2_pos#1 main::line2/(const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) + to:main::plot2 +main::plot2: scope:[main] from main::line2_@1 + [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) + [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + to:main::@6 +main::@6: scope:[main] from main::plot2 + [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) + [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) + [25] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) + [26] if((byte) main::line2_i#1<(const byte) main::line2_ysize#0) goto main::line2_@1 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) + to:main::@return +main::@return: scope:[main] from main::@6 + [27] return [ ] ( main:2 [ ] ) + to:@return diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.log b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.log new file mode 100644 index 000000000..97b32a9c1 --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.log @@ -0,0 +1,1602 @@ +PARSING src/test/java/dk/camelot64/kickc/test/kc/inline-function-level2.kc +// Inline functions in two levels + +void main() { + for(byte* sc = $400;sc<$400+1000;sc++) *sc = ' '; + line(2, $40, 10, '*'); + line(4, $80, 15, '.'); +} + +byte* cur_line = $400; + +inline void line(byte xpos, byte xadd, byte ysize, byte ch) { + cur_line = $400; + word pos = {xpos, 0}; + for( byte i=0;ipos, ch); + pos += xadd; + cur_line += 40; + } +} + +inline void plot(byte xpos, byte ch) { + *(cur_line+xpos) = ch; +} + + + + +Adding pre/post-modifier (byte*) main::sc ← ++ (byte*) main::sc +Adding pre/post-modifier (byte) line::i ← ++ (byte) line::i +SYMBOLS +(label) @1 +(label) @2 +(label) @3 +(label) @begin +(label) @end +(byte*) cur_line +inline (void()) line((byte) line::xpos , (byte) line::xadd , (byte) line::ysize , (byte) line::ch) +(byte~) line::$0 +(void~) line::$1 +(bool~) line::$2 +(label) line::@1 +(label) line::@2 +(label) line::@return +(byte) line::ch +(byte) line::i +(word) line::pos +(byte) line::xadd +(byte) line::xpos +(byte) line::ysize +(void()) main() +(word/signed word/dword/signed dword~) main::$0 +(bool~) main::$1 +(void~) main::$2 +(void~) main::$3 +(label) main::@1 +(label) main::@2 +(label) main::@return +(byte*) main::sc +inline (void()) plot((byte) plot::xpos , (byte) plot::ch) +(byte*~) plot::$0 +(label) plot::@return +(byte) plot::ch +(byte) plot::xpos + +Promoting word/signed word/dword/signed dword to byte* in main::sc ← ((byte*)) 1024 +Promoting word/signed word/dword/signed dword to byte* in cur_line ← ((byte*)) 1024 +Promoting word/signed word/dword/signed dword to byte* in cur_line ← ((byte*)) 1024 +INITIAL CONTROL FLOW GRAPH +@begin: scope:[] from + to:@1 +main: scope:[main] from + (byte*) main::sc ← ((byte*)) (word/signed word/dword/signed dword) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@1 + *((byte*) main::sc) ← (byte) ' ' + (byte*) main::sc ← ++ (byte*) main::sc + (word/signed word/dword/signed dword~) main::$0 ← (word/signed word/dword/signed dword) 1024 + (word/signed word/dword/signed dword) 1000 + (bool~) main::$1 ← (byte*) main::sc < (word/signed word/dword/signed dword~) main::$0 + if((bool~) main::$1) goto main::@1 + to:main::@2 +main::@2: scope:[main] from main::@1 + (void~) main::$2 ← call line (byte/signed byte/word/signed word/dword/signed dword) 2 (byte/signed byte/word/signed word/dword/signed dword) 64 (byte/signed byte/word/signed word/dword/signed dword) 10 (byte) '*' + (void~) main::$3 ← call line (byte/signed byte/word/signed word/dword/signed dword) 4 (byte/word/signed word/dword/signed dword) 128 (byte/signed byte/word/signed word/dword/signed dword) 15 (byte) '.' + to:main::@return +main::@return: scope:[main] from main::@2 + return + to:@return +@1: scope:[] from @begin + (byte*) cur_line ← ((byte*)) (word/signed word/dword/signed dword) 1024 + to:@2 +line: scope:[line] from + (byte*) cur_line ← ((byte*)) (word/signed word/dword/signed dword) 1024 + (word) line::pos ← { (byte) line::xpos, (byte/signed byte/word/signed word/dword/signed dword) 0 } + (byte) line::i ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:line::@1 +line::@1: scope:[line] from line line::@1 + (byte~) line::$0 ← > (word) line::pos + (void~) line::$1 ← call plot (byte~) line::$0 (byte) line::ch + (word) line::pos ← (word) line::pos + (byte) line::xadd + (byte*) cur_line ← (byte*) cur_line + (byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) line::i ← ++ (byte) line::i + (bool~) line::$2 ← (byte) line::i < (byte) line::ysize + if((bool~) line::$2) goto line::@1 + to:line::@2 +line::@2: scope:[line] from line::@1 + to:line::@return +line::@return: scope:[line] from line::@2 + return + to:@return +@2: scope:[] from @1 + to:@3 +plot: scope:[plot] from + (byte*~) plot::$0 ← (byte*) cur_line + (byte) plot::xpos + *((byte*~) plot::$0) ← (byte) plot::ch + to:plot::@return +plot::@return: scope:[plot] from plot + return + to:@return +@3: scope:[] from @2 + call main + to:@end +@end: scope:[] from @3 + +Inlined call call line (byte/signed byte/word/signed word/dword/signed dword) 2 (byte/signed byte/word/signed word/dword/signed dword) 64 (byte/signed byte/word/signed word/dword/signed dword) 10 (byte) '*' +Inlined call call plot (byte~) main::line1_$0 (byte) main::line1_ch +Inlined call call line (byte/signed byte/word/signed word/dword/signed dword) 4 (byte/word/signed word/dword/signed dword) 128 (byte/signed byte/word/signed word/dword/signed dword) 15 (byte) '.' +Inlined call call plot (byte~) main::line2_$0 (byte) main::line2_ch +Inlined call call plot (byte~) line::$0 (byte) line::ch +Removing unused procedure line +Removing unused procedure plot +Removing empty block main::plot1_@return +Removing empty block main::line1_@2 +Removing empty block main::line1_@return +Removing empty block main::plot2_@return +Removing empty block main::line2_@2 +Removing empty block main::line2_@return +Removing empty block main::@5 +Removing empty block @2 +PROCEDURE MODIFY VARIABLE ANALYSIS +main modifies cur_line + +Completing Phi functions... +Completing Phi functions... +Completing Phi functions... +Completing Phi functions... + +CONTROL FLOW GRAPH SSA WITH ASSIGNMENT CALL & RETURN +@begin: scope:[] from + to:@1 +main: scope:[main] from @3 + (byte*) main::sc#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + to:main::@1 +main::@1: scope:[main] from main main::@1 + (byte*) main::sc#2 ← phi( main/(byte*) main::sc#0 main::@1/(byte*) main::sc#1 ) + *((byte*) main::sc#2) ← (byte) ' ' + (byte*) main::sc#1 ← ++ (byte*) main::sc#2 + (word/signed word/dword/signed dword~) main::$0 ← (word/signed word/dword/signed dword) 1024 + (word/signed word/dword/signed dword) 1000 + (bool~) main::$1 ← (byte*) main::sc#1 < (word/signed word/dword/signed dword~) main::$0 + if((bool~) main::$1) goto main::@1 + to:main::@2 +main::@2: scope:[main] from main::@1 + (byte) main::line1_xpos#0 ← (byte/signed byte/word/signed word/dword/signed dword) 2 + (byte) main::line1_xadd#0 ← (byte/signed byte/word/signed word/dword/signed dword) 64 + (byte) main::line1_ysize#0 ← (byte/signed byte/word/signed word/dword/signed dword) 10 + (byte) main::line1_ch#0 ← (byte) '*' + to:main::line1 +main::line1: scope:[main] from main::@2 + (byte) main::line1_ysize#4 ← phi( main::@2/(byte) main::line1_ysize#0 ) + (byte) main::line1_xadd#4 ← phi( main::@2/(byte) main::line1_xadd#0 ) + (byte) main::line1_ch#3 ← phi( main::@2/(byte) main::line1_ch#0 ) + (byte) main::line1_xpos#1 ← phi( main::@2/(byte) main::line1_xpos#0 ) + (byte*) cur_line#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + (word) main::line1_pos#0 ← { (byte) main::line1_xpos#1, (byte/signed byte/word/signed word/dword/signed dword) 0 } + (byte) main::line1_i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:main::line1_@1 +main::line1_@1: scope:[main] from main::@4 main::line1 main::line1_@1 + (byte) main::line1_ysize#3 ← phi( main::@4/(byte) main::line1_ysize#1 main::line1/(byte) main::line1_ysize#4 main::line1_@1/(byte) main::line1_ysize#3 ) + (byte) main::line1_i#4 ← phi( main::@4/(byte) main::line1_i#1 main::line1/(byte) main::line1_i#0 main::line1_@1/(byte) main::line1_i#4 ) + (byte) main::line1_xadd#3 ← phi( main::@4/(byte) main::line1_xadd#1 main::line1/(byte) main::line1_xadd#4 main::line1_@1/(byte) main::line1_xadd#3 ) + (byte*) cur_line#13 ← phi( main::@4/(byte*) cur_line#1 main::line1/(byte*) cur_line#0 main::line1_@1/(byte*) cur_line#13 ) + (byte) main::line1_ch#1 ← phi( main::@4/(byte) main::line1_ch#2 main::line1/(byte) main::line1_ch#3 main::line1_@1/(byte) main::line1_ch#1 ) + (word) main::line1_pos#2 ← phi( main::@4/(word) main::line1_pos#1 main::line1/(word) main::line1_pos#0 main::line1_@1/(word) main::line1_pos#2 ) + (byte) main::line1_$0#0 ← > (word) main::line1_pos#2 + (byte) main::plot1_xpos#0 ← (byte) main::line1_$0#0 + (byte) main::plot1_ch#0 ← (byte) main::line1_ch#1 + to:main::plot1 +main::plot1: scope:[main] from main::line1_@1 + (byte) main::line1_ch#4 ← phi( main::line1_@1/(byte) main::line1_ch#1 ) + (byte) main::line1_ysize#2 ← phi( main::line1_@1/(byte) main::line1_ysize#3 ) + (byte) main::line1_i#3 ← phi( main::line1_@1/(byte) main::line1_i#4 ) + (byte) main::line1_xadd#2 ← phi( main::line1_@1/(byte) main::line1_xadd#3 ) + (word) main::line1_pos#4 ← phi( main::line1_@1/(word) main::line1_pos#2 ) + (byte) main::plot1_ch#1 ← phi( main::line1_@1/(byte) main::plot1_ch#0 ) + (byte) main::plot1_xpos#1 ← phi( main::line1_@1/(byte) main::plot1_xpos#0 ) + (byte*) cur_line#7 ← phi( main::line1_@1/(byte*) cur_line#13 ) + (byte*) main::plot1_$0#0 ← (byte*) cur_line#7 + (byte) main::plot1_xpos#1 + *((byte*) main::plot1_$0#0) ← (byte) main::plot1_ch#1 + to:main::@4 +main::@4: scope:[main] from main::plot1 + (byte) main::line1_ch#2 ← phi( main::plot1/(byte) main::line1_ch#4 ) + (byte) main::line1_ysize#1 ← phi( main::plot1/(byte) main::line1_ysize#2 ) + (byte) main::line1_i#2 ← phi( main::plot1/(byte) main::line1_i#3 ) + (byte*) cur_line#8 ← phi( main::plot1/(byte*) cur_line#7 ) + (byte) main::line1_xadd#1 ← phi( main::plot1/(byte) main::line1_xadd#2 ) + (word) main::line1_pos#3 ← phi( main::plot1/(word) main::line1_pos#4 ) + (word) main::line1_pos#1 ← (word) main::line1_pos#3 + (byte) main::line1_xadd#1 + (byte*) cur_line#1 ← (byte*) cur_line#8 + (byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 + (bool) main::line1_$2#0 ← (byte) main::line1_i#1 < (byte) main::line1_ysize#1 + if((bool) main::line1_$2#0) goto main::line1_@1 + to:main::@3 +main::@3: scope:[main] from main::@4 + (byte) main::line2_xpos#0 ← (byte/signed byte/word/signed word/dword/signed dword) 4 + (byte) main::line2_xadd#0 ← (byte/word/signed word/dword/signed dword) 128 + (byte) main::line2_ysize#0 ← (byte/signed byte/word/signed word/dword/signed dword) 15 + (byte) main::line2_ch#0 ← (byte) '.' + to:main::line2 +main::line2: scope:[main] from main::@3 + (byte) main::line2_ysize#4 ← phi( main::@3/(byte) main::line2_ysize#0 ) + (byte) main::line2_xadd#4 ← phi( main::@3/(byte) main::line2_xadd#0 ) + (byte) main::line2_ch#3 ← phi( main::@3/(byte) main::line2_ch#0 ) + (byte) main::line2_xpos#1 ← phi( main::@3/(byte) main::line2_xpos#0 ) + (byte*) cur_line#2 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + (word) main::line2_pos#0 ← { (byte) main::line2_xpos#1, (byte/signed byte/word/signed word/dword/signed dword) 0 } + (byte) main::line2_i#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:main::line2_@1 +main::line2_@1: scope:[main] from main::@6 main::line2 main::line2_@1 + (byte) main::line2_ysize#3 ← phi( main::@6/(byte) main::line2_ysize#1 main::line2/(byte) main::line2_ysize#4 main::line2_@1/(byte) main::line2_ysize#3 ) + (byte) main::line2_i#4 ← phi( main::@6/(byte) main::line2_i#1 main::line2/(byte) main::line2_i#0 main::line2_@1/(byte) main::line2_i#4 ) + (byte) main::line2_xadd#3 ← phi( main::@6/(byte) main::line2_xadd#1 main::line2/(byte) main::line2_xadd#4 main::line2_@1/(byte) main::line2_xadd#3 ) + (byte*) cur_line#14 ← phi( main::@6/(byte*) cur_line#3 main::line2/(byte*) cur_line#2 main::line2_@1/(byte*) cur_line#14 ) + (byte) main::line2_ch#1 ← phi( main::@6/(byte) main::line2_ch#2 main::line2/(byte) main::line2_ch#3 main::line2_@1/(byte) main::line2_ch#1 ) + (word) main::line2_pos#2 ← phi( main::@6/(word) main::line2_pos#1 main::line2/(word) main::line2_pos#0 main::line2_@1/(word) main::line2_pos#2 ) + (byte) main::line2_$0#0 ← > (word) main::line2_pos#2 + (byte) main::plot2_xpos#0 ← (byte) main::line2_$0#0 + (byte) main::plot2_ch#0 ← (byte) main::line2_ch#1 + to:main::plot2 +main::plot2: scope:[main] from main::line2_@1 + (byte) main::line2_ch#4 ← phi( main::line2_@1/(byte) main::line2_ch#1 ) + (byte) main::line2_ysize#2 ← phi( main::line2_@1/(byte) main::line2_ysize#3 ) + (byte) main::line2_i#3 ← phi( main::line2_@1/(byte) main::line2_i#4 ) + (byte) main::line2_xadd#2 ← phi( main::line2_@1/(byte) main::line2_xadd#3 ) + (word) main::line2_pos#4 ← phi( main::line2_@1/(word) main::line2_pos#2 ) + (byte) main::plot2_ch#1 ← phi( main::line2_@1/(byte) main::plot2_ch#0 ) + (byte) main::plot2_xpos#1 ← phi( main::line2_@1/(byte) main::plot2_xpos#0 ) + (byte*) cur_line#9 ← phi( main::line2_@1/(byte*) cur_line#14 ) + (byte*) main::plot2_$0#0 ← (byte*) cur_line#9 + (byte) main::plot2_xpos#1 + *((byte*) main::plot2_$0#0) ← (byte) main::plot2_ch#1 + to:main::@6 +main::@6: scope:[main] from main::plot2 + (byte) main::line2_ch#2 ← phi( main::plot2/(byte) main::line2_ch#4 ) + (byte) main::line2_ysize#1 ← phi( main::plot2/(byte) main::line2_ysize#2 ) + (byte) main::line2_i#2 ← phi( main::plot2/(byte) main::line2_i#3 ) + (byte*) cur_line#10 ← phi( main::plot2/(byte*) cur_line#9 ) + (byte) main::line2_xadd#1 ← phi( main::plot2/(byte) main::line2_xadd#2 ) + (word) main::line2_pos#3 ← phi( main::plot2/(word) main::line2_pos#4 ) + (word) main::line2_pos#1 ← (word) main::line2_pos#3 + (byte) main::line2_xadd#1 + (byte*) cur_line#3 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 + (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 + (bool) main::line2_$2#0 ← (byte) main::line2_i#1 < (byte) main::line2_ysize#1 + if((bool) main::line2_$2#0) goto main::line2_@1 + to:main::@return +main::@return: scope:[main] from main::@6 + (byte*) cur_line#11 ← phi( main::@6/(byte*) cur_line#3 ) + (byte*) cur_line#4 ← (byte*) cur_line#11 + return + to:@return +@1: scope:[] from @begin + (byte*) cur_line#5 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + to:@3 +@3: scope:[] from @1 + (byte*) cur_line#15 ← phi( @1/(byte*) cur_line#5 ) + call main + to:@4 +@4: scope:[] from @3 + (byte*) cur_line#12 ← phi( @3/(byte*) cur_line#4 ) + (byte*) cur_line#6 ← (byte*) cur_line#12 + to:@end +@end: scope:[] from @4 + +SYMBOL TABLE SSA +(label) @1 +(label) @3 +(label) @4 +(label) @begin +(label) @end +(byte*) cur_line +(byte*) cur_line#0 +(byte*) cur_line#1 +(byte*) cur_line#10 +(byte*) cur_line#11 +(byte*) cur_line#12 +(byte*) cur_line#13 +(byte*) cur_line#14 +(byte*) cur_line#15 +(byte*) cur_line#2 +(byte*) cur_line#3 +(byte*) cur_line#4 +(byte*) cur_line#5 +(byte*) cur_line#6 +(byte*) cur_line#7 +(byte*) cur_line#8 +(byte*) cur_line#9 +(void()) main() +(word/signed word/dword/signed dword~) main::$0 +(bool~) main::$1 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@6 +(label) main::@return +(label) main::line1 +(byte~) main::line1_$0 +(byte) main::line1_$0#0 +(bool~) main::line1_$2 +(bool) main::line1_$2#0 +(label) main::line1_@1 +(byte) main::line1_ch +(byte) main::line1_ch#0 +(byte) main::line1_ch#1 +(byte) main::line1_ch#2 +(byte) main::line1_ch#3 +(byte) main::line1_ch#4 +(byte) main::line1_i +(byte) main::line1_i#0 +(byte) main::line1_i#1 +(byte) main::line1_i#2 +(byte) main::line1_i#3 +(byte) main::line1_i#4 +(word) main::line1_pos +(word) main::line1_pos#0 +(word) main::line1_pos#1 +(word) main::line1_pos#2 +(word) main::line1_pos#3 +(word) main::line1_pos#4 +(byte) main::line1_xadd +(byte) main::line1_xadd#0 +(byte) main::line1_xadd#1 +(byte) main::line1_xadd#2 +(byte) main::line1_xadd#3 +(byte) main::line1_xadd#4 +(byte) main::line1_xpos +(byte) main::line1_xpos#0 +(byte) main::line1_xpos#1 +(byte) main::line1_ysize +(byte) main::line1_ysize#0 +(byte) main::line1_ysize#1 +(byte) main::line1_ysize#2 +(byte) main::line1_ysize#3 +(byte) main::line1_ysize#4 +(label) main::line2 +(byte~) main::line2_$0 +(byte) main::line2_$0#0 +(bool~) main::line2_$2 +(bool) main::line2_$2#0 +(label) main::line2_@1 +(byte) main::line2_ch +(byte) main::line2_ch#0 +(byte) main::line2_ch#1 +(byte) main::line2_ch#2 +(byte) main::line2_ch#3 +(byte) main::line2_ch#4 +(byte) main::line2_i +(byte) main::line2_i#0 +(byte) main::line2_i#1 +(byte) main::line2_i#2 +(byte) main::line2_i#3 +(byte) main::line2_i#4 +(word) main::line2_pos +(word) main::line2_pos#0 +(word) main::line2_pos#1 +(word) main::line2_pos#2 +(word) main::line2_pos#3 +(word) main::line2_pos#4 +(byte) main::line2_xadd +(byte) main::line2_xadd#0 +(byte) main::line2_xadd#1 +(byte) main::line2_xadd#2 +(byte) main::line2_xadd#3 +(byte) main::line2_xadd#4 +(byte) main::line2_xpos +(byte) main::line2_xpos#0 +(byte) main::line2_xpos#1 +(byte) main::line2_ysize +(byte) main::line2_ysize#0 +(byte) main::line2_ysize#1 +(byte) main::line2_ysize#2 +(byte) main::line2_ysize#3 +(byte) main::line2_ysize#4 +(label) main::plot1 +(byte*~) main::plot1_$0 +(byte*) main::plot1_$0#0 +(byte) main::plot1_ch +(byte) main::plot1_ch#0 +(byte) main::plot1_ch#1 +(byte) main::plot1_xpos +(byte) main::plot1_xpos#0 +(byte) main::plot1_xpos#1 +(label) main::plot2 +(byte*~) main::plot2_$0 +(byte*) main::plot2_$0#0 +(byte) main::plot2_ch +(byte) main::plot2_ch#0 +(byte) main::plot2_ch#1 +(byte) main::plot2_xpos +(byte) main::plot2_xpos#0 +(byte) main::plot2_xpos#1 +(byte*) main::sc +(byte*) main::sc#0 +(byte*) main::sc#1 +(byte*) main::sc#2 + +OPTIMIZING CONTROL FLOW GRAPH +Not aliassing across scopes: cur_line#12 cur_line#4 +Alias (byte) main::line1_xpos#0 = (byte) main::line1_xpos#1 +Alias (byte) main::line1_ch#0 = (byte) main::line1_ch#3 +Alias (byte) main::line1_xadd#0 = (byte) main::line1_xadd#4 +Alias (byte) main::line1_ysize#0 = (byte) main::line1_ysize#4 +Alias (byte) main::plot1_xpos#0 = (byte) main::line1_$0#0 (byte) main::plot1_xpos#1 +Alias (byte) main::line1_ch#1 = (byte) main::plot1_ch#0 (byte) main::plot1_ch#1 (byte) main::line1_ch#4 (byte) main::line1_ch#2 +Alias (byte*) cur_line#13 = (byte*) cur_line#7 (byte*) cur_line#8 +Alias (word) main::line1_pos#2 = (word) main::line1_pos#4 (word) main::line1_pos#3 +Alias (byte) main::line1_xadd#1 = (byte) main::line1_xadd#2 (byte) main::line1_xadd#3 +Alias (byte) main::line1_i#2 = (byte) main::line1_i#3 (byte) main::line1_i#4 +Alias (byte) main::line1_ysize#1 = (byte) main::line1_ysize#2 (byte) main::line1_ysize#3 +Alias (byte) main::line2_xpos#0 = (byte) main::line2_xpos#1 +Alias (byte) main::line2_ch#0 = (byte) main::line2_ch#3 +Alias (byte) main::line2_xadd#0 = (byte) main::line2_xadd#4 +Alias (byte) main::line2_ysize#0 = (byte) main::line2_ysize#4 +Alias (byte) main::plot2_xpos#0 = (byte) main::line2_$0#0 (byte) main::plot2_xpos#1 +Alias (byte) main::line2_ch#1 = (byte) main::plot2_ch#0 (byte) main::plot2_ch#1 (byte) main::line2_ch#4 (byte) main::line2_ch#2 +Alias (byte*) cur_line#10 = (byte*) cur_line#9 (byte*) cur_line#14 +Alias (word) main::line2_pos#2 = (word) main::line2_pos#4 (word) main::line2_pos#3 +Alias (byte) main::line2_xadd#1 = (byte) main::line2_xadd#2 (byte) main::line2_xadd#3 +Alias (byte) main::line2_i#2 = (byte) main::line2_i#3 (byte) main::line2_i#4 +Alias (byte) main::line2_ysize#1 = (byte) main::line2_ysize#2 (byte) main::line2_ysize#3 +Alias (byte*) cur_line#11 = (byte*) cur_line#3 (byte*) cur_line#4 +Alias (byte*) cur_line#15 = (byte*) cur_line#5 +Alias (byte*) cur_line#12 = (byte*) cur_line#6 +Succesful SSA optimization Pass2AliasElimination +Not aliassing identity: main::line1_ch#1 main::line1_ch#1 +Not aliassing identity: main::line1_xadd#1 main::line1_xadd#1 +Not aliassing identity: main::line1_ysize#1 main::line1_ysize#1 +Not aliassing identity: main::line2_ch#1 main::line2_ch#1 +Not aliassing identity: main::line2_xadd#1 main::line2_xadd#1 +Not aliassing identity: main::line2_ysize#1 main::line2_ysize#1 +Not aliassing across scopes: cur_line#12 cur_line#11 +Self Phi Eliminated (word) main::line1_pos#2 +Self Phi Eliminated (byte) main::line1_ch#1 +Self Phi Eliminated (byte) main::line1_ch#1 +Self Phi Eliminated (byte*) cur_line#13 +Self Phi Eliminated (byte) main::line1_xadd#1 +Self Phi Eliminated (byte) main::line1_xadd#1 +Self Phi Eliminated (byte) main::line1_i#2 +Self Phi Eliminated (byte) main::line1_ysize#1 +Self Phi Eliminated (byte) main::line1_ysize#1 +Self Phi Eliminated (word) main::line2_pos#2 +Self Phi Eliminated (byte) main::line2_ch#1 +Self Phi Eliminated (byte) main::line2_ch#1 +Self Phi Eliminated (byte*) cur_line#10 +Self Phi Eliminated (byte) main::line2_xadd#1 +Self Phi Eliminated (byte) main::line2_xadd#1 +Self Phi Eliminated (byte) main::line2_i#2 +Self Phi Eliminated (byte) main::line2_ysize#1 +Self Phi Eliminated (byte) main::line2_ysize#1 +Succesful SSA optimization Pass2SelfPhiElimination +Redundant Phi (byte) main::line1_ch#1 (byte) main::line1_ch#0 +Redundant Phi (byte) main::line1_xadd#1 (byte) main::line1_xadd#0 +Redundant Phi (byte) main::line1_ysize#1 (byte) main::line1_ysize#0 +Redundant Phi (byte) main::line2_ch#1 (byte) main::line2_ch#0 +Redundant Phi (byte) main::line2_xadd#1 (byte) main::line2_xadd#0 +Redundant Phi (byte) main::line2_ysize#1 (byte) main::line2_ysize#0 +Redundant Phi (byte*) cur_line#12 (byte*) cur_line#11 +Succesful SSA optimization Pass2RedundantPhiElimination +Simple Condition (bool~) main::$1 if((byte*) main::sc#1<(word/signed word/dword/signed dword~) main::$0) goto main::@1 +Simple Condition (bool) main::line1_$2#0 if((byte) main::line1_i#1<(byte) main::line1_ysize#0) goto main::line1_@1 +Simple Condition (bool) main::line2_$2#0 if((byte) main::line2_i#1<(byte) main::line2_ysize#0) goto main::line2_@1 +Succesful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) main::sc#0 = ((byte*))1024 +Constant (const word/signed word/dword/signed dword) main::$0 = 1024+1000 +Constant (const byte) main::line1_xpos#0 = 2 +Constant (const byte) main::line1_xadd#0 = 64 +Constant (const byte) main::line1_ysize#0 = 10 +Constant (const byte) main::line1_ch#0 = '*' +Constant (const byte*) cur_line#0 = ((byte*))1024 +Constant (const byte) main::line1_i#0 = 0 +Constant (const byte) main::line2_xpos#0 = 4 +Constant (const byte) main::line2_xadd#0 = 128 +Constant (const byte) main::line2_ysize#0 = 15 +Constant (const byte) main::line2_ch#0 = '.' +Constant (const byte*) cur_line#2 = ((byte*))1024 +Constant (const byte) main::line2_i#0 = 0 +Constant (const byte*) cur_line#15 = ((byte*))1024 +Succesful SSA optimization Pass2ConstantIdentification +Fixing inline constructor with main::$4 ← main::line1_xpos#0 w= 0 +Fixing inline constructor with main::$5 ← main::line2_xpos#0 w= 0 +Succesful SSA optimization Pass2FixInlineConstructors +Inferred type updated to word/signed word/dword/signed dword in (word~) main::$4 ← (const byte) main::line1_xpos#0 w= (byte/signed byte/word/signed word/dword/signed dword) 0 +Inferred type updated to word/signed word/dword/signed dword in (word~) main::$5 ← (const byte) main::line2_xpos#0 w= (byte/signed byte/word/signed word/dword/signed dword) 0 +Eliminating unused constant (const byte*) cur_line#15 +Succesful SSA optimization PassNEliminateUnusedVars +Culled Empty Block (label) main::@2 +Culled Empty Block (label) main::@3 +Culled Empty Block (label) @1 +Culled Empty Block (label) @4 +Succesful SSA optimization Pass2CullEmptyBlocks +Alias (word) main::line1_pos#0 = (word/signed word/dword/signed dword~) main::$4 +Alias (word) main::line2_pos#0 = (word/signed word/dword/signed dword~) main::$5 +Succesful SSA optimization Pass2AliasElimination +Constant (const word) main::line1_pos#0 = main::line1_xpos#0*256+0 +Constant (const word) main::line2_pos#0 = main::line2_xpos#0*256+0 +Succesful SSA optimization Pass2ConstantIdentification +OPTIMIZING CONTROL FLOW GRAPH +Inlining constant with var siblings (const byte*) main::sc#0 +Inlining constant with var siblings (const byte*) main::sc#0 +Inlining constant with var siblings (const byte) main::line1_i#0 +Inlining constant with var siblings (const byte) main::line1_i#0 +Inlining constant with var siblings (const byte) main::line2_i#0 +Inlining constant with var siblings (const byte) main::line2_i#0 +Inlining constant with var siblings (const word) main::line1_pos#0 +Inlining constant with var siblings (const word) main::line1_pos#0 +Inlining constant with var siblings (const word) main::line2_pos#0 +Inlining constant with var siblings (const word) main::line2_pos#0 +Inlining constant with var siblings (const byte*) cur_line#0 +Inlining constant with var siblings (const byte*) cur_line#0 +Inlining constant with var siblings (const byte*) cur_line#0 +Inlining constant with var siblings (const byte*) cur_line#0 +Inlining constant with var siblings (const byte*) cur_line#2 +Inlining constant with var siblings (const byte*) cur_line#2 +Inlining constant with var siblings (const byte*) cur_line#2 +Inlining constant with var siblings (const byte*) cur_line#2 +Constant inlined main::line2_i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined main::$0 = (word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000 +Constant inlined main::line1_i#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined main::line2_pos#0 = (const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined cur_line#0 = ((byte*))(word/signed word/dword/signed dword) 1024 +Constant inlined main::sc#0 = ((byte*))(word/signed word/dword/signed dword) 1024 +Constant inlined cur_line#2 = ((byte*))(word/signed word/dword/signed dword) 1024 +Constant inlined main::line1_pos#0 = (const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 +Succesful SSA optimization Pass2ConstantInlining +Block Sequence Planned @begin @3 @end main main::@1 main::line1 main::line1_@1 main::plot1 main::@4 main::line2 main::line2_@1 main::plot2 main::@6 main::@return +Added new block during phi lifting main::@7(between main::@1 and main::@1) +Added new block during phi lifting main::@8(between main::@4 and main::line1_@1) +Added new block during phi lifting main::@9(between main::@6 and main::line2_@1) +Block Sequence Planned @begin @3 @end main main::@1 main::line1 main::line1_@1 main::plot1 main::@4 main::line2 main::line2_@1 main::plot2 main::@6 main::@return main::@9 main::@8 main::@7 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @3 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::line1 +Adding NOP phi() at start of main::line2 +CALL GRAPH +Calls in [] to main:2 + +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Created 7 initial phi equivalence classes +Coalesced [28] main::line2_pos#5 ← main::line2_pos#1 +Coalesced [29] cur_line#17 ← cur_line#11 +Coalesced [30] main::line2_i#5 ← main::line2_i#1 +Coalesced [31] main::line1_pos#5 ← main::line1_pos#1 +Coalesced [32] cur_line#16 ← cur_line#1 +Coalesced [33] main::line1_i#5 ← main::line1_i#1 +Coalesced [34] main::sc#3 ← main::sc#1 +Coalesced down to 7 phi equivalence classes +Culled Empty Block (label) main::@9 +Culled Empty Block (label) main::@8 +Culled Empty Block (label) main::@7 +Block Sequence Planned @begin @3 @end main main::@1 main::line1 main::line1_@1 main::plot1 main::@4 main::line2 main::line2_@1 main::plot2 main::@6 main::@return +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @3 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::line1 +Adding NOP phi() at start of main::line2 +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... +Propagating live ranges... + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() [ ] ( ) + to:@3 +@3: scope:[] from @begin + [1] phi() [ ] ( ) + [2] call main [ ] ( ) + to:@end +@end: scope:[] from @3 + [3] phi() [ ] ( ) +main: scope:[main] from @3 + [4] phi() [ ] ( main:2 [ ] ) + to:main::@1 +main::@1: scope:[main] from main main::@1 + [5] (byte*) main::sc#2 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@1/(byte*) main::sc#1 ) [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) + [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) + [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) + [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) + to:main::line1 +main::line1: scope:[main] from main::@1 + [9] phi() [ ] ( main:2 [ ] ) + to:main::line1_@1 +main::line1_@1: scope:[main] from main::@4 main::line1 main::line1_@1 + [10] (byte) main::line1_i#2 ← phi( main::@4/(byte) main::line1_i#1 main::line1/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [10] (byte*) cur_line#13 ← phi( main::@4/(byte*) cur_line#1 main::line1/((byte*))(word/signed word/dword/signed dword) 1024 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [10] (word) main::line1_pos#2 ← phi( main::@4/(word) main::line1_pos#1 main::line1/(const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) + to:main::plot1 +main::plot1: scope:[main] from main::line1_@1 + [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) + [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) + to:main::@4 +main::@4: scope:[main] from main::plot1 + [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) + [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) + [16] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) + [17] if((byte) main::line1_i#1<(const byte) main::line1_ysize#0) goto main::line1_@1 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) + to:main::line2 +main::line2: scope:[main] from main::@4 + [18] phi() [ ] ( main:2 [ ] ) + to:main::line2_@1 +main::line2_@1: scope:[main] from main::@6 main::line2 main::line2_@1 + [19] (byte) main::line2_i#2 ← phi( main::@6/(byte) main::line2_i#1 main::line2/(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [19] (byte*) cur_line#10 ← phi( main::@6/(byte*) cur_line#11 main::line2/((byte*))(word/signed word/dword/signed dword) 1024 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [19] (word) main::line2_pos#2 ← phi( main::@6/(word) main::line2_pos#1 main::line2/(const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 ) [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) + to:main::plot2 +main::plot2: scope:[main] from main::line2_@1 + [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) + [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) + to:main::@6 +main::@6: scope:[main] from main::plot2 + [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) + [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) + [25] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) + [26] if((byte) main::line2_i#1<(const byte) main::line2_ysize#0) goto main::line2_@1 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) + to:main::@return +main::@return: scope:[main] from main::@6 + [27] return [ ] ( main:2 [ ] ) + to:@return + +DOMINATORS +@begin dominated by @begin +@3 dominated by @begin @3 +@end dominated by @begin @end @3 +main dominated by @begin main @3 +main::@1 dominated by @begin main @3 main::@1 +main::line1 dominated by @begin main::line1 main @3 main::@1 +main::line1_@1 dominated by @begin main::line1 main::line1_@1 main @3 main::@1 +main::plot1 dominated by @begin main::line1 main::line1_@1 main main::plot1 @3 main::@1 +main::@4 dominated by @begin main::line1 main::line1_@1 main main::plot1 @3 main::@1 main::@4 +main::line2 dominated by @begin main::line1 main::line1_@1 main::line2 main main::plot1 @3 main::@1 main::@4 +main::line2_@1 dominated by @begin main::line1 main::line1_@1 main::line2 main main::line2_@1 main::plot1 @3 main::@1 main::@4 +main::plot2 dominated by @begin main::line1 main::line1_@1 main::line2 main main::line2_@1 main::plot1 @3 main::@1 main::plot2 main::@4 +main::@6 dominated by @begin main::line1 main::line1_@1 main::line2 main main::line2_@1 main::plot1 @3 main::@1 main::@6 main::plot2 main::@4 +main::@return dominated by main::@return @begin main::line1 main::line1_@1 main::line2 main main::line2_@1 main::plot1 @3 main::@1 main::@6 main::plot2 main::@4 + +NATURAL LOOPS +Found back edge: Loop head: main::@1 tails: main::@1 blocks: null +Found back edge: Loop head: main::line1_@1 tails: main::line1_@1 blocks: null +Found back edge: Loop head: main::line1_@1 tails: main::@4 blocks: null +Found back edge: Loop head: main::line2_@1 tails: main::line2_@1 blocks: null +Found back edge: Loop head: main::line2_@1 tails: main::@6 blocks: null +Populated: Loop head: main::@1 tails: main::@1 blocks: main::@1 +Populated: Loop head: main::line1_@1 tails: main::line1_@1 blocks: main::line1_@1 +Populated: Loop head: main::line1_@1 tails: main::@4 blocks: main::@4 main::plot1 main::line1_@1 +Populated: Loop head: main::line2_@1 tails: main::line2_@1 blocks: main::line2_@1 +Populated: Loop head: main::line2_@1 tails: main::@6 blocks: main::@6 main::plot2 main::line2_@1 +Loop head: main::@1 tails: main::@1 blocks: main::@1 +Loop head: main::line1_@1 tails: main::line1_@1 blocks: main::line1_@1 +Loop head: main::line1_@1 tails: main::@4 blocks: main::@4 main::plot1 main::line1_@1 +Loop head: main::line2_@1 tails: main::line2_@1 blocks: main::line2_@1 +Loop head: main::line2_@1 tails: main::@6 blocks: main::@6 main::plot2 main::line2_@1 + +NATURAL LOOPS WITH DEPTH +Found 0 loops in scope [] +Found 5 loops in scope [main] + Loop head: main::@1 tails: main::@1 blocks: main::@1 + Loop head: main::line1_@1 tails: main::line1_@1 blocks: main::line1_@1 + Loop head: main::line1_@1 tails: main::@4 blocks: main::@4 main::plot1 main::line1_@1 + Loop head: main::line2_@1 tails: main::line2_@1 blocks: main::line2_@1 + Loop head: main::line2_@1 tails: main::@6 blocks: main::@6 main::plot2 main::line2_@1 +Loop head: main::@1 tails: main::@1 blocks: main::@1 depth: 1 +Loop head: main::line1_@1 tails: main::line1_@1 blocks: main::line1_@1 depth: 2 +Loop head: main::line1_@1 tails: main::@4 blocks: main::@4 main::plot1 main::line1_@1 depth: 1 +Loop head: main::line2_@1 tails: main::line2_@1 blocks: main::line2_@1 depth: 2 +Loop head: main::line2_@1 tails: main::@6 blocks: main::@6 main::plot2 main::line2_@1 depth: 1 + + +VARIABLE REGISTER WEIGHTS +(byte*) cur_line +(byte*) cur_line#1 7.333333333333333 +(byte*) cur_line#10 6.6000000000000005 +(byte*) cur_line#11 7.333333333333333 +(byte*) cur_line#13 6.6000000000000005 +(void()) main() +(byte~) main::line1_$0 +(bool~) main::line1_$2 +(byte) main::line1_ch +(byte) main::line1_i +(byte) main::line1_i#1 16.5 +(byte) main::line1_i#2 3.6666666666666665 +(word) main::line1_pos +(word) main::line1_pos#1 5.5 +(word) main::line1_pos#2 30.75 +(byte) main::line1_xadd +(byte) main::line1_xpos +(byte) main::line1_ysize +(byte~) main::line2_$0 +(bool~) main::line2_$2 +(byte) main::line2_ch +(byte) main::line2_i +(byte) main::line2_i#1 16.5 +(byte) main::line2_i#2 3.6666666666666665 +(word) main::line2_pos +(word) main::line2_pos#1 5.5 +(word) main::line2_pos#2 30.75 +(byte) main::line2_xadd +(byte) main::line2_xpos +(byte) main::line2_ysize +(byte*~) main::plot1_$0 +(byte*) main::plot1_$0#0 22.0 +(byte) main::plot1_ch +(byte) main::plot1_xpos +(byte) main::plot1_xpos#0 112.0 +(byte*~) main::plot2_$0 +(byte*) main::plot2_$0#0 22.0 +(byte) main::plot2_ch +(byte) main::plot2_xpos +(byte) main::plot2_xpos#0 112.0 +(byte*) main::sc +(byte*) main::sc#1 16.5 +(byte*) main::sc#2 16.5 + +Initial phi equivalence classes +[ main::sc#2 main::sc#1 ] +[ main::line1_pos#2 main::line1_pos#1 ] +[ cur_line#13 cur_line#1 ] +[ main::line1_i#2 main::line1_i#1 ] +[ main::line2_pos#2 main::line2_pos#1 ] +[ cur_line#10 cur_line#11 ] +[ main::line2_i#2 main::line2_i#1 ] +Added variable main::plot1_xpos#0 to zero page equivalence class [ main::plot1_xpos#0 ] +Added variable main::plot1_$0#0 to zero page equivalence class [ main::plot1_$0#0 ] +Added variable main::plot2_xpos#0 to zero page equivalence class [ main::plot2_xpos#0 ] +Added variable main::plot2_$0#0 to zero page equivalence class [ main::plot2_$0#0 ] +Complete equivalence classes +[ main::sc#2 main::sc#1 ] +[ main::line1_pos#2 main::line1_pos#1 ] +[ cur_line#13 cur_line#1 ] +[ main::line1_i#2 main::line1_i#1 ] +[ main::line2_pos#2 main::line2_pos#1 ] +[ cur_line#10 cur_line#11 ] +[ main::line2_i#2 main::line2_i#1 ] +[ main::plot1_xpos#0 ] +[ main::plot1_$0#0 ] +[ main::plot2_xpos#0 ] +[ main::plot2_$0#0 ] +Allocated zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] +Allocated zp ZP_WORD:4 [ main::line1_pos#2 main::line1_pos#1 ] +Allocated zp ZP_WORD:6 [ cur_line#13 cur_line#1 ] +Allocated zp ZP_BYTE:8 [ main::line1_i#2 main::line1_i#1 ] +Allocated zp ZP_WORD:9 [ main::line2_pos#2 main::line2_pos#1 ] +Allocated zp ZP_WORD:11 [ cur_line#10 cur_line#11 ] +Allocated zp ZP_BYTE:13 [ main::line2_i#2 main::line2_i#1 ] +Allocated zp ZP_BYTE:14 [ main::plot1_xpos#0 ] +Allocated zp ZP_WORD:15 [ main::plot1_$0#0 ] +Allocated zp ZP_BYTE:17 [ main::plot2_xpos#0 ] +Allocated zp ZP_WORD:18 [ main::plot2_$0#0 ] + +INITIAL ASM +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label cur_line = 6 + .label cur_line_10 = $b + .label cur_line_11 = $b +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @3 [phi:@begin->@3] +b3_from_bbegin: + jmp b3 +//SEG4 @3 +b3: +//SEG5 [2] call main [ ] ( ) +//SEG6 [4] phi from @3 to main [phi:@3->main] +main_from_b3: + jsr main +//SEG7 [3] phi from @3 to @end [phi:@3->@end] +bend_from_b3: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + .const line1_xpos = 2 + .const line1_xadd = $40 + .const line1_ysize = $a + .const line1_ch = '*' + .const line2_xpos = 4 + .const line2_xadd = $80 + .const line2_ysize = $f + .const line2_ch = '.' + .label sc = 2 + .label plot1_xpos = $e + .label plot1__0 = $f + .label line1_pos = 4 + .label line1_i = 8 + .label plot2_xpos = $11 + .label plot2__0 = $12 + .label line2_pos = 9 + .label line2_i = $d + //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG11 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 + lda #<$400 + sta sc + lda #>$400 + sta sc+1 + jmp b1 + //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG13 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG14 main::@1 + b1: + //SEG15 [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) -- _deref_pbuz1=vbuc1 + lda #' ' + ldy #0 + sta (sc),y + //SEG16 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1=_inc_pbuz1 + inc sc + bne !+ + inc sc+1 + !: + //SEG17 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1_lt_vwuc1_then_la1 + lda sc+1 + cmp #>$400+$3e8 + bcc b1_from_b1 + bne !+ + lda sc + cmp #<$400+$3e8 + bcc b1_from_b1 + !: + //SEG18 [9] phi from main::@1 to main::line1 [phi:main::@1->main::line1] + line1_from_b1: + jmp line1 + //SEG19 main::line1 + line1: + //SEG20 [10] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] + line1_b1_from_line1: + //SEG21 [10] phi (byte) main::line1_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#0] -- vbuz1=vbuc1 + lda #0 + sta line1_i + //SEG22 [10] phi (byte*) cur_line#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line1->main::line1_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + //SEG23 [10] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#2] -- vwuz1=vwuc1 + lda #line1_xpos*$100+0 + sta line1_pos+1 + jmp line1_b1 + //SEG24 [10] phi from main::@4 to main::line1_@1 [phi:main::@4->main::line1_@1] + line1_b1_from_b4: + //SEG25 [10] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@4->main::line1_@1#0] -- register_copy + //SEG26 [10] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@4->main::line1_@1#1] -- register_copy + //SEG27 [10] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@4->main::line1_@1#2] -- register_copy + jmp line1_b1 + //SEG28 [10] phi from main::line1_@1 to main::line1_@1 [phi:main::line1_@1->main::line1_@1] + line1_b1_from_line1_b1: + jmp line1_b1 + //SEG29 main::line1_@1 + line1_b1: + //SEG30 [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) -- vbuz1=_hi_vwuz2 + lda line1_pos+1 + sta plot1_xpos + jmp plot1 + //SEG31 main::plot1 + plot1: + //SEG32 [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuz3 + lda plot1_xpos + clc + adc cur_line + sta plot1__0 + lda #0 + adc cur_line+1 + sta plot1__0+1 + //SEG33 [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line1_ch + ldy #0 + sta (plot1__0),y + jmp b4 + //SEG34 main::@4 + b4: + //SEG35 [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line1_pos + adc #line1_xadd + sta line1_pos+1 + //SEG36 [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + //SEG37 [16] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuz1=_inc_vbuz1 + inc line1_i + //SEG38 [17] if((byte) main::line1_i#1<(const byte) main::line1_ysize#0) goto main::line1_@1 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuz1_lt_vbuc1_then_la1 + lda line1_i + cmp #line1_ysize + bcc line1_b1_from_b4 + //SEG39 [18] phi from main::@4 to main::line2 [phi:main::@4->main::line2] + line2_from_b4: + jmp line2 + //SEG40 main::line2 + line2: + //SEG41 [19] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] + line2_b1_from_line2: + //SEG42 [19] phi (byte) main::line2_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#0] -- vbuz1=vbuc1 + lda #0 + sta line2_i + //SEG43 [19] phi (byte*) cur_line#10 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line2->main::line2_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line_10 + lda #>$400 + sta cur_line_10+1 + //SEG44 [19] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#2] -- vwuz1=vwuc1 + lda #line2_xpos*$100+0 + sta line2_pos+1 + jmp line2_b1 + //SEG45 [19] phi from main::@6 to main::line2_@1 [phi:main::@6->main::line2_@1] + line2_b1_from_b6: + //SEG46 [19] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@6->main::line2_@1#0] -- register_copy + //SEG47 [19] phi (byte*) cur_line#10 = (byte*) cur_line#11 [phi:main::@6->main::line2_@1#1] -- register_copy + //SEG48 [19] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@6->main::line2_@1#2] -- register_copy + jmp line2_b1 + //SEG49 [19] phi from main::line2_@1 to main::line2_@1 [phi:main::line2_@1->main::line2_@1] + line2_b1_from_line2_b1: + jmp line2_b1 + //SEG50 main::line2_@1 + line2_b1: + //SEG51 [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) -- vbuz1=_hi_vwuz2 + lda line2_pos+1 + sta plot2_xpos + jmp plot2 + //SEG52 main::plot2 + plot2: + //SEG53 [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuz3 + lda plot2_xpos + clc + adc cur_line_10 + sta plot2__0 + lda #0 + adc cur_line_10+1 + sta plot2__0+1 + //SEG54 [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line2_ch + ldy #0 + sta (plot2__0),y + jmp b6 + //SEG55 main::@6 + b6: + //SEG56 [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line2_pos + adc #line2_xadd + sta line2_pos+1 + //SEG57 [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line_11 + clc + adc #$28 + sta cur_line_11 + bcc !+ + inc cur_line_11+1 + !: + //SEG58 [25] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuz1=_inc_vbuz1 + inc line2_i + //SEG59 [26] if((byte) main::line2_i#1<(const byte) main::line2_ysize#0) goto main::line2_@1 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuz1_lt_vbuc1_then_la1 + lda line2_i + cmp #line2_ysize + bcc line2_b1_from_b6 + jmp breturn + //SEG60 main::@return + breturn: + //SEG61 [27] return [ ] ( main:2 [ ] ) + rts +} + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) always clobbers reg byte a reg byte y +Statement [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a +Statement [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:8 [ main::line1_i#2 main::line1_i#1 ] +Statement [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) always clobbers reg byte a +Statement [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:8 [ main::line1_i#2 main::line1_i#1 ] +Statement [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) always clobbers reg byte a +Statement [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) always clobbers reg byte a +Statement [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:13 [ main::line2_i#2 main::line2_i#1 ] +Statement [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) always clobbers reg byte a +Statement [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:13 [ main::line2_i#2 main::line2_i#1 ] +Statement [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) always clobbers reg byte a +Statement [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) always clobbers reg byte a +Statement [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) always clobbers reg byte a reg byte y +Statement [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) always clobbers reg byte a +Statement [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) always clobbers reg byte a +Statement [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) always clobbers reg byte a +Statement [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) always clobbers reg byte a reg byte y +Statement [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) always clobbers reg byte a +Statement [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) always clobbers reg byte a +Statement [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) always clobbers reg byte a +Statement [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) always clobbers reg byte a +Statement [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) always clobbers reg byte a reg byte y +Statement [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) always clobbers reg byte a +Statement [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) always clobbers reg byte a +Potential registers zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] : zp ZP_WORD:2 , +Potential registers zp ZP_WORD:4 [ main::line1_pos#2 main::line1_pos#1 ] : zp ZP_WORD:4 , +Potential registers zp ZP_WORD:6 [ cur_line#13 cur_line#1 ] : zp ZP_WORD:6 , +Potential registers zp ZP_BYTE:8 [ main::line1_i#2 main::line1_i#1 ] : zp ZP_BYTE:8 , reg byte x , +Potential registers zp ZP_WORD:9 [ main::line2_pos#2 main::line2_pos#1 ] : zp ZP_WORD:9 , +Potential registers zp ZP_WORD:11 [ cur_line#10 cur_line#11 ] : zp ZP_WORD:11 , +Potential registers zp ZP_BYTE:13 [ main::line2_i#2 main::line2_i#1 ] : zp ZP_BYTE:13 , reg byte x , +Potential registers zp ZP_BYTE:14 [ main::plot1_xpos#0 ] : zp ZP_BYTE:14 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:15 [ main::plot1_$0#0 ] : zp ZP_WORD:15 , +Potential registers zp ZP_BYTE:17 [ main::plot2_xpos#0 ] : zp ZP_BYTE:17 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:18 [ main::plot2_$0#0 ] : zp ZP_WORD:18 , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 112: zp ZP_BYTE:14 [ main::plot1_xpos#0 ] 112: zp ZP_BYTE:17 [ main::plot2_xpos#0 ] 36.25: zp ZP_WORD:4 [ main::line1_pos#2 main::line1_pos#1 ] 36.25: zp ZP_WORD:9 [ main::line2_pos#2 main::line2_pos#1 ] 33: zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] 22: zp ZP_WORD:15 [ main::plot1_$0#0 ] 22: zp ZP_WORD:18 [ main::plot2_$0#0 ] 20.17: zp ZP_BYTE:8 [ main::line1_i#2 main::line1_i#1 ] 20.17: zp ZP_BYTE:13 [ main::line2_i#2 main::line2_i#1 ] +Uplift Scope [] 13.93: zp ZP_WORD:6 [ cur_line#13 cur_line#1 ] 13.93: zp ZP_WORD:11 [ cur_line#10 cur_line#11 ] + +Uplifting [main] best 9434 combination reg byte a [ main::plot1_xpos#0 ] reg byte a [ main::plot2_xpos#0 ] zp ZP_WORD:4 [ main::line1_pos#2 main::line1_pos#1 ] zp ZP_WORD:9 [ main::line2_pos#2 main::line2_pos#1 ] zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] zp ZP_WORD:15 [ main::plot1_$0#0 ] zp ZP_WORD:18 [ main::plot2_$0#0 ] reg byte x [ main::line1_i#2 main::line1_i#1 ] reg byte x [ main::line2_i#2 main::line2_i#1 ] +Uplifting [] best 9434 combination zp ZP_WORD:6 [ cur_line#13 cur_line#1 ] zp ZP_WORD:11 [ cur_line#10 cur_line#11 ] +Coalescing zero page register [ zp ZP_WORD:2 [ main::sc#2 main::sc#1 ] ] with [ zp ZP_WORD:4 [ main::line1_pos#2 main::line1_pos#1 ] ] +Coalescing zero page register [ zp ZP_WORD:2 [ main::sc#2 main::sc#1 main::line1_pos#2 main::line1_pos#1 ] ] with [ zp ZP_WORD:9 [ main::line2_pos#2 main::line2_pos#1 ] ] +Coalescing zero page register [ zp ZP_WORD:6 [ cur_line#13 cur_line#1 ] ] with [ zp ZP_WORD:11 [ cur_line#10 cur_line#11 ] ] +Coalescing zero page register [ zp ZP_WORD:15 [ main::plot1_$0#0 ] ] with [ zp ZP_WORD:18 [ main::plot2_$0#0 ] ] +Allocated (was zp ZP_WORD:6) zp ZP_WORD:4 [ cur_line#13 cur_line#1 cur_line#10 cur_line#11 ] +Allocated (was zp ZP_WORD:15) zp ZP_WORD:6 [ main::plot1_$0#0 main::plot2_$0#0 ] + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label cur_line = 4 +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @3 [phi:@begin->@3] +b3_from_bbegin: + jmp b3 +//SEG4 @3 +b3: +//SEG5 [2] call main [ ] ( ) +//SEG6 [4] phi from @3 to main [phi:@3->main] +main_from_b3: + jsr main +//SEG7 [3] phi from @3 to @end [phi:@3->@end] +bend_from_b3: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + .const line1_xpos = 2 + .const line1_xadd = $40 + .const line1_ysize = $a + .const line1_ch = '*' + .const line2_xpos = 4 + .const line2_xadd = $80 + .const line2_ysize = $f + .const line2_ch = '.' + .label sc = 2 + .label plot1__0 = 6 + .label line1_pos = 2 + .label plot2__0 = 6 + .label line2_pos = 2 + //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG11 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 + lda #<$400 + sta sc + lda #>$400 + sta sc+1 + jmp b1 + //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG13 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG14 main::@1 + b1: + //SEG15 [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) -- _deref_pbuz1=vbuc1 + lda #' ' + ldy #0 + sta (sc),y + //SEG16 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1=_inc_pbuz1 + inc sc + bne !+ + inc sc+1 + !: + //SEG17 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1_lt_vwuc1_then_la1 + lda sc+1 + cmp #>$400+$3e8 + bcc b1_from_b1 + bne !+ + lda sc + cmp #<$400+$3e8 + bcc b1_from_b1 + !: + //SEG18 [9] phi from main::@1 to main::line1 [phi:main::@1->main::line1] + line1_from_b1: + jmp line1 + //SEG19 main::line1 + line1: + //SEG20 [10] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] + line1_b1_from_line1: + //SEG21 [10] phi (byte) main::line1_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG22 [10] phi (byte*) cur_line#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line1->main::line1_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + //SEG23 [10] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#2] -- vwuz1=vwuc1 + lda #line1_xpos*$100+0 + sta line1_pos+1 + jmp line1_b1 + //SEG24 [10] phi from main::@4 to main::line1_@1 [phi:main::@4->main::line1_@1] + line1_b1_from_b4: + //SEG25 [10] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@4->main::line1_@1#0] -- register_copy + //SEG26 [10] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@4->main::line1_@1#1] -- register_copy + //SEG27 [10] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@4->main::line1_@1#2] -- register_copy + jmp line1_b1 + //SEG28 [10] phi from main::line1_@1 to main::line1_@1 [phi:main::line1_@1->main::line1_@1] + line1_b1_from_line1_b1: + jmp line1_b1 + //SEG29 main::line1_@1 + line1_b1: + //SEG30 [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) -- vbuaa=_hi_vwuz1 + lda line1_pos+1 + jmp plot1 + //SEG31 main::plot1 + plot1: + //SEG32 [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuaa + clc + adc cur_line + sta plot1__0 + lda #0 + adc cur_line+1 + sta plot1__0+1 + //SEG33 [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line1_ch + ldy #0 + sta (plot1__0),y + jmp b4 + //SEG34 main::@4 + b4: + //SEG35 [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line1_pos + adc #line1_xadd + sta line1_pos+1 + //SEG36 [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + //SEG37 [16] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuxx=_inc_vbuxx + inx + //SEG38 [17] if((byte) main::line1_i#1<(const byte) main::line1_ysize#0) goto main::line1_@1 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuxx_lt_vbuc1_then_la1 + cpx #line1_ysize + bcc line1_b1_from_b4 + //SEG39 [18] phi from main::@4 to main::line2 [phi:main::@4->main::line2] + line2_from_b4: + jmp line2 + //SEG40 main::line2 + line2: + //SEG41 [19] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] + line2_b1_from_line2: + //SEG42 [19] phi (byte) main::line2_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG43 [19] phi (byte*) cur_line#10 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line2->main::line2_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + //SEG44 [19] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#2] -- vwuz1=vwuc1 + lda #line2_xpos*$100+0 + sta line2_pos+1 + jmp line2_b1 + //SEG45 [19] phi from main::@6 to main::line2_@1 [phi:main::@6->main::line2_@1] + line2_b1_from_b6: + //SEG46 [19] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@6->main::line2_@1#0] -- register_copy + //SEG47 [19] phi (byte*) cur_line#10 = (byte*) cur_line#11 [phi:main::@6->main::line2_@1#1] -- register_copy + //SEG48 [19] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@6->main::line2_@1#2] -- register_copy + jmp line2_b1 + //SEG49 [19] phi from main::line2_@1 to main::line2_@1 [phi:main::line2_@1->main::line2_@1] + line2_b1_from_line2_b1: + jmp line2_b1 + //SEG50 main::line2_@1 + line2_b1: + //SEG51 [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) -- vbuaa=_hi_vwuz1 + lda line2_pos+1 + jmp plot2 + //SEG52 main::plot2 + plot2: + //SEG53 [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuaa + clc + adc cur_line + sta plot2__0 + lda #0 + adc cur_line+1 + sta plot2__0+1 + //SEG54 [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line2_ch + ldy #0 + sta (plot2__0),y + jmp b6 + //SEG55 main::@6 + b6: + //SEG56 [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line2_pos + adc #line2_xadd + sta line2_pos+1 + //SEG57 [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + //SEG58 [25] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuxx=_inc_vbuxx + inx + //SEG59 [26] if((byte) main::line2_i#1<(const byte) main::line2_ysize#0) goto main::line2_@1 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuxx_lt_vbuc1_then_la1 + cpx #line2_ysize + bcc line2_b1_from_b6 + jmp breturn + //SEG60 main::@return + breturn: + //SEG61 [27] return [ ] ( main:2 [ ] ) + rts +} + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b3 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp line1 +Removing instruction jmp line1_b1 +Removing instruction jmp plot1 +Removing instruction jmp b4 +Removing instruction jmp line2 +Removing instruction jmp line2_b1 +Removing instruction jmp plot2 +Removing instruction jmp b6 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Replacing label b1_from_b1 with b1 +Replacing label b1_from_b1 with b1 +Removing instruction bbegin: +Removing instruction b3_from_bbegin: +Removing instruction main_from_b3: +Removing instruction bend_from_b3: +Removing instruction b1_from_b1: +Removing instruction line1_from_b1: +Removing instruction line1_b1_from_line1: +Removing instruction line1_b1_from_line1_b1: +Removing instruction line2_from_b4: +Removing instruction line2_b1_from_line2: +Removing instruction line2_b1_from_line2_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction b3: +Removing instruction bend: +Removing instruction b1_from_main: +Removing instruction line1: +Removing instruction plot1: +Removing instruction b4: +Removing instruction line2: +Removing instruction plot2: +Removing instruction b6: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Skipping double jump to line1_b1 in bcc line1_b1_from_b4 +Skipping double jump to line2_b1 in bcc line2_b1_from_b6 +Succesful ASM optimization Pass5DoubleJumpElimination +Relabelling long label line1_b1_from_b4 to b2 +Relabelling long label line2_b1_from_b6 to b3 +Succesful ASM optimization Pass5RelabelLongLabels +Removing instruction jmp b1 +Removing instruction jmp line1_b1 +Removing instruction jmp line2_b1 +Succesful ASM optimization Pass5NextJumpElimination +Replacing label line1_b1 with b2 +Replacing label line1_b1 with b2 +Replacing label line2_b1 with b3 +Replacing label line2_b1 with b3 +Removing instruction line1_b1: +Removing instruction line2_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction jmp b2 +Removing instruction jmp b3 +Succesful ASM optimization Pass5NextJumpElimination + +FINAL SYMBOL TABLE +(label) @3 +(label) @begin +(label) @end +(byte*) cur_line +(byte*) cur_line#1 cur_line zp ZP_WORD:4 7.333333333333333 +(byte*) cur_line#10 cur_line zp ZP_WORD:4 6.6000000000000005 +(byte*) cur_line#11 cur_line zp ZP_WORD:4 7.333333333333333 +(byte*) cur_line#13 cur_line zp ZP_WORD:4 6.6000000000000005 +(void()) main() +(label) main::@1 +(label) main::@4 +(label) main::@6 +(label) main::@return +(label) main::line1 +(byte~) main::line1_$0 +(bool~) main::line1_$2 +(label) main::line1_@1 +(byte) main::line1_ch +(const byte) main::line1_ch#0 line1_ch = (byte) '*' +(byte) main::line1_i +(byte) main::line1_i#1 reg byte x 16.5 +(byte) main::line1_i#2 reg byte x 3.6666666666666665 +(word) main::line1_pos +(word) main::line1_pos#1 line1_pos zp ZP_WORD:2 5.5 +(word) main::line1_pos#2 line1_pos zp ZP_WORD:2 30.75 +(byte) main::line1_xadd +(const byte) main::line1_xadd#0 line1_xadd = (byte/signed byte/word/signed word/dword/signed dword) 64 +(byte) main::line1_xpos +(const byte) main::line1_xpos#0 line1_xpos = (byte/signed byte/word/signed word/dword/signed dword) 2 +(byte) main::line1_ysize +(const byte) main::line1_ysize#0 line1_ysize = (byte/signed byte/word/signed word/dword/signed dword) 10 +(label) main::line2 +(byte~) main::line2_$0 +(bool~) main::line2_$2 +(label) main::line2_@1 +(byte) main::line2_ch +(const byte) main::line2_ch#0 line2_ch = (byte) '.' +(byte) main::line2_i +(byte) main::line2_i#1 reg byte x 16.5 +(byte) main::line2_i#2 reg byte x 3.6666666666666665 +(word) main::line2_pos +(word) main::line2_pos#1 line2_pos zp ZP_WORD:2 5.5 +(word) main::line2_pos#2 line2_pos zp ZP_WORD:2 30.75 +(byte) main::line2_xadd +(const byte) main::line2_xadd#0 line2_xadd = (byte/word/signed word/dword/signed dword) 128 +(byte) main::line2_xpos +(const byte) main::line2_xpos#0 line2_xpos = (byte/signed byte/word/signed word/dword/signed dword) 4 +(byte) main::line2_ysize +(const byte) main::line2_ysize#0 line2_ysize = (byte/signed byte/word/signed word/dword/signed dword) 15 +(label) main::plot1 +(byte*~) main::plot1_$0 +(byte*) main::plot1_$0#0 plot1_$0 zp ZP_WORD:6 22.0 +(byte) main::plot1_ch +(byte) main::plot1_xpos +(byte) main::plot1_xpos#0 reg byte a 112.0 +(label) main::plot2 +(byte*~) main::plot2_$0 +(byte*) main::plot2_$0#0 plot2_$0 zp ZP_WORD:6 22.0 +(byte) main::plot2_ch +(byte) main::plot2_xpos +(byte) main::plot2_xpos#0 reg byte a 112.0 +(byte*) main::sc +(byte*) main::sc#1 sc zp ZP_WORD:2 16.5 +(byte*) main::sc#2 sc zp ZP_WORD:2 16.5 + +zp ZP_WORD:2 [ main::sc#2 main::sc#1 main::line1_pos#2 main::line1_pos#1 main::line2_pos#2 main::line2_pos#1 ] +zp ZP_WORD:4 [ cur_line#13 cur_line#1 cur_line#10 cur_line#11 ] +reg byte x [ main::line1_i#2 main::line1_i#1 ] +reg byte x [ main::line2_i#2 main::line2_i#1 ] +reg byte a [ main::plot1_xpos#0 ] +zp ZP_WORD:6 [ main::plot1_$0#0 main::plot2_$0#0 ] +reg byte a [ main::plot2_xpos#0 ] + + +FINAL ASSEMBLER +Score: 6872 + +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label cur_line = 4 +//SEG2 @begin +//SEG3 [1] phi from @begin to @3 [phi:@begin->@3] +//SEG4 @3 +//SEG5 [2] call main [ ] ( ) +//SEG6 [4] phi from @3 to main [phi:@3->main] + jsr main +//SEG7 [3] phi from @3 to @end [phi:@3->@end] +//SEG8 @end +//SEG9 main +main: { + .const line1_xpos = 2 + .const line1_xadd = $40 + .const line1_ysize = $a + .const line1_ch = '*' + .const line2_xpos = 4 + .const line2_xadd = $80 + .const line2_ysize = $f + .const line2_ch = '.' + .label sc = 2 + .label plot1__0 = 6 + .label line1_pos = 2 + .label plot2__0 = 6 + .label line2_pos = 2 + //SEG10 [5] phi from main to main::@1 [phi:main->main::@1] + //SEG11 [5] phi (byte*) main::sc#2 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1 + lda #<$400 + sta sc + lda #>$400 + sta sc+1 + //SEG12 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG13 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG14 main::@1 + b1: + //SEG15 [6] *((byte*) main::sc#2) ← (byte) ' ' [ main::sc#2 ] ( main:2 [ main::sc#2 ] ) -- _deref_pbuz1=vbuc1 + lda #' ' + ldy #0 + sta (sc),y + //SEG16 [7] (byte*) main::sc#1 ← ++ (byte*) main::sc#2 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1=_inc_pbuz1 + inc sc + bne !+ + inc sc+1 + !: + //SEG17 [8] if((byte*) main::sc#1<(word/signed word/dword/signed dword) 1024+(word/signed word/dword/signed dword) 1000) goto main::@1 [ main::sc#1 ] ( main:2 [ main::sc#1 ] ) -- pbuz1_lt_vwuc1_then_la1 + lda sc+1 + cmp #>$400+$3e8 + bcc b1 + bne !+ + lda sc + cmp #<$400+$3e8 + bcc b1 + !: + //SEG18 [9] phi from main::@1 to main::line1 [phi:main::@1->main::line1] + //SEG19 main::line1 + //SEG20 [10] phi from main::line1 to main::line1_@1 [phi:main::line1->main::line1_@1] + //SEG21 [10] phi (byte) main::line1_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG22 [10] phi (byte*) cur_line#13 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line1->main::line1_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + //SEG23 [10] phi (word) main::line1_pos#2 = (const byte) main::line1_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line1->main::line1_@1#2] -- vwuz1=vwuc1 + lda #line1_xpos*$100+0 + sta line1_pos+1 + //SEG24 [10] phi from main::@4 to main::line1_@1 [phi:main::@4->main::line1_@1] + b2: + //SEG25 [10] phi (byte) main::line1_i#2 = (byte) main::line1_i#1 [phi:main::@4->main::line1_@1#0] -- register_copy + //SEG26 [10] phi (byte*) cur_line#13 = (byte*) cur_line#1 [phi:main::@4->main::line1_@1#1] -- register_copy + //SEG27 [10] phi (word) main::line1_pos#2 = (word) main::line1_pos#1 [phi:main::@4->main::line1_@1#2] -- register_copy + //SEG28 [10] phi from main::line1_@1 to main::line1_@1 [phi:main::line1_@1->main::line1_@1] + //SEG29 main::line1_@1 + //SEG30 [11] (byte) main::plot1_xpos#0 ← > (word) main::line1_pos#2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_xpos#0 ] ) -- vbuaa=_hi_vwuz1 + lda line1_pos+1 + //SEG31 main::plot1 + //SEG32 [12] (byte*) main::plot1_$0#0 ← (byte*) cur_line#13 + (byte) main::plot1_xpos#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 main::plot1_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuaa + clc + adc cur_line + sta plot1__0 + lda #0 + adc cur_line+1 + sta plot1__0+1 + //SEG33 [13] *((byte*) main::plot1_$0#0) ← (const byte) main::line1_ch#0 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ( main:2 [ main::line1_pos#2 cur_line#13 main::line1_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line1_ch + ldy #0 + sta (plot1__0),y + //SEG34 main::@4 + //SEG35 [14] (word) main::line1_pos#1 ← (word) main::line1_pos#2 + (const byte) main::line1_xadd#0 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ( main:2 [ cur_line#13 main::line1_i#2 main::line1_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line1_pos + adc #line1_xadd + sta line1_pos+1 + //SEG36 [15] (byte*) cur_line#1 ← (byte*) cur_line#13 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ( main:2 [ main::line1_i#2 main::line1_pos#1 cur_line#1 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + //SEG37 [16] (byte) main::line1_i#1 ← ++ (byte) main::line1_i#2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuxx=_inc_vbuxx + inx + //SEG38 [17] if((byte) main::line1_i#1<(const byte) main::line1_ysize#0) goto main::line1_@1 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ( main:2 [ main::line1_pos#1 cur_line#1 main::line1_i#1 ] ) -- vbuxx_lt_vbuc1_then_la1 + cpx #line1_ysize + bcc b2 + //SEG39 [18] phi from main::@4 to main::line2 [phi:main::@4->main::line2] + //SEG40 main::line2 + //SEG41 [19] phi from main::line2 to main::line2_@1 [phi:main::line2->main::line2_@1] + //SEG42 [19] phi (byte) main::line2_i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG43 [19] phi (byte*) cur_line#10 = ((byte*))(word/signed word/dword/signed dword) 1024 [phi:main::line2->main::line2_@1#1] -- pbuz1=pbuc1 + lda #<$400 + sta cur_line + lda #>$400 + sta cur_line+1 + //SEG44 [19] phi (word) main::line2_pos#2 = (const byte) main::line2_xpos#0*(word/signed word/dword/signed dword) 256+(byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::line2->main::line2_@1#2] -- vwuz1=vwuc1 + lda #line2_xpos*$100+0 + sta line2_pos+1 + //SEG45 [19] phi from main::@6 to main::line2_@1 [phi:main::@6->main::line2_@1] + b3: + //SEG46 [19] phi (byte) main::line2_i#2 = (byte) main::line2_i#1 [phi:main::@6->main::line2_@1#0] -- register_copy + //SEG47 [19] phi (byte*) cur_line#10 = (byte*) cur_line#11 [phi:main::@6->main::line2_@1#1] -- register_copy + //SEG48 [19] phi (word) main::line2_pos#2 = (word) main::line2_pos#1 [phi:main::@6->main::line2_@1#2] -- register_copy + //SEG49 [19] phi from main::line2_@1 to main::line2_@1 [phi:main::line2_@1->main::line2_@1] + //SEG50 main::line2_@1 + //SEG51 [20] (byte) main::plot2_xpos#0 ← > (word) main::line2_pos#2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_xpos#0 ] ) -- vbuaa=_hi_vwuz1 + lda line2_pos+1 + //SEG52 main::plot2 + //SEG53 [21] (byte*) main::plot2_$0#0 ← (byte*) cur_line#10 + (byte) main::plot2_xpos#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 main::plot2_$0#0 ] ) -- pbuz1=pbuz2_plus_vbuaa + clc + adc cur_line + sta plot2__0 + lda #0 + adc cur_line+1 + sta plot2__0+1 + //SEG54 [22] *((byte*) main::plot2_$0#0) ← (const byte) main::line2_ch#0 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ( main:2 [ main::line2_pos#2 cur_line#10 main::line2_i#2 ] ) -- _deref_pbuz1=vbuc1 + lda #line2_ch + ldy #0 + sta (plot2__0),y + //SEG55 main::@6 + //SEG56 [23] (word) main::line2_pos#1 ← (word) main::line2_pos#2 + (const byte) main::line2_xadd#0 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ( main:2 [ cur_line#10 main::line2_i#2 main::line2_pos#1 ] ) -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line2_pos + adc #line2_xadd + sta line2_pos+1 + //SEG57 [24] (byte*) cur_line#11 ← (byte*) cur_line#10 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ( main:2 [ main::line2_i#2 main::line2_pos#1 cur_line#11 ] ) -- pbuz1=pbuz1_plus_vbuc1 + lda cur_line + clc + adc #$28 + sta cur_line + bcc !+ + inc cur_line+1 + !: + //SEG58 [25] (byte) main::line2_i#1 ← ++ (byte) main::line2_i#2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuxx=_inc_vbuxx + inx + //SEG59 [26] if((byte) main::line2_i#1<(const byte) main::line2_ysize#0) goto main::line2_@1 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ( main:2 [ main::line2_pos#1 cur_line#11 main::line2_i#1 ] ) -- vbuxx_lt_vbuc1_then_la1 + cpx #line2_ysize + bcc b3 + //SEG60 main::@return + //SEG61 [27] return [ ] ( main:2 [ ] ) + rts +} + diff --git a/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.sym b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.sym new file mode 100644 index 000000000..a720c6d5e --- /dev/null +++ b/src/test/java/dk/camelot64/kickc/test/ref/inline-function-level2.sym @@ -0,0 +1,72 @@ +(label) @3 +(label) @begin +(label) @end +(byte*) cur_line +(byte*) cur_line#1 cur_line zp ZP_WORD:4 7.333333333333333 +(byte*) cur_line#10 cur_line zp ZP_WORD:4 6.6000000000000005 +(byte*) cur_line#11 cur_line zp ZP_WORD:4 7.333333333333333 +(byte*) cur_line#13 cur_line zp ZP_WORD:4 6.6000000000000005 +(void()) main() +(label) main::@1 +(label) main::@4 +(label) main::@6 +(label) main::@return +(label) main::line1 +(byte~) main::line1_$0 +(bool~) main::line1_$2 +(label) main::line1_@1 +(byte) main::line1_ch +(const byte) main::line1_ch#0 line1_ch = (byte) '*' +(byte) main::line1_i +(byte) main::line1_i#1 reg byte x 16.5 +(byte) main::line1_i#2 reg byte x 3.6666666666666665 +(word) main::line1_pos +(word) main::line1_pos#1 line1_pos zp ZP_WORD:2 5.5 +(word) main::line1_pos#2 line1_pos zp ZP_WORD:2 30.75 +(byte) main::line1_xadd +(const byte) main::line1_xadd#0 line1_xadd = (byte/signed byte/word/signed word/dword/signed dword) 64 +(byte) main::line1_xpos +(const byte) main::line1_xpos#0 line1_xpos = (byte/signed byte/word/signed word/dword/signed dword) 2 +(byte) main::line1_ysize +(const byte) main::line1_ysize#0 line1_ysize = (byte/signed byte/word/signed word/dword/signed dword) 10 +(label) main::line2 +(byte~) main::line2_$0 +(bool~) main::line2_$2 +(label) main::line2_@1 +(byte) main::line2_ch +(const byte) main::line2_ch#0 line2_ch = (byte) '.' +(byte) main::line2_i +(byte) main::line2_i#1 reg byte x 16.5 +(byte) main::line2_i#2 reg byte x 3.6666666666666665 +(word) main::line2_pos +(word) main::line2_pos#1 line2_pos zp ZP_WORD:2 5.5 +(word) main::line2_pos#2 line2_pos zp ZP_WORD:2 30.75 +(byte) main::line2_xadd +(const byte) main::line2_xadd#0 line2_xadd = (byte/word/signed word/dword/signed dword) 128 +(byte) main::line2_xpos +(const byte) main::line2_xpos#0 line2_xpos = (byte/signed byte/word/signed word/dword/signed dword) 4 +(byte) main::line2_ysize +(const byte) main::line2_ysize#0 line2_ysize = (byte/signed byte/word/signed word/dword/signed dword) 15 +(label) main::plot1 +(byte*~) main::plot1_$0 +(byte*) main::plot1_$0#0 plot1_$0 zp ZP_WORD:6 22.0 +(byte) main::plot1_ch +(byte) main::plot1_xpos +(byte) main::plot1_xpos#0 reg byte a 112.0 +(label) main::plot2 +(byte*~) main::plot2_$0 +(byte*) main::plot2_$0#0 plot2_$0 zp ZP_WORD:6 22.0 +(byte) main::plot2_ch +(byte) main::plot2_xpos +(byte) main::plot2_xpos#0 reg byte a 112.0 +(byte*) main::sc +(byte*) main::sc#1 sc zp ZP_WORD:2 16.5 +(byte*) main::sc#2 sc zp ZP_WORD:2 16.5 + +zp ZP_WORD:2 [ main::sc#2 main::sc#1 main::line1_pos#2 main::line1_pos#1 main::line2_pos#2 main::line2_pos#1 ] +zp ZP_WORD:4 [ cur_line#13 cur_line#1 cur_line#10 cur_line#11 ] +reg byte x [ main::line1_i#2 main::line1_i#1 ] +reg byte x [ main::line2_i#2 main::line2_i#1 ] +reg byte a [ main::plot1_xpos#0 ] +zp ZP_WORD:6 [ main::plot1_$0#0 main::plot2_$0#0 ] +reg byte a [ main::plot2_xpos#0 ]