diff --git a/src/main/fragment/pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1.asm b/src/main/fragment/pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1.asm new file mode 100644 index 000000000..90afbd8fb --- /dev/null +++ b/src/main/fragment/pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1.asm @@ -0,0 +1,16 @@ +lda #<{c1} +clc +adc {z1} +sta !a1+ +1 +lda #>{c1} +adc {z1}+1 +sta !a1+ +2 +lda #<{c2} +clc +adc {z1} +sta !a2+ +1 +lda #>{c2} +adc {z1}+1 +sta !a2+ +2 +!a2: lda {c2} +!a1: sta {c1} diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 8e6cfed54..27e416975 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 testScrollUp() throws IOException, URISyntaxException { + compileAndCompare("test-scroll-up"); + } + @Test public void testWordsizeArrays() throws IOException, URISyntaxException { compileAndCompare("test-word-size-arrays"); diff --git a/src/test/kc/test-scroll-up.kc b/src/test/kc/test-scroll-up.kc new file mode 100644 index 000000000..2e77bbc3e --- /dev/null +++ b/src/test/kc/test-scroll-up.kc @@ -0,0 +1,31 @@ +// Tests different ways of scrolling up the screen + +const byte* screen = $400; + +void main() { + scrollup1(); + scrollup2(); + scrollup3(); +} + +void scrollup1() { + for (word line = 0; line < 40*24; line += 40) + for (byte c=0; c<40; ++c) + screen[line+c] = screen[line+c+40]; +} + +void scrollup2() { + byte* line1 = screen; + byte* line2 = screen+40; + for( byte l: 0..23 ) + for (byte c: 0..39) + *line1++ = *line2++; +} + +void scrollup3() { + for (word line = 0; line < 40*24; line += 40) { + word l2 = line; + for (byte c=0; c<40; ++c) + screen[l2++] = screen[l2+40]; + } +} diff --git a/src/test/ref/test-scroll-up.asm b/src/test/ref/test-scroll-up.asm new file mode 100644 index 000000000..6aaf4c98e --- /dev/null +++ b/src/test/ref/test-scroll-up.asm @@ -0,0 +1,165 @@ +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label screen = $400 +main: { + jsr scrollup1 + jsr scrollup2 + jsr scrollup3 + rts +} +scrollup3: { + .label l2 = 2 + .label l2_1 = 4 + .label line = 2 + .label l2_2 = 4 + .label l2_4 = 4 + lda #<0 + sta l2 + sta l2+1 + b1: + lda l2 + sta l2_4 + lda l2+1 + sta l2_4+1 + ldx #0 + b2: + lda #screen + adc l2_2+1 + sta !a1++2 + lda #screen+$28 + adc l2_2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + inc l2_1 + bne !+ + inc l2_1+1 + !: + inx + cpx #$28 + bcc b2 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + cmp #>$28*$18 + bcc b1 + bne !+ + lda line + cmp #<$28*$18 + bcc b1 + !: + rts +} +scrollup2: { + .label line1 = 4 + .label line2 = 2 + .label l = 6 + lda #0 + sta l + lda #screen + sta line1+1 + lda #screen+$28 + sta line2+1 + b1: + ldx #0 + b2: + ldy #0 + lda (line2),y + sta (line1),y + inc line1 + bne !+ + inc line1+1 + !: + inc line2 + bne !+ + inc line2+1 + !: + inx + cpx #$28 + bne b2 + inc l + lda l + cmp #$18 + bne b1 + rts +} +scrollup1: { + .label _0 = 4 + .label _2 = 7 + .label line = 2 + lda #<0 + sta line + sta line+1 + b1: + ldx #0 + b2: + txa + clc + adc line + sta _0 + lda #0 + adc line+1 + sta _0+1 + txa + clc + adc line + sta _2 + lda #0 + adc line+1 + sta _2+1 + lda #screen + adc _0+1 + sta !a1++2 + lda #screen+$28 + adc _2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + inx + cpx #$28 + bcc b2 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + cmp #>$28*$18 + bcc b1 + bne !+ + lda line + cmp #<$28*$18 + bcc b1 + !: + rts +} diff --git a/src/test/ref/test-scroll-up.cfg b/src/test/ref/test-scroll-up.cfg new file mode 100644 index 000000000..27dc01c16 --- /dev/null +++ b/src/test/ref/test-scroll-up.cfg @@ -0,0 +1,92 @@ +@begin: scope:[] from + [0] phi() + to:@4 +@4: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @4 + [3] phi() +main: scope:[main] from @4 + [4] phi() + [5] call scrollup1 + to:main::@1 +main::@1: scope:[main] from main + [6] phi() + [7] call scrollup2 + to:main::@2 +main::@2: scope:[main] from main::@1 + [8] phi() + [9] call scrollup3 + to:main::@return +main::@return: scope:[main] from main::@2 + [10] return + to:@return +scrollup3: scope:[scrollup3] from main::@2 + [11] phi() + to:scrollup3::@1 +scrollup3::@1: scope:[scrollup3] from scrollup3 scrollup3::@3 + [12] (word) scrollup3::l2#0 ← phi( scrollup3/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@3/(word) scrollup3::line#1 ) + [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 + to:scrollup3::@2 +scrollup3::@2: scope:[scrollup3] from scrollup3::@1 scrollup3::@2 + [14] (byte) scrollup3::c#2 ← phi( scrollup3::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@2/(byte) scrollup3::c#1 ) + [14] (word) scrollup3::l2#2 ← phi( scrollup3::@1/(word~) scrollup3::l2#4 scrollup3::@2/(word) scrollup3::l2#1 ) + [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) + [16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 + [17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 + [18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 + to:scrollup3::@3 +scrollup3::@3: scope:[scrollup3] from scrollup3::@2 + [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 + [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 + to:scrollup3::@return +scrollup3::@return: scope:[scrollup3] from scrollup3::@3 + [21] return + to:@return +scrollup2: scope:[scrollup2] from main::@1 + [22] phi() + to:scrollup2::@1 +scrollup2::@1: scope:[scrollup2] from scrollup2 scrollup2::@3 + [23] (byte) scrollup2::l#4 ← phi( scrollup2/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@3/(byte) scrollup2::l#1 ) + [23] (byte*) scrollup2::line1#3 ← phi( scrollup2/(const byte*) screen#0 scrollup2::@3/(byte*) scrollup2::line1#1 ) + [23] (byte*) scrollup2::line2#3 ← phi( scrollup2/(const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 scrollup2::@3/(byte*) scrollup2::line2#1 ) + to:scrollup2::@2 +scrollup2::@2: scope:[scrollup2] from scrollup2::@1 scrollup2::@2 + [24] (byte) scrollup2::c#2 ← phi( scrollup2::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@2/(byte) scrollup2::c#1 ) + [24] (byte*) scrollup2::line1#2 ← phi( scrollup2::@1/(byte*) scrollup2::line1#3 scrollup2::@2/(byte*) scrollup2::line1#1 ) + [24] (byte*) scrollup2::line2#2 ← phi( scrollup2::@1/(byte*) scrollup2::line2#3 scrollup2::@2/(byte*) scrollup2::line2#1 ) + [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) + [26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 + [27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 + [28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2 + [29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2 + to:scrollup2::@3 +scrollup2::@3: scope:[scrollup2] from scrollup2::@2 + [30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4 + [31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1 + to:scrollup2::@return +scrollup2::@return: scope:[scrollup2] from scrollup2::@3 + [32] return + to:@return +scrollup1: scope:[scrollup1] from main + [33] phi() + to:scrollup1::@1 +scrollup1::@1: scope:[scrollup1] from scrollup1 scrollup1::@3 + [34] (word) scrollup1::line#4 ← phi( scrollup1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@3/(word) scrollup1::line#1 ) + to:scrollup1::@2 +scrollup1::@2: scope:[scrollup1] from scrollup1::@1 scrollup1::@2 + [35] (byte) scrollup1::c#2 ← phi( scrollup1::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@2/(byte) scrollup1::c#1 ) + [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 + [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 + [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) + [39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 + [40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 + to:scrollup1::@3 +scrollup1::@3: scope:[scrollup1] from scrollup1::@2 + [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 + [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 + to:scrollup1::@return +scrollup1::@return: scope:[scrollup1] from scrollup1::@3 + [43] return + to:@return diff --git a/src/test/ref/test-scroll-up.log b/src/test/ref/test-scroll-up.log new file mode 100644 index 000000000..8100ce8b2 --- /dev/null +++ b/src/test/ref/test-scroll-up.log @@ -0,0 +1,1621 @@ + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) screen#0 ← ((byte*)) (word/signed word/dword/signed dword) 1024 + to:@4 +main: scope:[main] from @4 + call scrollup1 + to:main::@1 +main::@1: scope:[main] from main + call scrollup2 + to:main::@2 +main::@2: scope:[main] from main::@1 + call scrollup3 + to:main::@3 +main::@3: scope:[main] from main::@2 + to:main::@return +main::@return: scope:[main] from main::@3 + return + to:@return +scrollup1: scope:[scrollup1] from main + (word) scrollup1::line#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup1::@1 +scrollup1::@1: scope:[scrollup1] from scrollup1 scrollup1::@3 + (word) scrollup1::line#4 ← phi( scrollup1/(word) scrollup1::line#0 scrollup1::@3/(word) scrollup1::line#1 ) + (byte) scrollup1::c#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup1::@2 +scrollup1::@2: scope:[scrollup1] from scrollup1::@1 scrollup1::@2 + (byte) scrollup1::c#2 ← phi( scrollup1::@1/(byte) scrollup1::c#0 scrollup1::@2/(byte) scrollup1::c#1 ) + (word) scrollup1::line#2 ← phi( scrollup1::@1/(word) scrollup1::line#4 scrollup1::@2/(word) scrollup1::line#2 ) + (word~) scrollup1::$0 ← (word) scrollup1::line#2 + (byte) scrollup1::c#2 + (word~) scrollup1::$1 ← (word) scrollup1::line#2 + (byte) scrollup1::c#2 + (word/signed dword/dword~) scrollup1::$2 ← (word~) scrollup1::$1 + (byte/signed byte/word/signed word/dword/signed dword) 40 + *((byte*) screen#0 + (word~) scrollup1::$0) ← *((byte*) screen#0 + (word/signed dword/dword~) scrollup1::$2) + (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 + (bool~) scrollup1::$3 ← (byte) scrollup1::c#1 < (byte/signed byte/word/signed word/dword/signed dword) 40 + if((bool~) scrollup1::$3) goto scrollup1::@2 + to:scrollup1::@3 +scrollup1::@3: scope:[scrollup1] from scrollup1::@2 + (word) scrollup1::line#3 ← phi( scrollup1::@2/(word) scrollup1::line#2 ) + (word) scrollup1::line#1 ← (word) scrollup1::line#3 + (byte/signed byte/word/signed word/dword/signed dword) 40 + (word/signed word/dword/signed dword~) scrollup1::$4 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 24 + (bool~) scrollup1::$5 ← (word) scrollup1::line#1 < (word/signed word/dword/signed dword~) scrollup1::$4 + if((bool~) scrollup1::$5) goto scrollup1::@1 + to:scrollup1::@return +scrollup1::@return: scope:[scrollup1] from scrollup1::@3 + return + to:@return +scrollup2: scope:[scrollup2] from main::@1 + (byte*) scrollup2::line1#0 ← (byte*) screen#0 + (byte*~) scrollup2::$0 ← (byte*) screen#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 + (byte*) scrollup2::line2#0 ← (byte*~) scrollup2::$0 + (byte) scrollup2::l#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup2::@1 +scrollup2::@1: scope:[scrollup2] from scrollup2 scrollup2::@3 + (byte) scrollup2::l#4 ← phi( scrollup2/(byte) scrollup2::l#0 scrollup2::@3/(byte) scrollup2::l#1 ) + (byte*) scrollup2::line1#3 ← phi( scrollup2/(byte*) scrollup2::line1#0 scrollup2::@3/(byte*) scrollup2::line1#4 ) + (byte*) scrollup2::line2#3 ← phi( scrollup2/(byte*) scrollup2::line2#0 scrollup2::@3/(byte*) scrollup2::line2#4 ) + (byte) scrollup2::c#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup2::@2 +scrollup2::@2: scope:[scrollup2] from scrollup2::@1 scrollup2::@2 + (byte) scrollup2::l#3 ← phi( scrollup2::@1/(byte) scrollup2::l#4 scrollup2::@2/(byte) scrollup2::l#3 ) + (byte) scrollup2::c#2 ← phi( scrollup2::@1/(byte) scrollup2::c#0 scrollup2::@2/(byte) scrollup2::c#1 ) + (byte*) scrollup2::line1#2 ← phi( scrollup2::@1/(byte*) scrollup2::line1#3 scrollup2::@2/(byte*) scrollup2::line1#1 ) + (byte*) scrollup2::line2#2 ← phi( scrollup2::@1/(byte*) scrollup2::line2#3 scrollup2::@2/(byte*) scrollup2::line2#1 ) + *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) + (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 + (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 + (byte) scrollup2::c#1 ← (byte) scrollup2::c#2 + rangenext(0,39) + (bool~) scrollup2::$1 ← (byte) scrollup2::c#1 != rangelast(0,39) + if((bool~) scrollup2::$1) goto scrollup2::@2 + to:scrollup2::@3 +scrollup2::@3: scope:[scrollup2] from scrollup2::@2 + (byte*) scrollup2::line1#4 ← phi( scrollup2::@2/(byte*) scrollup2::line1#1 ) + (byte*) scrollup2::line2#4 ← phi( scrollup2::@2/(byte*) scrollup2::line2#1 ) + (byte) scrollup2::l#2 ← phi( scrollup2::@2/(byte) scrollup2::l#3 ) + (byte) scrollup2::l#1 ← (byte) scrollup2::l#2 + rangenext(0,23) + (bool~) scrollup2::$2 ← (byte) scrollup2::l#1 != rangelast(0,23) + if((bool~) scrollup2::$2) goto scrollup2::@1 + to:scrollup2::@return +scrollup2::@return: scope:[scrollup2] from scrollup2::@3 + return + to:@return +scrollup3: scope:[scrollup3] from main::@2 + (word) scrollup3::line#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup3::@1 +scrollup3::@1: scope:[scrollup3] from scrollup3 scrollup3::@3 + (word) scrollup3::line#2 ← phi( scrollup3/(word) scrollup3::line#0 scrollup3::@3/(word) scrollup3::line#1 ) + (word) scrollup3::l2#0 ← (word) scrollup3::line#2 + (byte) scrollup3::c#0 ← (byte/signed byte/word/signed word/dword/signed dword) 0 + to:scrollup3::@2 +scrollup3::@2: scope:[scrollup3] from scrollup3::@1 scrollup3::@2 + (word) scrollup3::line#4 ← phi( scrollup3::@1/(word) scrollup3::line#2 scrollup3::@2/(word) scrollup3::line#4 ) + (byte) scrollup3::c#2 ← phi( scrollup3::@1/(byte) scrollup3::c#0 scrollup3::@2/(byte) scrollup3::c#1 ) + (word) scrollup3::l2#2 ← phi( scrollup3::@1/(word) scrollup3::l2#0 scrollup3::@2/(word) scrollup3::l2#1 ) + (word/signed dword/dword~) scrollup3::$0 ← (word) scrollup3::l2#2 + (byte/signed byte/word/signed word/dword/signed dword) 40 + *((byte*) screen#0 + (word) scrollup3::l2#2) ← *((byte*) screen#0 + (word/signed dword/dword~) scrollup3::$0) + (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 + (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 + (bool~) scrollup3::$1 ← (byte) scrollup3::c#1 < (byte/signed byte/word/signed word/dword/signed dword) 40 + if((bool~) scrollup3::$1) goto scrollup3::@2 + to:scrollup3::@3 +scrollup3::@3: scope:[scrollup3] from scrollup3::@2 + (word) scrollup3::line#3 ← phi( scrollup3::@2/(word) scrollup3::line#4 ) + (word) scrollup3::line#1 ← (word) scrollup3::line#3 + (byte/signed byte/word/signed word/dword/signed dword) 40 + (word/signed word/dword/signed dword~) scrollup3::$2 ← (byte/signed byte/word/signed word/dword/signed dword) 40 * (byte/signed byte/word/signed word/dword/signed dword) 24 + (bool~) scrollup3::$3 ← (word) scrollup3::line#1 < (word/signed word/dword/signed dword~) scrollup3::$2 + if((bool~) scrollup3::$3) goto scrollup3::@1 + to:scrollup3::@return +scrollup3::@return: scope:[scrollup3] from scrollup3::@3 + return + to:@return +@4: scope:[] from @begin + call main + to:@5 +@5: scope:[] from @4 + to:@end +@end: scope:[] from @5 + +SYMBOL TABLE SSA +(label) @4 +(label) @5 +(label) @begin +(label) @end +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@return +(byte*) screen +(byte*) screen#0 +(void()) scrollup1() +(word~) scrollup1::$0 +(word~) scrollup1::$1 +(word/signed dword/dword~) scrollup1::$2 +(bool~) scrollup1::$3 +(word/signed word/dword/signed dword~) scrollup1::$4 +(bool~) scrollup1::$5 +(label) scrollup1::@1 +(label) scrollup1::@2 +(label) scrollup1::@3 +(label) scrollup1::@return +(byte) scrollup1::c +(byte) scrollup1::c#0 +(byte) scrollup1::c#1 +(byte) scrollup1::c#2 +(word) scrollup1::line +(word) scrollup1::line#0 +(word) scrollup1::line#1 +(word) scrollup1::line#2 +(word) scrollup1::line#3 +(word) scrollup1::line#4 +(void()) scrollup2() +(byte*~) scrollup2::$0 +(bool~) scrollup2::$1 +(bool~) scrollup2::$2 +(label) scrollup2::@1 +(label) scrollup2::@2 +(label) scrollup2::@3 +(label) scrollup2::@return +(byte) scrollup2::c +(byte) scrollup2::c#0 +(byte) scrollup2::c#1 +(byte) scrollup2::c#2 +(byte) scrollup2::l +(byte) scrollup2::l#0 +(byte) scrollup2::l#1 +(byte) scrollup2::l#2 +(byte) scrollup2::l#3 +(byte) scrollup2::l#4 +(byte*) scrollup2::line1 +(byte*) scrollup2::line1#0 +(byte*) scrollup2::line1#1 +(byte*) scrollup2::line1#2 +(byte*) scrollup2::line1#3 +(byte*) scrollup2::line1#4 +(byte*) scrollup2::line2 +(byte*) scrollup2::line2#0 +(byte*) scrollup2::line2#1 +(byte*) scrollup2::line2#2 +(byte*) scrollup2::line2#3 +(byte*) scrollup2::line2#4 +(void()) scrollup3() +(word/signed dword/dword~) scrollup3::$0 +(bool~) scrollup3::$1 +(word/signed word/dword/signed dword~) scrollup3::$2 +(bool~) scrollup3::$3 +(label) scrollup3::@1 +(label) scrollup3::@2 +(label) scrollup3::@3 +(label) scrollup3::@return +(byte) scrollup3::c +(byte) scrollup3::c#0 +(byte) scrollup3::c#1 +(byte) scrollup3::c#2 +(word) scrollup3::l2 +(word) scrollup3::l2#0 +(word) scrollup3::l2#1 +(word) scrollup3::l2#2 +(word) scrollup3::line +(word) scrollup3::line#0 +(word) scrollup3::line#1 +(word) scrollup3::line#2 +(word) scrollup3::line#3 +(word) scrollup3::line#4 + +Culled Empty Block (label) main::@3 +Culled Empty Block (label) @5 +Successful SSA optimization Pass2CullEmptyBlocks +Alias (word) scrollup1::line#2 = (word) scrollup1::line#3 +Alias (byte*) scrollup2::line2#0 = (byte*~) scrollup2::$0 +Alias (byte) scrollup2::l#2 = (byte) scrollup2::l#3 +Alias (byte*) scrollup2::line2#1 = (byte*) scrollup2::line2#4 +Alias (byte*) scrollup2::line1#1 = (byte*) scrollup2::line1#4 +Alias (word) scrollup3::l2#0 = (word) scrollup3::line#2 +Alias (word) scrollup3::line#3 = (word) scrollup3::line#4 +Successful SSA optimization Pass2AliasElimination +Self Phi Eliminated (word) scrollup1::line#2 +Self Phi Eliminated (byte) scrollup2::l#2 +Self Phi Eliminated (word) scrollup3::line#3 +Successful SSA optimization Pass2SelfPhiElimination +Redundant Phi (word) scrollup1::line#2 (word) scrollup1::line#4 +Redundant Phi (byte) scrollup2::l#2 (byte) scrollup2::l#4 +Redundant Phi (word) scrollup3::line#3 (word) scrollup3::l2#0 +Successful SSA optimization Pass2RedundantPhiElimination +Simple Condition (bool~) scrollup1::$3 [15] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 +Simple Condition (bool~) scrollup1::$5 [20] if((word) scrollup1::line#1<(word/signed word/dword/signed dword~) scrollup1::$4) goto scrollup1::@1 +Simple Condition (bool~) scrollup2::$1 [34] if((byte) scrollup2::c#1!=rangelast(0,39)) goto scrollup2::@2 +Simple Condition (bool~) scrollup2::$2 [38] if((byte) scrollup2::l#1!=rangelast(0,23)) goto scrollup2::@1 +Simple Condition (bool~) scrollup3::$1 [50] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 +Simple Condition (bool~) scrollup3::$3 [55] if((word) scrollup3::line#1<(word/signed word/dword/signed dword~) scrollup3::$2) goto scrollup3::@1 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) screen#0 = ((byte*))1024 +Constant (const word) scrollup1::line#0 = 0 +Constant (const byte) scrollup1::c#0 = 0 +Constant (const word/signed word/dword/signed dword) scrollup1::$4 = 40*24 +Constant (const byte) scrollup2::l#0 = 0 +Constant (const byte) scrollup2::c#0 = 0 +Constant (const word) scrollup3::line#0 = 0 +Constant (const byte) scrollup3::c#0 = 0 +Constant (const word/signed word/dword/signed dword) scrollup3::$2 = 40*24 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) scrollup2::line1#0 = screen#0 +Constant (const byte*) scrollup2::line2#0 = screen#0+40 +Successful SSA optimization Pass2ConstantIdentification +Consolidated array index constant in assignment *(screen#0+40 + scrollup1::$2) +Consolidated array index constant in assignment *(screen#0+40 + scrollup3::$0) +Successful SSA optimization Pass2ConstantAdditionElimination +Inferred type updated to word in [8] (word/signed dword/dword~) scrollup1::$2 ← (word~) scrollup1::$1 +Inferred type updated to word in [27] (word/signed dword/dword~) scrollup3::$0 ← (word) scrollup3::l2#2 +Resolved ranged next value scrollup2::c#1 ← ++ scrollup2::c#2 to ++ +Resolved ranged comparison value if(scrollup2::c#1!=rangelast(0,39)) goto scrollup2::@2 to (byte/signed byte/word/signed word/dword/signed dword) 40 +Resolved ranged next value scrollup2::l#1 ← ++ scrollup2::l#4 to ++ +Resolved ranged comparison value if(scrollup2::l#1!=rangelast(0,23)) goto scrollup2::@1 to (byte/signed byte/word/signed word/dword/signed dword) 24 +Alias (word~) scrollup1::$2 = (word~) scrollup1::$1 +Alias (word) scrollup3::l2#2 = (word~) scrollup3::$0 +Successful SSA optimization Pass2AliasElimination +Inlining constant with var siblings (const word) scrollup1::line#0 +Inlining constant with var siblings (const byte) scrollup1::c#0 +Inlining constant with var siblings (const byte) scrollup2::l#0 +Inlining constant with var siblings (const byte) scrollup2::c#0 +Inlining constant with var siblings (const byte*) scrollup2::line1#0 +Inlining constant with var siblings (const byte*) scrollup2::line2#0 +Inlining constant with var siblings (const word) scrollup3::line#0 +Inlining constant with var siblings (const byte) scrollup3::c#0 +Constant inlined scrollup2::l#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup3::line#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup3::c#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup3::$2 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24 +Constant inlined scrollup1::$4 = (byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24 +Constant inlined scrollup2::c#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup1::c#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup1::line#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 +Constant inlined scrollup2::line2#0 = (const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 +Constant inlined scrollup2::line1#0 = (const byte*) screen#0 +Successful SSA optimization Pass2ConstantInlining +Added new block during phi lifting scrollup3::@5(between scrollup3::@3 and scrollup3::@1) +Added new block during phi lifting scrollup3::@6(between scrollup3::@2 and scrollup3::@2) +Added new block during phi lifting scrollup2::@5(between scrollup2::@3 and scrollup2::@1) +Added new block during phi lifting scrollup2::@6(between scrollup2::@2 and scrollup2::@2) +Added new block during phi lifting scrollup1::@5(between scrollup1::@3 and scrollup1::@1) +Added new block during phi lifting scrollup1::@6(between scrollup1::@2 and scrollup1::@2) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @4 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@1 +Adding NOP phi() at start of main::@2 +Adding NOP phi() at start of scrollup3 +Adding NOP phi() at start of scrollup2 +Adding NOP phi() at start of scrollup1 +CALL GRAPH +Calls in [] to main:2 +Calls in [main] to scrollup1:5 scrollup2:7 scrollup3:9 + +Created 11 initial phi equivalence classes +Not coalescing [13] scrollup3::l2#4 ← scrollup3::l2#0 +Coalesced [22] scrollup3::l2#3 ← scrollup3::line#1 +Coalesced [23] scrollup3::l2#5 ← scrollup3::l2#1 +Coalesced [24] scrollup3::c#3 ← scrollup3::c#1 +Coalesced [27] scrollup2::line2#6 ← scrollup2::line2#3 +Coalesced [28] scrollup2::line1#6 ← scrollup2::line1#3 +Coalesced [38] scrollup2::line2#5 ← scrollup2::line2#1 +Coalesced [39] scrollup2::line1#5 ← scrollup2::line1#1 +Coalesced [40] scrollup2::l#5 ← scrollup2::l#1 +Coalesced (already) [41] scrollup2::line2#7 ← scrollup2::line2#1 +Coalesced (already) [42] scrollup2::line1#7 ← scrollup2::line1#1 +Coalesced [43] scrollup2::c#3 ← scrollup2::c#1 +Coalesced [55] scrollup1::line#5 ← scrollup1::line#1 +Coalesced [56] scrollup1::c#3 ← scrollup1::c#1 +Coalesced down to 9 phi equivalence classes +Culled Empty Block (label) scrollup3::@5 +Culled Empty Block (label) scrollup3::@6 +Culled Empty Block (label) scrollup2::@5 +Culled Empty Block (label) scrollup2::@6 +Culled Empty Block (label) scrollup1::@5 +Culled Empty Block (label) scrollup1::@6 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @4 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@1 +Adding NOP phi() at start of main::@2 +Adding NOP phi() at start of scrollup3 +Adding NOP phi() at start of scrollup2 +Adding NOP phi() at start of scrollup1 + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@4 +@4: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @4 + [3] phi() +main: scope:[main] from @4 + [4] phi() + [5] call scrollup1 + to:main::@1 +main::@1: scope:[main] from main + [6] phi() + [7] call scrollup2 + to:main::@2 +main::@2: scope:[main] from main::@1 + [8] phi() + [9] call scrollup3 + to:main::@return +main::@return: scope:[main] from main::@2 + [10] return + to:@return +scrollup3: scope:[scrollup3] from main::@2 + [11] phi() + to:scrollup3::@1 +scrollup3::@1: scope:[scrollup3] from scrollup3 scrollup3::@3 + [12] (word) scrollup3::l2#0 ← phi( scrollup3/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@3/(word) scrollup3::line#1 ) + [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 + to:scrollup3::@2 +scrollup3::@2: scope:[scrollup3] from scrollup3::@1 scrollup3::@2 + [14] (byte) scrollup3::c#2 ← phi( scrollup3::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup3::@2/(byte) scrollup3::c#1 ) + [14] (word) scrollup3::l2#2 ← phi( scrollup3::@1/(word~) scrollup3::l2#4 scrollup3::@2/(word) scrollup3::l2#1 ) + [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) + [16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 + [17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 + [18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 + to:scrollup3::@3 +scrollup3::@3: scope:[scrollup3] from scrollup3::@2 + [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 + [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 + to:scrollup3::@return +scrollup3::@return: scope:[scrollup3] from scrollup3::@3 + [21] return + to:@return +scrollup2: scope:[scrollup2] from main::@1 + [22] phi() + to:scrollup2::@1 +scrollup2::@1: scope:[scrollup2] from scrollup2 scrollup2::@3 + [23] (byte) scrollup2::l#4 ← phi( scrollup2/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@3/(byte) scrollup2::l#1 ) + [23] (byte*) scrollup2::line1#3 ← phi( scrollup2/(const byte*) screen#0 scrollup2::@3/(byte*) scrollup2::line1#1 ) + [23] (byte*) scrollup2::line2#3 ← phi( scrollup2/(const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 scrollup2::@3/(byte*) scrollup2::line2#1 ) + to:scrollup2::@2 +scrollup2::@2: scope:[scrollup2] from scrollup2::@1 scrollup2::@2 + [24] (byte) scrollup2::c#2 ← phi( scrollup2::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup2::@2/(byte) scrollup2::c#1 ) + [24] (byte*) scrollup2::line1#2 ← phi( scrollup2::@1/(byte*) scrollup2::line1#3 scrollup2::@2/(byte*) scrollup2::line1#1 ) + [24] (byte*) scrollup2::line2#2 ← phi( scrollup2::@1/(byte*) scrollup2::line2#3 scrollup2::@2/(byte*) scrollup2::line2#1 ) + [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) + [26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 + [27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 + [28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2 + [29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2 + to:scrollup2::@3 +scrollup2::@3: scope:[scrollup2] from scrollup2::@2 + [30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4 + [31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1 + to:scrollup2::@return +scrollup2::@return: scope:[scrollup2] from scrollup2::@3 + [32] return + to:@return +scrollup1: scope:[scrollup1] from main + [33] phi() + to:scrollup1::@1 +scrollup1::@1: scope:[scrollup1] from scrollup1 scrollup1::@3 + [34] (word) scrollup1::line#4 ← phi( scrollup1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@3/(word) scrollup1::line#1 ) + to:scrollup1::@2 +scrollup1::@2: scope:[scrollup1] from scrollup1::@1 scrollup1::@2 + [35] (byte) scrollup1::c#2 ← phi( scrollup1::@1/(byte/signed byte/word/signed word/dword/signed dword) 0 scrollup1::@2/(byte) scrollup1::c#1 ) + [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 + [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 + [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) + [39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 + [40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 + to:scrollup1::@3 +scrollup1::@3: scope:[scrollup1] from scrollup1::@2 + [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 + [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 + to:scrollup1::@return +scrollup1::@return: scope:[scrollup1] from scrollup1::@3 + [43] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte*) screen +(void()) scrollup1() +(word~) scrollup1::$0 101.0 +(word~) scrollup1::$2 202.0 +(byte) scrollup1::c +(byte) scrollup1::c#1 151.5 +(byte) scrollup1::c#2 101.0 +(word) scrollup1::line +(word) scrollup1::line#1 16.5 +(word) scrollup1::line#4 32.0 +(void()) scrollup2() +(byte) scrollup2::c +(byte) scrollup2::c#1 151.5 +(byte) scrollup2::c#2 50.5 +(byte) scrollup2::l +(byte) scrollup2::l#1 16.5 +(byte) scrollup2::l#4 3.142857142857143 +(byte*) scrollup2::line1 +(byte*) scrollup2::line1#1 35.5 +(byte*) scrollup2::line1#2 157.0 +(byte*) scrollup2::line1#3 22.0 +(byte*) scrollup2::line2 +(byte*) scrollup2::line2#1 42.599999999999994 +(byte*) scrollup2::line2#2 104.66666666666666 +(byte*) scrollup2::line2#3 22.0 +(void()) scrollup3() +(byte) scrollup3::c +(byte) scrollup3::c#1 151.5 +(byte) scrollup3::c#2 67.33333333333333 +(word) scrollup3::l2 +(word) scrollup3::l2#0 4.714285714285714 +(word) scrollup3::l2#1 67.33333333333333 +(word) scrollup3::l2#2 207.5 +(word~) scrollup3::l2#4 22.0 +(word) scrollup3::line +(word) scrollup3::line#1 16.5 + +Initial phi equivalence classes +[ scrollup3::l2#0 scrollup3::line#1 ] +[ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] +[ scrollup3::c#2 scrollup3::c#1 ] +[ scrollup2::l#4 scrollup2::l#1 ] +[ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] +[ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] +[ scrollup2::c#2 scrollup2::c#1 ] +[ scrollup1::line#4 scrollup1::line#1 ] +[ scrollup1::c#2 scrollup1::c#1 ] +Added variable scrollup1::$0 to zero page equivalence class [ scrollup1::$0 ] +Added variable scrollup1::$2 to zero page equivalence class [ scrollup1::$2 ] +Complete equivalence classes +[ scrollup3::l2#0 scrollup3::line#1 ] +[ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] +[ scrollup3::c#2 scrollup3::c#1 ] +[ scrollup2::l#4 scrollup2::l#1 ] +[ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] +[ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] +[ scrollup2::c#2 scrollup2::c#1 ] +[ scrollup1::line#4 scrollup1::line#1 ] +[ scrollup1::c#2 scrollup1::c#1 ] +[ scrollup1::$0 ] +[ scrollup1::$2 ] +Allocated zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 ] +Allocated zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] +Allocated zp ZP_BYTE:6 [ scrollup3::c#2 scrollup3::c#1 ] +Allocated zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Allocated zp ZP_WORD:8 [ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] +Allocated zp ZP_WORD:10 [ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] +Allocated zp ZP_BYTE:12 [ scrollup2::c#2 scrollup2::c#1 ] +Allocated zp ZP_WORD:13 [ scrollup1::line#4 scrollup1::line#1 ] +Allocated zp ZP_BYTE:15 [ scrollup1::c#2 scrollup1::c#1 ] +Allocated zp ZP_WORD:16 [ scrollup1::$0 ] +Allocated zp ZP_WORD:18 [ scrollup1::$2 ] + +INITIAL ASM +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label screen = $400 +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @4 [phi:@begin->@4] +b4_from_bbegin: + jmp b4 +//SEG4 @4 +b4: +//SEG5 [2] call main +//SEG6 [4] phi from @4 to main [phi:@4->main] +main_from_b4: + jsr main +//SEG7 [3] phi from @4 to @end [phi:@4->@end] +bend_from_b4: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + //SEG10 [5] call scrollup1 + //SEG11 [33] phi from main to scrollup1 [phi:main->scrollup1] + scrollup1_from_main: + jsr scrollup1 + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + jmp b1 + //SEG13 main::@1 + b1: + //SEG14 [7] call scrollup2 + //SEG15 [22] phi from main::@1 to scrollup2 [phi:main::@1->scrollup2] + scrollup2_from_b1: + jsr scrollup2 + //SEG16 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + b2_from_b1: + jmp b2 + //SEG17 main::@2 + b2: + //SEG18 [9] call scrollup3 + //SEG19 [11] phi from main::@2 to scrollup3 [phi:main::@2->scrollup3] + scrollup3_from_b2: + jsr scrollup3 + jmp breturn + //SEG20 main::@return + breturn: + //SEG21 [10] return + rts +} +//SEG22 scrollup3 +scrollup3: { + .label l2 = 2 + .label l2_1 = 4 + .label c = 6 + .label line = 2 + .label l2_2 = 4 + .label l2_4 = 4 + //SEG23 [12] phi from scrollup3 to scrollup3::@1 [phi:scrollup3->scrollup3::@1] + b1_from_scrollup3: + //SEG24 [12] phi (word) scrollup3::l2#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3->scrollup3::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta l2 + lda #>0 + sta l2+1 + jmp b1 + //SEG25 [12] phi from scrollup3::@3 to scrollup3::@1 [phi:scrollup3::@3->scrollup3::@1] + b1_from_b3: + //SEG26 [12] phi (word) scrollup3::l2#0 = (word) scrollup3::line#1 [phi:scrollup3::@3->scrollup3::@1#0] -- register_copy + jmp b1 + //SEG27 scrollup3::@1 + b1: + //SEG28 [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 -- vwuz1=vwuz2 + lda l2 + sta l2_4 + lda l2+1 + sta l2_4+1 + //SEG29 [14] phi from scrollup3::@1 to scrollup3::@2 [phi:scrollup3::@1->scrollup3::@2] + b2_from_b1: + //SEG30 [14] phi (byte) scrollup3::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3::@1->scrollup3::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG31 [14] phi (word) scrollup3::l2#2 = (word~) scrollup3::l2#4 [phi:scrollup3::@1->scrollup3::@2#1] -- register_copy + jmp b2 + //SEG32 [14] phi from scrollup3::@2 to scrollup3::@2 [phi:scrollup3::@2->scrollup3::@2] + b2_from_b2: + //SEG33 [14] phi (byte) scrollup3::c#2 = (byte) scrollup3::c#1 [phi:scrollup3::@2->scrollup3::@2#0] -- register_copy + //SEG34 [14] phi (word) scrollup3::l2#2 = (word) scrollup3::l2#1 [phi:scrollup3::@2->scrollup3::@2#1] -- register_copy + jmp b2 + //SEG35 scrollup3::@2 + b2: + //SEG36 [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1 + lda #screen + adc l2_2+1 + sta !a1++2 + lda #screen+$28 + adc l2_2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG37 [16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 -- vwuz1=_inc_vwuz1 + inc l2_1 + bne !+ + inc l2_1+1 + !: + //SEG38 [17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 -- vbuz1=_inc_vbuz1 + inc c + //SEG39 [18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 -- vbuz1_lt_vbuc1_then_la1 + lda c + cmp #$28 + bcc b2_from_b2 + jmp b3 + //SEG40 scrollup3::@3 + b3: + //SEG41 [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG42 [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 -- vwuz1_lt_vwuc1_then_la1 + lda line+1 + cmp #>$28*$18 + bcc b1_from_b3 + bne !+ + lda line + cmp #<$28*$18 + bcc b1_from_b3 + !: + jmp breturn + //SEG43 scrollup3::@return + breturn: + //SEG44 [21] return + rts +} +//SEG45 scrollup2 +scrollup2: { + .label line1 = $a + .label line2 = 8 + .label c = $c + .label l = 7 + //SEG46 [23] phi from scrollup2 to scrollup2::@1 [phi:scrollup2->scrollup2::@1] + b1_from_scrollup2: + //SEG47 [23] phi (byte) scrollup2::l#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2->scrollup2::@1#0] -- vbuz1=vbuc1 + lda #0 + sta l + //SEG48 [23] phi (byte*) scrollup2::line1#3 = (const byte*) screen#0 [phi:scrollup2->scrollup2::@1#1] -- pbuz1=pbuc1 + lda #screen + sta line1+1 + //SEG49 [23] phi (byte*) scrollup2::line2#3 = (const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 [phi:scrollup2->scrollup2::@1#2] -- pbuz1=pbuc1 + lda #screen+$28 + sta line2+1 + jmp b1 + //SEG50 [23] phi from scrollup2::@3 to scrollup2::@1 [phi:scrollup2::@3->scrollup2::@1] + b1_from_b3: + //SEG51 [23] phi (byte) scrollup2::l#4 = (byte) scrollup2::l#1 [phi:scrollup2::@3->scrollup2::@1#0] -- register_copy + //SEG52 [23] phi (byte*) scrollup2::line1#3 = (byte*) scrollup2::line1#1 [phi:scrollup2::@3->scrollup2::@1#1] -- register_copy + //SEG53 [23] phi (byte*) scrollup2::line2#3 = (byte*) scrollup2::line2#1 [phi:scrollup2::@3->scrollup2::@1#2] -- register_copy + jmp b1 + //SEG54 scrollup2::@1 + b1: + //SEG55 [24] phi from scrollup2::@1 to scrollup2::@2 [phi:scrollup2::@1->scrollup2::@2] + b2_from_b1: + //SEG56 [24] phi (byte) scrollup2::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2::@1->scrollup2::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG57 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#3 [phi:scrollup2::@1->scrollup2::@2#1] -- register_copy + //SEG58 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#3 [phi:scrollup2::@1->scrollup2::@2#2] -- register_copy + jmp b2 + //SEG59 [24] phi from scrollup2::@2 to scrollup2::@2 [phi:scrollup2::@2->scrollup2::@2] + b2_from_b2: + //SEG60 [24] phi (byte) scrollup2::c#2 = (byte) scrollup2::c#1 [phi:scrollup2::@2->scrollup2::@2#0] -- register_copy + //SEG61 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#1 [phi:scrollup2::@2->scrollup2::@2#1] -- register_copy + //SEG62 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#1 [phi:scrollup2::@2->scrollup2::@2#2] -- register_copy + jmp b2 + //SEG63 scrollup2::@2 + b2: + //SEG64 [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) -- _deref_pbuz1=_deref_pbuz2 + ldy #0 + lda (line2),y + ldy #0 + sta (line1),y + //SEG65 [26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 -- pbuz1=_inc_pbuz1 + inc line1 + bne !+ + inc line1+1 + !: + //SEG66 [27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 -- pbuz1=_inc_pbuz1 + inc line2 + bne !+ + inc line2+1 + !: + //SEG67 [28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2 -- vbuz1=_inc_vbuz1 + inc c + //SEG68 [29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2 -- vbuz1_neq_vbuc1_then_la1 + lda c + cmp #$28 + bne b2_from_b2 + jmp b3 + //SEG69 scrollup2::@3 + b3: + //SEG70 [30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4 -- vbuz1=_inc_vbuz1 + inc l + //SEG71 [31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1 -- vbuz1_neq_vbuc1_then_la1 + lda l + cmp #$18 + bne b1_from_b3 + jmp breturn + //SEG72 scrollup2::@return + breturn: + //SEG73 [32] return + rts +} +//SEG74 scrollup1 +scrollup1: { + .label _0 = $10 + .label _2 = $12 + .label c = $f + .label line = $d + //SEG75 [34] phi from scrollup1 to scrollup1::@1 [phi:scrollup1->scrollup1::@1] + b1_from_scrollup1: + //SEG76 [34] phi (word) scrollup1::line#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1->scrollup1::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta line + lda #>0 + sta line+1 + jmp b1 + //SEG77 [34] phi from scrollup1::@3 to scrollup1::@1 [phi:scrollup1::@3->scrollup1::@1] + b1_from_b3: + //SEG78 [34] phi (word) scrollup1::line#4 = (word) scrollup1::line#1 [phi:scrollup1::@3->scrollup1::@1#0] -- register_copy + jmp b1 + //SEG79 scrollup1::@1 + b1: + //SEG80 [35] phi from scrollup1::@1 to scrollup1::@2 [phi:scrollup1::@1->scrollup1::@2] + b2_from_b1: + //SEG81 [35] phi (byte) scrollup1::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1::@1->scrollup1::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c + jmp b2 + //SEG82 [35] phi from scrollup1::@2 to scrollup1::@2 [phi:scrollup1::@2->scrollup1::@2] + b2_from_b2: + //SEG83 [35] phi (byte) scrollup1::c#2 = (byte) scrollup1::c#1 [phi:scrollup1::@2->scrollup1::@2#0] -- register_copy + jmp b2 + //SEG84 scrollup1::@2 + b2: + //SEG85 [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuz3 + lda c + clc + adc line + sta _0 + lda #0 + adc line+1 + sta _0+1 + //SEG86 [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuz3 + lda c + clc + adc line + sta _2 + lda #0 + adc line+1 + sta _2+1 + //SEG87 [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz2 + lda #screen + adc _0+1 + sta !a1++2 + lda #screen+$28 + adc _2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG88 [39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 -- vbuz1=_inc_vbuz1 + inc c + //SEG89 [40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 -- vbuz1_lt_vbuc1_then_la1 + lda c + cmp #$28 + bcc b2_from_b2 + jmp b3 + //SEG90 scrollup1::@3 + b3: + //SEG91 [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG92 [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 -- vwuz1_lt_vwuc1_then_la1 + lda line+1 + cmp #>$28*$18 + bcc b1_from_b3 + bne !+ + lda line + cmp #<$28*$18 + bcc b1_from_b3 + !: + jmp breturn + //SEG93 scrollup1::@return + breturn: + //SEG94 [43] return + rts +} + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 [ scrollup3::l2#0 scrollup3::l2#4 ] ( main:2::scrollup3:9 [ scrollup3::l2#0 scrollup3::l2#4 ] ) always clobbers reg byte a +Statement [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) [ scrollup3::l2#0 scrollup3::l2#2 scrollup3::c#2 ] ( main:2::scrollup3:9 [ scrollup3::l2#0 scrollup3::l2#2 scrollup3::c#2 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:6 [ scrollup3::c#2 scrollup3::c#1 ] +Statement [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ scrollup3::line#1 ] ( main:2::scrollup3:9 [ scrollup3::line#1 ] ) always clobbers reg byte a +Statement [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 [ scrollup3::line#1 ] ( main:2::scrollup3:9 [ scrollup3::line#1 ] ) always clobbers reg byte a +Statement [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) [ scrollup2::l#4 scrollup2::line2#2 scrollup2::line1#2 scrollup2::c#2 ] ( main:2::scrollup2:7 [ scrollup2::l#4 scrollup2::line2#2 scrollup2::line1#2 scrollup2::c#2 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:12 [ scrollup2::c#2 scrollup2::c#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:12 [ scrollup2::c#2 scrollup2::c#1 ] +Statement [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:15 [ scrollup1::c#2 scrollup1::c#1 ] +Statement [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 scrollup1::$2 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 scrollup1::$2 ] ) always clobbers reg byte a +Statement [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) [ scrollup1::line#4 scrollup1::c#2 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 ] ) always clobbers reg byte a +Statement [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ scrollup1::line#1 ] ( main:2::scrollup1:5 [ scrollup1::line#1 ] ) always clobbers reg byte a +Statement [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 [ scrollup1::line#1 ] ( main:2::scrollup1:5 [ scrollup1::line#1 ] ) always clobbers reg byte a +Statement [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 [ scrollup3::l2#0 scrollup3::l2#4 ] ( main:2::scrollup3:9 [ scrollup3::l2#0 scrollup3::l2#4 ] ) always clobbers reg byte a +Statement [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) [ scrollup3::l2#0 scrollup3::l2#2 scrollup3::c#2 ] ( main:2::scrollup3:9 [ scrollup3::l2#0 scrollup3::l2#2 scrollup3::c#2 ] ) always clobbers reg byte a +Statement [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ scrollup3::line#1 ] ( main:2::scrollup3:9 [ scrollup3::line#1 ] ) always clobbers reg byte a +Statement [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 [ scrollup3::line#1 ] ( main:2::scrollup3:9 [ scrollup3::line#1 ] ) always clobbers reg byte a +Statement [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) [ scrollup2::l#4 scrollup2::line2#2 scrollup2::line1#2 scrollup2::c#2 ] ( main:2::scrollup2:7 [ scrollup2::l#4 scrollup2::line2#2 scrollup2::line1#2 scrollup2::c#2 ] ) always clobbers reg byte a reg byte y +Statement [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 ] ) always clobbers reg byte a +Statement [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 scrollup1::$2 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 scrollup1::$0 scrollup1::$2 ] ) always clobbers reg byte a +Statement [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) [ scrollup1::line#4 scrollup1::c#2 ] ( main:2::scrollup1:5 [ scrollup1::line#4 scrollup1::c#2 ] ) always clobbers reg byte a +Statement [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 [ scrollup1::line#1 ] ( main:2::scrollup1:5 [ scrollup1::line#1 ] ) always clobbers reg byte a +Statement [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 [ scrollup1::line#1 ] ( main:2::scrollup1:5 [ scrollup1::line#1 ] ) always clobbers reg byte a +Potential registers zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 ] : zp ZP_WORD:2 , +Potential registers zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] : zp ZP_WORD:4 , +Potential registers zp ZP_BYTE:6 [ scrollup3::c#2 scrollup3::c#1 ] : zp ZP_BYTE:6 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] : zp ZP_BYTE:7 , reg byte x , +Potential registers zp ZP_WORD:8 [ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] : zp ZP_WORD:8 , +Potential registers zp ZP_WORD:10 [ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] : zp ZP_WORD:10 , +Potential registers zp ZP_BYTE:12 [ scrollup2::c#2 scrollup2::c#1 ] : zp ZP_BYTE:12 , reg byte x , +Potential registers zp ZP_WORD:13 [ scrollup1::line#4 scrollup1::line#1 ] : zp ZP_WORD:13 , +Potential registers zp ZP_BYTE:15 [ scrollup1::c#2 scrollup1::c#1 ] : zp ZP_BYTE:15 , reg byte x , reg byte y , +Potential registers zp ZP_WORD:16 [ scrollup1::$0 ] : zp ZP_WORD:16 , +Potential registers zp ZP_WORD:18 [ scrollup1::$2 ] : zp ZP_WORD:18 , + +REGISTER UPLIFT SCOPES +Uplift Scope [scrollup2] 214.5: zp ZP_WORD:10 [ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] 202: zp ZP_BYTE:12 [ scrollup2::c#2 scrollup2::c#1 ] 169.27: zp ZP_WORD:8 [ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] 19.64: zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Uplift Scope [scrollup1] 252.5: zp ZP_BYTE:15 [ scrollup1::c#2 scrollup1::c#1 ] 202: zp ZP_WORD:18 [ scrollup1::$2 ] 101: zp ZP_WORD:16 [ scrollup1::$0 ] 48.5: zp ZP_WORD:13 [ scrollup1::line#4 scrollup1::line#1 ] +Uplift Scope [scrollup3] 296.83: zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] 218.83: zp ZP_BYTE:6 [ scrollup3::c#2 scrollup3::c#1 ] 21.21: zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 ] +Uplift Scope [main] +Uplift Scope [] + +Uplifting [scrollup2] best 27488 combination zp ZP_WORD:10 [ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] reg byte x [ scrollup2::c#2 scrollup2::c#1 ] zp ZP_WORD:8 [ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Uplifting [scrollup1] best 26388 combination reg byte x [ scrollup1::c#2 scrollup1::c#1 ] zp ZP_WORD:18 [ scrollup1::$2 ] zp ZP_WORD:16 [ scrollup1::$0 ] zp ZP_WORD:13 [ scrollup1::line#4 scrollup1::line#1 ] +Uplifting [scrollup3] best 25488 combination zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] reg byte x [ scrollup3::c#2 scrollup3::c#1 ] zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 ] +Uplifting [main] best 25488 combination +Uplifting [] best 25488 combination +Attempting to uplift remaining variables inzp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Uplifting [scrollup2] best 25488 combination zp ZP_BYTE:7 [ scrollup2::l#4 scrollup2::l#1 ] +Coalescing zero page register [ zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 ] ] with [ zp ZP_WORD:8 [ scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] ] +Coalescing zero page register [ zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 ] ] with [ zp ZP_WORD:13 [ scrollup1::line#4 scrollup1::line#1 ] ] +Coalescing zero page register [ zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 ] ] with [ zp ZP_WORD:10 [ scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] ] +Coalescing zero page register [ zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 ] ] with [ zp ZP_WORD:16 [ scrollup1::$0 ] ] +Allocated (was zp ZP_BYTE:7) zp ZP_BYTE:6 [ scrollup2::l#4 scrollup2::l#1 ] +Allocated (was zp ZP_WORD:18) zp ZP_WORD:7 [ scrollup1::$2 ] + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label screen = $400 +//SEG2 @begin +bbegin: +//SEG3 [1] phi from @begin to @4 [phi:@begin->@4] +b4_from_bbegin: + jmp b4 +//SEG4 @4 +b4: +//SEG5 [2] call main +//SEG6 [4] phi from @4 to main [phi:@4->main] +main_from_b4: + jsr main +//SEG7 [3] phi from @4 to @end [phi:@4->@end] +bend_from_b4: + jmp bend +//SEG8 @end +bend: +//SEG9 main +main: { + //SEG10 [5] call scrollup1 + //SEG11 [33] phi from main to scrollup1 [phi:main->scrollup1] + scrollup1_from_main: + jsr scrollup1 + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + jmp b1 + //SEG13 main::@1 + b1: + //SEG14 [7] call scrollup2 + //SEG15 [22] phi from main::@1 to scrollup2 [phi:main::@1->scrollup2] + scrollup2_from_b1: + jsr scrollup2 + //SEG16 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + b2_from_b1: + jmp b2 + //SEG17 main::@2 + b2: + //SEG18 [9] call scrollup3 + //SEG19 [11] phi from main::@2 to scrollup3 [phi:main::@2->scrollup3] + scrollup3_from_b2: + jsr scrollup3 + jmp breturn + //SEG20 main::@return + breturn: + //SEG21 [10] return + rts +} +//SEG22 scrollup3 +scrollup3: { + .label l2 = 2 + .label l2_1 = 4 + .label line = 2 + .label l2_2 = 4 + .label l2_4 = 4 + //SEG23 [12] phi from scrollup3 to scrollup3::@1 [phi:scrollup3->scrollup3::@1] + b1_from_scrollup3: + //SEG24 [12] phi (word) scrollup3::l2#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3->scrollup3::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta l2 + lda #>0 + sta l2+1 + jmp b1 + //SEG25 [12] phi from scrollup3::@3 to scrollup3::@1 [phi:scrollup3::@3->scrollup3::@1] + b1_from_b3: + //SEG26 [12] phi (word) scrollup3::l2#0 = (word) scrollup3::line#1 [phi:scrollup3::@3->scrollup3::@1#0] -- register_copy + jmp b1 + //SEG27 scrollup3::@1 + b1: + //SEG28 [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 -- vwuz1=vwuz2 + lda l2 + sta l2_4 + lda l2+1 + sta l2_4+1 + //SEG29 [14] phi from scrollup3::@1 to scrollup3::@2 [phi:scrollup3::@1->scrollup3::@2] + b2_from_b1: + //SEG30 [14] phi (byte) scrollup3::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3::@1->scrollup3::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG31 [14] phi (word) scrollup3::l2#2 = (word~) scrollup3::l2#4 [phi:scrollup3::@1->scrollup3::@2#1] -- register_copy + jmp b2 + //SEG32 [14] phi from scrollup3::@2 to scrollup3::@2 [phi:scrollup3::@2->scrollup3::@2] + b2_from_b2: + //SEG33 [14] phi (byte) scrollup3::c#2 = (byte) scrollup3::c#1 [phi:scrollup3::@2->scrollup3::@2#0] -- register_copy + //SEG34 [14] phi (word) scrollup3::l2#2 = (word) scrollup3::l2#1 [phi:scrollup3::@2->scrollup3::@2#1] -- register_copy + jmp b2 + //SEG35 scrollup3::@2 + b2: + //SEG36 [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1 + lda #screen + adc l2_2+1 + sta !a1++2 + lda #screen+$28 + adc l2_2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG37 [16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 -- vwuz1=_inc_vwuz1 + inc l2_1 + bne !+ + inc l2_1+1 + !: + //SEG38 [17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG39 [18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 -- vbuxx_lt_vbuc1_then_la1 + cpx #$28 + bcc b2_from_b2 + jmp b3 + //SEG40 scrollup3::@3 + b3: + //SEG41 [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG42 [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 -- vwuz1_lt_vwuc1_then_la1 + lda line+1 + cmp #>$28*$18 + bcc b1_from_b3 + bne !+ + lda line + cmp #<$28*$18 + bcc b1_from_b3 + !: + jmp breturn + //SEG43 scrollup3::@return + breturn: + //SEG44 [21] return + rts +} +//SEG45 scrollup2 +scrollup2: { + .label line1 = 4 + .label line2 = 2 + .label l = 6 + //SEG46 [23] phi from scrollup2 to scrollup2::@1 [phi:scrollup2->scrollup2::@1] + b1_from_scrollup2: + //SEG47 [23] phi (byte) scrollup2::l#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2->scrollup2::@1#0] -- vbuz1=vbuc1 + lda #0 + sta l + //SEG48 [23] phi (byte*) scrollup2::line1#3 = (const byte*) screen#0 [phi:scrollup2->scrollup2::@1#1] -- pbuz1=pbuc1 + lda #screen + sta line1+1 + //SEG49 [23] phi (byte*) scrollup2::line2#3 = (const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 [phi:scrollup2->scrollup2::@1#2] -- pbuz1=pbuc1 + lda #screen+$28 + sta line2+1 + jmp b1 + //SEG50 [23] phi from scrollup2::@3 to scrollup2::@1 [phi:scrollup2::@3->scrollup2::@1] + b1_from_b3: + //SEG51 [23] phi (byte) scrollup2::l#4 = (byte) scrollup2::l#1 [phi:scrollup2::@3->scrollup2::@1#0] -- register_copy + //SEG52 [23] phi (byte*) scrollup2::line1#3 = (byte*) scrollup2::line1#1 [phi:scrollup2::@3->scrollup2::@1#1] -- register_copy + //SEG53 [23] phi (byte*) scrollup2::line2#3 = (byte*) scrollup2::line2#1 [phi:scrollup2::@3->scrollup2::@1#2] -- register_copy + jmp b1 + //SEG54 scrollup2::@1 + b1: + //SEG55 [24] phi from scrollup2::@1 to scrollup2::@2 [phi:scrollup2::@1->scrollup2::@2] + b2_from_b1: + //SEG56 [24] phi (byte) scrollup2::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2::@1->scrollup2::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG57 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#3 [phi:scrollup2::@1->scrollup2::@2#1] -- register_copy + //SEG58 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#3 [phi:scrollup2::@1->scrollup2::@2#2] -- register_copy + jmp b2 + //SEG59 [24] phi from scrollup2::@2 to scrollup2::@2 [phi:scrollup2::@2->scrollup2::@2] + b2_from_b2: + //SEG60 [24] phi (byte) scrollup2::c#2 = (byte) scrollup2::c#1 [phi:scrollup2::@2->scrollup2::@2#0] -- register_copy + //SEG61 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#1 [phi:scrollup2::@2->scrollup2::@2#1] -- register_copy + //SEG62 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#1 [phi:scrollup2::@2->scrollup2::@2#2] -- register_copy + jmp b2 + //SEG63 scrollup2::@2 + b2: + //SEG64 [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) -- _deref_pbuz1=_deref_pbuz2 + ldy #0 + lda (line2),y + ldy #0 + sta (line1),y + //SEG65 [26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 -- pbuz1=_inc_pbuz1 + inc line1 + bne !+ + inc line1+1 + !: + //SEG66 [27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 -- pbuz1=_inc_pbuz1 + inc line2 + bne !+ + inc line2+1 + !: + //SEG67 [28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG68 [29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2 -- vbuxx_neq_vbuc1_then_la1 + cpx #$28 + bne b2_from_b2 + jmp b3 + //SEG69 scrollup2::@3 + b3: + //SEG70 [30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4 -- vbuz1=_inc_vbuz1 + inc l + //SEG71 [31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1 -- vbuz1_neq_vbuc1_then_la1 + lda l + cmp #$18 + bne b1_from_b3 + jmp breturn + //SEG72 scrollup2::@return + breturn: + //SEG73 [32] return + rts +} +//SEG74 scrollup1 +scrollup1: { + .label _0 = 4 + .label _2 = 7 + .label line = 2 + //SEG75 [34] phi from scrollup1 to scrollup1::@1 [phi:scrollup1->scrollup1::@1] + b1_from_scrollup1: + //SEG76 [34] phi (word) scrollup1::line#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1->scrollup1::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta line + lda #>0 + sta line+1 + jmp b1 + //SEG77 [34] phi from scrollup1::@3 to scrollup1::@1 [phi:scrollup1::@3->scrollup1::@1] + b1_from_b3: + //SEG78 [34] phi (word) scrollup1::line#4 = (word) scrollup1::line#1 [phi:scrollup1::@3->scrollup1::@1#0] -- register_copy + jmp b1 + //SEG79 scrollup1::@1 + b1: + //SEG80 [35] phi from scrollup1::@1 to scrollup1::@2 [phi:scrollup1::@1->scrollup1::@2] + b2_from_b1: + //SEG81 [35] phi (byte) scrollup1::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1::@1->scrollup1::@2#0] -- vbuxx=vbuc1 + ldx #0 + jmp b2 + //SEG82 [35] phi from scrollup1::@2 to scrollup1::@2 [phi:scrollup1::@2->scrollup1::@2] + b2_from_b2: + //SEG83 [35] phi (byte) scrollup1::c#2 = (byte) scrollup1::c#1 [phi:scrollup1::@2->scrollup1::@2#0] -- register_copy + jmp b2 + //SEG84 scrollup1::@2 + b2: + //SEG85 [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuxx + txa + clc + adc line + sta _0 + lda #0 + adc line+1 + sta _0+1 + //SEG86 [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuxx + txa + clc + adc line + sta _2 + lda #0 + adc line+1 + sta _2+1 + //SEG87 [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz2 + lda #screen + adc _0+1 + sta !a1++2 + lda #screen+$28 + adc _2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG88 [39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG89 [40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 -- vbuxx_lt_vbuc1_then_la1 + cpx #$28 + bcc b2_from_b2 + jmp b3 + //SEG90 scrollup1::@3 + b3: + //SEG91 [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG92 [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 -- vwuz1_lt_vwuc1_then_la1 + lda line+1 + cmp #>$28*$18 + bcc b1_from_b3 + bne !+ + lda line + cmp #<$28*$18 + bcc b1_from_b3 + !: + jmp breturn + //SEG93 scrollup1::@return + breturn: + //SEG94 [43] return + rts +} + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b4 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction lda #>0 +Removing instruction lda line+1 +Removing instruction ldy #0 +Removing instruction lda #>0 +Removing instruction lda line+1 +Succesful ASM optimization Pass5UnnecesaryLoadElimination +Replacing label b2_from_b2 with b2 +Replacing label b1_from_b3 with b1 +Replacing label b1_from_b3 with b1 +Replacing label b2_from_b2 with b2 +Replacing label b1_from_b3 with b1 +Replacing label b2_from_b2 with b2 +Replacing label b1_from_b3 with b1 +Replacing label b1_from_b3 with b1 +Removing instruction b4_from_bbegin: +Removing instruction b4: +Removing instruction main_from_b4: +Removing instruction bend_from_b4: +Removing instruction b1_from_main: +Removing instruction scrollup2_from_b1: +Removing instruction b2_from_b1: +Removing instruction scrollup3_from_b2: +Removing instruction b1_from_b3: +Removing instruction b2_from_b2: +Removing instruction b1_from_b3: +Removing instruction b2_from_b1: +Removing instruction b2_from_b2: +Removing instruction b1_from_b3: +Removing instruction b2_from_b1: +Removing instruction b2_from_b2: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction bend: +Removing instruction scrollup1_from_main: +Removing instruction b1: +Removing instruction b2: +Removing instruction breturn: +Removing instruction b1_from_scrollup3: +Removing instruction b2_from_b1: +Removing instruction b3: +Removing instruction breturn: +Removing instruction b1_from_scrollup2: +Removing instruction b3: +Removing instruction breturn: +Removing instruction b1_from_scrollup1: +Removing instruction b3: +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 +Removing instruction jmp b2 +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b1 +Removing instruction jmp b2 +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @4 +(label) @begin +(label) @end +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@return +(byte*) screen +(const byte*) screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024 +(void()) scrollup1() +(word~) scrollup1::$0 $0 zp ZP_WORD:4 101.0 +(word~) scrollup1::$2 $2 zp ZP_WORD:7 202.0 +(label) scrollup1::@1 +(label) scrollup1::@2 +(label) scrollup1::@3 +(label) scrollup1::@return +(byte) scrollup1::c +(byte) scrollup1::c#1 reg byte x 151.5 +(byte) scrollup1::c#2 reg byte x 101.0 +(word) scrollup1::line +(word) scrollup1::line#1 line zp ZP_WORD:2 16.5 +(word) scrollup1::line#4 line zp ZP_WORD:2 32.0 +(void()) scrollup2() +(label) scrollup2::@1 +(label) scrollup2::@2 +(label) scrollup2::@3 +(label) scrollup2::@return +(byte) scrollup2::c +(byte) scrollup2::c#1 reg byte x 151.5 +(byte) scrollup2::c#2 reg byte x 50.5 +(byte) scrollup2::l +(byte) scrollup2::l#1 l zp ZP_BYTE:6 16.5 +(byte) scrollup2::l#4 l zp ZP_BYTE:6 3.142857142857143 +(byte*) scrollup2::line1 +(byte*) scrollup2::line1#1 line1 zp ZP_WORD:4 35.5 +(byte*) scrollup2::line1#2 line1 zp ZP_WORD:4 157.0 +(byte*) scrollup2::line1#3 line1 zp ZP_WORD:4 22.0 +(byte*) scrollup2::line2 +(byte*) scrollup2::line2#1 line2 zp ZP_WORD:2 42.599999999999994 +(byte*) scrollup2::line2#2 line2 zp ZP_WORD:2 104.66666666666666 +(byte*) scrollup2::line2#3 line2 zp ZP_WORD:2 22.0 +(void()) scrollup3() +(label) scrollup3::@1 +(label) scrollup3::@2 +(label) scrollup3::@3 +(label) scrollup3::@return +(byte) scrollup3::c +(byte) scrollup3::c#1 reg byte x 151.5 +(byte) scrollup3::c#2 reg byte x 67.33333333333333 +(word) scrollup3::l2 +(word) scrollup3::l2#0 l2 zp ZP_WORD:2 4.714285714285714 +(word) scrollup3::l2#1 l2#1 zp ZP_WORD:4 67.33333333333333 +(word) scrollup3::l2#2 l2#2 zp ZP_WORD:4 207.5 +(word~) scrollup3::l2#4 l2#4 zp ZP_WORD:4 22.0 +(word) scrollup3::line +(word) scrollup3::line#1 line zp ZP_WORD:2 16.5 + +zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 scrollup1::line#4 scrollup1::line#1 ] +zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 scrollup1::$0 ] +reg byte x [ scrollup3::c#2 scrollup3::c#1 ] +zp ZP_BYTE:6 [ scrollup2::l#4 scrollup2::l#1 ] +reg byte x [ scrollup2::c#2 scrollup2::c#1 ] +reg byte x [ scrollup1::c#2 scrollup1::c#1 ] +zp ZP_WORD:7 [ scrollup1::$2 ] + + +FINAL ASSEMBLER +Score: 22197 + +//SEG0 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG1 Global Constants & labels + .label screen = $400 +//SEG2 @begin +//SEG3 [1] phi from @begin to @4 [phi:@begin->@4] +//SEG4 @4 +//SEG5 [2] call main +//SEG6 [4] phi from @4 to main [phi:@4->main] +//SEG7 [3] phi from @4 to @end [phi:@4->@end] +//SEG8 @end +//SEG9 main +main: { + //SEG10 [5] call scrollup1 + //SEG11 [33] phi from main to scrollup1 [phi:main->scrollup1] + jsr scrollup1 + //SEG12 [6] phi from main to main::@1 [phi:main->main::@1] + //SEG13 main::@1 + //SEG14 [7] call scrollup2 + //SEG15 [22] phi from main::@1 to scrollup2 [phi:main::@1->scrollup2] + jsr scrollup2 + //SEG16 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + //SEG17 main::@2 + //SEG18 [9] call scrollup3 + //SEG19 [11] phi from main::@2 to scrollup3 [phi:main::@2->scrollup3] + jsr scrollup3 + //SEG20 main::@return + //SEG21 [10] return + rts +} +//SEG22 scrollup3 +scrollup3: { + .label l2 = 2 + .label l2_1 = 4 + .label line = 2 + .label l2_2 = 4 + .label l2_4 = 4 + //SEG23 [12] phi from scrollup3 to scrollup3::@1 [phi:scrollup3->scrollup3::@1] + //SEG24 [12] phi (word) scrollup3::l2#0 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3->scrollup3::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta l2 + sta l2+1 + //SEG25 [12] phi from scrollup3::@3 to scrollup3::@1 [phi:scrollup3::@3->scrollup3::@1] + //SEG26 [12] phi (word) scrollup3::l2#0 = (word) scrollup3::line#1 [phi:scrollup3::@3->scrollup3::@1#0] -- register_copy + //SEG27 scrollup3::@1 + b1: + //SEG28 [13] (word~) scrollup3::l2#4 ← (word) scrollup3::l2#0 -- vwuz1=vwuz2 + lda l2 + sta l2_4 + lda l2+1 + sta l2_4+1 + //SEG29 [14] phi from scrollup3::@1 to scrollup3::@2 [phi:scrollup3::@1->scrollup3::@2] + //SEG30 [14] phi (byte) scrollup3::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup3::@1->scrollup3::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG31 [14] phi (word) scrollup3::l2#2 = (word~) scrollup3::l2#4 [phi:scrollup3::@1->scrollup3::@2#1] -- register_copy + //SEG32 [14] phi from scrollup3::@2 to scrollup3::@2 [phi:scrollup3::@2->scrollup3::@2] + //SEG33 [14] phi (byte) scrollup3::c#2 = (byte) scrollup3::c#1 [phi:scrollup3::@2->scrollup3::@2#0] -- register_copy + //SEG34 [14] phi (word) scrollup3::l2#2 = (word) scrollup3::l2#1 [phi:scrollup3::@2->scrollup3::@2#1] -- register_copy + //SEG35 scrollup3::@2 + b2: + //SEG36 [15] *((const byte*) screen#0 + (word) scrollup3::l2#2) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word) scrollup3::l2#2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz1 + lda #screen + adc l2_2+1 + sta !a1++2 + lda #screen+$28 + adc l2_2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG37 [16] (word) scrollup3::l2#1 ← ++ (word) scrollup3::l2#2 -- vwuz1=_inc_vwuz1 + inc l2_1 + bne !+ + inc l2_1+1 + !: + //SEG38 [17] (byte) scrollup3::c#1 ← ++ (byte) scrollup3::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG39 [18] if((byte) scrollup3::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup3::@2 -- vbuxx_lt_vbuc1_then_la1 + cpx #$28 + bcc b2 + //SEG40 scrollup3::@3 + //SEG41 [19] (word) scrollup3::line#1 ← (word) scrollup3::l2#0 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG42 [20] if((word) scrollup3::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup3::@1 -- vwuz1_lt_vwuc1_then_la1 + cmp #>$28*$18 + bcc b1 + bne !+ + lda line + cmp #<$28*$18 + bcc b1 + !: + //SEG43 scrollup3::@return + //SEG44 [21] return + rts +} +//SEG45 scrollup2 +scrollup2: { + .label line1 = 4 + .label line2 = 2 + .label l = 6 + //SEG46 [23] phi from scrollup2 to scrollup2::@1 [phi:scrollup2->scrollup2::@1] + //SEG47 [23] phi (byte) scrollup2::l#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2->scrollup2::@1#0] -- vbuz1=vbuc1 + lda #0 + sta l + //SEG48 [23] phi (byte*) scrollup2::line1#3 = (const byte*) screen#0 [phi:scrollup2->scrollup2::@1#1] -- pbuz1=pbuc1 + lda #screen + sta line1+1 + //SEG49 [23] phi (byte*) scrollup2::line2#3 = (const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 [phi:scrollup2->scrollup2::@1#2] -- pbuz1=pbuc1 + lda #screen+$28 + sta line2+1 + //SEG50 [23] phi from scrollup2::@3 to scrollup2::@1 [phi:scrollup2::@3->scrollup2::@1] + //SEG51 [23] phi (byte) scrollup2::l#4 = (byte) scrollup2::l#1 [phi:scrollup2::@3->scrollup2::@1#0] -- register_copy + //SEG52 [23] phi (byte*) scrollup2::line1#3 = (byte*) scrollup2::line1#1 [phi:scrollup2::@3->scrollup2::@1#1] -- register_copy + //SEG53 [23] phi (byte*) scrollup2::line2#3 = (byte*) scrollup2::line2#1 [phi:scrollup2::@3->scrollup2::@1#2] -- register_copy + //SEG54 scrollup2::@1 + b1: + //SEG55 [24] phi from scrollup2::@1 to scrollup2::@2 [phi:scrollup2::@1->scrollup2::@2] + //SEG56 [24] phi (byte) scrollup2::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup2::@1->scrollup2::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG57 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#3 [phi:scrollup2::@1->scrollup2::@2#1] -- register_copy + //SEG58 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#3 [phi:scrollup2::@1->scrollup2::@2#2] -- register_copy + //SEG59 [24] phi from scrollup2::@2 to scrollup2::@2 [phi:scrollup2::@2->scrollup2::@2] + //SEG60 [24] phi (byte) scrollup2::c#2 = (byte) scrollup2::c#1 [phi:scrollup2::@2->scrollup2::@2#0] -- register_copy + //SEG61 [24] phi (byte*) scrollup2::line1#2 = (byte*) scrollup2::line1#1 [phi:scrollup2::@2->scrollup2::@2#1] -- register_copy + //SEG62 [24] phi (byte*) scrollup2::line2#2 = (byte*) scrollup2::line2#1 [phi:scrollup2::@2->scrollup2::@2#2] -- register_copy + //SEG63 scrollup2::@2 + b2: + //SEG64 [25] *((byte*) scrollup2::line1#2) ← *((byte*) scrollup2::line2#2) -- _deref_pbuz1=_deref_pbuz2 + ldy #0 + lda (line2),y + sta (line1),y + //SEG65 [26] (byte*) scrollup2::line1#1 ← ++ (byte*) scrollup2::line1#2 -- pbuz1=_inc_pbuz1 + inc line1 + bne !+ + inc line1+1 + !: + //SEG66 [27] (byte*) scrollup2::line2#1 ← ++ (byte*) scrollup2::line2#2 -- pbuz1=_inc_pbuz1 + inc line2 + bne !+ + inc line2+1 + !: + //SEG67 [28] (byte) scrollup2::c#1 ← ++ (byte) scrollup2::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG68 [29] if((byte) scrollup2::c#1!=(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup2::@2 -- vbuxx_neq_vbuc1_then_la1 + cpx #$28 + bne b2 + //SEG69 scrollup2::@3 + //SEG70 [30] (byte) scrollup2::l#1 ← ++ (byte) scrollup2::l#4 -- vbuz1=_inc_vbuz1 + inc l + //SEG71 [31] if((byte) scrollup2::l#1!=(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup2::@1 -- vbuz1_neq_vbuc1_then_la1 + lda l + cmp #$18 + bne b1 + //SEG72 scrollup2::@return + //SEG73 [32] return + rts +} +//SEG74 scrollup1 +scrollup1: { + .label _0 = 4 + .label _2 = 7 + .label line = 2 + //SEG75 [34] phi from scrollup1 to scrollup1::@1 [phi:scrollup1->scrollup1::@1] + //SEG76 [34] phi (word) scrollup1::line#4 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1->scrollup1::@1#0] -- vwuz1=vbuc1 + lda #<0 + sta line + sta line+1 + //SEG77 [34] phi from scrollup1::@3 to scrollup1::@1 [phi:scrollup1::@3->scrollup1::@1] + //SEG78 [34] phi (word) scrollup1::line#4 = (word) scrollup1::line#1 [phi:scrollup1::@3->scrollup1::@1#0] -- register_copy + //SEG79 scrollup1::@1 + b1: + //SEG80 [35] phi from scrollup1::@1 to scrollup1::@2 [phi:scrollup1::@1->scrollup1::@2] + //SEG81 [35] phi (byte) scrollup1::c#2 = (byte/signed byte/word/signed word/dword/signed dword) 0 [phi:scrollup1::@1->scrollup1::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG82 [35] phi from scrollup1::@2 to scrollup1::@2 [phi:scrollup1::@2->scrollup1::@2] + //SEG83 [35] phi (byte) scrollup1::c#2 = (byte) scrollup1::c#1 [phi:scrollup1::@2->scrollup1::@2#0] -- register_copy + //SEG84 scrollup1::@2 + b2: + //SEG85 [36] (word~) scrollup1::$0 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuxx + txa + clc + adc line + sta _0 + lda #0 + adc line+1 + sta _0+1 + //SEG86 [37] (word~) scrollup1::$2 ← (word) scrollup1::line#4 + (byte) scrollup1::c#2 -- vwuz1=vwuz2_plus_vbuxx + txa + clc + adc line + sta _2 + lda #0 + adc line+1 + sta _2+1 + //SEG87 [38] *((const byte*) screen#0 + (word~) scrollup1::$0) ← *((const byte*) screen#0+(byte/signed byte/word/signed word/dword/signed dword) 40 + (word~) scrollup1::$2) -- pbuc1_derefidx_vwuz1=pbuc2_derefidx_vwuz2 + lda #screen + adc _0+1 + sta !a1++2 + lda #screen+$28 + adc _2+1 + sta !a2++2 + !a2: + lda screen+$28 + !a1: + sta screen + //SEG88 [39] (byte) scrollup1::c#1 ← ++ (byte) scrollup1::c#2 -- vbuxx=_inc_vbuxx + inx + //SEG89 [40] if((byte) scrollup1::c#1<(byte/signed byte/word/signed word/dword/signed dword) 40) goto scrollup1::@2 -- vbuxx_lt_vbuc1_then_la1 + cpx #$28 + bcc b2 + //SEG90 scrollup1::@3 + //SEG91 [41] (word) scrollup1::line#1 ← (word) scrollup1::line#4 + (byte/signed byte/word/signed word/dword/signed dword) 40 -- vwuz1=vwuz1_plus_vbuc1 + clc + lda line + adc #<$28 + sta line + lda line+1 + adc #>$28 + sta line+1 + //SEG92 [42] if((word) scrollup1::line#1<(byte/signed byte/word/signed word/dword/signed dword) 40*(byte/signed byte/word/signed word/dword/signed dword) 24) goto scrollup1::@1 -- vwuz1_lt_vwuc1_then_la1 + cmp #>$28*$18 + bcc b1 + bne !+ + lda line + cmp #<$28*$18 + bcc b1 + !: + //SEG93 scrollup1::@return + //SEG94 [43] return + rts +} + diff --git a/src/test/ref/test-scroll-up.sym b/src/test/ref/test-scroll-up.sym new file mode 100644 index 000000000..3fff2e17c --- /dev/null +++ b/src/test/ref/test-scroll-up.sym @@ -0,0 +1,64 @@ +(label) @4 +(label) @begin +(label) @end +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@return +(byte*) screen +(const byte*) screen#0 screen = ((byte*))(word/signed word/dword/signed dword) 1024 +(void()) scrollup1() +(word~) scrollup1::$0 $0 zp ZP_WORD:4 101.0 +(word~) scrollup1::$2 $2 zp ZP_WORD:7 202.0 +(label) scrollup1::@1 +(label) scrollup1::@2 +(label) scrollup1::@3 +(label) scrollup1::@return +(byte) scrollup1::c +(byte) scrollup1::c#1 reg byte x 151.5 +(byte) scrollup1::c#2 reg byte x 101.0 +(word) scrollup1::line +(word) scrollup1::line#1 line zp ZP_WORD:2 16.5 +(word) scrollup1::line#4 line zp ZP_WORD:2 32.0 +(void()) scrollup2() +(label) scrollup2::@1 +(label) scrollup2::@2 +(label) scrollup2::@3 +(label) scrollup2::@return +(byte) scrollup2::c +(byte) scrollup2::c#1 reg byte x 151.5 +(byte) scrollup2::c#2 reg byte x 50.5 +(byte) scrollup2::l +(byte) scrollup2::l#1 l zp ZP_BYTE:6 16.5 +(byte) scrollup2::l#4 l zp ZP_BYTE:6 3.142857142857143 +(byte*) scrollup2::line1 +(byte*) scrollup2::line1#1 line1 zp ZP_WORD:4 35.5 +(byte*) scrollup2::line1#2 line1 zp ZP_WORD:4 157.0 +(byte*) scrollup2::line1#3 line1 zp ZP_WORD:4 22.0 +(byte*) scrollup2::line2 +(byte*) scrollup2::line2#1 line2 zp ZP_WORD:2 42.599999999999994 +(byte*) scrollup2::line2#2 line2 zp ZP_WORD:2 104.66666666666666 +(byte*) scrollup2::line2#3 line2 zp ZP_WORD:2 22.0 +(void()) scrollup3() +(label) scrollup3::@1 +(label) scrollup3::@2 +(label) scrollup3::@3 +(label) scrollup3::@return +(byte) scrollup3::c +(byte) scrollup3::c#1 reg byte x 151.5 +(byte) scrollup3::c#2 reg byte x 67.33333333333333 +(word) scrollup3::l2 +(word) scrollup3::l2#0 l2 zp ZP_WORD:2 4.714285714285714 +(word) scrollup3::l2#1 l2#1 zp ZP_WORD:4 67.33333333333333 +(word) scrollup3::l2#2 l2#2 zp ZP_WORD:4 207.5 +(word~) scrollup3::l2#4 l2#4 zp ZP_WORD:4 22.0 +(word) scrollup3::line +(word) scrollup3::line#1 line zp ZP_WORD:2 16.5 + +zp ZP_WORD:2 [ scrollup3::l2#0 scrollup3::line#1 scrollup2::line2#2 scrollup2::line2#3 scrollup2::line2#1 scrollup1::line#4 scrollup1::line#1 ] +zp ZP_WORD:4 [ scrollup3::l2#2 scrollup3::l2#4 scrollup3::l2#1 scrollup2::line1#2 scrollup2::line1#3 scrollup2::line1#1 scrollup1::$0 ] +reg byte x [ scrollup3::c#2 scrollup3::c#1 ] +zp ZP_BYTE:6 [ scrollup2::l#4 scrollup2::l#1 ] +reg byte x [ scrollup2::c#2 scrollup2::c#1 ] +reg byte x [ scrollup1::c#2 scrollup1::c#1 ] +zp ZP_WORD:7 [ scrollup1::$2 ]