diff --git a/src/main/java/dk/camelot64/kickc/CompileLog.java b/src/main/java/dk/camelot64/kickc/CompileLog.java index e90400437..63779d6af 100644 --- a/src/main/java/dk/camelot64/kickc/CompileLog.java +++ b/src/main/java/dk/camelot64/kickc/CompileLog.java @@ -62,6 +62,9 @@ public class CompileLog { */ private boolean verboseCreateSsa = false; + /** Should comments be output as part of the intermediate SSA prints. */ + private boolean verboseComments = false; + /** * Should the log be output to System.out while being built @@ -84,6 +87,10 @@ public class CompileLog { return log; } + public void setVerboseComments(boolean verboseComments) { + this.verboseComments = verboseComments; + } + public void setVerboseLoopUnroll(boolean verboseLoopUnroll) { this.verboseLoopUnroll = verboseLoopUnroll; } @@ -184,4 +191,8 @@ public class CompileLog { public String toString() { return log.toString(); } + + public boolean isVerboseComments() { + return verboseComments; + } } diff --git a/src/main/java/dk/camelot64/kickc/model/ControlFlowBlock.java b/src/main/java/dk/camelot64/kickc/model/ControlFlowBlock.java index e549dbcf6..11bd5d658 100644 --- a/src/main/java/dk/camelot64/kickc/model/ControlFlowBlock.java +++ b/src/main/java/dk/camelot64/kickc/model/ControlFlowBlock.java @@ -38,12 +38,24 @@ public class ControlFlowBlock { /** If the last statement of the block is a call this is the block containing the start of the called procedure. When the procedure returns control moves on to the default successor. */ private LabelRef callSuccessor; + /** The comments for the block. */ + private List comments; + public ControlFlowBlock(LabelRef label, ScopeRef scope) { this.label = label; this.scope = scope; this.statements = new ArrayList<>(); this.defaultSuccessor = null; this.conditionalSuccessor = null; + this.comments = new ArrayList<>(); + } + + public List getComments() { + return comments; + } + + public void setComments(List comments) { + this.comments = comments; } public LabelRef getLabel() { @@ -159,6 +171,11 @@ public class ControlFlowBlock { } out.append("\n"); for(Statement statement : statements) { + if(program.getLog().isVerboseComments()) { + for(Comment comment : statement.getComments()) { + out.append(" // " + comment.getComment() + "\n"); + } + } out.append(" " + statement.toString(program, program.getLog().isVerboseLiveRanges()) + "\n"); } if(defaultSuccessor != null) { diff --git a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java index 3f29fd4b6..22992a340 100644 --- a/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java +++ b/src/main/java/dk/camelot64/kickc/model/ControlFlowGraphCopyVisitor.java @@ -54,6 +54,7 @@ public class ControlFlowGraphCopyVisitor extends ControlFlowGraphBaseVisitor { // Create and assign declared loop variable Variable lValue = getForVariable(forDeclCtx); KickCParser.ExprContext initializer = forDeclCtx.expr(); - List comments = getCommentsSymbol(ctx); if(initializer != null) { - addInitialAssignment(initializer, lValue, comments); + addInitialAssignment(initializer, lValue, Comment.NO_COMMENTS); } // Add label Label repeatLabel = getCurrentSymbols().addLabelIntermediate(); - StatementLabel repeatTarget = new StatementLabel(repeatLabel.getRef(), new StatementSource(ctx), Comment.NO_COMMENTS); + List comments = getCommentsSymbol(stmtForCtx); + StatementLabel repeatTarget = new StatementLabel(repeatLabel.getRef(), new StatementSource(ctx), comments); sequence.addStatement(repeatTarget); // Add body if(stmtForCtx.stmt() != null) { @@ -618,12 +618,12 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor { // Assign loop variable with first value RValue rangeLastValue = (RValue) visit(rangeLastCtx); RValue rangeFirstValue = (RValue) visit(rangeFirstCtx); - List comments = ensureUnusedComments(getCommentsSymbol(ctx)); - Statement stmtInit = new StatementAssignment(lValue.getRef(), rangeFirstValue, new StatementSource(ctx), comments); + Statement stmtInit = new StatementAssignment(lValue.getRef(), rangeFirstValue, new StatementSource(ctx), Comment.NO_COMMENTS); sequence.addStatement(stmtInit); // Add label + List comments = ensureUnusedComments(getCommentsSymbol(stmtForCtx)); Label repeatLabel = getCurrentSymbols().addLabelIntermediate(); - StatementLabel repeatTarget = new StatementLabel(repeatLabel.getRef(), new StatementSource(ctx), Comment.NO_COMMENTS); + StatementLabel repeatTarget = new StatementLabel(repeatLabel.getRef(), new StatementSource(ctx), comments); sequence.addStatement(repeatTarget); // Add body if(stmtForCtx.stmt() != null) { diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java index a13fd90ab..91af6e483 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass1GenerateControlFlowGraph.java @@ -43,6 +43,7 @@ public class Pass1GenerateControlFlowGraph extends Pass1Base { if(statement instanceof StatementLabel) { StatementLabel statementLabel = (StatementLabel) statement; ControlFlowBlock nextBlock = getOrCreateBlock(statementLabel.getLabel(), currentBlock.getScope()); + nextBlock.setComments(statementLabel.getComments()); currentBlock.setDefaultSuccessor(nextBlock.getLabel()); blockStack.pop(); blockStack.push(nextBlock); diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java index 3bfb43aba..a798f9131 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass4CodeGeneration.java @@ -79,6 +79,8 @@ public class Pass4CodeGeneration { addZpLabels(asm, currentScope); } + generateComments(asm, block.getComments()); + // Generate entry points (if needed) genBlockEntryPoints(asm, block); diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 6171de390..33b7f584e 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 testCommentsLoop() throws IOException, URISyntaxException { + compileAndCompare("test-comments-loop"); + } + @Test public void testCommentsSingle() throws IOException, URISyntaxException { compileAndCompare("test-comments-single"); diff --git a/src/test/kc/test-comments-loop.kc b/src/test/kc/test-comments-loop.kc new file mode 100644 index 000000000..58aabbfb0 --- /dev/null +++ b/src/test/kc/test-comments-loop.kc @@ -0,0 +1,8 @@ +void main() { + const byte* SCREEN = $400; + // Do some sums + for(byte b: 0..10 ) { + SCREEN[b] = 'a'; + } +} + diff --git a/src/test/ref/asm-clobber.asm b/src/test/ref/asm-clobber.asm index 085142d87..feec9103f 100644 --- a/src/test/ref/asm-clobber.asm +++ b/src/test/ref/asm-clobber.asm @@ -6,6 +6,7 @@ main: { .label l = 2 ldx #0 + // First loop with no clobber b1: lda #0 b2: @@ -18,6 +19,7 @@ main: { cpx #$65 bne b1 ldy #0 + // Then loop with clobbering A&X b3: lda #0 sta l diff --git a/src/test/ref/asm-clobber.log b/src/test/ref/asm-clobber.log index a28af1968..6ad0f1c56 100644 --- a/src/test/ref/asm-clobber.log +++ b/src/test/ref/asm-clobber.log @@ -309,6 +309,7 @@ main: { lda #0 sta i jmp b1 + // First loop with no clobber //SEG13 [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1] b1_from_b5: //SEG14 [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy @@ -352,6 +353,7 @@ main: { lda #0 sta k jmp b3 + // Then loop with clobbering A&X //SEG29 [12] phi from main::@7 to main::@3 [phi:main::@7->main::@3] b3_from_b7: //SEG30 [12] phi (byte) main::k#4 = (byte) main::k#1 [phi:main::@7->main::@3#0] -- register_copy @@ -456,6 +458,7 @@ main: { //SEG12 [5] phi (byte) main::i#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // First loop with no clobber //SEG13 [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1] b1_from_b5: //SEG14 [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy @@ -494,6 +497,7 @@ main: { //SEG28 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@3#0] -- vbuyy=vbuc1 ldy #0 jmp b3 + // Then loop with clobbering A&X //SEG29 [12] phi from main::@7 to main::@3 [phi:main::@7->main::@3] b3_from_b7: //SEG30 [12] phi (byte) main::k#4 = (byte) main::k#1 [phi:main::@7->main::@3#0] -- register_copy @@ -640,6 +644,7 @@ main: { //SEG11 [5] phi from main to main::@1 [phi:main->main::@1] //SEG12 [5] phi (byte) main::i#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 ldx #0 + // First loop with no clobber //SEG13 [5] phi from main::@5 to main::@1 [phi:main::@5->main::@1] //SEG14 [5] phi (byte) main::i#4 = (byte) main::i#1 [phi:main::@5->main::@1#0] -- register_copy //SEG15 main::@1 @@ -668,6 +673,7 @@ main: { //SEG27 [12] phi from main::@5 to main::@3 [phi:main::@5->main::@3] //SEG28 [12] phi (byte) main::k#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@3#0] -- vbuyy=vbuc1 ldy #0 + // Then loop with clobbering A&X //SEG29 [12] phi from main::@7 to main::@3 [phi:main::@7->main::@3] //SEG30 [12] phi (byte) main::k#4 = (byte) main::k#1 [phi:main::@7->main::@3#0] -- register_copy //SEG31 main::@3 diff --git a/src/test/ref/c64dtv-8bppcharstretch.asm b/src/test/ref/c64dtv-8bppcharstretch.asm index 35cef25d4..e532de27f 100644 --- a/src/test/ref/c64dtv-8bppcharstretch.asm +++ b/src/test/ref/c64dtv-8bppcharstretch.asm @@ -109,6 +109,7 @@ main: { lda #(SCREEN&$3fff)>>6|(>(SCREEN&$3fff))>>2 sta VIC_MEMORY ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x diff --git a/src/test/ref/c64dtv-8bppcharstretch.log b/src/test/ref/c64dtv-8bppcharstretch.log index e95581e61..a7b1bbf4f 100644 --- a/src/test/ref/c64dtv-8bppcharstretch.log +++ b/src/test/ref/c64dtv-8bppcharstretch.log @@ -2085,6 +2085,7 @@ main: { lda #0 sta j jmp b1 + // DTV Palette - Grey Tones //SEG37 [27] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG38 [27] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy @@ -2864,6 +2865,7 @@ main: { //SEG36 [27] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@17->main::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG37 [27] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG38 [27] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy @@ -3856,6 +3858,7 @@ main: { //SEG35 [27] phi from main::@17 to main::@1 [phi:main::@17->main::@1] //SEG36 [27] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@17->main::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG37 [27] phi from main::@1 to main::@1 [phi:main::@1->main::@1] //SEG38 [27] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy //SEG39 main::@1 diff --git a/src/test/ref/c64dtv-8bppchunkystretch.asm b/src/test/ref/c64dtv-8bppchunkystretch.asm index 7fdbfa6bc..fcf95c113 100644 --- a/src/test/ref/c64dtv-8bppchunkystretch.asm +++ b/src/test/ref/c64dtv-8bppchunkystretch.asm @@ -87,6 +87,7 @@ main: { lda #(CHUNKY&$3fff)>>6|(0)>>2 sta VIC_MEMORY ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x diff --git a/src/test/ref/c64dtv-8bppchunkystretch.log b/src/test/ref/c64dtv-8bppchunkystretch.log index 97cb411c4..c59ec6ae9 100644 --- a/src/test/ref/c64dtv-8bppchunkystretch.log +++ b/src/test/ref/c64dtv-8bppchunkystretch.log @@ -1705,6 +1705,7 @@ main: { lda #0 sta j jmp b1 + // DTV Palette - Grey Tones //SEG31 [21] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG32 [21] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy @@ -2251,6 +2252,7 @@ main: { //SEG30 [21] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@17->main::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG31 [21] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG32 [21] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy @@ -3012,6 +3014,7 @@ main: { //SEG29 [21] phi from main::@17 to main::@1 [phi:main::@17->main::@1] //SEG30 [21] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@17->main::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG31 [21] phi from main::@1 to main::@1 [phi:main::@1->main::@1] //SEG32 [21] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@1->main::@1#0] -- register_copy //SEG33 main::@1 diff --git a/src/test/ref/c64dtv-blittermin.asm b/src/test/ref/c64dtv-blittermin.asm index 369513e46..0aa7b49d9 100644 --- a/src/test/ref/c64dtv-blittermin.asm +++ b/src/test/ref/c64dtv-blittermin.asm @@ -136,6 +136,7 @@ main: { lda #DTV_BLIT_DEST_CONT sta DTV_BLITTER_CONTROL2 ldx #0 + // wait til blitter is ready b2: lda DTV_BLITTER_CONTROL2 and #DTV_BLIT_STATUS_BUSY diff --git a/src/test/ref/c64dtv-blittermin.log b/src/test/ref/c64dtv-blittermin.log index 1b2dd35b5..153f597b3 100644 --- a/src/test/ref/c64dtv-blittermin.log +++ b/src/test/ref/c64dtv-blittermin.log @@ -1376,6 +1376,7 @@ main: { lda #0 sta r jmp b2 + // wait til blitter is ready //SEG44 [36] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -1694,6 +1695,7 @@ main: { //SEG43 [36] phi (byte) main::r#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@2#0] -- vbuxx=vbuc1 ldx #0 jmp b2 + // wait til blitter is ready //SEG44 [36] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -2196,6 +2198,7 @@ main: { //SEG42 [36] phi from main to main::@2 [phi:main->main::@2] //SEG43 [36] phi (byte) main::r#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@2#0] -- vbuxx=vbuc1 ldx #0 + // wait til blitter is ready //SEG44 [36] phi from main::@2 to main::@2 [phi:main::@2->main::@2] //SEG45 [36] phi from main::@3 to main::@2 [phi:main::@3->main::@2] //SEG46 [36] phi (byte) main::r#2 = (byte) main::r#1 [phi:main::@3->main::@2#0] -- register_copy diff --git a/src/test/ref/c64dtv-color.asm b/src/test/ref/c64dtv-color.asm index c6ad34abd..149f41af0 100644 --- a/src/test/ref/c64dtv-color.asm +++ b/src/test/ref/c64dtv-color.asm @@ -59,6 +59,7 @@ main: { cpx #0 bne b7 ldx #0 + // Rotate palette b8: lda palette,x sta DTV_PALETTE,x diff --git a/src/test/ref/c64dtv-color.log b/src/test/ref/c64dtv-color.log index ce0f30db0..c597c9af1 100644 --- a/src/test/ref/c64dtv-color.log +++ b/src/test/ref/c64dtv-color.log @@ -1185,6 +1185,7 @@ main: { lda #0 sta c jmp b8 + // Rotate palette //SEG28 [14] phi from main::@8 to main::@8 [phi:main::@8->main::@8] b8_from_b8: //SEG29 [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@8->main::@8#0] -- register_copy @@ -1337,6 +1338,7 @@ main: { //SEG27 [14] phi (byte) main::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@7->main::@8#0] -- vbuxx=vbuc1 ldx #0 jmp b8 + // Rotate palette //SEG28 [14] phi from main::@8 to main::@8 [phi:main::@8->main::@8] b8_from_b8: //SEG29 [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@8->main::@8#0] -- register_copy @@ -1684,6 +1686,7 @@ main: { //SEG26 [14] phi from main::@7 to main::@8 [phi:main::@7->main::@8] //SEG27 [14] phi (byte) main::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@7->main::@8#0] -- vbuxx=vbuc1 ldx #0 + // Rotate palette //SEG28 [14] phi from main::@8 to main::@8 [phi:main::@8->main::@8] //SEG29 [14] phi (byte) main::c#2 = (byte) main::c#1 [phi:main::@8->main::@8#0] -- register_copy //SEG30 main::@8 diff --git a/src/test/ref/c64dtv-gfxexplorer.asm b/src/test/ref/c64dtv-gfxexplorer.asm index 2f96133ff..50b2e5118 100644 --- a/src/test/ref/c64dtv-gfxexplorer.asm +++ b/src/test/ref/c64dtv-gfxexplorer.asm @@ -496,6 +496,7 @@ gfx_mode: { cmp #0 beq b18 ldy #0 + // DTV Palette - Grey Tones b13: tya sta DTV_PALETTE,y @@ -511,6 +512,7 @@ gfx_mode: { cmp #KEY_SPACE bne b19 rts + // DTV Palette - default b18: ldy #0 b15: @@ -605,6 +607,7 @@ keyboard_event_scan: { sta keyboard_modifiers breturn: rts + // Something has changed on the keyboard row - check each column b6: lda #0 sta col @@ -1001,6 +1004,7 @@ form_mode: { lda #0 sta DTV_PLANEA_START_HI tay + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,y sta DTV_PALETTE,y @@ -1013,6 +1017,7 @@ form_mode: { sta BORDERCOL lda form_fields_val sta preset_current + // Let the user change values in the form b5: lda RASTER cmp #$ff @@ -1310,6 +1315,7 @@ apply_preset: { sta preset+1 b22: ldy #0 + // Copy preset values into the fields b23: lda (preset),y sta form_fields_val,y diff --git a/src/test/ref/c64dtv-gfxexplorer.log b/src/test/ref/c64dtv-gfxexplorer.log index b5e4360da..cabca5121 100644 --- a/src/test/ref/c64dtv-gfxexplorer.log +++ b/src/test/ref/c64dtv-gfxexplorer.log @@ -14722,6 +14722,7 @@ gfx_mode: { lda #0 sta j jmp b13 + // DTV Palette - Grey Tones //SEG223 [137] phi from gfx_mode::@13 to gfx_mode::@13 [phi:gfx_mode::@13->gfx_mode::@13] b13_from_b13: //SEG224 [137] phi (byte) gfx_mode::j#2 = (byte) gfx_mode::j#1 [phi:gfx_mode::@13->gfx_mode::@13#0] -- register_copy @@ -14780,6 +14781,7 @@ gfx_mode: { breturn: //SEG244 [149] return rts + // DTV Palette - default //SEG245 [150] phi from gfx_mode::@15 to gfx_mode::@15 [phi:gfx_mode::@15->gfx_mode::@15] b15_from_b15: //SEG246 [150] phi (byte) gfx_mode::i#2 = (byte) gfx_mode::i#1 [phi:gfx_mode::@15->gfx_mode::@15#0] -- register_copy @@ -15067,6 +15069,7 @@ keyboard_event_scan: { breturn: //SEG342 [195] return rts + // Something has changed on the keyboard row - check each column //SEG343 [196] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b4_from_b25: //SEG344 [196] phi (byte) keyboard_events_size#18 = (byte) keyboard_events_size#118 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -15801,6 +15804,7 @@ form_mode: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG536 [284] phi from form_mode::@1 to form_mode::@1 [phi:form_mode::@1->form_mode::@1] b1_from_b1: //SEG537 [284] phi (byte) form_mode::i#2 = (byte) form_mode::i#1 [phi:form_mode::@1->form_mode::@1#0] -- register_copy @@ -15838,6 +15842,7 @@ form_mode: { //SEG549 [291] phi (byte) keyboard_events_size#47 = (byte) keyboard_events_size#27 [phi:form_mode::@10/form_mode::@32->form_mode::@2#2] -- register_copy //SEG550 [291] phi (signed byte) form_cursor_count#21 = (signed byte) form_cursor_count#1 [phi:form_mode::@10/form_mode::@32->form_mode::@2#3] -- register_copy jmp b2 + // Let the user change values in the form //SEG551 [291] phi from form_mode::@8 to form_mode::@2 [phi:form_mode::@8->form_mode::@2] b2_from_b8: //SEG552 [291] phi (byte) form_field_idx#28 = (byte) form_field_idx#18 [phi:form_mode::@8->form_mode::@2#0] -- register_copy @@ -16453,6 +16458,7 @@ apply_preset: { lda #0 sta i jmp b23 + // Copy preset values into the fields //SEG724 [359] phi from apply_preset::@23 to apply_preset::@23 [phi:apply_preset::@23->apply_preset::@23] b23_from_b23: //SEG725 [359] phi (byte) apply_preset::i#2 = (byte) apply_preset::i#1 [phi:apply_preset::@23->apply_preset::@23#0] -- register_copy @@ -21840,6 +21846,7 @@ gfx_mode: { //SEG222 [137] phi (byte) gfx_mode::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:gfx_mode::@33->gfx_mode::@13#0] -- vbuyy=vbuc1 ldy #0 jmp b13 + // DTV Palette - Grey Tones //SEG223 [137] phi from gfx_mode::@13 to gfx_mode::@13 [phi:gfx_mode::@13->gfx_mode::@13] b13_from_b13: //SEG224 [137] phi (byte) gfx_mode::j#2 = (byte) gfx_mode::j#1 [phi:gfx_mode::@13->gfx_mode::@13#0] -- register_copy @@ -21891,6 +21898,7 @@ gfx_mode: { breturn: //SEG244 [149] return rts + // DTV Palette - default //SEG245 [150] phi from gfx_mode::@15 to gfx_mode::@15 [phi:gfx_mode::@15->gfx_mode::@15] b15_from_b15: //SEG246 [150] phi (byte) gfx_mode::i#2 = (byte) gfx_mode::i#1 [phi:gfx_mode::@15->gfx_mode::@15#0] -- register_copy @@ -22138,6 +22146,7 @@ keyboard_event_scan: { breturn: //SEG342 [195] return rts + // Something has changed on the keyboard row - check each column //SEG343 [196] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b4_from_b25: //SEG344 [196] phi (byte) keyboard_events_size#18 = (byte) keyboard_events_size#118 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -22817,6 +22826,7 @@ form_mode: { //SEG535 [284] phi (byte) form_mode::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:form_mode::@29->form_mode::@1#0] -- vbuyy=vbuc1 ldy #0 jmp b1 + // DTV Palette - default //SEG536 [284] phi from form_mode::@1 to form_mode::@1 [phi:form_mode::@1->form_mode::@1] b1_from_b1: //SEG537 [284] phi (byte) form_mode::i#2 = (byte) form_mode::i#1 [phi:form_mode::@1->form_mode::@1#0] -- register_copy @@ -22852,6 +22862,7 @@ form_mode: { //SEG549 [291] phi (byte) keyboard_events_size#47 = (byte) keyboard_events_size#27 [phi:form_mode::@10/form_mode::@32->form_mode::@2#2] -- register_copy //SEG550 [291] phi (signed byte) form_cursor_count#21 = (signed byte) form_cursor_count#1 [phi:form_mode::@10/form_mode::@32->form_mode::@2#3] -- register_copy jmp b2 + // Let the user change values in the form //SEG551 [291] phi from form_mode::@8 to form_mode::@2 [phi:form_mode::@8->form_mode::@2] b2_from_b8: //SEG552 [291] phi (byte) form_field_idx#28 = (byte) form_field_idx#18 [phi:form_mode::@8->form_mode::@2#0] -- register_copy @@ -23414,6 +23425,7 @@ apply_preset: { //SEG723 [359] phi (byte) apply_preset::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:apply_preset::@22->apply_preset::@23#0] -- vbuyy=vbuc1 ldy #0 jmp b23 + // Copy preset values into the fields //SEG724 [359] phi from apply_preset::@23 to apply_preset::@23 [phi:apply_preset::@23->apply_preset::@23] b23_from_b23: //SEG725 [359] phi (byte) apply_preset::i#2 = (byte) apply_preset::i#1 [phi:apply_preset::@23->apply_preset::@23#0] -- register_copy @@ -27292,13 +27304,12 @@ Replacing instruction ldy #0 with TAY Removing instruction lda form_fields_val Removing instruction lda x0 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Removing instruction b2: -Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction bbegin: Removing instruction b17: Removing instruction b9: Removing instruction b3: Removing instruction b27: +Removing instruction b2: Removing instruction b38: Removing instruction b39: Removing instruction b36: @@ -27319,18 +27330,18 @@ Removing instruction b37: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b7 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [758] beq b5 to bne -Fixing long branch [762] beq b6 to bne -Fixing long branch [766] beq b7 to bne -Fixing long branch [770] beq b8 to bne -Fixing long branch [756] beq b4 to bne -Fixing long branch [776] beq b9 to bne -Fixing long branch [780] beq b10 to bne -Fixing long branch [784] beq b11 to bne -Fixing long branch [788] beq b12 to bne -Fixing long branch [754] beq b3 to bne -Fixing long branch [794] beq b13 to bne -Fixing long branch [1339] bmi b2 to bpl +Fixing long branch [761] beq b5 to bne +Fixing long branch [765] beq b6 to bne +Fixing long branch [769] beq b7 to bne +Fixing long branch [773] beq b8 to bne +Fixing long branch [759] beq b4 to bne +Fixing long branch [779] beq b9 to bne +Fixing long branch [783] beq b10 to bne +Fixing long branch [787] beq b11 to bne +Fixing long branch [791] beq b12 to bne +Fixing long branch [757] beq b3 to bne +Fixing long branch [797] beq b13 to bne +Fixing long branch [1345] bmi b2 to bpl FINAL SYMBOL TABLE (label) @68 @@ -29760,6 +29771,7 @@ gfx_mode: { //SEG221 [137] phi from gfx_mode::@33 to gfx_mode::@13 [phi:gfx_mode::@33->gfx_mode::@13] //SEG222 [137] phi (byte) gfx_mode::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:gfx_mode::@33->gfx_mode::@13#0] -- vbuyy=vbuc1 ldy #0 + // DTV Palette - Grey Tones //SEG223 [137] phi from gfx_mode::@13 to gfx_mode::@13 [phi:gfx_mode::@13->gfx_mode::@13] //SEG224 [137] phi (byte) gfx_mode::j#2 = (byte) gfx_mode::j#1 [phi:gfx_mode::@13->gfx_mode::@13#0] -- register_copy //SEG225 gfx_mode::@13 @@ -29797,6 +29809,7 @@ gfx_mode: { //SEG243 gfx_mode::@return //SEG244 [149] return rts + // DTV Palette - default //SEG245 [150] phi from gfx_mode::@15 to gfx_mode::@15 [phi:gfx_mode::@15->gfx_mode::@15] //SEG246 [150] phi (byte) gfx_mode::i#2 = (byte) gfx_mode::i#1 [phi:gfx_mode::@15->gfx_mode::@15#0] -- register_copy //SEG247 [150] phi from gfx_mode::@33 to gfx_mode::@15 [phi:gfx_mode::@33->gfx_mode::@15] @@ -29989,6 +30002,7 @@ keyboard_event_scan: { breturn: //SEG342 [195] return rts + // Something has changed on the keyboard row - check each column //SEG343 [196] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b6: //SEG344 [196] phi (byte) keyboard_events_size#18 = (byte) keyboard_events_size#118 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -30578,6 +30592,7 @@ form_mode: { //SEG534 [284] phi from form_mode::@29 to form_mode::@1 [phi:form_mode::@29->form_mode::@1] //SEG535 [284] phi (byte) form_mode::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:form_mode::@29->form_mode::@1#0] -- vbuyy=vbuc1 tay + // DTV Palette - default //SEG536 [284] phi from form_mode::@1 to form_mode::@1 [phi:form_mode::@1->form_mode::@1] //SEG537 [284] phi (byte) form_mode::i#2 = (byte) form_mode::i#1 [phi:form_mode::@1->form_mode::@1#0] -- register_copy //SEG538 form_mode::@1 @@ -30605,6 +30620,7 @@ form_mode: { //SEG548 [291] phi (byte) form_field_idx#28 = (byte) form_field_idx#1 [phi:form_mode::@10/form_mode::@32->form_mode::@2#1] -- register_copy //SEG549 [291] phi (byte) keyboard_events_size#47 = (byte) keyboard_events_size#27 [phi:form_mode::@10/form_mode::@32->form_mode::@2#2] -- register_copy //SEG550 [291] phi (signed byte) form_cursor_count#21 = (signed byte) form_cursor_count#1 [phi:form_mode::@10/form_mode::@32->form_mode::@2#3] -- register_copy + // Let the user change values in the form //SEG551 [291] phi from form_mode::@8 to form_mode::@2 [phi:form_mode::@8->form_mode::@2] //SEG552 [291] phi (byte) form_field_idx#28 = (byte) form_field_idx#18 [phi:form_mode::@8->form_mode::@2#0] -- register_copy //SEG553 [291] phi (byte) keyboard_events_size#47 = (byte) keyboard_events_size#24 [phi:form_mode::@8->form_mode::@2#1] -- register_copy @@ -31075,6 +31091,7 @@ apply_preset: { //SEG722 [359] phi from apply_preset::@22 to apply_preset::@23 [phi:apply_preset::@22->apply_preset::@23] //SEG723 [359] phi (byte) apply_preset::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:apply_preset::@22->apply_preset::@23#0] -- vbuyy=vbuc1 ldy #0 + // Copy preset values into the fields //SEG724 [359] phi from apply_preset::@23 to apply_preset::@23 [phi:apply_preset::@23->apply_preset::@23] //SEG725 [359] phi (byte) apply_preset::i#2 = (byte) apply_preset::i#1 [phi:apply_preset::@23->apply_preset::@23#0] -- register_copy //SEG726 apply_preset::@23 diff --git a/src/test/ref/c64dtv-gfxmodes.asm b/src/test/ref/c64dtv-gfxmodes.asm index 8aa4331d9..4276e5707 100644 --- a/src/test/ref/c64dtv-gfxmodes.asm +++ b/src/test/ref/c64dtv-gfxmodes.asm @@ -145,6 +145,7 @@ menu: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,x sta DTV_PALETTE,x @@ -155,6 +156,7 @@ menu: { sta c lda #>COLS sta c+1 + // Char Colors b2: lda #LIGHT_GREEN ldy #0 @@ -299,6 +301,7 @@ mode_8bppchunkybmm: { // Border color sta BORDERCOL tax + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -370,6 +373,8 @@ mode_8bppchunkybmm: { } // Allow the user to control the DTV graphics using different keys mode_ctrl: { + b1: + // Wait for the raster b4: lda RASTER cmp #$ff @@ -437,11 +442,11 @@ mode_ctrl: { ldx #0 b14: cpx dtv_control - beq b4 + beq b1 stx dtv_control stx DTV_CONTROL stx BORDERCOL - jmp b4 + jmp b1 } // Determines whether a specific key is currently pressed by accessing the matrix directly // The key is a keyboard code defined from the keyboard matrix by %00rrrccc, where rrr is the row ID (0-7) and ccc is the column ID (0-7) @@ -540,6 +545,7 @@ mode_8bpppixelcell: { // Border color sta BORDERCOL tax + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -693,6 +699,7 @@ mode_sixsfred: { lda #>COLORS/$400 sta DTV_COLOR_BANK_HI ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -841,6 +848,7 @@ mode_twoplanebitmap: { lda #>COLORS/$400 sta DTV_COLOR_BANK_HI ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -1006,6 +1014,7 @@ mode_sixsfred2: { lda #>COLORS/$400 sta DTV_COLOR_BANK_HI ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -1150,6 +1159,7 @@ mode_hicolmcchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -1258,6 +1268,7 @@ mode_hicolecmchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -1364,6 +1375,7 @@ mode_hicolstdchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - Grey Tones b1: txa sta DTV_PALETTE,x @@ -1457,6 +1469,7 @@ mode_stdbitmap: { lda #(SCREEN&$3fff)/$40|(BITMAP&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,x sta DTV_PALETTE,x @@ -1924,6 +1937,7 @@ mode_mcchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,x sta DTV_PALETTE,x @@ -2035,6 +2049,7 @@ mode_ecmchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,x sta DTV_PALETTE,x @@ -2143,6 +2158,7 @@ mode_stdchar: { lda #(SCREEN&$3fff)/$40|(CHARSET&$3fff)/$400 sta VIC_MEMORY ldx #0 + // DTV Palette - default b1: lda DTV_PALETTE_DEFAULT,x sta DTV_PALETTE,x diff --git a/src/test/ref/c64dtv-gfxmodes.log b/src/test/ref/c64dtv-gfxmodes.log index 68fb94f27..eb7189c0f 100644 --- a/src/test/ref/c64dtv-gfxmodes.log +++ b/src/test/ref/c64dtv-gfxmodes.log @@ -12782,6 +12782,7 @@ menu: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG29 [19] phi from menu::@1 to menu::@1 [phi:menu::@1->menu::@1] b1_from_b1: //SEG30 [19] phi (byte) menu::i#2 = (byte) menu::i#1 [phi:menu::@1->menu::@1#0] -- register_copy @@ -12806,6 +12807,7 @@ menu: { lda #>COLS sta c+1 jmp b2 + // Char Colors //SEG37 [23] phi from menu::@2 to menu::@2 [phi:menu::@2->menu::@2] b2_from_b2: //SEG38 [23] phi (byte*) menu::c#2 = (byte*) menu::c#1 [phi:menu::@2->menu::@2#0] -- register_copy @@ -13318,6 +13320,7 @@ mode_8bppchunkybmm: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG215 [129] phi from mode_8bppchunkybmm::@1 to mode_8bppchunkybmm::@1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1] b1_from_b1: //SEG216 [129] phi (byte) mode_8bppchunkybmm::i#2 = (byte) mode_8bppchunkybmm::i#1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1#0] -- register_copy @@ -13519,6 +13522,7 @@ mode_ctrl: { //SEG284 mode_ctrl::@1 b1: jmp b4 + // Wait for the raster //SEG285 mode_ctrl::@4 b4: //SEG286 [157] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto mode_ctrl::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -14020,6 +14024,7 @@ mode_8bpppixelcell: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG431 [243] phi from mode_8bpppixelcell::@1 to mode_8bpppixelcell::@1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1] b1_from_b1: //SEG432 [243] phi (byte) mode_8bpppixelcell::i#2 = (byte) mode_8bpppixelcell::i#1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1#0] -- register_copy @@ -14359,6 +14364,7 @@ mode_sixsfred: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG547 [299] phi from mode_sixsfred::@1 to mode_sixsfred::@1 [phi:mode_sixsfred::@1->mode_sixsfred::@1] b1_from_b1: //SEG548 [299] phi (byte) mode_sixsfred::i#2 = (byte) mode_sixsfred::i#1 [phi:mode_sixsfred::@1->mode_sixsfred::@1#0] -- register_copy @@ -14677,6 +14683,7 @@ mode_twoplanebitmap: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG649 [352] phi from mode_twoplanebitmap::@1 to mode_twoplanebitmap::@1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1] b1_from_b1: //SEG650 [352] phi (byte) mode_twoplanebitmap::i#2 = (byte) mode_twoplanebitmap::i#1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1#0] -- register_copy @@ -15030,6 +15037,7 @@ mode_sixsfred2: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG762 [412] phi from mode_sixsfred2::@1 to mode_sixsfred2::@1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1] b1_from_b1: //SEG763 [412] phi (byte) mode_sixsfred2::i#2 = (byte) mode_sixsfred2::i#1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1#0] -- register_copy @@ -15335,6 +15343,7 @@ mode_hicolmcchar: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG858 [459] phi from mode_hicolmcchar::@1 to mode_hicolmcchar::@1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1] b1_from_b1: //SEG859 [459] phi (byte) mode_hicolmcchar::i#2 = (byte) mode_hicolmcchar::i#1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1#0] -- register_copy @@ -15543,6 +15552,7 @@ mode_hicolecmchar: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG919 [493] phi from mode_hicolecmchar::@1 to mode_hicolecmchar::@1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1] b1_from_b1: //SEG920 [493] phi (byte) mode_hicolecmchar::i#2 = (byte) mode_hicolecmchar::i#1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1#0] -- register_copy @@ -15750,6 +15760,7 @@ mode_hicolstdchar: { lda #0 sta i jmp b1 + // DTV Palette - Grey Tones //SEG981 [528] phi from mode_hicolstdchar::@1 to mode_hicolstdchar::@1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1] b1_from_b1: //SEG982 [528] phi (byte) mode_hicolstdchar::i#2 = (byte) mode_hicolstdchar::i#1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1#0] -- register_copy @@ -15941,6 +15952,7 @@ mode_stdbitmap: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG1038 [558] phi from mode_stdbitmap::@1 to mode_stdbitmap::@1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1] b1_from_b1: //SEG1039 [558] phi (byte) mode_stdbitmap::i#2 = (byte) mode_stdbitmap::i#1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1#0] -- register_copy @@ -17094,6 +17106,7 @@ mode_mcchar: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG1431 [767] phi from mode_mcchar::@1 to mode_mcchar::@1 [phi:mode_mcchar::@1->mode_mcchar::@1] b1_from_b1: //SEG1432 [767] phi (byte) mode_mcchar::i#2 = (byte) mode_mcchar::i#1 [phi:mode_mcchar::@1->mode_mcchar::@1#0] -- register_copy @@ -17313,6 +17326,7 @@ mode_ecmchar: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG1494 [803] phi from mode_ecmchar::@1 to mode_ecmchar::@1 [phi:mode_ecmchar::@1->mode_ecmchar::@1] b1_from_b1: //SEG1495 [803] phi (byte) mode_ecmchar::i#2 = (byte) mode_ecmchar::i#1 [phi:mode_ecmchar::@1->mode_ecmchar::@1#0] -- register_copy @@ -17531,6 +17545,7 @@ mode_stdchar: { lda #0 sta i jmp b1 + // DTV Palette - default //SEG1558 [840] phi from mode_stdchar::@1 to mode_stdchar::@1 [phi:mode_stdchar::@1->mode_stdchar::@1] b1_from_b1: //SEG1559 [840] phi (byte) mode_stdchar::i#2 = (byte) mode_stdchar::i#1 [phi:mode_stdchar::@1->mode_stdchar::@1#0] -- register_copy @@ -19666,6 +19681,7 @@ menu: { //SEG28 [19] phi (byte) menu::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:menu->menu::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - default //SEG29 [19] phi from menu::@1 to menu::@1 [phi:menu::@1->menu::@1] b1_from_b1: //SEG30 [19] phi (byte) menu::i#2 = (byte) menu::i#1 [phi:menu::@1->menu::@1#0] -- register_copy @@ -19688,6 +19704,7 @@ menu: { lda #>COLS sta c+1 jmp b2 + // Char Colors //SEG37 [23] phi from menu::@2 to menu::@2 [phi:menu::@2->menu::@2] b2_from_b2: //SEG38 [23] phi (byte*) menu::c#2 = (byte*) menu::c#1 [phi:menu::@2->menu::@2#0] -- register_copy @@ -20124,6 +20141,7 @@ mode_8bppchunkybmm: { //SEG214 [129] phi (byte) mode_8bppchunkybmm::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_8bppchunkybmm->mode_8bppchunkybmm::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG215 [129] phi from mode_8bppchunkybmm::@1 to mode_8bppchunkybmm::@1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1] b1_from_b1: //SEG216 [129] phi (byte) mode_8bppchunkybmm::i#2 = (byte) mode_8bppchunkybmm::i#1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1#0] -- register_copy @@ -20308,6 +20326,7 @@ mode_ctrl: { //SEG284 mode_ctrl::@1 b1: jmp b4 + // Wait for the raster //SEG285 mode_ctrl::@4 b4: //SEG286 [157] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto mode_ctrl::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -20707,6 +20726,7 @@ mode_8bpppixelcell: { //SEG430 [243] phi (byte) mode_8bpppixelcell::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_8bpppixelcell->mode_8bpppixelcell::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG431 [243] phi from mode_8bpppixelcell::@1 to mode_8bpppixelcell::@1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1] b1_from_b1: //SEG432 [243] phi (byte) mode_8bpppixelcell::i#2 = (byte) mode_8bpppixelcell::i#1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1#0] -- register_copy @@ -21020,6 +21040,7 @@ mode_sixsfred: { //SEG546 [299] phi (byte) mode_sixsfred::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_sixsfred->mode_sixsfred::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG547 [299] phi from mode_sixsfred::@1 to mode_sixsfred::@1 [phi:mode_sixsfred::@1->mode_sixsfred::@1] b1_from_b1: //SEG548 [299] phi (byte) mode_sixsfred::i#2 = (byte) mode_sixsfred::i#1 [phi:mode_sixsfred::@1->mode_sixsfred::@1#0] -- register_copy @@ -21314,6 +21335,7 @@ mode_twoplanebitmap: { //SEG648 [352] phi (byte) mode_twoplanebitmap::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_twoplanebitmap->mode_twoplanebitmap::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG649 [352] phi from mode_twoplanebitmap::@1 to mode_twoplanebitmap::@1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1] b1_from_b1: //SEG650 [352] phi (byte) mode_twoplanebitmap::i#2 = (byte) mode_twoplanebitmap::i#1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1#0] -- register_copy @@ -21641,6 +21663,7 @@ mode_sixsfred2: { //SEG761 [412] phi (byte) mode_sixsfred2::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_sixsfred2->mode_sixsfred2::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG762 [412] phi from mode_sixsfred2::@1 to mode_sixsfred2::@1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1] b1_from_b1: //SEG763 [412] phi (byte) mode_sixsfred2::i#2 = (byte) mode_sixsfred2::i#1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1#0] -- register_copy @@ -21923,6 +21946,7 @@ mode_hicolmcchar: { //SEG857 [459] phi (byte) mode_hicolmcchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolmcchar->mode_hicolmcchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG858 [459] phi from mode_hicolmcchar::@1 to mode_hicolmcchar::@1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1] b1_from_b1: //SEG859 [459] phi (byte) mode_hicolmcchar::i#2 = (byte) mode_hicolmcchar::i#1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1#0] -- register_copy @@ -22114,6 +22138,7 @@ mode_hicolecmchar: { //SEG918 [493] phi (byte) mode_hicolecmchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolecmchar->mode_hicolecmchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG919 [493] phi from mode_hicolecmchar::@1 to mode_hicolecmchar::@1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1] b1_from_b1: //SEG920 [493] phi (byte) mode_hicolecmchar::i#2 = (byte) mode_hicolecmchar::i#1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1#0] -- register_copy @@ -22304,6 +22329,7 @@ mode_hicolstdchar: { //SEG980 [528] phi (byte) mode_hicolstdchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolstdchar->mode_hicolstdchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - Grey Tones //SEG981 [528] phi from mode_hicolstdchar::@1 to mode_hicolstdchar::@1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1] b1_from_b1: //SEG982 [528] phi (byte) mode_hicolstdchar::i#2 = (byte) mode_hicolstdchar::i#1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1#0] -- register_copy @@ -22477,6 +22503,7 @@ mode_stdbitmap: { //SEG1037 [558] phi (byte) mode_stdbitmap::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_stdbitmap->mode_stdbitmap::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - default //SEG1038 [558] phi from mode_stdbitmap::@1 to mode_stdbitmap::@1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1] b1_from_b1: //SEG1039 [558] phi (byte) mode_stdbitmap::i#2 = (byte) mode_stdbitmap::i#1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1#0] -- register_copy @@ -23494,6 +23521,7 @@ mode_mcchar: { //SEG1430 [767] phi (byte) mode_mcchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_mcchar->mode_mcchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - default //SEG1431 [767] phi from mode_mcchar::@1 to mode_mcchar::@1 [phi:mode_mcchar::@1->mode_mcchar::@1] b1_from_b1: //SEG1432 [767] phi (byte) mode_mcchar::i#2 = (byte) mode_mcchar::i#1 [phi:mode_mcchar::@1->mode_mcchar::@1#0] -- register_copy @@ -23691,6 +23719,7 @@ mode_ecmchar: { //SEG1493 [803] phi (byte) mode_ecmchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_ecmchar->mode_ecmchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - default //SEG1494 [803] phi from mode_ecmchar::@1 to mode_ecmchar::@1 [phi:mode_ecmchar::@1->mode_ecmchar::@1] b1_from_b1: //SEG1495 [803] phi (byte) mode_ecmchar::i#2 = (byte) mode_ecmchar::i#1 [phi:mode_ecmchar::@1->mode_ecmchar::@1#0] -- register_copy @@ -23887,6 +23916,7 @@ mode_stdchar: { //SEG1557 [840] phi (byte) mode_stdchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_stdchar->mode_stdchar::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // DTV Palette - default //SEG1558 [840] phi from mode_stdchar::@1 to mode_stdchar::@1 [phi:mode_stdchar::@1->mode_stdchar::@1] b1_from_b1: //SEG1559 [840] phi (byte) mode_stdchar::i#2 = (byte) mode_stdchar::i#1 [phi:mode_stdchar::@1->mode_stdchar::@1#0] -- register_copy @@ -24516,7 +24546,6 @@ Replacing label b4_from_b3 with b4 Replacing label b3_from_b4 with b3 Replacing label b3_from_b4 with b3 Replacing label b2_from_b7 with b2 -Replacing label b1 with b4 Replacing label b8_from_b33 with b8 Replacing label b9_from_b34 with b9 Replacing label b10_from_b35 with b10 @@ -24524,7 +24553,7 @@ Replacing label b11_from_b36 with b11 Replacing label b12_from_b37 with b12 Replacing label b13_from_b38 with b13 Replacing label b46_from_b39 with b46 -Replacing label b1_from_b14 with b4 +Replacing label b1_from_b14 with b1 Replacing label b1_from_b1 with b1 Replacing label b3_from_b3 with b3 Replacing label b2_from_b9 with b2 @@ -24657,7 +24686,6 @@ Removing instruction b11_from_b8: Removing instruction mode_ctrl_from_b11: Removing instruction b1_from_mode_ctrl: Removing instruction b1_from_b14: -Removing instruction b1: Removing instruction b6_from_b4: Removing instruction keyboard_key_pressed_from_b6: Removing instruction b8_from_b23: @@ -25016,10 +25044,10 @@ Updating BasicUpstart to call main directly Removing instruction jsr main Succesful ASM optimization Pass5SkipBegin Skipping double jump to b14 in beq b46 -Skipping double jump to b4 in jmp b1_from_b30 +Skipping double jump to b1 in jmp b1_from_b30 Skipping double jump to b2 in bne b10 Succesful ASM optimization Pass5DoubleJumpElimination -Relabelling long label b1_from_b30 to b1 +Relabelling long label b1_from_b30 to b2 Relabelling long label b7_from_b6 to b8 Succesful ASM optimization Pass5RelabelLongLabels Removing instruction jmp b1 @@ -25028,7 +25056,7 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 Removing instruction jmp b4 -Removing instruction jmp b4 +Removing instruction jmp b1 Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 @@ -25088,7 +25116,7 @@ Replacing instruction ldx #0 with TAX Replacing instruction ldx #0 with TAX Removing instruction lda x0 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Removing instruction b1: +Removing instruction b2: Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction bbegin: Removing instruction b46: @@ -25097,7 +25125,7 @@ Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b14 Removing unreachable instruction jmp b2 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [260] beq b4 to bne +Fixing long branch [262] beq b4 to bne FINAL SYMBOL TABLE (label) @54 @@ -26793,6 +26821,7 @@ menu: { //SEG27 [19] phi from menu to menu::@1 [phi:menu->menu::@1] //SEG28 [19] phi (byte) menu::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:menu->menu::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - default //SEG29 [19] phi from menu::@1 to menu::@1 [phi:menu::@1->menu::@1] //SEG30 [19] phi (byte) menu::i#2 = (byte) menu::i#1 [phi:menu::@1->menu::@1#0] -- register_copy //SEG31 menu::@1 @@ -26811,6 +26840,7 @@ menu: { sta c lda #>COLS sta c+1 + // Char Colors //SEG37 [23] phi from menu::@2 to menu::@2 [phi:menu::@2->menu::@2] //SEG38 [23] phi (byte*) menu::c#2 = (byte*) menu::c#1 [phi:menu::@2->menu::@2#0] -- register_copy //SEG39 menu::@2 @@ -27133,6 +27163,7 @@ mode_8bppchunkybmm: { //SEG213 [129] phi from mode_8bppchunkybmm to mode_8bppchunkybmm::@1 [phi:mode_8bppchunkybmm->mode_8bppchunkybmm::@1] //SEG214 [129] phi (byte) mode_8bppchunkybmm::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_8bppchunkybmm->mode_8bppchunkybmm::@1#0] -- vbuxx=vbuc1 tax + // DTV Palette - Grey Tones //SEG215 [129] phi from mode_8bppchunkybmm::@1 to mode_8bppchunkybmm::@1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1] //SEG216 [129] phi (byte) mode_8bppchunkybmm::i#2 = (byte) mode_8bppchunkybmm::i#1 [phi:mode_8bppchunkybmm::@1->mode_8bppchunkybmm::@1#0] -- register_copy //SEG217 mode_8bppchunkybmm::@1 @@ -27274,6 +27305,8 @@ mode_ctrl: { //SEG282 [156] phi (byte) dtv_control#114 = (byte) dtv_control#145 [phi:mode_ctrl/mode_ctrl::@30->mode_ctrl::@1#0] -- register_copy //SEG283 [156] phi from mode_ctrl::@14 to mode_ctrl::@1 [phi:mode_ctrl::@14->mode_ctrl::@1] //SEG284 mode_ctrl::@1 + b1: + // Wait for the raster //SEG285 mode_ctrl::@4 b4: //SEG286 [157] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto mode_ctrl::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -27439,7 +27472,7 @@ mode_ctrl: { b14: //SEG382 [206] if((byte) mode_ctrl::ctrl#14==(byte) dtv_control#114) goto mode_ctrl::@1 -- vbuxx_eq_vbuz1_then_la1 cpx dtv_control - beq b4 + beq b1 //SEG383 mode_ctrl::@30 //SEG384 [207] (byte) dtv_control#17 ← (byte) mode_ctrl::ctrl#14 -- vbuz1=vbuxx stx dtv_control @@ -27447,7 +27480,7 @@ mode_ctrl: { stx DTV_CONTROL //SEG386 [209] *((const byte*) BORDERCOL#0) ← (byte) mode_ctrl::ctrl#14 -- _deref_pbuc1=vbuxx stx BORDERCOL - jmp b4 + jmp b1 //SEG387 [210] phi from mode_ctrl::@39 to mode_ctrl::@46 [phi:mode_ctrl::@39->mode_ctrl::@46] //SEG388 mode_ctrl::@46 //SEG389 [205] phi from mode_ctrl::@46 to mode_ctrl::@14 [phi:mode_ctrl::@46->mode_ctrl::@14] @@ -27590,6 +27623,7 @@ mode_8bpppixelcell: { //SEG429 [243] phi from mode_8bpppixelcell to mode_8bpppixelcell::@1 [phi:mode_8bpppixelcell->mode_8bpppixelcell::@1] //SEG430 [243] phi (byte) mode_8bpppixelcell::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_8bpppixelcell->mode_8bpppixelcell::@1#0] -- vbuxx=vbuc1 tax + // DTV Palette - Grey Tones //SEG431 [243] phi from mode_8bpppixelcell::@1 to mode_8bpppixelcell::@1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1] //SEG432 [243] phi (byte) mode_8bpppixelcell::i#2 = (byte) mode_8bpppixelcell::i#1 [phi:mode_8bpppixelcell::@1->mode_8bpppixelcell::@1#0] -- register_copy //SEG433 mode_8bpppixelcell::@1 @@ -27859,6 +27893,7 @@ mode_sixsfred: { //SEG545 [299] phi from mode_sixsfred to mode_sixsfred::@1 [phi:mode_sixsfred->mode_sixsfred::@1] //SEG546 [299] phi (byte) mode_sixsfred::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_sixsfred->mode_sixsfred::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG547 [299] phi from mode_sixsfred::@1 to mode_sixsfred::@1 [phi:mode_sixsfred::@1->mode_sixsfred::@1] //SEG548 [299] phi (byte) mode_sixsfred::i#2 = (byte) mode_sixsfred::i#1 [phi:mode_sixsfred::@1->mode_sixsfred::@1#0] -- register_copy //SEG549 mode_sixsfred::@1 @@ -28109,6 +28144,7 @@ mode_twoplanebitmap: { //SEG647 [352] phi from mode_twoplanebitmap to mode_twoplanebitmap::@1 [phi:mode_twoplanebitmap->mode_twoplanebitmap::@1] //SEG648 [352] phi (byte) mode_twoplanebitmap::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_twoplanebitmap->mode_twoplanebitmap::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG649 [352] phi from mode_twoplanebitmap::@1 to mode_twoplanebitmap::@1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1] //SEG650 [352] phi (byte) mode_twoplanebitmap::i#2 = (byte) mode_twoplanebitmap::i#1 [phi:mode_twoplanebitmap::@1->mode_twoplanebitmap::@1#0] -- register_copy //SEG651 mode_twoplanebitmap::@1 @@ -28387,6 +28423,7 @@ mode_sixsfred2: { //SEG760 [412] phi from mode_sixsfred2 to mode_sixsfred2::@1 [phi:mode_sixsfred2->mode_sixsfred2::@1] //SEG761 [412] phi (byte) mode_sixsfred2::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_sixsfred2->mode_sixsfred2::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG762 [412] phi from mode_sixsfred2::@1 to mode_sixsfred2::@1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1] //SEG763 [412] phi (byte) mode_sixsfred2::i#2 = (byte) mode_sixsfred2::i#1 [phi:mode_sixsfred2::@1->mode_sixsfred2::@1#0] -- register_copy //SEG764 mode_sixsfred2::@1 @@ -28627,6 +28664,7 @@ mode_hicolmcchar: { //SEG856 [459] phi from mode_hicolmcchar to mode_hicolmcchar::@1 [phi:mode_hicolmcchar->mode_hicolmcchar::@1] //SEG857 [459] phi (byte) mode_hicolmcchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolmcchar->mode_hicolmcchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG858 [459] phi from mode_hicolmcchar::@1 to mode_hicolmcchar::@1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1] //SEG859 [459] phi (byte) mode_hicolmcchar::i#2 = (byte) mode_hicolmcchar::i#1 [phi:mode_hicolmcchar::@1->mode_hicolmcchar::@1#0] -- register_copy //SEG860 mode_hicolmcchar::@1 @@ -28796,6 +28834,7 @@ mode_hicolecmchar: { //SEG917 [493] phi from mode_hicolecmchar to mode_hicolecmchar::@1 [phi:mode_hicolecmchar->mode_hicolecmchar::@1] //SEG918 [493] phi (byte) mode_hicolecmchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolecmchar->mode_hicolecmchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG919 [493] phi from mode_hicolecmchar::@1 to mode_hicolecmchar::@1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1] //SEG920 [493] phi (byte) mode_hicolecmchar::i#2 = (byte) mode_hicolecmchar::i#1 [phi:mode_hicolecmchar::@1->mode_hicolecmchar::@1#0] -- register_copy //SEG921 mode_hicolecmchar::@1 @@ -28964,6 +29003,7 @@ mode_hicolstdchar: { //SEG979 [528] phi from mode_hicolstdchar to mode_hicolstdchar::@1 [phi:mode_hicolstdchar->mode_hicolstdchar::@1] //SEG980 [528] phi (byte) mode_hicolstdchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_hicolstdchar->mode_hicolstdchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - Grey Tones //SEG981 [528] phi from mode_hicolstdchar::@1 to mode_hicolstdchar::@1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1] //SEG982 [528] phi (byte) mode_hicolstdchar::i#2 = (byte) mode_hicolstdchar::i#1 [phi:mode_hicolstdchar::@1->mode_hicolstdchar::@1#0] -- register_copy //SEG983 mode_hicolstdchar::@1 @@ -29114,6 +29154,7 @@ mode_stdbitmap: { //SEG1036 [558] phi from mode_stdbitmap to mode_stdbitmap::@1 [phi:mode_stdbitmap->mode_stdbitmap::@1] //SEG1037 [558] phi (byte) mode_stdbitmap::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_stdbitmap->mode_stdbitmap::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - default //SEG1038 [558] phi from mode_stdbitmap::@1 to mode_stdbitmap::@1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1] //SEG1039 [558] phi (byte) mode_stdbitmap::i#2 = (byte) mode_stdbitmap::i#1 [phi:mode_stdbitmap::@1->mode_stdbitmap::@1#0] -- register_copy //SEG1040 mode_stdbitmap::@1 @@ -29974,6 +30015,7 @@ mode_mcchar: { //SEG1429 [767] phi from mode_mcchar to mode_mcchar::@1 [phi:mode_mcchar->mode_mcchar::@1] //SEG1430 [767] phi (byte) mode_mcchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_mcchar->mode_mcchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - default //SEG1431 [767] phi from mode_mcchar::@1 to mode_mcchar::@1 [phi:mode_mcchar::@1->mode_mcchar::@1] //SEG1432 [767] phi (byte) mode_mcchar::i#2 = (byte) mode_mcchar::i#1 [phi:mode_mcchar::@1->mode_mcchar::@1#0] -- register_copy //SEG1433 mode_mcchar::@1 @@ -30148,6 +30190,7 @@ mode_ecmchar: { //SEG1492 [803] phi from mode_ecmchar to mode_ecmchar::@1 [phi:mode_ecmchar->mode_ecmchar::@1] //SEG1493 [803] phi (byte) mode_ecmchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_ecmchar->mode_ecmchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - default //SEG1494 [803] phi from mode_ecmchar::@1 to mode_ecmchar::@1 [phi:mode_ecmchar::@1->mode_ecmchar::@1] //SEG1495 [803] phi (byte) mode_ecmchar::i#2 = (byte) mode_ecmchar::i#1 [phi:mode_ecmchar::@1->mode_ecmchar::@1#0] -- register_copy //SEG1496 mode_ecmchar::@1 @@ -30320,6 +30363,7 @@ mode_stdchar: { //SEG1556 [840] phi from mode_stdchar to mode_stdchar::@1 [phi:mode_stdchar->mode_stdchar::@1] //SEG1557 [840] phi (byte) mode_stdchar::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:mode_stdchar->mode_stdchar::@1#0] -- vbuxx=vbuc1 ldx #0 + // DTV Palette - default //SEG1558 [840] phi from mode_stdchar::@1 to mode_stdchar::@1 [phi:mode_stdchar::@1->mode_stdchar::@1] //SEG1559 [840] phi (byte) mode_stdchar::i#2 = (byte) mode_stdchar::i#1 [phi:mode_stdchar::@1->mode_stdchar::@1#0] -- register_copy //SEG1560 mode_stdchar::@1 diff --git a/src/test/ref/complex/tetris/tetris.asm b/src/test/ref/complex/tetris/tetris.asm index 0a8423b12..532bc725d 100644 --- a/src/test/ref/complex/tetris/tetris.asm +++ b/src/test/ref/complex/tetris/tetris.asm @@ -229,6 +229,8 @@ main: { sta render_screen_render lda #0 sta render_screen_show + b1: + // Wait for a frame to pass b4: lda RASTER cmp #$ff @@ -247,7 +249,7 @@ main: { jsr play_movement lda play_movement.return cmp #0 - beq b4 + beq b1 ldx render_screen_render jsr render_playfield ldy current_ypos @@ -266,7 +268,7 @@ main: { jsr render_next jsr render_score jsr render_screen_swap - jmp b4 + jmp b1 } // Swap rendering to the other screen (used for double buffering) render_screen_swap: { @@ -1031,6 +1033,7 @@ play_remove_lines: { sta y ldx #PLAYFIELD_LINES*PLAYFIELD_COLS-1 ldy #PLAYFIELD_LINES*PLAYFIELD_COLS-1 + // Read all lines and rewrite them b1: lda #1 sta full @@ -1066,6 +1069,7 @@ play_remove_lines: { cmp #PLAYFIELD_LINES-1+1 bne b1 b5: + // Write zeros in the rest of the lines cpx #$ff bne b6 rts @@ -1233,6 +1237,7 @@ keyboard_event_scan: { ora #KEY_MODIFIER_COMMODORE breturn: rts + // Something has changed on the keyboard row - check each column b6: ldx #0 b4: @@ -1348,6 +1353,7 @@ play_init: { lda MOVEDOWN_SLOW_SPEEDS sta current_movedown_slow ldx #0 + // Set the initial score add values b2: txa asl diff --git a/src/test/ref/complex/tetris/tetris.log b/src/test/ref/complex/tetris/tetris.log index 8c324f893..c0da3d314 100644 --- a/src/test/ref/complex/tetris/tetris.log +++ b/src/test/ref/complex/tetris/tetris.log @@ -13247,6 +13247,7 @@ main: { //SEG111 main::@1 b1: jmp b4 + // Wait for a frame to pass //SEG112 main::@4 b4: //SEG113 [39] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -15255,6 +15256,7 @@ play_remove_lines: { lda #PLAYFIELD_LINES*PLAYFIELD_COLS-1 sta r jmp b1 + // Read all lines and rewrite them //SEG805 [345] phi from play_remove_lines::@4 to play_remove_lines::@1 [phi:play_remove_lines::@4->play_remove_lines::@1] b1_from_b4: //SEG806 [345] phi (byte) play_remove_lines::removed#11 = (byte) play_remove_lines::removed#7 [phi:play_remove_lines::@4->play_remove_lines::@1#0] -- register_copy @@ -15350,6 +15352,7 @@ play_remove_lines: { b5_from_b6: //SEG844 [361] phi (byte) play_remove_lines::w#6 = (byte) play_remove_lines::w#11 [phi:play_remove_lines::@4/play_remove_lines::@6->play_remove_lines::@5#0] -- register_copy jmp b5 + // Write zeros in the rest of the lines //SEG845 play_remove_lines::@5 b5: //SEG846 [362] if((byte) play_remove_lines::w#6!=(byte/word/signed word/dword/signed dword) 255) goto play_remove_lines::@6 -- vbuz1_neq_vbuc1_then_la1 @@ -15794,6 +15797,7 @@ keyboard_event_scan: { breturn: //SEG990 [430] return rts + // Something has changed on the keyboard row - check each column //SEG991 [431] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b4_from_b25: //SEG992 [431] phi (byte) keyboard_events_size#10 = (byte) keyboard_events_size#29 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -16052,6 +16056,7 @@ play_init: { lda #0 sta b jmp b2 + // Set the initial score add values //SEG1067 [471] phi from play_init::@2 to play_init::@2 [phi:play_init::@2->play_init::@2] b2_from_b2: //SEG1068 [471] phi (byte) play_init::b#2 = (byte) play_init::b#1 [phi:play_init::@2->play_init::@2#0] -- register_copy @@ -18484,6 +18489,7 @@ main: { //SEG111 main::@1 b1: jmp b4 + // Wait for a frame to pass //SEG112 main::@4 b4: //SEG113 [39] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -20248,6 +20254,7 @@ play_remove_lines: { //SEG804 [345] phi (byte) play_remove_lines::r#3 = (const byte) PLAYFIELD_LINES#0*(const byte) PLAYFIELD_COLS#0-(byte/signed byte/word/signed word/dword/signed dword) 1 [phi:play_remove_lines->play_remove_lines::@1#3] -- vbuyy=vbuc1 ldy #PLAYFIELD_LINES*PLAYFIELD_COLS-1 jmp b1 + // Read all lines and rewrite them //SEG805 [345] phi from play_remove_lines::@4 to play_remove_lines::@1 [phi:play_remove_lines::@4->play_remove_lines::@1] b1_from_b4: //SEG806 [345] phi (byte) play_remove_lines::removed#11 = (byte) play_remove_lines::removed#7 [phi:play_remove_lines::@4->play_remove_lines::@1#0] -- register_copy @@ -20341,6 +20348,7 @@ play_remove_lines: { b5_from_b6: //SEG844 [361] phi (byte) play_remove_lines::w#6 = (byte) play_remove_lines::w#11 [phi:play_remove_lines::@4/play_remove_lines::@6->play_remove_lines::@5#0] -- register_copy jmp b5 + // Write zeros in the rest of the lines //SEG845 play_remove_lines::@5 b5: //SEG846 [362] if((byte) play_remove_lines::w#6!=(byte/word/signed word/dword/signed dword) 255) goto play_remove_lines::@6 -- vbuxx_neq_vbuc1_then_la1 @@ -20728,6 +20736,7 @@ keyboard_event_scan: { breturn: //SEG990 [430] return rts + // Something has changed on the keyboard row - check each column //SEG991 [431] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b4_from_b25: //SEG992 [431] phi (byte) keyboard_events_size#10 = (byte) keyboard_events_size#29 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -20956,6 +20965,7 @@ play_init: { //SEG1066 [471] phi (byte) play_init::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:play_init::@3->play_init::@2#0] -- vbuxx=vbuc1 ldx #0 jmp b2 + // Set the initial score add values //SEG1067 [471] phi from play_init::@2 to play_init::@2 [phi:play_init::@2->play_init::@2] b2_from_b2: //SEG1068 [471] phi (byte) play_init::b#2 = (byte) play_init::b#1 [phi:play_init::@2->play_init::@2#0] -- register_copy @@ -21921,9 +21931,7 @@ Removing instruction lda #BLACK Removing instruction ldy #0 Removing instruction ldy #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination -Replacing label b1 with b4 -Replacing label b1_from_b11 with b4 -Replacing label b1 with b4 +Replacing label b1_from_b11 with b1 Replacing label b1_from_render_bcd with b1 Replacing label b4_from_b6 with b4 Replacing label b3_from_b11 with b3 @@ -21951,7 +21959,6 @@ Replacing label b18_from_b2 with b18 Replacing label b2_from_b3 with b2 Replacing label b4_from_b9 with b4 Replacing label b1_from_b4 with b1 -Replacing label b5_from_b6 with b5 Replacing label b1_from_b3 with b1 Replacing label b10_from_b27 with b10 Replacing label b11_from_b28 with b11 @@ -21989,7 +21996,6 @@ Removing instruction play_spawn_current_from_b30: Removing instruction b31_from_b30: Removing instruction render_playfield_from_b31: Removing instruction b1_from_b11: -Removing instruction b1: Removing instruction b6_from_b4: Removing instruction b35_from_b6: Removing instruction keyboard_event_scan_from_b35: @@ -22051,7 +22057,6 @@ Removing instruction b2_from_b3: Removing instruction b4_from_b10: Removing instruction b4_from_b9: Removing instruction b5_from_b4: -Removing instruction b5_from_b6: Removing instruction b18_from_b2: Removing instruction b3_from_b18: Removing instruction b1_from_b3: @@ -22220,6 +22225,7 @@ Removing instruction b1_from_play_remove_lines: Removing instruction b3_from_b2: Removing instruction b9: Removing instruction b10: +Removing instruction b5: Removing instruction breturn: Removing instruction b1_from_play_lock_current: Removing instruction b2_from_b1: @@ -22285,11 +22291,12 @@ Relabelling long label breturn_from_b6 to b3 Relabelling long label b1_from_play_move_down to b3 Relabelling long label breturn_from_b4 to b5 Relabelling long label b2_from_play_increase_level to b1 +Relabelling long label b5_from_b6 to b5 Relabelling long label breturn_from_keyboard_event_get to b1 Relabelling long label b9_from_b26 to b2 Relabelling long label b4_from_b25 to b6 Succesful ASM optimization Pass5RelabelLongLabels -Removing instruction jmp b4 +Removing instruction jmp b1 Removing instruction jmp b3 Removing instruction jmp b4 Removing instruction jmp b1 @@ -23999,6 +24006,8 @@ main: { //SEG109 [38] phi (byte*) current_piece#10 = (byte*) current_piece#15 [phi:main::@11->main::@1#13] -- register_copy //SEG110 [38] phi (byte) current_movedown_slow#14 = (byte) current_movedown_slow#21 [phi:main::@11->main::@1#14] -- register_copy //SEG111 main::@1 + b1: + // Wait for a frame to pass //SEG112 main::@4 b4: //SEG113 [39] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto main::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -24043,7 +24052,7 @@ main: { //SEG136 main::@11 //SEG137 [54] if((byte) main::render#1==(byte/signed byte/word/signed word/dword/signed dword) 0) goto main::@1 -- vbuaa_eq_0_then_la1 cmp #0 - beq b4 + beq b1 //SEG138 main::@23 //SEG139 [55] (byte~) render_screen_render#70 ← (byte) render_screen_render#18 -- vbuxx=vbuz1 ldx render_screen_render @@ -24111,7 +24120,7 @@ main: { //SEG184 [38] phi (byte) current_movedown_slow#14 = (byte) current_movedown_slow#21 [phi:main::@42->main::@1#14] -- register_copy //SEG185 [38] phi (byte) render_screen_render#18 = (byte) render_screen_render#11 [phi:main::@42->main::@1#15] -- register_copy //SEG186 [38] phi (byte) render_screen_show#16 = (byte) render_screen_show#13 [phi:main::@42->main::@1#16] -- register_copy - jmp b4 + jmp b1 } //SEG187 render_screen_swap // Swap rendering to the other screen (used for double buffering) @@ -25494,6 +25503,7 @@ play_remove_lines: { ldx #PLAYFIELD_LINES*PLAYFIELD_COLS-1 //SEG804 [345] phi (byte) play_remove_lines::r#3 = (const byte) PLAYFIELD_LINES#0*(const byte) PLAYFIELD_COLS#0-(byte/signed byte/word/signed word/dword/signed dword) 1 [phi:play_remove_lines->play_remove_lines::@1#3] -- vbuyy=vbuc1 ldy #PLAYFIELD_LINES*PLAYFIELD_COLS-1 + // Read all lines and rewrite them //SEG805 [345] phi from play_remove_lines::@4 to play_remove_lines::@1 [phi:play_remove_lines::@4->play_remove_lines::@1] //SEG806 [345] phi (byte) play_remove_lines::removed#11 = (byte) play_remove_lines::removed#7 [phi:play_remove_lines::@4->play_remove_lines::@1#0] -- register_copy //SEG807 [345] phi (byte) play_remove_lines::y#8 = (byte) play_remove_lines::y#1 [phi:play_remove_lines::@4->play_remove_lines::@1#1] -- register_copy @@ -25567,9 +25577,10 @@ play_remove_lines: { cmp #PLAYFIELD_LINES-1+1 bne b1 //SEG843 [361] phi from play_remove_lines::@4 play_remove_lines::@6 to play_remove_lines::@5 [phi:play_remove_lines::@4/play_remove_lines::@6->play_remove_lines::@5] - //SEG844 [361] phi (byte) play_remove_lines::w#6 = (byte) play_remove_lines::w#11 [phi:play_remove_lines::@4/play_remove_lines::@6->play_remove_lines::@5#0] -- register_copy - //SEG845 play_remove_lines::@5 b5: + //SEG844 [361] phi (byte) play_remove_lines::w#6 = (byte) play_remove_lines::w#11 [phi:play_remove_lines::@4/play_remove_lines::@6->play_remove_lines::@5#0] -- register_copy + // Write zeros in the rest of the lines + //SEG845 play_remove_lines::@5 //SEG846 [362] if((byte) play_remove_lines::w#6!=(byte/word/signed word/dword/signed dword) 255) goto play_remove_lines::@6 -- vbuxx_neq_vbuc1_then_la1 cpx #$ff bne b6 @@ -25882,6 +25893,7 @@ keyboard_event_scan: { breturn: //SEG990 [430] return rts + // Something has changed on the keyboard row - check each column //SEG991 [431] phi from keyboard_event_scan::@25 to keyboard_event_scan::@4 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4] b6: //SEG992 [431] phi (byte) keyboard_events_size#10 = (byte) keyboard_events_size#29 [phi:keyboard_event_scan::@25->keyboard_event_scan::@4#0] -- register_copy @@ -26073,6 +26085,7 @@ play_init: { //SEG1065 [471] phi from play_init::@3 to play_init::@2 [phi:play_init::@3->play_init::@2] //SEG1066 [471] phi (byte) play_init::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:play_init::@3->play_init::@2#0] -- vbuxx=vbuc1 ldx #0 + // Set the initial score add values //SEG1067 [471] phi from play_init::@2 to play_init::@2 [phi:play_init::@2->play_init::@2] //SEG1068 [471] phi (byte) play_init::b#2 = (byte) play_init::b#1 [phi:play_init::@2->play_init::@2#0] -- register_copy //SEG1069 play_init::@2 diff --git a/src/test/ref/examples/3d/3d.asm b/src/test/ref/examples/3d/3d.asm index 61c1d6a23..ff5f2f55d 100644 --- a/src/test/ref/examples/3d/3d.asm +++ b/src/test/ref/examples/3d/3d.asm @@ -62,6 +62,8 @@ anim: { lda #0 sta sy sta sx + // signed byte xmin = 0; + // signed byte xmax = 0; b4: lda RASTER cmp #$ff diff --git a/src/test/ref/examples/3d/3d.log b/src/test/ref/examples/3d/3d.log index d0f3aad69..562f39eca 100644 --- a/src/test/ref/examples/3d/3d.log +++ b/src/test/ref/examples/3d/3d.log @@ -5778,6 +5778,8 @@ anim: { lda #0 sta sx jmp b1 + // signed byte xmin = 0; + // signed byte xmax = 0; //SEG36 anim::@1 b1: jmp b4 @@ -8559,6 +8561,8 @@ anim: { lda #0 sta sx jmp b1 + // signed byte xmin = 0; + // signed byte xmax = 0; //SEG36 anim::@1 b1: jmp b4 @@ -10683,9 +10687,9 @@ Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [316] bne b1 to beq -Fixing long branch [1003] bne b2 to beq -Fixing long branch [1013] bne b1 to beq +Fixing long branch [318] bne b1 to beq +Fixing long branch [1005] bne b2 to beq +Fixing long branch [1015] bne b1 to beq FINAL SYMBOL TABLE (label) @33 @@ -11411,6 +11415,8 @@ anim: { sta sy //SEG35 [22] phi (signed byte) sx#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:anim->anim::@1#1] -- vbsz1=vbuc1 sta sx + // signed byte xmin = 0; + // signed byte xmax = 0; //SEG36 anim::@1 //SEG37 anim::@4 b4: diff --git a/src/test/ref/examples/chargen/chargen-analysis.asm b/src/test/ref/examples/chargen/chargen-analysis.asm index c219fda2b..4fec859bf 100644 --- a/src/test/ref/examples/chargen/chargen-analysis.asm +++ b/src/test/ref/examples/chargen/chargen-analysis.asm @@ -76,6 +76,7 @@ main: { sta sc lda #>SCREEN sta sc+1 + // Clear screen b1: lda #' ' ldy #0 @@ -183,6 +184,7 @@ main: { b9: lda #0 sta ch + // Check for key presses - and plot char if found b10: ldx ch jsr keyboard_get_keycode diff --git a/src/test/ref/examples/chargen/chargen-analysis.log b/src/test/ref/examples/chargen/chargen-analysis.log index bf2ad19b7..92e9e33fa 100644 --- a/src/test/ref/examples/chargen/chargen-analysis.log +++ b/src/test/ref/examples/chargen/chargen-analysis.log @@ -2714,6 +2714,7 @@ main: { lda #>SCREEN sta sc+1 jmp b1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy @@ -3014,6 +3015,7 @@ main: { lda #0 sta ch jmp b10 + // Check for key presses - and plot char if found //SEG116 [49] phi from main::@12 to main::@10 [phi:main::@12->main::@10] b10_from_b12: //SEG117 [49] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@10#0] -- register_copy @@ -3870,6 +3872,7 @@ main: { lda #>SCREEN sta sc+1 jmp b1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy @@ -4137,6 +4140,7 @@ main: { lda #0 sta ch jmp b10 + // Check for key presses - and plot char if found //SEG116 [49] phi from main::@12 to main::@10 [phi:main::@12->main::@10] b10_from_b12: //SEG117 [49] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@10#0] -- register_copy @@ -5343,6 +5347,7 @@ main: { sta sc lda #>SCREEN sta sc+1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy //SEG15 main::@1 @@ -5553,6 +5558,7 @@ main: { //SEG115 [49] phi (byte) main::ch#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@9->main::@10#0] -- vbuz1=vbuc1 lda #0 sta ch + // Check for key presses - and plot char if found //SEG116 [49] phi from main::@12 to main::@10 [phi:main::@12->main::@10] //SEG117 [49] phi (byte) main::ch#2 = (byte) main::ch#1 [phi:main::@12->main::@10#0] -- register_copy //SEG118 main::@10 diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.asm b/src/test/ref/examples/multiplexer/simple-multiplexer.asm index a572c8293..f4775ae58 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.asm +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.asm @@ -73,6 +73,7 @@ loop: { sta plex_show_idx tax sta plex_free_next + // Show the sprites b11: lda #BLACK sta BORDERCOL diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.log b/src/test/ref/examples/multiplexer/simple-multiplexer.log index 81d36f749..4436f2a67 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.log +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.log @@ -2631,6 +2631,7 @@ loop: { lda #0 sta plex_free_next jmp b11 + // Show the sprites //SEG57 [27] phi from loop::@31 to loop::@11 [phi:loop::@31->loop::@11] b11_from_b31: //SEG58 [27] phi (byte) loop::ss#6 = (byte) loop::ss#1 [phi:loop::@31->loop::@11#0] -- register_copy @@ -3457,6 +3458,7 @@ loop: { lda #0 sta plex_free_next jmp b11 + // Show the sprites //SEG57 [27] phi from loop::@31 to loop::@11 [phi:loop::@31->loop::@11] b11_from_b31: //SEG58 [27] phi (byte) loop::ss#6 = (byte) loop::ss#1 [phi:loop::@31->loop::@11#0] -- register_copy @@ -4417,6 +4419,7 @@ loop: { tax //SEG56 [27] phi (byte) plex_free_next#17 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:loop::@8->loop::@11#4] -- vbuz1=vbuc1 sta plex_free_next + // Show the sprites //SEG57 [27] phi from loop::@31 to loop::@11 [phi:loop::@31->loop::@11] //SEG58 [27] phi (byte) loop::ss#6 = (byte) loop::ss#1 [phi:loop::@31->loop::@11#0] -- register_copy //SEG59 [27] phi (byte) plex_sprite_msb#44 = (byte) plex_sprite_msb#16 [phi:loop::@31->loop::@11#1] -- register_copy diff --git a/src/test/ref/examples/scroll/scroll.asm b/src/test/ref/examples/scroll/scroll.asm index d17901cf4..4edd418af 100644 --- a/src/test/ref/examples/scroll/scroll.asm +++ b/src/test/ref/examples/scroll/scroll.asm @@ -14,6 +14,7 @@ main: { lda #>TEXT sta nxt+1 ldx #7 + // Wait for raster b2: lda RASTER cmp #$fe @@ -27,6 +28,7 @@ main: { cpx #$ff bne b4 ldx #0 + // Hard scroll b5: lda line+1,x sta line,x diff --git a/src/test/ref/examples/scroll/scroll.log b/src/test/ref/examples/scroll/scroll.log index 51c63c7e5..47a14b5cd 100644 --- a/src/test/ref/examples/scroll/scroll.log +++ b/src/test/ref/examples/scroll/scroll.log @@ -667,6 +667,7 @@ main: { lda #7 sta scroll jmp b2 + // Wait for raster //SEG16 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -700,6 +701,7 @@ main: { lda #0 sta i jmp b5 + // Hard scroll //SEG27 [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5] b5_from_b5: //SEG28 [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy @@ -904,6 +906,7 @@ main: { //SEG15 [6] phi (byte) main::scroll#7 = (byte/signed byte/word/signed word/dword/signed dword) 7 [phi:main->main::@2#1] -- vbuxx=vbuc1 ldx #7 jmp b2 + // Wait for raster //SEG16 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -935,6 +938,7 @@ main: { //SEG26 [12] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@8->main::@5#0] -- vbuxx=vbuc1 ldx #0 jmp b5 + // Hard scroll //SEG27 [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5] b5_from_b5: //SEG28 [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy @@ -1202,6 +1206,7 @@ main: { sta nxt+1 //SEG15 [6] phi (byte) main::scroll#7 = (byte/signed byte/word/signed word/dword/signed dword) 7 [phi:main->main::@2#1] -- vbuxx=vbuc1 ldx #7 + // Wait for raster //SEG16 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] //SEG17 main::@2 b2: @@ -1226,6 +1231,7 @@ main: { //SEG25 [12] phi from main::@8 to main::@5 [phi:main::@8->main::@5] //SEG26 [12] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@8->main::@5#0] -- vbuxx=vbuc1 ldx #0 + // Hard scroll //SEG27 [12] phi from main::@5 to main::@5 [phi:main::@5->main::@5] //SEG28 [12] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@5->main::@5#0] -- register_copy //SEG29 main::@5 diff --git a/src/test/ref/examples/scrollbig/scrollbig.asm b/src/test/ref/examples/scrollbig/scrollbig.asm index e432da29c..f4862264e 100644 --- a/src/test/ref/examples/scrollbig/scrollbig.asm +++ b/src/test/ref/examples/scrollbig/scrollbig.asm @@ -24,6 +24,7 @@ main: { lda #1 sta current_bit ldx #7 + // Wait for raster b2: lda RASTER cmp #$fe @@ -115,6 +116,7 @@ scroll_bit: { } scroll_hard: { ldx #0 + // Hard scroll b1: lda SCREEN+1,x sta SCREEN,x diff --git a/src/test/ref/examples/scrollbig/scrollbig.log b/src/test/ref/examples/scrollbig/scrollbig.log index e45216ed8..85d51d2d4 100644 --- a/src/test/ref/examples/scrollbig/scrollbig.log +++ b/src/test/ref/examples/scrollbig/scrollbig.log @@ -1626,6 +1626,7 @@ main: { lda #7 sta scroll jmp b2 + // Wait for raster //SEG18 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -1878,6 +1879,7 @@ scroll_hard: { lda #0 sta i jmp b1 + // Hard scroll //SEG108 [46] phi from scroll_hard::@1 to scroll_hard::@1 [phi:scroll_hard::@1->scroll_hard::@1] b1_from_b1: //SEG109 [46] phi (byte) scroll_hard::i#2 = (byte) scroll_hard::i#1 [phi:scroll_hard::@1->scroll_hard::@1#0] -- register_copy @@ -2174,6 +2176,7 @@ main: { //SEG17 [6] phi (byte) scroll#18 = (byte/signed byte/word/signed word/dword/signed dword) 7 [phi:main->main::@2#3] -- vbuxx=vbuc1 ldx #7 jmp b2 + // Wait for raster //SEG18 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: jmp b2 @@ -2399,6 +2402,7 @@ scroll_hard: { //SEG107 [46] phi (byte) scroll_hard::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scroll_hard->scroll_hard::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // Hard scroll //SEG108 [46] phi from scroll_hard::@1 to scroll_hard::@1 [phi:scroll_hard::@1->scroll_hard::@1] b1_from_b1: //SEG109 [46] phi (byte) scroll_hard::i#2 = (byte) scroll_hard::i#1 [phi:scroll_hard::@1->scroll_hard::@1#0] -- register_copy @@ -2779,6 +2783,7 @@ main: { sta current_bit //SEG17 [6] phi (byte) scroll#18 = (byte/signed byte/word/signed word/dword/signed dword) 7 [phi:main->main::@2#3] -- vbuxx=vbuc1 ldx #7 + // Wait for raster //SEG18 [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2] //SEG19 main::@2 b2: @@ -2960,6 +2965,7 @@ scroll_hard: { //SEG106 [46] phi from scroll_hard to scroll_hard::@1 [phi:scroll_hard->scroll_hard::@1] //SEG107 [46] phi (byte) scroll_hard::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scroll_hard->scroll_hard::@1#0] -- vbuxx=vbuc1 ldx #0 + // Hard scroll //SEG108 [46] phi from scroll_hard::@1 to scroll_hard::@1 [phi:scroll_hard::@1->scroll_hard::@1] //SEG109 [46] phi (byte) scroll_hard::i#2 = (byte) scroll_hard::i#1 [phi:scroll_hard::@1->scroll_hard::@1#0] -- register_copy //SEG110 scroll_hard::@1 diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.asm b/src/test/ref/examples/scrolllogo/scrolllogo.asm index de46eb6a8..46755e755 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.asm +++ b/src/test/ref/examples/scrolllogo/scrolllogo.asm @@ -69,6 +69,8 @@ loop: { lda #<0 sta xsin_idx sta xsin_idx+1 + b1: + // Wait for the raster to reach the bottom of the screen b4: lda RASTER cmp #$ff @@ -107,7 +109,7 @@ loop: { sta xsin_idx+1 b7: dec BORDERCOL - jmp b4 + jmp b1 } render_logo: { .label _3 = $e @@ -261,6 +263,7 @@ sin16s_gen2: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x sta sin16s.x diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.log b/src/test/ref/examples/scrolllogo/scrolllogo.log index b40908d02..7113abc4c 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.log +++ b/src/test/ref/examples/scrolllogo/scrolllogo.log @@ -4267,6 +4267,7 @@ loop: { //SEG53 loop::@1 b1: jmp b4 + // Wait for the raster to reach the bottom of the screen //SEG54 loop::@4 b4: //SEG55 [27] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto loop::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -4797,6 +4798,7 @@ sin16s_gen2: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG194 [102] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] b1_from_b5: //SEG195 [102] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy @@ -6440,6 +6442,7 @@ loop: { //SEG53 loop::@1 b1: jmp b4 + // Wait for the raster to reach the bottom of the screen //SEG54 loop::@4 b4: //SEG55 [27] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto loop::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -6863,6 +6866,7 @@ sin16s_gen2: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG194 [102] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] b1_from_b5: //SEG195 [102] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy @@ -7782,7 +7786,6 @@ Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label b1_from_b1 with b1 Replacing label b16_from_b15 with b16 Replacing label b16_from_b15 with b16 -Replacing label b1 with b4 Replacing label b15_from_b35 with b15 Replacing label b1_from_b5 with b1 Replacing label b1_from_b5 with b1 @@ -7812,7 +7815,6 @@ Removing instruction b2_from_b1: Removing instruction sin16s_gen2_from_b2: Removing instruction b6_from_b2: Removing instruction loop_from_b6: -Removing instruction b1: Removing instruction b16_from_b15: Removing instruction b7_from_b16: Removing instruction b15_from_b11: @@ -8564,6 +8566,8 @@ loop: { sta xsin_idx sta xsin_idx+1 //SEG53 loop::@1 + b1: + // Wait for the raster to reach the bottom of the screen //SEG54 loop::@4 b4: //SEG55 [27] if(*((const byte*) RASTER#0)!=(byte/word/signed word/dword/signed dword) 255) goto loop::@4 -- _deref_pbuc1_neq_vbuc2_then_la1 @@ -8619,7 +8623,7 @@ loop: { dec BORDERCOL //SEG69 [26] phi from loop::@7 to loop::@1 [phi:loop::@7->loop::@1] //SEG70 [26] phi (word) xsin_idx#11 = (word) xsin_idx#19 [phi:loop::@7->loop::@1#0] -- register_copy - jmp b4 + jmp b1 //SEG71 [37] phi from loop::@15 to loop::@16 [phi:loop::@15->loop::@16] //SEG72 loop::@16 //SEG73 [35] phi from loop::@16 to loop::@7 [phi:loop::@16->loop::@7] @@ -8896,6 +8900,7 @@ sin16s_gen2: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG194 [102] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] //SEG195 [102] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy //SEG196 [102] phi (signed word*) sin16s_gen2::sintab#2 = (signed word*) sin16s_gen2::sintab#0 [phi:sin16s_gen2::@5->sin16s_gen2::@1#1] -- register_copy diff --git a/src/test/ref/examples/sinplotter/sine-plotter.asm b/src/test/ref/examples/sinplotter/sine-plotter.asm index a29db0ec0..ecc94f0e1 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.asm +++ b/src/test/ref/examples/sinplotter/sine-plotter.asm @@ -257,6 +257,7 @@ sin16s_gen2: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x sta sin16s.x diff --git a/src/test/ref/examples/sinplotter/sine-plotter.log b/src/test/ref/examples/sinplotter/sine-plotter.log index 7733480b1..6467be5dc 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.log +++ b/src/test/ref/examples/sinplotter/sine-plotter.log @@ -4255,6 +4255,7 @@ sin16s_gen2: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG137 [74] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] b1_from_b5: //SEG138 [74] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy @@ -6404,6 +6405,7 @@ sin16s_gen2: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG137 [74] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] b1_from_b5: //SEG138 [74] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy @@ -8597,6 +8599,7 @@ sin16s_gen2: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG137 [74] phi from sin16s_gen2::@5 to sin16s_gen2::@1 [phi:sin16s_gen2::@5->sin16s_gen2::@1] //SEG138 [74] phi (word) sin16s_gen2::i#2 = (word) sin16s_gen2::i#1 [phi:sin16s_gen2::@5->sin16s_gen2::@1#0] -- register_copy //SEG139 [74] phi (signed word*) sin16s_gen2::sintab#2 = (signed word*) sin16s_gen2::sintab#0 [phi:sin16s_gen2::@5->sin16s_gen2::@1#1] -- register_copy diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.asm b/src/test/ref/examples/sinsprites/sinus-sprites.asm index 8c8f51d52..cbdda9781 100644 --- a/src/test/ref/examples/sinsprites/sinus-sprites.asm +++ b/src/test/ref/examples/sinsprites/sinus-sprites.asm @@ -252,6 +252,7 @@ gen_sintab: { lda #0 sta progress_idx sta i + // f_min = min + (max - min) / 2 b1: lda i sta setFAC.w @@ -521,6 +522,7 @@ gen_chargen_sprite: { sta c b3: ldx #0 + // generate 3 pixels in the sprite byte (s_gen) b4: lda s_gen asl diff --git a/src/test/ref/examples/sinsprites/sinus-sprites.log b/src/test/ref/examples/sinsprites/sinus-sprites.log index 653a44850..6f7ea7593 100644 --- a/src/test/ref/examples/sinsprites/sinus-sprites.log +++ b/src/test/ref/examples/sinsprites/sinus-sprites.log @@ -4115,6 +4115,7 @@ gen_sintab: { lda #0 sta i jmp b1 + // f_min = min + (max - min) / 2 //SEG206 [95] phi from gen_sintab::@23 to gen_sintab::@1 [phi:gen_sintab::@23->gen_sintab::@1] b1_from_b23: //SEG207 [95] phi (byte*) progress_cursor#34 = (byte*) progress_cursor#11 [phi:gen_sintab::@23->gen_sintab::@1#0] -- register_copy @@ -4738,6 +4739,7 @@ gen_chargen_sprite: { //SEG404 [191] phi (byte) gen_chargen_sprite::s_gen_cnt#3 = (byte) gen_chargen_sprite::s_gen_cnt#4 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#2] -- register_copy //SEG405 [191] phi (byte) gen_chargen_sprite::s_gen#3 = (byte) gen_chargen_sprite::s_gen#5 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#3] -- register_copy jmp b4 + // generate 3 pixels in the sprite byte (s_gen) //SEG406 [191] phi from gen_chargen_sprite::@5 to gen_chargen_sprite::@4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4] b4_from_b5: //SEG407 [191] phi (byte*) gen_chargen_sprite::sprite#3 = (byte*) gen_chargen_sprite::sprite#4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4#0] -- register_copy @@ -5874,6 +5876,7 @@ gen_sintab: { lda #0 sta i jmp b1 + // f_min = min + (max - min) / 2 //SEG206 [95] phi from gen_sintab::@23 to gen_sintab::@1 [phi:gen_sintab::@23->gen_sintab::@1] b1_from_b23: //SEG207 [95] phi (byte*) progress_cursor#34 = (byte*) progress_cursor#11 [phi:gen_sintab::@23->gen_sintab::@1#0] -- register_copy @@ -6450,6 +6453,7 @@ gen_chargen_sprite: { //SEG404 [191] phi (byte) gen_chargen_sprite::s_gen_cnt#3 = (byte) gen_chargen_sprite::s_gen_cnt#4 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#2] -- register_copy //SEG405 [191] phi (byte) gen_chargen_sprite::s_gen#3 = (byte) gen_chargen_sprite::s_gen#5 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#3] -- register_copy jmp b4 + // generate 3 pixels in the sprite byte (s_gen) //SEG406 [191] phi from gen_chargen_sprite::@5 to gen_chargen_sprite::@4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4] b4_from_b5: //SEG407 [191] phi (byte*) gen_chargen_sprite::sprite#3 = (byte*) gen_chargen_sprite::sprite#4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4#0] -- register_copy @@ -7818,6 +7822,7 @@ gen_sintab: { sta progress_idx //SEG205 [95] phi (byte) gen_sintab::i#10 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:gen_sintab::@12->gen_sintab::@1#2] -- vbuz1=vbuc1 sta i + // f_min = min + (max - min) / 2 //SEG206 [95] phi from gen_sintab::@23 to gen_sintab::@1 [phi:gen_sintab::@23->gen_sintab::@1] //SEG207 [95] phi (byte*) progress_cursor#34 = (byte*) progress_cursor#11 [phi:gen_sintab::@23->gen_sintab::@1#0] -- register_copy //SEG208 [95] phi (byte) progress_idx#34 = (byte) progress_idx#12 [phi:gen_sintab::@23->gen_sintab::@1#1] -- register_copy @@ -8287,6 +8292,7 @@ gen_chargen_sprite: { ldx #0 //SEG404 [191] phi (byte) gen_chargen_sprite::s_gen_cnt#3 = (byte) gen_chargen_sprite::s_gen_cnt#4 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#2] -- register_copy //SEG405 [191] phi (byte) gen_chargen_sprite::s_gen#3 = (byte) gen_chargen_sprite::s_gen#5 [phi:gen_chargen_sprite::@3->gen_chargen_sprite::@4#3] -- register_copy + // generate 3 pixels in the sprite byte (s_gen) //SEG406 [191] phi from gen_chargen_sprite::@5 to gen_chargen_sprite::@4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4] //SEG407 [191] phi (byte*) gen_chargen_sprite::sprite#3 = (byte*) gen_chargen_sprite::sprite#4 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4#0] -- register_copy //SEG408 [191] phi (byte) gen_chargen_sprite::b#2 = (byte) gen_chargen_sprite::b#1 [phi:gen_chargen_sprite::@5->gen_chargen_sprite::@4#1] -- register_copy diff --git a/src/test/ref/inline-word.asm b/src/test/ref/inline-word.asm index 79faad31c..6a88beffd 100644 --- a/src/test/ref/inline-word.asm +++ b/src/test/ref/inline-word.asm @@ -7,6 +7,7 @@ main: { .label h = 2 lda #0 sta h + // constant array b1: ldx #4 b2: diff --git a/src/test/ref/inline-word.log b/src/test/ref/inline-word.log index 20f3fe163..adcd9ad1d 100644 --- a/src/test/ref/inline-word.log +++ b/src/test/ref/inline-word.log @@ -238,6 +238,7 @@ main: { lda #0 sta h jmp b1 + // constant array //SEG13 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] b1_from_b3: //SEG14 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy @@ -346,6 +347,7 @@ main: { lda #0 sta h jmp b1 + // constant array //SEG13 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] b1_from_b3: //SEG14 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy @@ -479,6 +481,7 @@ main: { //SEG12 [5] phi (byte) main::h#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 lda #0 sta h + // constant array //SEG13 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] //SEG14 [5] phi (byte) main::h#4 = (byte) main::h#1 [phi:main::@3->main::@1#0] -- register_copy //SEG15 main::@1 diff --git a/src/test/ref/ptr-complex.asm b/src/test/ref/ptr-complex.asm index e505dd03e..3ceaad9dd 100644 --- a/src/test/ref/ptr-complex.asm +++ b/src/test/ref/ptr-complex.asm @@ -11,6 +11,7 @@ main: { .label _11 = 4 lda screen+$50 ldx #0 + // RValue pointer expression (variable) b1: txa clc @@ -31,6 +32,7 @@ main: { lda screen+$7a sta screen+$52 ldx #0 + // LValue pointer expression (variable - directly) b2: txa clc diff --git a/src/test/ref/ptr-complex.log b/src/test/ref/ptr-complex.log index 6075e9612..53718cc5e 100644 --- a/src/test/ref/ptr-complex.log +++ b/src/test/ref/ptr-complex.log @@ -317,6 +317,7 @@ main: { lda #0 sta i jmp b1 + // RValue pointer expression (variable) //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy @@ -358,6 +359,7 @@ main: { lda #0 sta j jmp b2 + // LValue pointer expression (variable - directly) //SEG25 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: //SEG26 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy @@ -480,6 +482,7 @@ main: { //SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 ldx #0 jmp b1 + // RValue pointer expression (variable) //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy @@ -518,6 +521,7 @@ main: { //SEG24 [12] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@3->main::@2#0] -- vbuxx=vbuc1 ldx #0 jmp b2 + // LValue pointer expression (variable - directly) //SEG25 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2] b2_from_b2: //SEG26 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy @@ -665,6 +669,7 @@ main: { //SEG11 [5] phi from main to main::@1 [phi:main->main::@1] //SEG12 [5] phi (byte) main::i#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 ldx #0 + // RValue pointer expression (variable) //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] //SEG14 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy //SEG15 main::@1 @@ -697,6 +702,7 @@ main: { //SEG23 [12] phi from main::@3 to main::@2 [phi:main::@3->main::@2] //SEG24 [12] phi (byte) main::j#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@3->main::@2#0] -- vbuxx=vbuc1 ldx #0 + // LValue pointer expression (variable - directly) //SEG25 [12] phi from main::@2 to main::@2 [phi:main::@2->main::@2] //SEG26 [12] phi (byte) main::j#2 = (byte) main::j#1 [phi:main::@2->main::@2#0] -- register_copy //SEG27 main::@2 diff --git a/src/test/ref/sinusgen16.asm b/src/test/ref/sinusgen16.asm index 00114c597..a8a5ac134 100644 --- a/src/test/ref/sinusgen16.asm +++ b/src/test/ref/sinusgen16.asm @@ -190,6 +190,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x sta sin16s.x diff --git a/src/test/ref/sinusgen16.log b/src/test/ref/sinusgen16.log index d8b96bc55..91e3cbeaf 100644 --- a/src/test/ref/sinusgen16.log +++ b/src/test/ref/sinusgen16.log @@ -2839,6 +2839,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG133 [62] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG134 [62] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -4356,6 +4357,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG133 [62] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG134 [62] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -5831,6 +5833,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG133 [62] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] //SEG134 [62] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy //SEG135 [62] phi (signed word*) sin16s_gen::sintab#2 = (signed word*) sin16s_gen::sintab#0 [phi:sin16s_gen::@4->sin16s_gen::@1#1] -- register_copy diff --git a/src/test/ref/sinusgen16b.asm b/src/test/ref/sinusgen16b.asm index 29cd787cb..7867a3dc7 100644 --- a/src/test/ref/sinusgen16b.asm +++ b/src/test/ref/sinusgen16b.asm @@ -208,6 +208,7 @@ sin16s_genb: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x+2 sta sin16sb.x @@ -590,6 +591,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x sta sin16s.x diff --git a/src/test/ref/sinusgen16b.log b/src/test/ref/sinusgen16b.log index 95e9834a3..b7097f7f4 100644 --- a/src/test/ref/sinusgen16b.log +++ b/src/test/ref/sinusgen16b.log @@ -3645,6 +3645,7 @@ sin16s_genb: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG143 [66] phi from sin16s_genb::@4 to sin16s_genb::@1 [phi:sin16s_genb::@4->sin16s_genb::@1] b1_from_b4: //SEG144 [66] phi (word) sin16s_genb::i#2 = (word) sin16s_genb::i#1 [phi:sin16s_genb::@4->sin16s_genb::@1#0] -- register_copy @@ -4472,6 +4473,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG341 [167] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG342 [167] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -5791,6 +5793,7 @@ sin16s_genb: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG143 [66] phi from sin16s_genb::@4 to sin16s_genb::@1 [phi:sin16s_genb::@4->sin16s_genb::@1] b1_from_b4: //SEG144 [66] phi (word) sin16s_genb::i#2 = (word) sin16s_genb::i#1 [phi:sin16s_genb::@4->sin16s_genb::@1#0] -- register_copy @@ -6461,6 +6464,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG341 [167] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG342 [167] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -7805,6 +7809,7 @@ sin16s_genb: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG143 [66] phi from sin16s_genb::@4 to sin16s_genb::@1 [phi:sin16s_genb::@4->sin16s_genb::@1] //SEG144 [66] phi (word) sin16s_genb::i#2 = (word) sin16s_genb::i#1 [phi:sin16s_genb::@4->sin16s_genb::@1#0] -- register_copy //SEG145 [66] phi (signed word*) sin16s_genb::sintab#2 = (signed word*) sin16s_genb::sintab#0 [phi:sin16s_genb::@4->sin16s_genb::@1#1] -- register_copy @@ -8385,6 +8390,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG341 [167] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] //SEG342 [167] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy //SEG343 [167] phi (signed word*) sin16s_gen::sintab#2 = (signed word*) sin16s_gen::sintab#0 [phi:sin16s_gen::@4->sin16s_gen::@1#1] -- register_copy diff --git a/src/test/ref/sinusgen8.asm b/src/test/ref/sinusgen8.asm index 56f26b219..7ef965be3 100644 --- a/src/test/ref/sinusgen8.asm +++ b/src/test/ref/sinusgen8.asm @@ -160,6 +160,7 @@ sin8s_gen: { lda #<0 sta x sta x+1 + // u[4.12] b1: lda x sta sin8s.x diff --git a/src/test/ref/sinusgen8.log b/src/test/ref/sinusgen8.log index 24495dbe7..ea5ba4cd7 100644 --- a/src/test/ref/sinusgen8.log +++ b/src/test/ref/sinusgen8.log @@ -2671,6 +2671,7 @@ sin8s_gen: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG124 [58] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] b1_from_b4: //SEG125 [58] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy @@ -3918,6 +3919,7 @@ sin8s_gen: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG124 [58] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] b1_from_b4: //SEG125 [58] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy @@ -5225,6 +5227,7 @@ sin8s_gen: { lda #<0 sta x sta x+1 + // u[4.12] //SEG124 [58] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] //SEG125 [58] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy //SEG126 [58] phi (signed byte*) sin8s_gen::sintab#2 = (signed byte*) sin8s_gen::sintab#0 [phi:sin8s_gen::@4->sin8s_gen::@1#1] -- register_copy diff --git a/src/test/ref/sinusgen8b.asm b/src/test/ref/sinusgen8b.asm index 5d17800b2..fedc7edd8 100644 --- a/src/test/ref/sinusgen8b.asm +++ b/src/test/ref/sinusgen8b.asm @@ -195,6 +195,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] b1: lda x sta sin16s.x @@ -609,6 +610,7 @@ sin8s_gen: { lda #<0 sta x sta x+1 + // u[4.12] b1: lda x sta sin8s.x diff --git a/src/test/ref/sinusgen8b.log b/src/test/ref/sinusgen8b.log index af001c15f..ca0edc0e7 100644 --- a/src/test/ref/sinusgen8b.log +++ b/src/test/ref/sinusgen8b.log @@ -3947,6 +3947,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG134 [66] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG135 [66] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -4803,6 +4804,7 @@ sin8s_gen: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG333 [168] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] b1_from_b4: //SEG334 [168] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy @@ -6212,6 +6214,7 @@ sin16s_gen: { sta x+2 sta x+3 jmp b1 + // u[4.28] //SEG134 [66] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] b1_from_b4: //SEG135 [66] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy @@ -6915,6 +6918,7 @@ sin8s_gen: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG333 [168] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] b1_from_b4: //SEG334 [168] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy @@ -8400,6 +8404,7 @@ sin16s_gen: { sta x+1 sta x+2 sta x+3 + // u[4.28] //SEG134 [66] phi from sin16s_gen::@4 to sin16s_gen::@1 [phi:sin16s_gen::@4->sin16s_gen::@1] //SEG135 [66] phi (word) sin16s_gen::i#2 = (word) sin16s_gen::i#1 [phi:sin16s_gen::@4->sin16s_gen::@1#0] -- register_copy //SEG136 [66] phi (signed word*) sin16s_gen::sintab#2 = (signed word*) sin16s_gen::sintab#0 [phi:sin16s_gen::@4->sin16s_gen::@1#1] -- register_copy @@ -9013,6 +9018,7 @@ sin8s_gen: { lda #<0 sta x sta x+1 + // u[4.12] //SEG333 [168] phi from sin8s_gen::@4 to sin8s_gen::@1 [phi:sin8s_gen::@4->sin8s_gen::@1] //SEG334 [168] phi (word) sin8s_gen::i#2 = (word) sin8s_gen::i#1 [phi:sin8s_gen::@4->sin8s_gen::@1#0] -- register_copy //SEG335 [168] phi (signed byte*) sin8s_gen::sintab#2 = (signed byte*) sin8s_gen::sintab#0 [phi:sin8s_gen::@4->sin8s_gen::@1#1] -- register_copy diff --git a/src/test/ref/sinusgenscale8.asm b/src/test/ref/sinusgenscale8.asm index b45c7ac23..88c5c9bc1 100644 --- a/src/test/ref/sinusgenscale8.asm +++ b/src/test/ref/sinusgenscale8.asm @@ -96,6 +96,7 @@ sin8u_table: { lda #<0 sta x sta x+1 + // u[4.12] b1: lda x sta sin8s.x diff --git a/src/test/ref/sinusgenscale8.log b/src/test/ref/sinusgenscale8.log index f27096659..63e0f556d 100644 --- a/src/test/ref/sinusgenscale8.log +++ b/src/test/ref/sinusgenscale8.log @@ -3751,6 +3751,7 @@ sin8u_table: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG92 [34] phi from sin8u_table::@25 to sin8u_table::@1 [phi:sin8u_table::@25->sin8u_table::@1] b1_from_b25: //SEG93 [34] phi (word) sin8u_table::i#10 = (word) sin8u_table::i#1 [phi:sin8u_table::@25->sin8u_table::@1#0] -- register_copy @@ -5515,6 +5516,7 @@ sin8u_table: { lda #>0 sta x+1 jmp b1 + // u[4.12] //SEG92 [34] phi from sin8u_table::@25 to sin8u_table::@1 [phi:sin8u_table::@25->sin8u_table::@1] b1_from_b25: //SEG93 [34] phi (word) sin8u_table::i#10 = (word) sin8u_table::i#1 [phi:sin8u_table::@25->sin8u_table::@1#0] -- register_copy @@ -6848,8 +6850,8 @@ Removing instruction lda #<0 Succesful ASM optimization Pass5UnnecesaryLoadElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [171] bcc b1 to bcs -Fixing long branch [177] bcc b1 to bcs +Fixing long branch [172] bcc b1 to bcs +Fixing long branch [178] bcc b1 to bcs FINAL SYMBOL TABLE (label) @41 @@ -7420,6 +7422,7 @@ sin8u_table: { lda #<0 sta x sta x+1 + // u[4.12] //SEG92 [34] phi from sin8u_table::@25 to sin8u_table::@1 [phi:sin8u_table::@25->sin8u_table::@1] //SEG93 [34] phi (word) sin8u_table::i#10 = (word) sin8u_table::i#1 [phi:sin8u_table::@25->sin8u_table::@1#0] -- register_copy //SEG94 [34] phi (byte*) sin8u_table::sintab#2 = (byte*) sin8u_table::sintab#1 [phi:sin8u_table::@25->sin8u_table::@1#1] -- register_copy diff --git a/src/test/ref/test-comments-loop.asm b/src/test/ref/test-comments-loop.asm new file mode 100644 index 000000000..4f9576378 --- /dev/null +++ b/src/test/ref/test-comments-loop.asm @@ -0,0 +1,15 @@ +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +main: { + .label SCREEN = $400 + ldx #0 + // Do some sums + b1: + lda #'a' + sta SCREEN,x + inx + cpx #$b + bne b1 + rts +} diff --git a/src/test/ref/test-comments-loop.cfg b/src/test/ref/test-comments-loop.cfg new file mode 100644 index 000000000..fe9d7b95b --- /dev/null +++ b/src/test/ref/test-comments-loop.cfg @@ -0,0 +1,21 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [5] (byte) main::b#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::b#1 ) + [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' + [7] (byte) main::b#1 ← ++ (byte) main::b#2 + [8] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [9] return + to:@return diff --git a/src/test/ref/test-comments-loop.log b/src/test/ref/test-comments-loop.log new file mode 100644 index 000000000..b0a9c35de --- /dev/null +++ b/src/test/ref/test-comments-loop.log @@ -0,0 +1,311 @@ + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + to:@1 +main: scope:[main] from @1 + (byte*) main::SCREEN#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + (byte) main::b#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:main::@1 +main::@1: scope:[main] from main main::@1 + (byte) main::b#2 ← phi( main/(byte) main::b#0 main::@1/(byte) main::b#1 ) + *((byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' + (byte) main::b#1 ← (byte) main::b#2 + rangenext(0,10) + (bool~) main::$0 ← (byte) main::b#1 != rangelast(0,10) + if((bool~) main::$0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +@1: scope:[] from @begin + call main + to:@2 +@2: scope:[] from @1 + to:@end +@end: scope:[] from @2 + +SYMBOL TABLE SSA +(label) @1 +(label) @2 +(label) @begin +(label) @end +(void()) main() +(bool~) main::$0 +(label) main::@1 +(label) main::@return +(byte*) main::SCREEN +(byte*) main::SCREEN#0 +(byte) main::b +(byte) main::b#0 +(byte) main::b#1 +(byte) main::b#2 + +Culled Empty Block (label) @2 +Successful SSA optimization Pass2CullEmptyBlocks +Simple Condition (bool~) main::$0 [6] if((byte) main::b#1!=rangelast(0,10)) goto main::@1 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) main::SCREEN#0 = ((byte*))1024 +Constant (const byte) main::b#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +Resolved ranged next value main::b#1 ← ++ main::b#2 to ++ +Resolved ranged comparison value if(main::b#1!=rangelast(0,10)) goto main::@1 to (byte/signed byte/word/signed word/dword/signed dword) 11 +Inlining constant with var siblings (const byte) main::b#0 +Constant inlined main::b#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Successful SSA optimization Pass2ConstantInlining +Added new block during phi lifting main::@3(between main::@1 and main::@1) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +CALL GRAPH +Calls in [] to main:2 + +Created 1 initial phi equivalence classes +Coalesced [10] main::b#3 ← main::b#1 +Coalesced down to 1 phi equivalence classes +Culled Empty Block (label) main::@3 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() +main: scope:[main] from @1 + [4] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [5] (byte) main::b#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@1/(byte) main::b#1 ) + [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' + [7] (byte) main::b#1 ← ++ (byte) main::b#2 + [8] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [9] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte*) main::SCREEN +(byte) main::b +(byte) main::b#1 16.5 +(byte) main::b#2 16.5 + +Initial phi equivalence classes +[ main::b#2 main::b#1 ] +Complete equivalence classes +[ main::b#2 main::b#1 ] +Allocated zp ZP_BYTE:2 [ main::b#2 main::b#1 ] + +INITIAL ASM +//SEG0 File Comments +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG9 @end +bend: +//SEG10 main +main: { + .label SCREEN = $400 + .label b = 2 + //SEG11 [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta b + jmp b1 + // Do some sums + //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG15 main::@1 + b1: + //SEG16 [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' -- pbuc1_derefidx_vbuz1=vbuc2 + ldy b + lda #'a' + sta SCREEN,y + //SEG17 [7] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuz1=_inc_vbuz1 + inc b + //SEG18 [8] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda b + cmp #$b + bne b1_from_b1 + jmp breturn + //SEG19 main::@return + breturn: + //SEG20 [9] return + rts +} + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' [ main::b#2 ] ( main:2 [ main::b#2 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::b#2 main::b#1 ] +Statement [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' [ main::b#2 ] ( main:2 [ main::b#2 ] ) always clobbers reg byte a +Potential registers zp ZP_BYTE:2 [ main::b#2 main::b#1 ] : zp ZP_BYTE:2 , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 33: zp ZP_BYTE:2 [ main::b#2 main::b#1 ] +Uplift Scope [] + +Uplifting [main] best 263 combination reg byte x [ main::b#2 main::b#1 ] +Uplifting [] best 263 combination + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG9 @end +bend: +//SEG10 main +main: { + .label SCREEN = $400 + //SEG11 [5] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + jmp b1 + // Do some sums + //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG15 main::@1 + b1: + //SEG16 [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' -- pbuc1_derefidx_vbuxx=vbuc2 + lda #'a' + sta SCREEN,x + //SEG17 [7] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx + inx + //SEG18 [8] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #$b + bne b1_from_b1 + jmp breturn + //SEG19 main::@return + breturn: + //SEG20 [9] return + rts +} + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Replacing label b1_from_b1 with b1 +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction main_from_b1: +Removing instruction bend_from_b1: +Removing instruction b1_from_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction bend: +Removing instruction b1_from_main: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction jmp b1 +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(void()) main() +(label) main::@1 +(label) main::@return +(byte*) main::SCREEN +(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024 +(byte) main::b +(byte) main::b#1 reg byte x 16.5 +(byte) main::b#2 reg byte x 16.5 + +reg byte x [ main::b#2 main::b#1 ] + + +FINAL ASSEMBLER +Score: 161 + +//SEG0 File Comments +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG2 Global Constants & labels +//SEG3 @begin +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +//SEG5 @1 +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +//SEG9 @end +//SEG10 main +main: { + .label SCREEN = $400 + //SEG11 [5] phi from main to main::@1 [phi:main->main::@1] + //SEG12 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + // Do some sums + //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG14 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG15 main::@1 + b1: + //SEG16 [6] *((const byte*) main::SCREEN#0 + (byte) main::b#2) ← (byte) 'a' -- pbuc1_derefidx_vbuxx=vbuc2 + lda #'a' + sta SCREEN,x + //SEG17 [7] (byte) main::b#1 ← ++ (byte) main::b#2 -- vbuxx=_inc_vbuxx + inx + //SEG18 [8] if((byte) main::b#1!=(byte/signed byte/word/signed word/dword/signed dword) 11) goto main::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #$b + bne b1 + //SEG19 main::@return + //SEG20 [9] return + rts +} + diff --git a/src/test/ref/test-comments-loop.sym b/src/test/ref/test-comments-loop.sym new file mode 100644 index 000000000..5a3776e0f --- /dev/null +++ b/src/test/ref/test-comments-loop.sym @@ -0,0 +1,13 @@ +(label) @1 +(label) @begin +(label) @end +(void()) main() +(label) main::@1 +(label) main::@return +(byte*) main::SCREEN +(const byte*) main::SCREEN#0 SCREEN = ((byte*))(word/signed word/dword/signed dword) 1024 +(byte) main::b +(byte) main::b#1 reg byte x 16.5 +(byte) main::b#2 reg byte x 16.5 + +reg byte x [ main::b#2 main::b#1 ] diff --git a/src/test/ref/test-comments-single.asm b/src/test/ref/test-comments-single.asm index bd0b34cd6..f3ac2f2cc 100644 --- a/src/test/ref/test-comments-single.asm +++ b/src/test/ref/test-comments-single.asm @@ -10,6 +10,7 @@ main: { ldx #0 ldy #0 + // Do some sums b1: jsr sum // Output the result on the screen diff --git a/src/test/ref/test-comments-single.log b/src/test/ref/test-comments-single.log index 6157fdbde..77053d2a8 100644 --- a/src/test/ref/test-comments-single.log +++ b/src/test/ref/test-comments-single.log @@ -274,6 +274,7 @@ main: { lda #0 sta b jmp b1 + // Do some sums //SEG14 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] b1_from_b3: //SEG15 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy @@ -394,6 +395,7 @@ main: { //SEG13 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuyy=vbuc1 ldy #0 jmp b1 + // Do some sums //SEG14 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] b1_from_b3: //SEG15 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy @@ -537,6 +539,7 @@ main: { ldx #0 //SEG13 [5] phi (byte) main::b#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main->main::@1#1] -- vbuyy=vbuc1 ldy #0 + // Do some sums //SEG14 [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1] //SEG15 [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy //SEG16 [5] phi (byte) main::b#2 = (byte) main::b#1 [phi:main::@3->main::@1#1] -- register_copy diff --git a/src/test/ref/test-keyboard.asm b/src/test/ref/test-keyboard.asm index d78fbbf5b..aa1001f73 100644 --- a/src/test/ref/test-keyboard.asm +++ b/src/test/ref/test-keyboard.asm @@ -70,6 +70,7 @@ main: { sta sc lda #>$400 sta sc+1 + // Clear screen b1: lda #' ' ldy #0 @@ -97,6 +98,7 @@ main: { sta screen+1 lda #0 sta row + // Read & print keyboard matrix b6: ldy row jsr keyboard_matrix_read @@ -156,14 +158,15 @@ main: { lda ch cmp #$40 bne b10 - b13: + b2: + // Add some spaces txa tay lda #' ' sta (screen),y inx cpx #5 - bcc b13 + bcc b2 jmp b5 b8: lda #'1' diff --git a/src/test/ref/test-keyboard.log b/src/test/ref/test-keyboard.log index fa5853036..60c7855ae 100644 --- a/src/test/ref/test-keyboard.log +++ b/src/test/ref/test-keyboard.log @@ -1706,6 +1706,7 @@ main: { lda #>$400 sta sc+1 jmp b1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy @@ -1755,6 +1756,7 @@ main: { lda #0 sta row jmp b6 + // Read & print keyboard matrix //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6] b6_from_b20: //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy @@ -1930,6 +1932,7 @@ main: { b13_from_b13: //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy jmp b13 + // Add some spaces //SEG89 main::@13 b13: //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuz2=vbuc1 @@ -2267,6 +2270,7 @@ main: { lda #>$400 sta sc+1 jmp b1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] b1_from_b1: //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy @@ -2316,6 +2320,7 @@ main: { lda #0 sta row jmp b6 + // Read & print keyboard matrix //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6] b6_from_b20: //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy @@ -2472,6 +2477,7 @@ main: { b13_from_b13: //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy jmp b13 + // Add some spaces //SEG89 main::@13 b13: //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 @@ -2621,7 +2627,6 @@ Replacing label b6_from_b20 with b6 Replacing label b11_from_b29 with b11 Replacing label b11_from_b30 with b11 Replacing label b10_from_b11 with b10 -Replacing label b13_from_b13 with b13 Removing instruction b12_from_bbegin: Removing instruction b12: Removing instruction main_from_b12: @@ -2635,7 +2640,6 @@ Removing instruction b11_from_b23: Removing instruction b11_from_b29: Removing instruction b11_from_b30: Removing instruction b13_from_b11: -Removing instruction b13_from_b13: Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction bend: Removing instruction b1_from_main: @@ -2652,6 +2656,7 @@ Removing instruction b29: Removing instruction b22: Removing instruction b30: Removing instruction b23: +Removing instruction b13: Removing instruction keyboard_matrix_read_from_keyboard_key_pressed: Removing instruction b2: Removing instruction breturn: @@ -2662,6 +2667,8 @@ Succesful ASM optimization Pass5UnusedLabelElimination Updating BasicUpstart to call main directly Removing instruction jsr main Succesful ASM optimization Pass5SkipBegin +Relabelling long label b13_from_b13 to b2 +Succesful ASM optimization Pass5RelabelLongLabels Removing instruction jmp b1 Removing instruction jmp b6 Removing instruction jmp b7 @@ -3081,6 +3088,7 @@ main: { sta sc lda #>$400 sta sc+1 + // Clear screen //SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1] //SEG14 [5] phi (byte*) main::sc#2 = (byte*) main::sc#1 [phi:main::@1->main::@1#0] -- register_copy //SEG15 main::@1 @@ -3122,6 +3130,7 @@ main: { //SEG26 [12] phi (byte) main::row#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@5->main::@6#1] -- vbuz1=vbuc1 lda #0 sta row + // Read & print keyboard matrix //SEG27 [12] phi from main::@20 to main::@6 [phi:main::@20->main::@6] //SEG28 [12] phi (byte*) main::screen#13 = (byte*) main::screen#1 [phi:main::@20->main::@6#0] -- register_copy //SEG29 [12] phi (byte) main::row#2 = (byte) main::row#1 [phi:main::@20->main::@6#1] -- register_copy @@ -3242,9 +3251,10 @@ main: { cmp #$40 bne b10 //SEG87 [44] phi from main::@11 main::@13 to main::@13 [phi:main::@11/main::@13->main::@13] + b2: //SEG88 [44] phi (byte) main::i#4 = (byte) main::i#6 [phi:main::@11/main::@13->main::@13#0] -- register_copy + // Add some spaces //SEG89 main::@13 - b13: //SEG90 [45] *((byte*) main::screen#2 + (byte) main::i#4) ← (byte) ' ' -- pbuz1_derefidx_vbuxx=vbuc1 txa tay @@ -3254,7 +3264,7 @@ main: { inx //SEG92 [47] if((byte) main::i#2<(byte/signed byte/word/signed word/dword/signed dword) 5) goto main::@13 -- vbuxx_lt_vbuc1_then_la1 cpx #5 - bcc b13 + bcc b2 jmp b5 //SEG93 main::@8 b8: diff --git a/src/test/ref/test-word-size-arrays.asm b/src/test/ref/test-word-size-arrays.asm index ea7b119e1..9be6fe475 100644 --- a/src/test/ref/test-word-size-arrays.asm +++ b/src/test/ref/test-word-size-arrays.asm @@ -63,6 +63,7 @@ main: { bcc b1 !: ldx #0 + // Cleare the bottom line b3: txa clc diff --git a/src/test/ref/test-word-size-arrays.log b/src/test/ref/test-word-size-arrays.log index 8f4e26451..19558bd07 100644 --- a/src/test/ref/test-word-size-arrays.log +++ b/src/test/ref/test-word-size-arrays.log @@ -369,6 +369,7 @@ main: { lda #0 sta c_5 jmp b3 + // Cleare the bottom line //SEG31 [14] phi from main::@3 to main::@3 [phi:main::@3->main::@3] b3_from_b3: //SEG32 [14] phi (byte) main::c#5 = (byte) main::c#3 [phi:main::@3->main::@3#0] -- register_copy @@ -561,6 +562,7 @@ main: { //SEG30 [14] phi (byte) main::c#5 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@4->main::@3#0] -- vbuxx=vbuc1 ldx #0 jmp b3 + // Cleare the bottom line //SEG31 [14] phi from main::@3 to main::@3 [phi:main::@3->main::@3] b3_from_b3: //SEG32 [14] phi (byte) main::c#5 = (byte) main::c#3 [phi:main::@3->main::@3#0] -- register_copy @@ -769,6 +771,7 @@ main: { //SEG29 [14] phi from main::@4 to main::@3 [phi:main::@4->main::@3] //SEG30 [14] phi (byte) main::c#5 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:main::@4->main::@3#0] -- vbuxx=vbuc1 ldx #0 + // Cleare the bottom line //SEG31 [14] phi from main::@3 to main::@3 [phi:main::@3->main::@3] //SEG32 [14] phi (byte) main::c#5 = (byte) main::c#3 [phi:main::@3->main::@3#0] -- register_copy //SEG33 main::@3