diff --git a/src/main/fragment/vbuaa=vbuaa_bor_pbuz1_derefidx_vbuxx.asm b/src/main/fragment/vbuaa=vbuaa_bor_pbuz1_derefidx_vbuxx.asm new file mode 100644 index 000000000..86c6d07f2 --- /dev/null +++ b/src/main/fragment/vbuaa=vbuaa_bor_pbuz1_derefidx_vbuxx.asm @@ -0,0 +1,3 @@ +stx $ff +ldy $ff +ora ({z1}),y \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java index 357e7a389..d7e88fef8 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentTemplateSynthesisRule.java @@ -542,6 +542,12 @@ class AsmFragmentTemplateSynthesisRule { // Rewrite wv.z1=(word)_ror_4 to wv.z1=(word) synths.add(new AsmFragmentTemplateSynthesisRule("vw(.*)z1=(.*)_ror_4", rvalAa, null, "vw$1z1=$2", "lsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}\nlsr {z1}+1\nror {z1}", null, null)); + // Rewrite vbuaa=(byte)_rol_N to wbuz1=(byte) + synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_1", rvalAa, null, "vbuaa=$1", "asl", null, null)); + synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_2", rvalAa, null, "vbuaa=$1", "asl\nasl", null, null)); + synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_3", rvalAa, null, "vbuaa=$1", "asl\nasl\nasl", null, null)); + synths.add(new AsmFragmentTemplateSynthesisRule("vbuaa=(.*)_rol_4", rvalAa, null, "vbuaa=$1", "asl\nasl\nasl\nasl", null, null)); + // Rewrite multiple _derefidx_vbuc1 to use YY synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_derefidx_vbuc1(.*)_derefidx_vbuc1(.*)", rvalYy+"|"+ threeC1, "ldy #{c1}", "$1_derefidx_vbuyy$2_derefidx_vbuyy$3", null, mapC1)); diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 2abf48e71..dfb64a6c5 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -35,9 +35,14 @@ public class TestPrograms { public TestPrograms() { } + @Test + public void testFontHex() throws IOException, URISyntaxException { + compileAndCompare("font-hex"); + } + @Test public void testMemcpy0() throws IOException, URISyntaxException { - compileAndCompare("memcpy-0", log()); + compileAndCompare("memcpy-0"); } @Test diff --git a/src/test/kc/font-hex.kc b/src/test/kc/font-hex.kc new file mode 100644 index 000000000..31cf8d150 --- /dev/null +++ b/src/test/kc/font-hex.kc @@ -0,0 +1,135 @@ +// Creates a font where each char contains the number of the char (00-ff) + +import "c64" +import "string" + +byte* SCREEN = 0x0400; +byte* CHARSET = 0x2000; + +void main() { + *D018 = toD018(SCREEN, CHARSET); + + // Make charset from proto chars + byte* charset = CHARSET; + byte* proto_hi = FONT_HEX_PROTO; + for( byte c: 0..15 ) { + byte* proto_lo = FONT_HEX_PROTO; + for( byte c: 0..15 ) { + for( byte i: 0..4) { + charset[i] = proto_hi[i]<<3 | proto_lo[i]; + } + charset[5] = 0; + charset[6] = 0; + charset[7] = 0; + proto_lo += 5; + charset += 8; + } + proto_hi += 5; + } + + // Show all chars on screen + for (byte c: 0..255) { + SCREEN[c] = c; + } + +} + +// Bit patterns for symbols 0-f (3x5 pixels) +byte[] FONT_HEX_PROTO = { + // 0 + 0b010, + 0b101, + 0b101, + 0b101, + 0b010, + // 1 + 0b110, + 0b010, + 0b010, + 0b010, + 0b111, + // 2 + 0b110, + 0b001, + 0b010, + 0b100, + 0b111, + // 3 + 0b110, + 0b001, + 0b010, + 0b001, + 0b110, + // 4 + 0b101, + 0b101, + 0b111, + 0b001, + 0b001, + // 5 + 0b111, + 0b100, + 0b110, + 0b001, + 0b110, + // 6 + 0b011, + 0b100, + 0b110, + 0b101, + 0b010, + // 7 + 0b111, + 0b001, + 0b001, + 0b001, + 0b001, + // 8 + 0b010, + 0b101, + 0b010, + 0b101, + 0b010, + // 9 + 0b010, + 0b101, + 0b011, + 0b001, + 0b001, + // a + 0b010, + 0b101, + 0b111, + 0b101, + 0b101, + // b + 0b110, + 0b101, + 0b110, + 0b101, + 0b110, + // c + 0b011, + 0b100, + 0b100, + 0b100, + 0b011, + // d + 0b110, + 0b101, + 0b101, + 0b101, + 0b110, + // e + 0b111, + 0b100, + 0b111, + 0b100, + 0b111, + // f + 0b111, + 0b100, + 0b111, + 0b100, + 0b100 +}; diff --git a/src/test/ref/font-hex.asm b/src/test/ref/font-hex.asm new file mode 100644 index 000000000..8564efcb3 --- /dev/null +++ b/src/test/ref/font-hex.asm @@ -0,0 +1,90 @@ +// Creates a font where each char contains the number of the char (00-ff) +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .label D018 = $d018 + .label SCREEN = $400 + .label CHARSET = $2000 +main: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label proto_lo = 5 + .label charset = 7 + .label proto_hi = 2 + .label c = 4 + lda #toD0181_return + sta D018 + lda #0 + sta c + lda #CHARSET + sta charset+1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + b1: + ldx #0 + lda #FONT_HEX_PROTO + sta proto_lo+1 + b2: + ldy #0 + b3: + lda (proto_hi),y + asl + asl + asl + ora (proto_lo),y + sta (charset),y + iny + cpy #5 + bne b3 + lda #0 + ldy #5 + sta (charset),y + ldy #6 + sta (charset),y + ldy #7 + sta (charset),y + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + inx + cpx #$10 + bne b2 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + inc c + lda #$10 + cmp c + bne b1 + ldx #0 + // Show all chars on screen + b6: + txa + sta SCREEN,x + inx + cpx #0 + bne b6 + rts +} + // Bit patterns for symbols 0-f (3x5 pixels) + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4 diff --git a/src/test/ref/font-hex.cfg b/src/test/ref/font-hex.cfg new file mode 100644 index 000000000..446020dbd --- /dev/null +++ b/src/test/ref/font-hex.cfg @@ -0,0 +1,59 @@ +@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::toD0181 +main::toD0181: scope:[main] from main + [5] phi() + to:main::@7 +main::@7: scope:[main] from main::toD0181 + [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 + to:main::@1 +main::@1: scope:[main] from main::@5 main::@7 + [7] (byte) main::c#6 ← phi( main::@5/(byte) main::c#1 main::@7/(byte) 0 ) + [7] (byte*) main::charset#5 ← phi( main::@5/(byte*) main::charset#1 main::@7/(const byte*) CHARSET#0 ) + [7] (byte*) main::proto_hi#6 ← phi( main::@5/(byte*) main::proto_hi#1 main::@7/(const byte[]) FONT_HEX_PROTO#0 ) + to:main::@2 +main::@2: scope:[main] from main::@1 main::@4 + [8] (byte) main::c1#4 ← phi( main::@1/(byte) 0 main::@4/(byte) main::c1#1 ) + [8] (byte*) main::charset#4 ← phi( main::@1/(byte*) main::charset#5 main::@4/(byte*) main::charset#1 ) + [8] (byte*) main::proto_lo#4 ← phi( main::@1/(const byte[]) FONT_HEX_PROTO#0 main::@4/(byte*) main::proto_lo#1 ) + to:main::@3 +main::@3: scope:[main] from main::@2 main::@3 + [9] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@3/(byte) main::i#1 ) + [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 + [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) + [12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2 + [13] (byte) main::i#1 ← ++ (byte) main::i#2 + [14] if((byte) main::i#1!=(byte) 5) goto main::@3 + to:main::@4 +main::@4: scope:[main] from main::@3 + [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 + [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 + [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 + [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 + [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 + [20] (byte) main::c1#1 ← ++ (byte) main::c1#4 + [21] if((byte) main::c1#1!=(byte) $10) goto main::@2 + to:main::@5 +main::@5: scope:[main] from main::@4 + [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 + [23] (byte) main::c#1 ← ++ (byte) main::c#6 + [24] if((byte) main::c#1!=(byte) $10) goto main::@1 + to:main::@6 +main::@6: scope:[main] from main::@5 main::@6 + [25] (byte) main::c2#2 ← phi( main::@5/(byte) 0 main::@6/(byte) main::c2#1 ) + [26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 + [27] (byte) main::c2#1 ← ++ (byte) main::c2#2 + [28] if((byte) main::c2#1!=(byte) 0) goto main::@6 + to:main::@return +main::@return: scope:[main] from main::@6 + [29] return + to:@return diff --git a/src/test/ref/font-hex.log b/src/test/ref/font-hex.log new file mode 100644 index 000000000..e8a8d8941 --- /dev/null +++ b/src/test/ref/font-hex.log @@ -0,0 +1,1481 @@ +Resolved forward reference FONT_HEX_PROTO to (byte[]) FONT_HEX_PROTO +Resolved forward reference FONT_HEX_PROTO to (byte[]) FONT_HEX_PROTO +Adding pointer type conversion cast (byte*) PROCPORT_DDR in (byte*) PROCPORT_DDR ← (number) 0 +Adding pointer type conversion cast (byte*) PROCPORT in (byte*) PROCPORT ← (number) 1 +Adding pointer type conversion cast (byte*) CHARGEN in (byte*) CHARGEN ← (number) $d000 +Adding pointer type conversion cast (byte*) SPRITES_XPOS in (byte*) SPRITES_XPOS ← (number) $d000 +Adding pointer type conversion cast (byte*) SPRITES_YPOS in (byte*) SPRITES_YPOS ← (number) $d001 +Adding pointer type conversion cast (byte*) SPRITES_XMSB in (byte*) SPRITES_XMSB ← (number) $d010 +Adding pointer type conversion cast (byte*) RASTER in (byte*) RASTER ← (number) $d012 +Adding pointer type conversion cast (byte*) SPRITES_ENABLE in (byte*) SPRITES_ENABLE ← (number) $d015 +Adding pointer type conversion cast (byte*) SPRITES_EXPAND_Y in (byte*) SPRITES_EXPAND_Y ← (number) $d017 +Adding pointer type conversion cast (byte*) SPRITES_PRIORITY in (byte*) SPRITES_PRIORITY ← (number) $d01b +Adding pointer type conversion cast (byte*) SPRITES_MC in (byte*) SPRITES_MC ← (number) $d01c +Adding pointer type conversion cast (byte*) SPRITES_EXPAND_X in (byte*) SPRITES_EXPAND_X ← (number) $d01d +Adding pointer type conversion cast (byte*) BORDERCOL in (byte*) BORDERCOL ← (number) $d020 +Adding pointer type conversion cast (byte*) BGCOL in (byte*) BGCOL ← (number) $d021 +Adding pointer type conversion cast (byte*) BGCOL1 in (byte*) BGCOL1 ← (number) $d021 +Adding pointer type conversion cast (byte*) BGCOL2 in (byte*) BGCOL2 ← (number) $d022 +Adding pointer type conversion cast (byte*) BGCOL3 in (byte*) BGCOL3 ← (number) $d023 +Adding pointer type conversion cast (byte*) BGCOL4 in (byte*) BGCOL4 ← (number) $d024 +Adding pointer type conversion cast (byte*) SPRITES_MC1 in (byte*) SPRITES_MC1 ← (number) $d025 +Adding pointer type conversion cast (byte*) SPRITES_MC2 in (byte*) SPRITES_MC2 ← (number) $d026 +Adding pointer type conversion cast (byte*) SPRITES_COLS in (byte*) SPRITES_COLS ← (number) $d027 +Adding pointer type conversion cast (byte*) VIC_CONTROL in (byte*) VIC_CONTROL ← (number) $d011 +Adding pointer type conversion cast (byte*) D011 in (byte*) D011 ← (number) $d011 +Adding pointer type conversion cast (byte*) VIC_CONTROL2 in (byte*) VIC_CONTROL2 ← (number) $d016 +Adding pointer type conversion cast (byte*) D016 in (byte*) D016 ← (number) $d016 +Adding pointer type conversion cast (byte*) D018 in (byte*) D018 ← (number) $d018 +Adding pointer type conversion cast (byte*) VIC_MEMORY in (byte*) VIC_MEMORY ← (number) $d018 +Adding pointer type conversion cast (byte*) LIGHTPEN_X in (byte*) LIGHTPEN_X ← (number) $d013 +Adding pointer type conversion cast (byte*) LIGHTPEN_Y in (byte*) LIGHTPEN_Y ← (number) $d014 +Adding pointer type conversion cast (byte*) IRQ_STATUS in (byte*) IRQ_STATUS ← (number) $d019 +Adding pointer type conversion cast (byte*) IRQ_ENABLE in (byte*) IRQ_ENABLE ← (number) $d01a +Adding pointer type conversion cast (byte*) COLS in (byte*) COLS ← (number) $d800 +Adding pointer type conversion cast (byte*) CIA1_PORT_A in (byte*) CIA1_PORT_A ← (number) $dc00 +Adding pointer type conversion cast (byte*) CIA1_PORT_B in (byte*) CIA1_PORT_B ← (number) $dc01 +Adding pointer type conversion cast (byte*) CIA1_PORT_A_DDR in (byte*) CIA1_PORT_A_DDR ← (number) $dc02 +Adding pointer type conversion cast (byte*) CIA1_PORT_B_DDR in (byte*) CIA1_PORT_B_DDR ← (number) $dc03 +Adding pointer type conversion cast (byte*) CIA1_INTERRUPT in (byte*) CIA1_INTERRUPT ← (number) $dc0d +Adding pointer type conversion cast (byte*) CIA2_PORT_A in (byte*) CIA2_PORT_A ← (number) $dd00 +Adding pointer type conversion cast (byte*) CIA2_PORT_B in (byte*) CIA2_PORT_B ← (number) $dd01 +Adding pointer type conversion cast (byte*) CIA2_PORT_A_DDR in (byte*) CIA2_PORT_A_DDR ← (number) $dd02 +Adding pointer type conversion cast (byte*) CIA2_PORT_B_DDR in (byte*) CIA2_PORT_B_DDR ← (number) $dd03 +Adding pointer type conversion cast (byte*) CIA2_INTERRUPT in (byte*) CIA2_INTERRUPT ← (number) $dd0d +Adding pointer type conversion cast (void()**) KERNEL_IRQ in (void()**) KERNEL_IRQ ← (number) $314 +Adding pointer type conversion cast (void()**) HARDWARE_IRQ in (void()**) HARDWARE_IRQ ← (number) $fffe +Adding pointer type conversion cast to void pointer (byte*) memcpy::source in (byte*) memcpy::src ← (void*) memcpy::source +Adding pointer type conversion cast to void pointer (byte*) memcpy::destination in (byte*) memcpy::dst ← (void*) memcpy::destination +Adding pointer type conversion cast to void pointer (byte*) memset::str in (byte*) memset::dst ← (void*) memset::str +Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $400 +Adding pointer type conversion cast (byte*) CHARSET in (byte*) CHARSET ← (number) $2000 +Warning! Adding boolean cast to non-boolean condition *((byte*) strcpy::src) +Identified constant variable (byte*) SCREEN +Identified constant variable (byte*) CHARSET +Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx +Inlined call (byte~) main::$0 ← call toD018 (byte*) SCREEN (byte*) CHARSET +Culled Empty Block (label) @1 +Culled Empty Block (label) @2 +Culled Empty Block (label) @3 +Culled Empty Block (label) @4 +Culled Empty Block (label) @5 +Culled Empty Block (label) @6 +Culled Empty Block (label) @7 +Culled Empty Block (label) main::toD0181_@1 +Culled Empty Block (label) main::@8 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) D018#0 ← ((byte*)) (number) $d018 + to:@8 +@8: scope:[] from @begin + (byte*) SCREEN#0 ← ((byte*)) (number) $400 + (byte*) CHARSET#0 ← ((byte*)) (number) $2000 + to:@9 +main: scope:[main] from @9 + (byte*) main::toD0181_screen#0 ← (byte*) SCREEN#0 + (byte*) main::toD0181_gfx#0 ← (byte*) CHARSET#0 + to:main::toD0181 +main::toD0181: scope:[main] from main + (byte*) main::toD0181_gfx#1 ← phi( main/(byte*) main::toD0181_gfx#0 ) + (byte*) main::toD0181_screen#1 ← phi( main/(byte*) main::toD0181_screen#0 ) + (word~) main::toD0181_$0#0 ← ((word)) (byte*) main::toD0181_screen#1 + (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (number) $3fff + (number~) main::toD0181_$2#0 ← (number~) main::toD0181_$1#0 * (number) 4 + (number~) main::toD0181_$3#0 ← > (number~) main::toD0181_$2#0 + (word~) main::toD0181_$4#0 ← ((word)) (byte*) main::toD0181_gfx#1 + (byte~) main::toD0181_$5#0 ← > (word~) main::toD0181_$4#0 + (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (number) 4 + (number~) main::toD0181_$7#0 ← (number~) main::toD0181_$6#0 & (number) $f + (number~) main::toD0181_$8#0 ← (number~) main::toD0181_$3#0 | (number~) main::toD0181_$7#0 + (byte) main::toD0181_return#0 ← (number~) main::toD0181_$8#0 + to:main::toD0181_@return +main::toD0181_@return: scope:[main] from main::toD0181 + (byte) main::toD0181_return#2 ← phi( main::toD0181/(byte) main::toD0181_return#0 ) + (byte) main::toD0181_return#1 ← (byte) main::toD0181_return#2 + to:main::@9 +main::@9: scope:[main] from main::toD0181_@return + (byte) main::toD0181_return#3 ← phi( main::toD0181_@return/(byte) main::toD0181_return#1 ) + (byte~) main::$0 ← (byte) main::toD0181_return#3 + *((byte*) D018#0) ← (byte~) main::$0 + (byte*) main::charset#0 ← (byte*) CHARSET#0 + (byte*) main::proto_hi#0 ← (byte[]) FONT_HEX_PROTO#0 + (byte) main::c#0 ← (byte) 0 + to:main::@1 +main::@1: scope:[main] from main::@5 main::@9 + (byte) main::c#6 ← phi( main::@5/(byte) main::c#1 main::@9/(byte) main::c#0 ) + (byte*) main::charset#5 ← phi( main::@5/(byte*) main::charset#6 main::@9/(byte*) main::charset#0 ) + (byte*) main::proto_hi#6 ← phi( main::@5/(byte*) main::proto_hi#1 main::@9/(byte*) main::proto_hi#0 ) + (byte*) main::proto_lo#0 ← (byte[]) FONT_HEX_PROTO#0 + (byte) main::c1#0 ← (byte) 0 + to:main::@2 +main::@2: scope:[main] from main::@1 main::@4 + (byte) main::c#5 ← phi( main::@1/(byte) main::c#6 main::@4/(byte) main::c#3 ) + (byte) main::c1#4 ← phi( main::@1/(byte) main::c1#0 main::@4/(byte) main::c1#1 ) + (byte*) main::charset#4 ← phi( main::@1/(byte*) main::charset#5 main::@4/(byte*) main::charset#1 ) + (byte*) main::proto_lo#4 ← phi( main::@1/(byte*) main::proto_lo#0 main::@4/(byte*) main::proto_lo#1 ) + (byte*) main::proto_hi#4 ← phi( main::@1/(byte*) main::proto_hi#6 main::@4/(byte*) main::proto_hi#5 ) + (byte) main::i#0 ← (byte) 0 + to:main::@3 +main::@3: scope:[main] from main::@2 main::@3 + (byte) main::c#4 ← phi( main::@2/(byte) main::c#5 main::@3/(byte) main::c#4 ) + (byte) main::c1#3 ← phi( main::@2/(byte) main::c1#4 main::@3/(byte) main::c1#3 ) + (byte*) main::charset#2 ← phi( main::@2/(byte*) main::charset#4 main::@3/(byte*) main::charset#2 ) + (byte*) main::proto_lo#2 ← phi( main::@2/(byte*) main::proto_lo#4 main::@3/(byte*) main::proto_lo#2 ) + (byte) main::i#2 ← phi( main::@2/(byte) main::i#0 main::@3/(byte) main::i#1 ) + (byte*) main::proto_hi#2 ← phi( main::@2/(byte*) main::proto_hi#4 main::@3/(byte*) main::proto_hi#2 ) + (byte~) main::$1 ← *((byte*) main::proto_hi#2 + (byte) main::i#2) << (number) 3 + (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#2 + (byte) main::i#2) + *((byte*) main::charset#2 + (byte) main::i#2) ← (byte~) main::$2 + (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,4) + (bool~) main::$3 ← (byte) main::i#1 != rangelast(0,4) + if((bool~) main::$3) goto main::@3 + to:main::@4 +main::@4: scope:[main] from main::@3 + (byte) main::c#3 ← phi( main::@3/(byte) main::c#4 ) + (byte*) main::proto_hi#5 ← phi( main::@3/(byte*) main::proto_hi#2 ) + (byte) main::c1#2 ← phi( main::@3/(byte) main::c1#3 ) + (byte*) main::proto_lo#3 ← phi( main::@3/(byte*) main::proto_lo#2 ) + (byte*) main::charset#3 ← phi( main::@3/(byte*) main::charset#2 ) + *((byte*) main::charset#3 + (number) 5) ← (number) 0 + *((byte*) main::charset#3 + (number) 6) ← (number) 0 + *((byte*) main::charset#3 + (number) 7) ← (number) 0 + (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#3 + (number) 5 + (byte*) main::charset#1 ← (byte*) main::charset#3 + (number) 8 + (byte) main::c1#1 ← (byte) main::c1#2 + rangenext(0,$f) + (bool~) main::$4 ← (byte) main::c1#1 != rangelast(0,$f) + if((bool~) main::$4) goto main::@2 + to:main::@5 +main::@5: scope:[main] from main::@4 + (byte*) main::charset#6 ← phi( main::@4/(byte*) main::charset#1 ) + (byte) main::c#2 ← phi( main::@4/(byte) main::c#3 ) + (byte*) main::proto_hi#3 ← phi( main::@4/(byte*) main::proto_hi#5 ) + (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#3 + (number) 5 + (byte) main::c#1 ← (byte) main::c#2 + rangenext(0,$f) + (bool~) main::$5 ← (byte) main::c#1 != rangelast(0,$f) + if((bool~) main::$5) goto main::@1 + to:main::@6 +main::@6: scope:[main] from main::@5 + (byte) main::c2#0 ← (byte) 0 + to:main::@7 +main::@7: scope:[main] from main::@6 main::@7 + (byte) main::c2#2 ← phi( main::@6/(byte) main::c2#0 main::@7/(byte) main::c2#1 ) + *((byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 + (byte) main::c2#1 ← (byte) main::c2#2 + rangenext(0,$ff) + (bool~) main::$6 ← (byte) main::c2#1 != rangelast(0,$ff) + if((bool~) main::$6) goto main::@7 + to:main::@return +main::@return: scope:[main] from main::@7 + return + to:@return +@9: scope:[] from @8 + (byte[]) FONT_HEX_PROTO#0 ← { (number) 2, (number) 5, (number) 5, (number) 5, (number) 2, (number) 6, (number) 2, (number) 2, (number) 2, (number) 7, (number) 6, (number) 1, (number) 2, (number) 4, (number) 7, (number) 6, (number) 1, (number) 2, (number) 1, (number) 6, (number) 5, (number) 5, (number) 7, (number) 1, (number) 1, (number) 7, (number) 4, (number) 6, (number) 1, (number) 6, (number) 3, (number) 4, (number) 6, (number) 5, (number) 2, (number) 7, (number) 1, (number) 1, (number) 1, (number) 1, (number) 2, (number) 5, (number) 2, (number) 5, (number) 2, (number) 2, (number) 5, (number) 3, (number) 1, (number) 1, (number) 2, (number) 5, (number) 7, (number) 5, (number) 5, (number) 6, (number) 5, (number) 6, (number) 5, (number) 6, (number) 3, (number) 4, (number) 4, (number) 4, (number) 3, (number) 6, (number) 5, (number) 5, (number) 5, (number) 6, (number) 7, (number) 4, (number) 7, (number) 4, (number) 7, (number) 7, (number) 4, (number) 7, (number) 4, (number) 4 } + call main + to:@10 +@10: scope:[] from @9 + to:@end +@end: scope:[] from @10 + +SYMBOL TABLE SSA +(label) @10 +(label) @8 +(label) @9 +(label) @begin +(label) @end +(byte*) CHARSET +(byte*) CHARSET#0 +(byte*) D018 +(byte*) D018#0 +(byte[]) FONT_HEX_PROTO +(byte[]) FONT_HEX_PROTO#0 +(byte*) SCREEN +(byte*) SCREEN#0 +(void()) main() +(byte~) main::$0 +(byte~) main::$1 +(byte~) main::$2 +(bool~) main::$3 +(bool~) main::$4 +(bool~) main::$5 +(bool~) main::$6 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@9 +(label) main::@return +(byte) main::c +(byte) main::c#0 +(byte) main::c#1 +(byte) main::c#2 +(byte) main::c#3 +(byte) main::c#4 +(byte) main::c#5 +(byte) main::c#6 +(byte) main::c1 +(byte) main::c1#0 +(byte) main::c1#1 +(byte) main::c1#2 +(byte) main::c1#3 +(byte) main::c1#4 +(byte) main::c2 +(byte) main::c2#0 +(byte) main::c2#1 +(byte) main::c2#2 +(byte*) main::charset +(byte*) main::charset#0 +(byte*) main::charset#1 +(byte*) main::charset#2 +(byte*) main::charset#3 +(byte*) main::charset#4 +(byte*) main::charset#5 +(byte*) main::charset#6 +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte*) main::proto_hi +(byte*) main::proto_hi#0 +(byte*) main::proto_hi#1 +(byte*) main::proto_hi#2 +(byte*) main::proto_hi#3 +(byte*) main::proto_hi#4 +(byte*) main::proto_hi#5 +(byte*) main::proto_hi#6 +(byte*) main::proto_lo +(byte*) main::proto_lo#0 +(byte*) main::proto_lo#1 +(byte*) main::proto_lo#2 +(byte*) main::proto_lo#3 +(byte*) main::proto_lo#4 +(label) main::toD0181 +(word~) main::toD0181_$0 +(word~) main::toD0181_$0#0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$1#0 +(number~) main::toD0181_$2 +(number~) main::toD0181_$2#0 +(number~) main::toD0181_$3 +(number~) main::toD0181_$3#0 +(word~) main::toD0181_$4 +(word~) main::toD0181_$4#0 +(byte~) main::toD0181_$5 +(byte~) main::toD0181_$5#0 +(number~) main::toD0181_$6 +(number~) main::toD0181_$6#0 +(number~) main::toD0181_$7 +(number~) main::toD0181_$7#0 +(number~) main::toD0181_$8 +(number~) main::toD0181_$8#0 +(label) main::toD0181_@return +(byte*) main::toD0181_gfx +(byte*) main::toD0181_gfx#0 +(byte*) main::toD0181_gfx#1 +(byte) main::toD0181_return +(byte) main::toD0181_return#0 +(byte) main::toD0181_return#1 +(byte) main::toD0181_return#2 +(byte) main::toD0181_return#3 +(byte*) main::toD0181_screen +(byte*) main::toD0181_screen#0 +(byte*) main::toD0181_screen#1 + +Adding number conversion cast (unumber) $3fff in (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (number) $3fff +Adding number conversion cast (unumber) main::toD0181_$1#0 in (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (unumber)(number) $3fff +Adding number conversion cast (unumber) 4 in (number~) main::toD0181_$2#0 ← (unumber~) main::toD0181_$1#0 * (number) 4 +Adding number conversion cast (unumber) main::toD0181_$2#0 in (number~) main::toD0181_$2#0 ← (unumber~) main::toD0181_$1#0 * (unumber)(number) 4 +Adding number conversion cast (unumber) main::toD0181_$3#0 in (number~) main::toD0181_$3#0 ← > (unumber~) main::toD0181_$2#0 +Adding number conversion cast (unumber) 4 in (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (number) 4 +Adding number conversion cast (unumber) main::toD0181_$6#0 in (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (unumber)(number) 4 +Adding number conversion cast (unumber) $f in (number~) main::toD0181_$7#0 ← (unumber~) main::toD0181_$6#0 & (number) $f +Adding number conversion cast (unumber) main::toD0181_$7#0 in (number~) main::toD0181_$7#0 ← (unumber~) main::toD0181_$6#0 & (unumber)(number) $f +Adding number conversion cast (unumber) main::toD0181_$8#0 in (number~) main::toD0181_$8#0 ← (unumber~) main::toD0181_$3#0 | (unumber~) main::toD0181_$7#0 +Adding number conversion cast (unumber) 3 in (byte~) main::$1 ← *((byte*) main::proto_hi#2 + (byte) main::i#2) << (number) 3 +Adding number conversion cast (unumber) 0 in *((byte*) main::charset#3 + (number) 5) ← (number) 0 +Adding number conversion cast (unumber) 5 in *((byte*) main::charset#3 + (number) 5) ← ((unumber)) (number) 0 +Adding number conversion cast (unumber) 0 in *((byte*) main::charset#3 + (number) 6) ← (number) 0 +Adding number conversion cast (unumber) 6 in *((byte*) main::charset#3 + (number) 6) ← ((unumber)) (number) 0 +Adding number conversion cast (unumber) 0 in *((byte*) main::charset#3 + (number) 7) ← (number) 0 +Adding number conversion cast (unumber) 7 in *((byte*) main::charset#3 + (number) 7) ← ((unumber)) (number) 0 +Adding number conversion cast (unumber) 5 in (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#3 + (number) 5 +Adding number conversion cast (unumber) 8 in (byte*) main::charset#1 ← (byte*) main::charset#3 + (number) 8 +Adding number conversion cast (unumber) 5 in (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#3 + (number) 5 +Successful SSA optimization PassNAddNumberTypeConversions +Adding number conversion cast (byte) to elements in (byte[]) FONT_HEX_PROTO#0 ← { (byte)(number) 2, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 2, (byte)(number) 6, (byte)(number) 2, (byte)(number) 2, (byte)(number) 2, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 4, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 1, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 1, (byte)(number) 6, (byte)(number) 3, (byte)(number) 4, (byte)(number) 6, (byte)(number) 5, (byte)(number) 2, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 2, (byte)(number) 5, (byte)(number) 3, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 7, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 3, (byte)(number) 4, (byte)(number) 4, (byte)(number) 4, (byte)(number) 3, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 7, (byte)(number) 4, (byte)(number) 7, (byte)(number) 4, (byte)(number) 7, (byte)(number) 7, (byte)(number) 4, (byte)(number) 7, (byte)(number) 4, (byte)(number) 4 } +Successful SSA optimization PassNAddArrayNumberTypeConversions +Inlining cast (byte*) D018#0 ← (byte*)(number) $d018 +Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $400 +Inlining cast (byte*) CHARSET#0 ← (byte*)(number) $2000 +Inlining cast (word~) main::toD0181_$0#0 ← (word)(byte*) main::toD0181_screen#1 +Inlining cast (word~) main::toD0181_$4#0 ← (word)(byte*) main::toD0181_gfx#1 +Inlining cast *((byte*) main::charset#3 + (unumber)(number) 5) ← (unumber)(number) 0 +Inlining cast *((byte*) main::charset#3 + (unumber)(number) 6) ← (unumber)(number) 0 +Inlining cast *((byte*) main::charset#3 + (unumber)(number) 7) ← (unumber)(number) 0 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 53272 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant pointer cast (byte*) 8192 +Simplifying constant integer cast $3fff +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Simplifying constant integer cast $f +Simplifying constant integer cast 3 +Simplifying constant integer cast 0 +Simplifying constant integer cast 5 +Simplifying constant integer cast 0 +Simplifying constant integer cast 6 +Simplifying constant integer cast 0 +Simplifying constant integer cast 7 +Simplifying constant integer cast 5 +Simplifying constant integer cast 8 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 6 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 7 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 1 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 7 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 6 +Simplifying constant integer cast 3 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 7 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 3 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 7 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 3 +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Simplifying constant integer cast 3 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (word) $3fff +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) $f +Finalized unsigned number type (byte) 3 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 6 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 7 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) 8 +Finalized unsigned number type (byte) 5 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to word in (unumber~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (word) $3fff +Inferred type updated to word in (unumber~) main::toD0181_$2#0 ← (word~) main::toD0181_$1#0 * (byte) 4 +Inferred type updated to byte in (unumber~) main::toD0181_$3#0 ← > (word~) main::toD0181_$2#0 +Inferred type updated to byte in (unumber~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (byte) 4 +Inferred type updated to byte in (unumber~) main::toD0181_$7#0 ← (byte~) main::toD0181_$6#0 & (byte) $f +Inferred type updated to byte in (unumber~) main::toD0181_$8#0 ← (byte~) main::toD0181_$3#0 | (byte~) main::toD0181_$7#0 +Alias (byte*) main::toD0181_screen#0 = (byte*) main::toD0181_screen#1 +Alias (byte*) main::toD0181_gfx#0 = (byte*) main::toD0181_gfx#1 +Alias (byte) main::toD0181_return#0 = (byte~) main::toD0181_$8#0 (byte) main::toD0181_return#2 (byte) main::toD0181_return#1 (byte) main::toD0181_return#3 (byte~) main::$0 +Alias (byte*) main::charset#2 = (byte*) main::charset#3 +Alias (byte*) main::proto_lo#2 = (byte*) main::proto_lo#3 +Alias (byte) main::c1#2 = (byte) main::c1#3 +Alias (byte*) main::proto_hi#2 = (byte*) main::proto_hi#5 (byte*) main::proto_hi#3 +Alias (byte) main::c#2 = (byte) main::c#3 (byte) main::c#4 +Alias (byte*) main::charset#1 = (byte*) main::charset#6 +Successful SSA optimization Pass2AliasElimination +Self Phi Eliminated (byte*) main::proto_hi#2 +Self Phi Eliminated (byte*) main::proto_lo#2 +Self Phi Eliminated (byte*) main::charset#2 +Self Phi Eliminated (byte) main::c1#2 +Self Phi Eliminated (byte) main::c#2 +Successful SSA optimization Pass2SelfPhiElimination +Identical Phi Values (byte*) main::proto_hi#2 (byte*) main::proto_hi#4 +Identical Phi Values (byte*) main::proto_lo#2 (byte*) main::proto_lo#4 +Identical Phi Values (byte*) main::charset#2 (byte*) main::charset#4 +Identical Phi Values (byte) main::c1#2 (byte) main::c1#4 +Identical Phi Values (byte) main::c#2 (byte) main::c#5 +Successful SSA optimization Pass2IdenticalPhiElimination +Simple Condition (bool~) main::$3 [35] if((byte) main::i#1!=rangelast(0,4)) goto main::@3 +Simple Condition (bool~) main::$4 [44] if((byte) main::c1#1!=rangelast(0,$f)) goto main::@2 +Simple Condition (bool~) main::$5 [49] if((byte) main::c#1!=rangelast(0,$f)) goto main::@1 +Simple Condition (bool~) main::$6 [55] if((byte) main::c2#1!=rangelast(0,$ff)) goto main::@7 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant right-side identified [57] (byte[]) FONT_HEX_PROTO#0 ← { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 3, (byte) 4, (byte) 4, (byte) 4, (byte) 3, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 4 } +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte*) D018#0 = (byte*) 53272 +Constant (const byte*) SCREEN#0 = (byte*) 1024 +Constant (const byte*) CHARSET#0 = (byte*) 8192 +Constant (const byte) main::c#0 = 0 +Constant (const byte) main::c1#0 = 0 +Constant (const byte) main::i#0 = 0 +Constant (const byte) main::c2#0 = 0 +Constant (const byte[]) FONT_HEX_PROTO#0 = { 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4 } +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) main::toD0181_screen#0 = SCREEN#0 +Constant (const byte*) main::toD0181_gfx#0 = CHARSET#0 +Constant (const byte*) main::charset#0 = CHARSET#0 +Constant (const byte*) main::proto_hi#0 = FONT_HEX_PROTO#0 +Constant (const byte*) main::proto_lo#0 = FONT_HEX_PROTO#0 +Successful SSA optimization Pass2ConstantIdentification +Constant value identified (word)main::toD0181_screen#0 in [6] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0 +Constant value identified (word)main::toD0181_gfx#0 in [10] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0 +Successful SSA optimization Pass2ConstantValues +Resolved ranged next value [33] main::i#1 ← ++ main::i#2 to ++ +Resolved ranged comparison value [35] if(main::i#1!=rangelast(0,4)) goto main::@3 to (number) 5 +Resolved ranged next value [42] main::c1#1 ← ++ main::c1#4 to ++ +Resolved ranged comparison value [44] if(main::c1#1!=rangelast(0,$f)) goto main::@2 to (number) $10 +Resolved ranged next value [47] main::c#1 ← ++ main::c#5 to ++ +Resolved ranged comparison value [49] if(main::c#1!=rangelast(0,$f)) goto main::@1 to (number) $10 +Resolved ranged next value [53] main::c2#1 ← ++ main::c2#2 to ++ +Resolved ranged comparison value [55] if(main::c2#1!=rangelast(0,$ff)) goto main::@7 to (number) 0 +Adding number conversion cast (unumber) 5 in if((byte) main::i#1!=(number) 5) goto main::@3 +Adding number conversion cast (unumber) $10 in if((byte) main::c1#1!=(number) $10) goto main::@2 +Adding number conversion cast (unumber) $10 in if((byte) main::c#1!=(number) $10) goto main::@1 +Adding number conversion cast (unumber) 0 in if((byte) main::c2#1!=(number) 0) goto main::@7 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast 5 +Simplifying constant integer cast $10 +Simplifying constant integer cast $10 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) $10 +Finalized unsigned number type (byte) $10 +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Self Phi Eliminated (byte*) main::proto_hi#4 +Self Phi Eliminated (byte) main::c#5 +Successful SSA optimization Pass2SelfPhiElimination +Identical Phi Values (byte*) main::proto_hi#4 (byte*) main::proto_hi#6 +Identical Phi Values (byte) main::c#5 (byte) main::c#6 +Successful SSA optimization Pass2IdenticalPhiElimination +Constant (const word) main::toD0181_$0#0 = (word)main::toD0181_screen#0 +Constant (const word) main::toD0181_$4#0 = (word)main::toD0181_gfx#0 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [0] (word~) main::toD0181_$1#0 ← (const word) main::toD0181_$0#0 & (word) $3fff +Constant right-side identified [3] (byte~) main::toD0181_$5#0 ← > (const word) main::toD0181_$4#0 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const word) main::toD0181_$1#0 = main::toD0181_$0#0&$3fff +Constant (const byte) main::toD0181_$5#0 = >main::toD0181_$4#0 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [0] (word~) main::toD0181_$2#0 ← (const word) main::toD0181_$1#0 * (byte) 4 +Constant right-side identified [2] (byte~) main::toD0181_$6#0 ← (const byte) main::toD0181_$5#0 / (byte) 4 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const word) main::toD0181_$2#0 = main::toD0181_$1#0*4 +Constant (const byte) main::toD0181_$6#0 = main::toD0181_$5#0/4 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [0] (byte~) main::toD0181_$3#0 ← > (const word) main::toD0181_$2#0 +Constant right-side identified [1] (byte~) main::toD0181_$7#0 ← (const byte) main::toD0181_$6#0 & (byte) $f +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::toD0181_$3#0 = >main::toD0181_$2#0 +Constant (const byte) main::toD0181_$7#0 = main::toD0181_$6#0&$f +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [0] (byte) main::toD0181_return#0 ← (const byte) main::toD0181_$3#0 | (const byte) main::toD0181_$7#0 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::toD0181_return#0 = main::toD0181_$3#0|main::toD0181_$7#0 +Successful SSA optimization Pass2ConstantIdentification +Inlining constant with var siblings (const byte) main::c#0 +Inlining constant with var siblings (const byte) main::c1#0 +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with var siblings (const byte) main::c2#0 +Inlining constant with var siblings (const byte*) main::charset#0 +Inlining constant with var siblings (const byte*) main::proto_hi#0 +Inlining constant with var siblings (const byte*) main::proto_lo#0 +Constant inlined main::c1#0 = (byte) 0 +Constant inlined main::toD0181_screen#0 = (const byte*) SCREEN#0 +Constant inlined main::toD0181_gfx#0 = (const byte*) CHARSET#0 +Constant inlined main::c2#0 = (byte) 0 +Constant inlined main::proto_hi#0 = (const byte[]) FONT_HEX_PROTO#0 +Constant inlined main::toD0181_$0#0 = (word)(const byte*) SCREEN#0 +Constant inlined main::toD0181_$1#0 = (word)(const byte*) SCREEN#0&(word) $3fff +Constant inlined main::toD0181_$6#0 = >(word)(const byte*) CHARSET#0/(byte) 4 +Constant inlined main::toD0181_$7#0 = >(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +Constant inlined main::c#0 = (byte) 0 +Constant inlined main::toD0181_$2#0 = (word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4 +Constant inlined main::toD0181_$3#0 = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4 +Constant inlined main::charset#0 = (const byte*) CHARSET#0 +Constant inlined main::toD0181_$4#0 = (word)(const byte*) CHARSET#0 +Constant inlined main::toD0181_$5#0 = >(word)(const byte*) CHARSET#0 +Constant inlined main::i#0 = (byte) 0 +Constant inlined main::proto_lo#0 = (const byte[]) FONT_HEX_PROTO#0 +Successful SSA optimization Pass2ConstantInlining +Added new block during phi lifting main::@10(between main::@5 and main::@1) +Added new block during phi lifting main::@11(between main::@4 and main::@2) +Added new block during phi lifting main::@12(between main::@3 and main::@3) +Added new block during phi lifting main::@13(between main::@7 and main::@7) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @8 +Adding NOP phi() at start of @9 +Adding NOP phi() at start of @10 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::toD0181 +Adding NOP phi() at start of main::toD0181_@return +Adding NOP phi() at start of main::@6 +CALL GRAPH +Calls in [] to main:3 + +Created 8 initial phi equivalence classes +Coalesced [11] main::charset#8 ← main::charset#5 +Coalesced [35] main::c2#3 ← main::c2#1 +Coalesced [36] main::proto_hi#7 ← main::proto_hi#1 +Coalesced [37] main::charset#7 ← main::charset#1 +Coalesced [38] main::c#7 ← main::c#1 +Coalesced [39] main::proto_lo#5 ← main::proto_lo#1 +Coalesced (already) [40] main::charset#9 ← main::charset#1 +Coalesced [41] main::c1#5 ← main::c1#1 +Coalesced [42] main::i#3 ← main::i#1 +Coalesced down to 7 phi equivalence classes +Culled Empty Block (label) @8 +Culled Empty Block (label) @10 +Culled Empty Block (label) main::toD0181_@return +Culled Empty Block (label) main::@6 +Culled Empty Block (label) main::@13 +Culled Empty Block (label) main::@10 +Culled Empty Block (label) main::@11 +Culled Empty Block (label) main::@12 +Renumbering block @9 to @1 +Renumbering block main::@7 to main::@6 +Renumbering block main::@9 to main::@7 +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 +Adding NOP phi() at start of main::toD0181 + +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::toD0181 +main::toD0181: scope:[main] from main + [5] phi() + to:main::@7 +main::@7: scope:[main] from main::toD0181 + [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 + to:main::@1 +main::@1: scope:[main] from main::@5 main::@7 + [7] (byte) main::c#6 ← phi( main::@5/(byte) main::c#1 main::@7/(byte) 0 ) + [7] (byte*) main::charset#5 ← phi( main::@5/(byte*) main::charset#1 main::@7/(const byte*) CHARSET#0 ) + [7] (byte*) main::proto_hi#6 ← phi( main::@5/(byte*) main::proto_hi#1 main::@7/(const byte[]) FONT_HEX_PROTO#0 ) + to:main::@2 +main::@2: scope:[main] from main::@1 main::@4 + [8] (byte) main::c1#4 ← phi( main::@1/(byte) 0 main::@4/(byte) main::c1#1 ) + [8] (byte*) main::charset#4 ← phi( main::@1/(byte*) main::charset#5 main::@4/(byte*) main::charset#1 ) + [8] (byte*) main::proto_lo#4 ← phi( main::@1/(const byte[]) FONT_HEX_PROTO#0 main::@4/(byte*) main::proto_lo#1 ) + to:main::@3 +main::@3: scope:[main] from main::@2 main::@3 + [9] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@3/(byte) main::i#1 ) + [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 + [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) + [12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2 + [13] (byte) main::i#1 ← ++ (byte) main::i#2 + [14] if((byte) main::i#1!=(byte) 5) goto main::@3 + to:main::@4 +main::@4: scope:[main] from main::@3 + [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 + [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 + [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 + [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 + [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 + [20] (byte) main::c1#1 ← ++ (byte) main::c1#4 + [21] if((byte) main::c1#1!=(byte) $10) goto main::@2 + to:main::@5 +main::@5: scope:[main] from main::@4 + [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 + [23] (byte) main::c#1 ← ++ (byte) main::c#6 + [24] if((byte) main::c#1!=(byte) $10) goto main::@1 + to:main::@6 +main::@6: scope:[main] from main::@5 main::@6 + [25] (byte) main::c2#2 ← phi( main::@5/(byte) 0 main::@6/(byte) main::c2#1 ) + [26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 + [27] (byte) main::c2#1 ← ++ (byte) main::c2#2 + [28] if((byte) main::c2#1!=(byte) 0) goto main::@6 + to:main::@return +main::@return: scope:[main] from main::@6 + [29] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte*) CHARSET +(byte*) D018 +(byte[]) FONT_HEX_PROTO +(byte*) SCREEN +(void()) main() +(byte~) main::$1 2002.0 +(byte~) main::$2 2002.0 +(byte) main::c +(byte) main::c#1 16.5 +(byte) main::c#6 1.375 +(byte) main::c1 +(byte) main::c1#1 151.5 +(byte) main::c1#4 16.833333333333332 +(byte) main::c2 +(byte) main::c2#1 16.5 +(byte) main::c2#2 22.0 +(byte*) main::charset +(byte*) main::charset#1 35.5 +(byte*) main::charset#4 137.90909090909093 +(byte*) main::charset#5 22.0 +(byte) main::i +(byte) main::i#1 1501.5 +(byte) main::i#2 1251.25 +(byte*) main::proto_hi +(byte*) main::proto_hi#1 7.333333333333333 +(byte*) main::proto_hi#6 68.2 +(byte*) main::proto_lo +(byte*) main::proto_lo#1 50.5 +(byte*) main::proto_lo#4 120.29999999999998 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(byte*) main::toD0181_screen + +Initial phi equivalence classes +[ main::proto_hi#6 main::proto_hi#1 ] +[ main::c#6 main::c#1 ] +[ main::proto_lo#4 main::proto_lo#1 ] +[ main::charset#4 main::charset#5 main::charset#1 ] +[ main::c1#4 main::c1#1 ] +[ main::i#2 main::i#1 ] +[ main::c2#2 main::c2#1 ] +Added variable main::$1 to zero page equivalence class [ main::$1 ] +Added variable main::$2 to zero page equivalence class [ main::$2 ] +Complete equivalence classes +[ main::proto_hi#6 main::proto_hi#1 ] +[ main::c#6 main::c#1 ] +[ main::proto_lo#4 main::proto_lo#1 ] +[ main::charset#4 main::charset#5 main::charset#1 ] +[ main::c1#4 main::c1#1 ] +[ main::i#2 main::i#1 ] +[ main::c2#2 main::c2#1 ] +[ main::$1 ] +[ main::$2 ] +Allocated zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] +Allocated zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Allocated zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] +Allocated zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] +Allocated zp ZP_BYTE:9 [ main::c1#4 main::c1#1 ] +Allocated zp ZP_BYTE:10 [ main::i#2 main::i#1 ] +Allocated zp ZP_BYTE:11 [ main::c2#2 main::c2#1 ] +Allocated zp ZP_BYTE:12 [ main::$1 ] +Allocated zp ZP_BYTE:13 [ main::$2 ] + +INITIAL ASM +//SEG0 File Comments +// Creates a font where each char contains the number of the char (00-ff) +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .label D018 = $d018 + .label SCREEN = $400 + .label CHARSET = $2000 +//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: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label _1 = $c + .label _2 = $d + .label i = $a + .label proto_lo = 5 + .label charset = 7 + .label c1 = 9 + .label proto_hi = 2 + .label c = 4 + .label c2 = $b + //SEG11 [5] phi from main to main::toD0181 [phi:main->main::toD0181] + toD0181_from_main: + jmp toD0181 + //SEG12 main::toD0181 + toD0181: + jmp b7 + //SEG13 main::@7 + b7: + //SEG14 [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG15 [7] phi from main::@7 to main::@1 [phi:main::@7->main::@1] + b1_from_b7: + //SEG16 [7] phi (byte) main::c#6 = (byte) 0 [phi:main::@7->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG17 [7] phi (byte*) main::charset#5 = (const byte*) CHARSET#0 [phi:main::@7->main::@1#1] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + //SEG18 [7] phi (byte*) main::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@7->main::@1#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + jmp b1 + //SEG19 [7] phi from main::@5 to main::@1 [phi:main::@5->main::@1] + b1_from_b5: + //SEG20 [7] phi (byte) main::c#6 = (byte) main::c#1 [phi:main::@5->main::@1#0] -- register_copy + //SEG21 [7] phi (byte*) main::charset#5 = (byte*) main::charset#1 [phi:main::@5->main::@1#1] -- register_copy + //SEG22 [7] phi (byte*) main::proto_hi#6 = (byte*) main::proto_hi#1 [phi:main::@5->main::@1#2] -- register_copy + jmp b1 + //SEG23 main::@1 + b1: + //SEG24 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + b2_from_b1: + //SEG25 [8] phi (byte) main::c1#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c1 + //SEG26 [8] phi (byte*) main::charset#4 = (byte*) main::charset#5 [phi:main::@1->main::@2#1] -- register_copy + //SEG27 [8] phi (byte*) main::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@1->main::@2#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + jmp b2 + //SEG28 [8] phi from main::@4 to main::@2 [phi:main::@4->main::@2] + b2_from_b4: + //SEG29 [8] phi (byte) main::c1#4 = (byte) main::c1#1 [phi:main::@4->main::@2#0] -- register_copy + //SEG30 [8] phi (byte*) main::charset#4 = (byte*) main::charset#1 [phi:main::@4->main::@2#1] -- register_copy + //SEG31 [8] phi (byte*) main::proto_lo#4 = (byte*) main::proto_lo#1 [phi:main::@4->main::@2#2] -- register_copy + jmp b2 + //SEG32 main::@2 + b2: + //SEG33 [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + b3_from_b2: + //SEG34 [9] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuz1=vbuc1 + lda #0 + sta i + jmp b3 + //SEG35 [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3] + b3_from_b3: + //SEG36 [9] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@3#0] -- register_copy + jmp b3 + //SEG37 main::@3 + b3: + //SEG38 [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 -- vbuz1=pbuz2_derefidx_vbuz3_rol_3 + ldy i + lda (proto_hi),y + asl + asl + asl + sta _1 + //SEG39 [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) -- vbuz1=vbuz2_bor_pbuz3_derefidx_vbuz4 + lda _1 + ldy i + ora (proto_lo),y + sta _2 + //SEG40 [12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2 -- pbuz1_derefidx_vbuz2=vbuz3 + lda _2 + ldy i + sta (charset),y + //SEG41 [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc i + //SEG42 [14] if((byte) main::i#1!=(byte) 5) goto main::@3 -- vbuz1_neq_vbuc1_then_la1 + lda #5 + cmp i + bne b3_from_b3 + jmp b4 + //SEG43 main::@4 + b4: + //SEG44 [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #5 + sta (charset),y + //SEG45 [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #6 + sta (charset),y + //SEG46 [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #7 + sta (charset),y + //SEG47 [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG48 [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG49 [20] (byte) main::c1#1 ← ++ (byte) main::c1#4 -- vbuz1=_inc_vbuz1 + inc c1 + //SEG50 [21] if((byte) main::c1#1!=(byte) $10) goto main::@2 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c1 + bne b2_from_b4 + jmp b5 + //SEG51 main::@5 + b5: + //SEG52 [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG53 [23] (byte) main::c#1 ← ++ (byte) main::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG54 [24] if((byte) main::c#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1_from_b5 + //SEG55 [25] phi from main::@5 to main::@6 [phi:main::@5->main::@6] + b6_from_b5: + //SEG56 [25] phi (byte) main::c2#2 = (byte) 0 [phi:main::@5->main::@6#0] -- vbuz1=vbuc1 + lda #0 + sta c2 + jmp b6 + // Show all chars on screen + //SEG57 [25] phi from main::@6 to main::@6 [phi:main::@6->main::@6] + b6_from_b6: + //SEG58 [25] phi (byte) main::c2#2 = (byte) main::c2#1 [phi:main::@6->main::@6#0] -- register_copy + jmp b6 + //SEG59 main::@6 + b6: + //SEG60 [26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 -- pbuc1_derefidx_vbuz1=vbuz1 + ldy c2 + tya + sta SCREEN,y + //SEG61 [27] (byte) main::c2#1 ← ++ (byte) main::c2#2 -- vbuz1=_inc_vbuz1 + inc c2 + //SEG62 [28] if((byte) main::c2#1!=(byte) 0) goto main::@6 -- vbuz1_neq_0_then_la1 + lda c2 + cmp #0 + bne b6_from_b6 + jmp breturn + //SEG63 main::@return + breturn: + //SEG64 [29] return + rts +} +//SEG65 File Data + // Bit patterns for symbols 0-f (3x5 pixels) + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$1 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:9 [ main::c1#4 main::c1#1 ] +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:10 [ main::i#2 main::i#1 ] +Statement [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$2 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$2 ] ) always clobbers reg byte a +Statement [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:9 [ main::c1#4 main::c1#1 ] +Statement [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 [ main::proto_hi#6 main::c#6 main::charset#4 main::c1#4 main::proto_lo#1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::charset#4 main::c1#4 main::proto_lo#1 ] ) always clobbers reg byte a +Statement [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 [ main::proto_hi#6 main::c#6 main::charset#1 main::c1#4 main::proto_lo#1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::charset#1 main::c1#4 main::proto_lo#1 ] ) always clobbers reg byte a +Statement [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 [ main::c#6 main::proto_hi#1 main::charset#1 ] ( main:2 [ main::c#6 main::proto_hi#1 main::charset#1 ] ) always clobbers reg byte a +Statement [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$1 ] ) always clobbers reg byte a +Statement [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$2 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 main::i#2 main::$2 ] ) always clobbers reg byte a +Statement [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ( main:2 [ main::proto_hi#6 main::c#6 main::proto_lo#4 main::charset#4 main::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 [ main::proto_hi#6 main::c#6 main::charset#4 main::c1#4 main::proto_lo#1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::charset#4 main::c1#4 main::proto_lo#1 ] ) always clobbers reg byte a +Statement [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 [ main::proto_hi#6 main::c#6 main::charset#1 main::c1#4 main::proto_lo#1 ] ( main:2 [ main::proto_hi#6 main::c#6 main::charset#1 main::c1#4 main::proto_lo#1 ] ) always clobbers reg byte a +Statement [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 [ main::c#6 main::proto_hi#1 main::charset#1 ] ( main:2 [ main::c#6 main::proto_hi#1 main::charset#1 ] ) always clobbers reg byte a +Potential registers zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] : zp ZP_WORD:2 , +Potential registers zp ZP_BYTE:4 [ main::c#6 main::c#1 ] : zp ZP_BYTE:4 , reg byte x , +Potential registers zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] : zp ZP_WORD:5 , +Potential registers zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] : zp ZP_WORD:7 , +Potential registers zp ZP_BYTE:9 [ main::c1#4 main::c1#1 ] : zp ZP_BYTE:9 , reg byte x , +Potential registers zp ZP_BYTE:10 [ main::i#2 main::i#1 ] : zp ZP_BYTE:10 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:11 [ main::c2#2 main::c2#1 ] : zp ZP_BYTE:11 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:12 [ main::$1 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:13 [ main::$2 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 2,752.75: zp ZP_BYTE:10 [ main::i#2 main::i#1 ] 2,002: zp ZP_BYTE:12 [ main::$1 ] 2,002: zp ZP_BYTE:13 [ main::$2 ] 195.41: zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] 170.8: zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] 168.33: zp ZP_BYTE:9 [ main::c1#4 main::c1#1 ] 75.53: zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] 38.5: zp ZP_BYTE:11 [ main::c2#2 main::c2#1 ] 17.88: zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Uplift Scope [] + +Uplifting [main] best 50782 combination reg byte y [ main::i#2 main::i#1 ] reg byte a [ main::$1 ] reg byte a [ main::$2 ] zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] reg byte x [ main::c1#4 main::c1#1 ] zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] zp ZP_BYTE:11 [ main::c2#2 main::c2#1 ] zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Limited combination testing to 100 combinations of 768 possible. +Uplifting [] best 50782 combination +Attempting to uplift remaining variables inzp ZP_BYTE:11 [ main::c2#2 main::c2#1 ] +Uplifting [main] best 50662 combination reg byte x [ main::c2#2 main::c2#1 ] +Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::c#6 main::c#1 ] +Uplifting [main] best 50662 combination zp ZP_BYTE:4 [ main::c#6 main::c#1 ] + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +// Creates a font where each char contains the number of the char (00-ff) +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .label D018 = $d018 + .label SCREEN = $400 + .label CHARSET = $2000 +//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: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label proto_lo = 5 + .label charset = 7 + .label proto_hi = 2 + .label c = 4 + //SEG11 [5] phi from main to main::toD0181 [phi:main->main::toD0181] + toD0181_from_main: + jmp toD0181 + //SEG12 main::toD0181 + toD0181: + jmp b7 + //SEG13 main::@7 + b7: + //SEG14 [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG15 [7] phi from main::@7 to main::@1 [phi:main::@7->main::@1] + b1_from_b7: + //SEG16 [7] phi (byte) main::c#6 = (byte) 0 [phi:main::@7->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG17 [7] phi (byte*) main::charset#5 = (const byte*) CHARSET#0 [phi:main::@7->main::@1#1] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + //SEG18 [7] phi (byte*) main::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@7->main::@1#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + jmp b1 + //SEG19 [7] phi from main::@5 to main::@1 [phi:main::@5->main::@1] + b1_from_b5: + //SEG20 [7] phi (byte) main::c#6 = (byte) main::c#1 [phi:main::@5->main::@1#0] -- register_copy + //SEG21 [7] phi (byte*) main::charset#5 = (byte*) main::charset#1 [phi:main::@5->main::@1#1] -- register_copy + //SEG22 [7] phi (byte*) main::proto_hi#6 = (byte*) main::proto_hi#1 [phi:main::@5->main::@1#2] -- register_copy + jmp b1 + //SEG23 main::@1 + b1: + //SEG24 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + b2_from_b1: + //SEG25 [8] phi (byte) main::c1#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG26 [8] phi (byte*) main::charset#4 = (byte*) main::charset#5 [phi:main::@1->main::@2#1] -- register_copy + //SEG27 [8] phi (byte*) main::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@1->main::@2#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + jmp b2 + //SEG28 [8] phi from main::@4 to main::@2 [phi:main::@4->main::@2] + b2_from_b4: + //SEG29 [8] phi (byte) main::c1#4 = (byte) main::c1#1 [phi:main::@4->main::@2#0] -- register_copy + //SEG30 [8] phi (byte*) main::charset#4 = (byte*) main::charset#1 [phi:main::@4->main::@2#1] -- register_copy + //SEG31 [8] phi (byte*) main::proto_lo#4 = (byte*) main::proto_lo#1 [phi:main::@4->main::@2#2] -- register_copy + jmp b2 + //SEG32 main::@2 + b2: + //SEG33 [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + b3_from_b2: + //SEG34 [9] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1 + ldy #0 + jmp b3 + //SEG35 [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3] + b3_from_b3: + //SEG36 [9] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@3#0] -- register_copy + jmp b3 + //SEG37 main::@3 + b3: + //SEG38 [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 -- vbuaa=pbuz1_derefidx_vbuyy_rol_3 + lda (proto_hi),y + asl + asl + asl + //SEG39 [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) -- vbuaa=vbuaa_bor_pbuz1_derefidx_vbuyy + ora (proto_lo),y + //SEG40 [12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2 -- pbuz1_derefidx_vbuyy=vbuaa + sta (charset),y + //SEG41 [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy + iny + //SEG42 [14] if((byte) main::i#1!=(byte) 5) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 + cpy #5 + bne b3_from_b3 + jmp b4 + //SEG43 main::@4 + b4: + //SEG44 [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #5 + sta (charset),y + //SEG45 [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #6 + sta (charset),y + //SEG46 [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #7 + sta (charset),y + //SEG47 [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG48 [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG49 [20] (byte) main::c1#1 ← ++ (byte) main::c1#4 -- vbuxx=_inc_vbuxx + inx + //SEG50 [21] if((byte) main::c1#1!=(byte) $10) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 + cpx #$10 + bne b2_from_b4 + jmp b5 + //SEG51 main::@5 + b5: + //SEG52 [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG53 [23] (byte) main::c#1 ← ++ (byte) main::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG54 [24] if((byte) main::c#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1_from_b5 + //SEG55 [25] phi from main::@5 to main::@6 [phi:main::@5->main::@6] + b6_from_b5: + //SEG56 [25] phi (byte) main::c2#2 = (byte) 0 [phi:main::@5->main::@6#0] -- vbuxx=vbuc1 + ldx #0 + jmp b6 + // Show all chars on screen + //SEG57 [25] phi from main::@6 to main::@6 [phi:main::@6->main::@6] + b6_from_b6: + //SEG58 [25] phi (byte) main::c2#2 = (byte) main::c2#1 [phi:main::@6->main::@6#0] -- register_copy + jmp b6 + //SEG59 main::@6 + b6: + //SEG60 [26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 -- pbuc1_derefidx_vbuxx=vbuxx + txa + sta SCREEN,x + //SEG61 [27] (byte) main::c2#1 ← ++ (byte) main::c2#2 -- vbuxx=_inc_vbuxx + inx + //SEG62 [28] if((byte) main::c2#1!=(byte) 0) goto main::@6 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b6_from_b6 + jmp breturn + //SEG63 main::@return + breturn: + //SEG64 [29] return + rts +} +//SEG65 File Data + // Bit patterns for symbols 0-f (3x5 pixels) + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp bend +Removing instruction jmp toD0181 +Removing instruction jmp b7 +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Removing instruction jmp b4 +Removing instruction jmp b5 +Removing instruction jmp b6 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction lda #0 +Removing instruction lda #0 +Succesful ASM optimization Pass5UnnecesaryLoadElimination +Replacing label b3_from_b3 with b3 +Replacing label b2_from_b4 with b2 +Replacing label b1_from_b5 with b1 +Replacing label b6_from_b6 with b6 +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction main_from_b1: +Removing instruction bend_from_b1: +Removing instruction toD0181_from_main: +Removing instruction toD0181: +Removing instruction b1_from_b5: +Removing instruction b2_from_b1: +Removing instruction b2_from_b4: +Removing instruction b3_from_b2: +Removing instruction b3_from_b3: +Removing instruction b6_from_b6: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction bend: +Removing instruction b7: +Removing instruction b1_from_b7: +Removing instruction b4: +Removing instruction b5: +Removing instruction b6_from_b5: +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 b3 +Removing instruction jmp b6 +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(byte*) CHARSET +(const byte*) CHARSET#0 CHARSET = (byte*) 8192 +(byte*) D018 +(const byte*) D018#0 D018 = (byte*) 53272 +(byte[]) FONT_HEX_PROTO +(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 3, (byte) 4, (byte) 4, (byte) 4, (byte) 3, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 4 } +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 1024 +(void()) main() +(byte~) main::$1 reg byte a 2002.0 +(byte~) main::$2 reg byte a 2002.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@return +(byte) main::c +(byte) main::c#1 c zp ZP_BYTE:4 16.5 +(byte) main::c#6 c zp ZP_BYTE:4 1.375 +(byte) main::c1 +(byte) main::c1#1 reg byte x 151.5 +(byte) main::c1#4 reg byte x 16.833333333333332 +(byte) main::c2 +(byte) main::c2#1 reg byte x 16.5 +(byte) main::c2#2 reg byte x 22.0 +(byte*) main::charset +(byte*) main::charset#1 charset zp ZP_WORD:7 35.5 +(byte*) main::charset#4 charset zp ZP_WORD:7 137.90909090909093 +(byte*) main::charset#5 charset zp ZP_WORD:7 22.0 +(byte) main::i +(byte) main::i#1 reg byte y 1501.5 +(byte) main::i#2 reg byte y 1251.25 +(byte*) main::proto_hi +(byte*) main::proto_hi#1 proto_hi zp ZP_WORD:2 7.333333333333333 +(byte*) main::proto_hi#6 proto_hi zp ZP_WORD:2 68.2 +(byte*) main::proto_lo +(byte*) main::proto_lo#1 proto_lo zp ZP_WORD:5 50.5 +(byte*) main::proto_lo#4 proto_lo zp ZP_WORD:5 120.29999999999998 +(label) main::toD0181 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(const byte) main::toD0181_return#0 toD0181_return = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4|>(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +(byte*) main::toD0181_screen + +zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] +zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] +zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] +reg byte x [ main::c1#4 main::c1#1 ] +reg byte y [ main::i#2 main::i#1 ] +reg byte x [ main::c2#2 main::c2#1 ] +reg byte a [ main::$1 ] +reg byte a [ main::$2 ] + + +FINAL ASSEMBLER +Score: 40167 + +//SEG0 File Comments +// Creates a font where each char contains the number of the char (00-ff) +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .label D018 = $d018 + .label SCREEN = $400 + .label CHARSET = $2000 +//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: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label proto_lo = 5 + .label charset = 7 + .label proto_hi = 2 + .label c = 4 + //SEG11 [5] phi from main to main::toD0181 [phi:main->main::toD0181] + //SEG12 main::toD0181 + //SEG13 main::@7 + //SEG14 [6] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG15 [7] phi from main::@7 to main::@1 [phi:main::@7->main::@1] + //SEG16 [7] phi (byte) main::c#6 = (byte) 0 [phi:main::@7->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG17 [7] phi (byte*) main::charset#5 = (const byte*) CHARSET#0 [phi:main::@7->main::@1#1] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + //SEG18 [7] phi (byte*) main::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@7->main::@1#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + //SEG19 [7] phi from main::@5 to main::@1 [phi:main::@5->main::@1] + //SEG20 [7] phi (byte) main::c#6 = (byte) main::c#1 [phi:main::@5->main::@1#0] -- register_copy + //SEG21 [7] phi (byte*) main::charset#5 = (byte*) main::charset#1 [phi:main::@5->main::@1#1] -- register_copy + //SEG22 [7] phi (byte*) main::proto_hi#6 = (byte*) main::proto_hi#1 [phi:main::@5->main::@1#2] -- register_copy + //SEG23 main::@1 + b1: + //SEG24 [8] phi from main::@1 to main::@2 [phi:main::@1->main::@2] + //SEG25 [8] phi (byte) main::c1#4 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuxx=vbuc1 + ldx #0 + //SEG26 [8] phi (byte*) main::charset#4 = (byte*) main::charset#5 [phi:main::@1->main::@2#1] -- register_copy + //SEG27 [8] phi (byte*) main::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:main::@1->main::@2#2] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + //SEG28 [8] phi from main::@4 to main::@2 [phi:main::@4->main::@2] + //SEG29 [8] phi (byte) main::c1#4 = (byte) main::c1#1 [phi:main::@4->main::@2#0] -- register_copy + //SEG30 [8] phi (byte*) main::charset#4 = (byte*) main::charset#1 [phi:main::@4->main::@2#1] -- register_copy + //SEG31 [8] phi (byte*) main::proto_lo#4 = (byte*) main::proto_lo#1 [phi:main::@4->main::@2#2] -- register_copy + //SEG32 main::@2 + b2: + //SEG33 [9] phi from main::@2 to main::@3 [phi:main::@2->main::@3] + //SEG34 [9] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#0] -- vbuyy=vbuc1 + ldy #0 + //SEG35 [9] phi from main::@3 to main::@3 [phi:main::@3->main::@3] + //SEG36 [9] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@3#0] -- register_copy + //SEG37 main::@3 + b3: + //SEG38 [10] (byte~) main::$1 ← *((byte*) main::proto_hi#6 + (byte) main::i#2) << (byte) 3 -- vbuaa=pbuz1_derefidx_vbuyy_rol_3 + lda (proto_hi),y + asl + asl + asl + //SEG39 [11] (byte~) main::$2 ← (byte~) main::$1 | *((byte*) main::proto_lo#4 + (byte) main::i#2) -- vbuaa=vbuaa_bor_pbuz1_derefidx_vbuyy + ora (proto_lo),y + //SEG40 [12] *((byte*) main::charset#4 + (byte) main::i#2) ← (byte~) main::$2 -- pbuz1_derefidx_vbuyy=vbuaa + sta (charset),y + //SEG41 [13] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy + iny + //SEG42 [14] if((byte) main::i#1!=(byte) 5) goto main::@3 -- vbuyy_neq_vbuc1_then_la1 + cpy #5 + bne b3 + //SEG43 main::@4 + //SEG44 [15] *((byte*) main::charset#4 + (byte) 5) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + lda #0 + ldy #5 + sta (charset),y + //SEG45 [16] *((byte*) main::charset#4 + (byte) 6) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + ldy #6 + sta (charset),y + //SEG46 [17] *((byte*) main::charset#4 + (byte) 7) ← (byte) 0 -- pbuz1_derefidx_vbuc1=vbuc2 + ldy #7 + sta (charset),y + //SEG47 [18] (byte*) main::proto_lo#1 ← (byte*) main::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG48 [19] (byte*) main::charset#1 ← (byte*) main::charset#4 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG49 [20] (byte) main::c1#1 ← ++ (byte) main::c1#4 -- vbuxx=_inc_vbuxx + inx + //SEG50 [21] if((byte) main::c1#1!=(byte) $10) goto main::@2 -- vbuxx_neq_vbuc1_then_la1 + cpx #$10 + bne b2 + //SEG51 main::@5 + //SEG52 [22] (byte*) main::proto_hi#1 ← (byte*) main::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG53 [23] (byte) main::c#1 ← ++ (byte) main::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG54 [24] if((byte) main::c#1!=(byte) $10) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1 + //SEG55 [25] phi from main::@5 to main::@6 [phi:main::@5->main::@6] + //SEG56 [25] phi (byte) main::c2#2 = (byte) 0 [phi:main::@5->main::@6#0] -- vbuxx=vbuc1 + ldx #0 + // Show all chars on screen + //SEG57 [25] phi from main::@6 to main::@6 [phi:main::@6->main::@6] + //SEG58 [25] phi (byte) main::c2#2 = (byte) main::c2#1 [phi:main::@6->main::@6#0] -- register_copy + //SEG59 main::@6 + b6: + //SEG60 [26] *((const byte*) SCREEN#0 + (byte) main::c2#2) ← (byte) main::c2#2 -- pbuc1_derefidx_vbuxx=vbuxx + txa + sta SCREEN,x + //SEG61 [27] (byte) main::c2#1 ← ++ (byte) main::c2#2 -- vbuxx=_inc_vbuxx + inx + //SEG62 [28] if((byte) main::c2#1!=(byte) 0) goto main::@6 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b6 + //SEG63 main::@return + //SEG64 [29] return + rts +} +//SEG65 File Data + // Bit patterns for symbols 0-f (3x5 pixels) + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 3, 4, 4, 4, 3, 6, 5, 5, 5, 6, 7, 4, 7, 4, 7, 7, 4, 7, 4, 4 + diff --git a/src/test/ref/font-hex.sym b/src/test/ref/font-hex.sym new file mode 100644 index 000000000..1ba39a6a5 --- /dev/null +++ b/src/test/ref/font-hex.sym @@ -0,0 +1,68 @@ +(label) @1 +(label) @begin +(label) @end +(byte*) CHARSET +(const byte*) CHARSET#0 CHARSET = (byte*) 8192 +(byte*) D018 +(const byte*) D018#0 D018 = (byte*) 53272 +(byte[]) FONT_HEX_PROTO +(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 3, (byte) 4, (byte) 4, (byte) 4, (byte) 3, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 7, (byte) 4, (byte) 4 } +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 1024 +(void()) main() +(byte~) main::$1 reg byte a 2002.0 +(byte~) main::$2 reg byte a 2002.0 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@return +(byte) main::c +(byte) main::c#1 c zp ZP_BYTE:4 16.5 +(byte) main::c#6 c zp ZP_BYTE:4 1.375 +(byte) main::c1 +(byte) main::c1#1 reg byte x 151.5 +(byte) main::c1#4 reg byte x 16.833333333333332 +(byte) main::c2 +(byte) main::c2#1 reg byte x 16.5 +(byte) main::c2#2 reg byte x 22.0 +(byte*) main::charset +(byte*) main::charset#1 charset zp ZP_WORD:7 35.5 +(byte*) main::charset#4 charset zp ZP_WORD:7 137.90909090909093 +(byte*) main::charset#5 charset zp ZP_WORD:7 22.0 +(byte) main::i +(byte) main::i#1 reg byte y 1501.5 +(byte) main::i#2 reg byte y 1251.25 +(byte*) main::proto_hi +(byte*) main::proto_hi#1 proto_hi zp ZP_WORD:2 7.333333333333333 +(byte*) main::proto_hi#6 proto_hi zp ZP_WORD:2 68.2 +(byte*) main::proto_lo +(byte*) main::proto_lo#1 proto_lo zp ZP_WORD:5 50.5 +(byte*) main::proto_lo#4 proto_lo zp ZP_WORD:5 120.29999999999998 +(label) main::toD0181 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(const byte) main::toD0181_return#0 toD0181_return = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4|>(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +(byte*) main::toD0181_screen + +zp ZP_WORD:2 [ main::proto_hi#6 main::proto_hi#1 ] +zp ZP_BYTE:4 [ main::c#6 main::c#1 ] +zp ZP_WORD:5 [ main::proto_lo#4 main::proto_lo#1 ] +zp ZP_WORD:7 [ main::charset#4 main::charset#5 main::charset#1 ] +reg byte x [ main::c1#4 main::c1#1 ] +reg byte y [ main::i#2 main::i#1 ] +reg byte x [ main::c2#2 main::c2#1 ] +reg byte a [ main::$1 ] +reg byte a [ main::$2 ]