Adding pointer type conversion cast (byte*) print_screen in (byte*) print_screen ← (number) $400 Culled Empty Block (label) @1 Culled Empty Block (label) @2 Culled Empty Block (label) print_str::@4 Culled Empty Block (label) print_str::@3 Culled Empty Block (label) print_str::@5 Culled Empty Block (label) print_str::@6 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) @8 Culled Empty Block (label) @9 Culled Empty Block (label) @10 Culled Empty Block (label) @11 Culled Empty Block (label) @12 Culled Empty Block (label) @13 Culled Empty Block (label) @14 Culled Empty Block (label) @15 Culled Empty Block (label) @16 Culled Empty Block (label) @17 Culled Empty Block (label) @18 CONTROL FLOW GRAPH SSA @begin: scope:[] from (byte*) print_screen#0 ← ((byte*)) (number) $400 (byte*) print_line_cursor#0 ← (byte*) print_screen#0 (byte*) print_char_cursor#0 ← (byte*) print_line_cursor#0 to:@19 print_str: scope:[print_str] from main main::@2 main::@4 (byte*) print_char_cursor#29 ← phi( main/(byte*) print_char_cursor#27 main::@2/(byte*) print_char_cursor#6 main::@4/(byte*) print_char_cursor#8 ) (byte*) print_str::str#6 ← phi( main/(byte*) print_str::str#1 main::@2/(byte*) print_str::str#2 main::@4/(byte*) print_str::str#3 ) to:print_str::@1 print_str::@1: scope:[print_str] from print_str print_str::@2 (byte*) print_char_cursor#25 ← phi( print_str/(byte*) print_char_cursor#29 print_str::@2/(byte*) print_char_cursor#1 ) (byte*) print_str::str#4 ← phi( print_str/(byte*) print_str::str#6 print_str::@2/(byte*) print_str::str#0 ) (bool~) print_str::$0 ← *((byte*) print_str::str#4) != (byte) '@' if((bool~) print_str::$0) goto print_str::@2 to:print_str::@return print_str::@2: scope:[print_str] from print_str::@1 (byte*) print_char_cursor#13 ← phi( print_str::@1/(byte*) print_char_cursor#25 ) (byte*) print_str::str#5 ← phi( print_str::@1/(byte*) print_str::str#4 ) *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#5) (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#13 (byte*) print_str::str#0 ← ++ (byte*) print_str::str#5 to:print_str::@1 print_str::@return: scope:[print_str] from print_str::@1 (byte*) print_char_cursor#14 ← phi( print_str::@1/(byte*) print_char_cursor#25 ) (byte*) print_char_cursor#2 ← (byte*) print_char_cursor#14 return to:@return print_ln: scope:[print_ln] from main::@1 main::@3 main::@5 (byte*) print_char_cursor#26 ← phi( main::@1/(byte*) print_char_cursor#5 main::@3/(byte*) print_char_cursor#7 main::@5/(byte*) print_char_cursor#9 ) (byte*) print_line_cursor#16 ← phi( main::@1/(byte*) print_line_cursor#17 main::@3/(byte*) print_line_cursor#18 main::@5/(byte*) print_line_cursor#19 ) to:print_ln::@1 print_ln::@1: scope:[print_ln] from print_ln print_ln::@1 (byte*) print_char_cursor#15 ← phi( print_ln/(byte*) print_char_cursor#26 print_ln::@1/(byte*) print_char_cursor#15 ) (byte*) print_line_cursor#8 ← phi( print_ln/(byte*) print_line_cursor#16 print_ln::@1/(byte*) print_line_cursor#1 ) (byte*~) print_ln::$0 ← (byte*) print_line_cursor#8 + (number) $28 (byte*) print_line_cursor#1 ← (byte*~) print_ln::$0 (bool~) print_ln::$1 ← (byte*) print_line_cursor#1 < (byte*) print_char_cursor#15 if((bool~) print_ln::$1) goto print_ln::@1 to:print_ln::@2 print_ln::@2: scope:[print_ln] from print_ln::@1 (byte*) print_line_cursor#9 ← phi( print_ln::@1/(byte*) print_line_cursor#1 ) (byte*) print_char_cursor#3 ← (byte*) print_line_cursor#9 to:print_ln::@return print_ln::@return: scope:[print_ln] from print_ln::@2 (byte*) print_char_cursor#16 ← phi( print_ln::@2/(byte*) print_char_cursor#3 ) (byte*) print_line_cursor#10 ← phi( print_ln::@2/(byte*) print_line_cursor#9 ) (byte*) print_line_cursor#2 ← (byte*) print_line_cursor#10 (byte*) print_char_cursor#4 ← (byte*) print_char_cursor#16 return to:@return @19: scope:[] from @begin (byte*) print_line_cursor#22 ← phi( @begin/(byte*) print_line_cursor#0 ) (byte*) print_char_cursor#30 ← phi( @begin/(byte*) print_char_cursor#0 ) (byte[]) msg#0 ← (const string) $0 (byte[]) msg2#0 ← (const string) $1 (byte[]) msg3#0 ← (const string) $2 to:@20 main: scope:[main] from @20 (byte*) print_line_cursor#21 ← phi( @20/(byte*) print_line_cursor#20 ) (byte*) print_char_cursor#27 ← phi( @20/(byte*) print_char_cursor#28 ) (byte*) print_str::str#1 ← (byte[]) msg#0 call print_str to:main::@1 main::@1: scope:[main] from main (byte*) print_line_cursor#17 ← phi( main/(byte*) print_line_cursor#21 ) (byte*) print_char_cursor#17 ← phi( main/(byte*) print_char_cursor#2 ) (byte*) print_char_cursor#5 ← (byte*) print_char_cursor#17 call print_ln to:main::@2 main::@2: scope:[main] from main::@1 (byte*) print_char_cursor#18 ← phi( main::@1/(byte*) print_char_cursor#4 ) (byte*) print_line_cursor#11 ← phi( main::@1/(byte*) print_line_cursor#2 ) (byte*) print_line_cursor#3 ← (byte*) print_line_cursor#11 (byte*) print_char_cursor#6 ← (byte*) print_char_cursor#18 (byte*) print_str::str#2 ← (byte[]) msg2#0 call print_str to:main::@3 main::@3: scope:[main] from main::@2 (byte*) print_line_cursor#18 ← phi( main::@2/(byte*) print_line_cursor#3 ) (byte*) print_char_cursor#19 ← phi( main::@2/(byte*) print_char_cursor#2 ) (byte*) print_char_cursor#7 ← (byte*) print_char_cursor#19 call print_ln to:main::@4 main::@4: scope:[main] from main::@3 (byte*) print_char_cursor#20 ← phi( main::@3/(byte*) print_char_cursor#4 ) (byte*) print_line_cursor#12 ← phi( main::@3/(byte*) print_line_cursor#2 ) (byte*) print_line_cursor#4 ← (byte*) print_line_cursor#12 (byte*) print_char_cursor#8 ← (byte*) print_char_cursor#20 (byte*) print_str::str#3 ← (byte[]) msg3#0 call print_str to:main::@5 main::@5: scope:[main] from main::@4 (byte*) print_line_cursor#19 ← phi( main::@4/(byte*) print_line_cursor#4 ) (byte*) print_char_cursor#21 ← phi( main::@4/(byte*) print_char_cursor#2 ) (byte*) print_char_cursor#9 ← (byte*) print_char_cursor#21 call print_ln to:main::@6 main::@6: scope:[main] from main::@5 (byte*) print_char_cursor#22 ← phi( main::@5/(byte*) print_char_cursor#4 ) (byte*) print_line_cursor#13 ← phi( main::@5/(byte*) print_line_cursor#2 ) (byte*) print_line_cursor#5 ← (byte*) print_line_cursor#13 (byte*) print_char_cursor#10 ← (byte*) print_char_cursor#22 to:main::@return main::@return: scope:[main] from main::@6 (byte*) print_line_cursor#14 ← phi( main::@6/(byte*) print_line_cursor#5 ) (byte*) print_char_cursor#23 ← phi( main::@6/(byte*) print_char_cursor#10 ) (byte*) print_char_cursor#11 ← (byte*) print_char_cursor#23 (byte*) print_line_cursor#6 ← (byte*) print_line_cursor#14 return to:@return @20: scope:[] from @19 (byte*) print_line_cursor#20 ← phi( @19/(byte*) print_line_cursor#22 ) (byte*) print_char_cursor#28 ← phi( @19/(byte*) print_char_cursor#30 ) call main to:@21 @21: scope:[] from @20 (byte*) print_line_cursor#15 ← phi( @20/(byte*) print_line_cursor#6 ) (byte*) print_char_cursor#24 ← phi( @20/(byte*) print_char_cursor#11 ) (byte*) print_char_cursor#12 ← (byte*) print_char_cursor#24 (byte*) print_line_cursor#7 ← (byte*) print_line_cursor#15 to:@end @end: scope:[] from @21 SYMBOL TABLE SSA (const string) $0 = (string) "hello world! @" (const string) $1 = (string) "hello c64! @" (const string) $2 = (string) "hello 2017! @" (label) @19 (label) @20 (label) @21 (label) @begin (label) @end (void()) main() (label) main::@1 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@5 (label) main::@6 (label) main::@return (byte[]) msg (byte[]) msg#0 (byte[]) msg2 (byte[]) msg2#0 (byte[]) msg3 (byte[]) msg3#0 (byte*) print_char_cursor (byte*) print_char_cursor#0 (byte*) print_char_cursor#1 (byte*) print_char_cursor#10 (byte*) print_char_cursor#11 (byte*) print_char_cursor#12 (byte*) print_char_cursor#13 (byte*) print_char_cursor#14 (byte*) print_char_cursor#15 (byte*) print_char_cursor#16 (byte*) print_char_cursor#17 (byte*) print_char_cursor#18 (byte*) print_char_cursor#19 (byte*) print_char_cursor#2 (byte*) print_char_cursor#20 (byte*) print_char_cursor#21 (byte*) print_char_cursor#22 (byte*) print_char_cursor#23 (byte*) print_char_cursor#24 (byte*) print_char_cursor#25 (byte*) print_char_cursor#26 (byte*) print_char_cursor#27 (byte*) print_char_cursor#28 (byte*) print_char_cursor#29 (byte*) print_char_cursor#3 (byte*) print_char_cursor#30 (byte*) print_char_cursor#4 (byte*) print_char_cursor#5 (byte*) print_char_cursor#6 (byte*) print_char_cursor#7 (byte*) print_char_cursor#8 (byte*) print_char_cursor#9 (byte*) print_line_cursor (byte*) print_line_cursor#0 (byte*) print_line_cursor#1 (byte*) print_line_cursor#10 (byte*) print_line_cursor#11 (byte*) print_line_cursor#12 (byte*) print_line_cursor#13 (byte*) print_line_cursor#14 (byte*) print_line_cursor#15 (byte*) print_line_cursor#16 (byte*) print_line_cursor#17 (byte*) print_line_cursor#18 (byte*) print_line_cursor#19 (byte*) print_line_cursor#2 (byte*) print_line_cursor#20 (byte*) print_line_cursor#21 (byte*) print_line_cursor#22 (byte*) print_line_cursor#3 (byte*) print_line_cursor#4 (byte*) print_line_cursor#5 (byte*) print_line_cursor#6 (byte*) print_line_cursor#7 (byte*) print_line_cursor#8 (byte*) print_line_cursor#9 (void()) print_ln() (byte*~) print_ln::$0 (bool~) print_ln::$1 (label) print_ln::@1 (label) print_ln::@2 (label) print_ln::@return (byte*) print_screen (byte*) print_screen#0 (void()) print_str((byte*) print_str::str) (bool~) print_str::$0 (label) print_str::@1 (label) print_str::@2 (label) print_str::@return (byte*) print_str::str (byte*) print_str::str#0 (byte*) print_str::str#1 (byte*) print_str::str#2 (byte*) print_str::str#3 (byte*) print_str::str#4 (byte*) print_str::str#5 (byte*) print_str::str#6 Adding number conversion cast (unumber) $28 in (byte*~) print_ln::$0 ← (byte*) print_line_cursor#8 + (number) $28 Successful SSA optimization PassNAddNumberTypeConversions Inlining cast (byte*) print_screen#0 ← (byte*)(number) $400 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast $28 Successful SSA optimization PassNCastSimplification Finalized unsigned number type (byte) $28 Successful SSA optimization PassNFinalizeNumberTypeConversions Alias (byte*) print_char_cursor#0 = (byte*) print_line_cursor#0 (byte*) print_screen#0 (byte*) print_char_cursor#30 (byte*) print_line_cursor#22 (byte*) print_char_cursor#28 (byte*) print_line_cursor#20 Alias (byte*) print_str::str#4 = (byte*) print_str::str#5 Alias (byte*) print_char_cursor#13 = (byte*) print_char_cursor#25 (byte*) print_char_cursor#14 (byte*) print_char_cursor#2 Alias (byte*) print_line_cursor#1 = (byte*~) print_ln::$0 (byte*) print_line_cursor#9 (byte*) print_char_cursor#3 (byte*) print_line_cursor#10 (byte*) print_char_cursor#16 (byte*) print_line_cursor#2 (byte*) print_char_cursor#4 Alias (byte*) print_line_cursor#17 = (byte*) print_line_cursor#21 Alias (byte*) print_char_cursor#17 = (byte*) print_char_cursor#5 Alias (byte*) print_line_cursor#11 = (byte*) print_line_cursor#3 (byte*) print_line_cursor#18 Alias (byte*) print_char_cursor#18 = (byte*) print_char_cursor#6 Alias (byte*) print_char_cursor#19 = (byte*) print_char_cursor#7 Alias (byte*) print_line_cursor#12 = (byte*) print_line_cursor#4 (byte*) print_line_cursor#19 Alias (byte*) print_char_cursor#20 = (byte*) print_char_cursor#8 Alias (byte*) print_char_cursor#21 = (byte*) print_char_cursor#9 Alias (byte*) print_line_cursor#13 = (byte*) print_line_cursor#5 (byte*) print_line_cursor#14 (byte*) print_line_cursor#6 Alias (byte*) print_char_cursor#10 = (byte*) print_char_cursor#22 (byte*) print_char_cursor#23 (byte*) print_char_cursor#11 Alias (byte*) print_char_cursor#12 = (byte*) print_char_cursor#24 Alias (byte*) print_line_cursor#15 = (byte*) print_line_cursor#7 Successful SSA optimization Pass2AliasElimination Self Phi Eliminated (byte*) print_char_cursor#15 Successful SSA optimization Pass2SelfPhiElimination Identical Phi Values (byte*) print_char_cursor#15 (byte*) print_char_cursor#26 Identical Phi Values (byte*) print_char_cursor#27 (byte*) print_char_cursor#0 Identical Phi Values (byte*) print_line_cursor#17 (byte*) print_char_cursor#0 Identical Phi Values (byte*) print_char_cursor#17 (byte*) print_char_cursor#13 Identical Phi Values (byte*) print_line_cursor#11 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#18 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#19 (byte*) print_char_cursor#13 Identical Phi Values (byte*) print_line_cursor#12 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#20 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#21 (byte*) print_char_cursor#13 Identical Phi Values (byte*) print_line_cursor#13 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#10 (byte*) print_line_cursor#1 Identical Phi Values (byte*) print_char_cursor#12 (byte*) print_char_cursor#10 Identical Phi Values (byte*) print_line_cursor#15 (byte*) print_line_cursor#13 Successful SSA optimization Pass2IdenticalPhiElimination Identical Phi Values (byte*) print_char_cursor#26 (byte*) print_char_cursor#13 Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) print_str::$0 [6] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 Simple Condition (bool~) print_ln::$1 [19] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 Successful SSA optimization Pass2ConditionalJumpSimplification Constant (const byte*) print_char_cursor#0 = (byte*) 1024 Constant (const byte[]) msg#0 = $0 Constant (const byte[]) msg2#0 = $1 Constant (const byte[]) msg3#0 = $2 Successful SSA optimization Pass2ConstantIdentification Constant (const byte*) print_str::str#1 = msg#0 Constant (const byte*) print_str::str#2 = msg2#0 Constant (const byte*) print_str::str#3 = msg3#0 Successful SSA optimization Pass2ConstantIdentification Inlining constant with var siblings (const byte*) print_str::str#1 Inlining constant with var siblings (const byte*) print_str::str#2 Inlining constant with var siblings (const byte*) print_str::str#3 Inlining constant with var siblings (const byte*) print_char_cursor#0 Constant inlined print_char_cursor#0 = (byte*) 1024 Constant inlined print_str::str#3 = (const byte[]) msg3#0 Constant inlined print_str::str#2 = (const byte[]) msg2#0 Constant inlined print_str::str#1 = (const byte[]) msg#0 Constant inlined $0 = (const byte[]) msg#0 Constant inlined $1 = (const byte[]) msg2#0 Constant inlined $2 = (const byte[]) msg3#0 Successful SSA optimization Pass2ConstantInlining Added new block during phi lifting print_ln::@3(between print_ln::@1 and print_ln::@1) Adding NOP phi() at start of @begin Adding NOP phi() at start of @19 Adding NOP phi() at start of @20 Adding NOP phi() at start of @21 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::@6 Adding NOP phi() at start of print_ln::@2 CALL GRAPH Calls in [] to main:3 Calls in [main] to print_str:7 print_ln:9 print_str:11 print_ln:13 print_str:15 print_ln:17 Created 6 initial phi equivalence classes Not coalescing [10] print_char_cursor#31 ← print_line_cursor#1 Coalesced [12] print_line_cursor#23 ← print_line_cursor#1 Not coalescing [14] print_char_cursor#32 ← print_line_cursor#1 Coalesced (already) [16] print_line_cursor#24 ← print_line_cursor#1 Coalesced [21] print_line_cursor#25 ← print_line_cursor#16 Coalesced (already) [27] print_line_cursor#26 ← print_line_cursor#1 Coalesced [29] print_str::str#7 ← print_str::str#6 Coalesced [30] print_char_cursor#33 ← print_char_cursor#29 Coalesced [37] print_str::str#8 ← print_str::str#0 Coalesced [38] print_char_cursor#34 ← print_char_cursor#1 Coalesced down to 3 phi equivalence classes Culled Empty Block (label) @19 Culled Empty Block (label) @21 Culled Empty Block (label) main::@6 Culled Empty Block (label) print_ln::@2 Culled Empty Block (label) print_ln::@3 Renumbering block @20 to @1 Adding NOP phi() at start of @begin Adding NOP phi() at start of @1 Adding NOP phi() at start of @end Adding NOP phi() at start of main Adding NOP phi() at start of main::@1 Adding NOP phi() at start of main::@3 Adding NOP phi() at start of main::@5 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() [5] call print_str to:main::@1 main::@1: scope:[main] from main [6] phi() [7] call print_ln to:main::@2 main::@2: scope:[main] from main::@1 [8] (byte*~) print_char_cursor#31 ← (byte*) print_line_cursor#1 [9] call print_str to:main::@3 main::@3: scope:[main] from main::@2 [10] phi() [11] call print_ln to:main::@4 main::@4: scope:[main] from main::@3 [12] (byte*~) print_char_cursor#32 ← (byte*) print_line_cursor#1 [13] call print_str to:main::@5 main::@5: scope:[main] from main::@4 [14] phi() [15] call print_ln to:main::@return main::@return: scope:[main] from main::@5 [16] return to:@return print_ln: scope:[print_ln] from main::@1 main::@3 main::@5 [17] (byte*) print_line_cursor#16 ← phi( main::@1/(byte*) 1024 main::@3/(byte*) print_line_cursor#1 main::@5/(byte*) print_line_cursor#1 ) to:print_ln::@1 print_ln::@1: scope:[print_ln] from print_ln print_ln::@1 [18] (byte*) print_line_cursor#8 ← phi( print_ln/(byte*) print_line_cursor#16 print_ln::@1/(byte*) print_line_cursor#1 ) [19] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#8 + (byte) $28 [20] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 to:print_ln::@return print_ln::@return: scope:[print_ln] from print_ln::@1 [21] return to:@return print_str: scope:[print_str] from main main::@2 main::@4 [22] (byte*) print_char_cursor#29 ← phi( main/(byte*) 1024 main::@2/(byte*~) print_char_cursor#31 main::@4/(byte*~) print_char_cursor#32 ) [22] (byte*) print_str::str#6 ← phi( main/(const byte[]) msg#0 main::@2/(const byte[]) msg2#0 main::@4/(const byte[]) msg3#0 ) to:print_str::@1 print_str::@1: scope:[print_str] from print_str print_str::@2 [23] (byte*) print_char_cursor#13 ← phi( print_str/(byte*) print_char_cursor#29 print_str::@2/(byte*) print_char_cursor#1 ) [23] (byte*) print_str::str#4 ← phi( print_str/(byte*) print_str::str#6 print_str::@2/(byte*) print_str::str#0 ) [24] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 to:print_str::@return print_str::@return: scope:[print_str] from print_str::@1 [25] return to:@return print_str::@2: scope:[print_str] from print_str::@1 [26] *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#4) [27] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#13 [28] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#4 to:print_str::@1 VARIABLE REGISTER WEIGHTS (void()) main() (byte[]) msg (byte[]) msg2 (byte[]) msg3 (byte*) print_char_cursor (byte*) print_char_cursor#1 11.0 (byte*) print_char_cursor#13 3.2857142857142856 (byte*) print_char_cursor#29 6.0 (byte*~) print_char_cursor#31 4.0 (byte*~) print_char_cursor#32 4.0 (byte*) print_line_cursor (byte*) print_line_cursor#1 3.7272727272727275 (byte*) print_line_cursor#16 6.0 (byte*) print_line_cursor#8 24.0 (void()) print_ln() (byte*) print_screen (void()) print_str((byte*) print_str::str) (byte*) print_str::str (byte*) print_str::str#0 22.0 (byte*) print_str::str#4 11.5 (byte*) print_str::str#6 2.0 Initial phi equivalence classes [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] [ print_str::str#4 print_str::str#6 print_str::str#0 ] [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] Complete equivalence classes [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] [ print_str::str#4 print_str::str#6 print_str::str#0 ] [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] Allocated zp ZP_WORD:2 [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] Allocated zp ZP_WORD:4 [ print_str::str#4 print_str::str#6 print_str::str#0 ] Allocated zp ZP_WORD:6 [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] INITIAL ASM //SEG0 File Comments //SEG1 Basic Upstart .pc = $801 "Basic" :BasicUpstart(bbegin) .pc = $80d "Program" //SEG2 Global Constants & labels .label print_char_cursor = 6 .label print_line_cursor = 2 //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: { //SEG11 [5] call print_str //SEG12 [22] phi from main to print_str [phi:main->print_str] print_str_from_main: //SEG13 [22] phi (byte*) print_char_cursor#29 = (byte*) 1024 [phi:main->print_str#0] -- pbuz1=pbuc1 lda #<$400 sta print_char_cursor lda #>$400 sta print_char_cursor+1 //SEG14 [22] phi (byte*) print_str::str#6 = (const byte[]) msg#0 [phi:main->print_str#1] -- pbuz1=pbuc1 lda #msg sta print_str.str+1 jsr print_str //SEG15 [6] phi from main to main::@1 [phi:main->main::@1] b1_from_main: jmp b1 //SEG16 main::@1 b1: //SEG17 [7] call print_ln //SEG18 [17] phi from main::@1 to print_ln [phi:main::@1->print_ln] print_ln_from_b1: //SEG19 [17] phi (byte*) print_line_cursor#16 = (byte*) 1024 [phi:main::@1->print_ln#0] -- pbuz1=pbuc1 lda #<$400 sta print_line_cursor lda #>$400 sta print_line_cursor+1 jsr print_ln jmp b2 //SEG20 main::@2 b2: //SEG21 [8] (byte*~) print_char_cursor#31 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG22 [9] call print_str //SEG23 [22] phi from main::@2 to print_str [phi:main::@2->print_str] print_str_from_b2: //SEG24 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#31 [phi:main::@2->print_str#0] -- register_copy //SEG25 [22] phi (byte*) print_str::str#6 = (const byte[]) msg2#0 [phi:main::@2->print_str#1] -- pbuz1=pbuc1 lda #msg2 sta print_str.str+1 jsr print_str //SEG26 [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3] b3_from_b2: jmp b3 //SEG27 main::@3 b3: //SEG28 [11] call print_ln //SEG29 [17] phi from main::@3 to print_ln [phi:main::@3->print_ln] print_ln_from_b3: //SEG30 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@3->print_ln#0] -- register_copy jsr print_ln jmp b4 //SEG31 main::@4 b4: //SEG32 [12] (byte*~) print_char_cursor#32 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG33 [13] call print_str //SEG34 [22] phi from main::@4 to print_str [phi:main::@4->print_str] print_str_from_b4: //SEG35 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#32 [phi:main::@4->print_str#0] -- register_copy //SEG36 [22] phi (byte*) print_str::str#6 = (const byte[]) msg3#0 [phi:main::@4->print_str#1] -- pbuz1=pbuc1 lda #msg3 sta print_str.str+1 jsr print_str //SEG37 [14] phi from main::@4 to main::@5 [phi:main::@4->main::@5] b5_from_b4: jmp b5 //SEG38 main::@5 b5: //SEG39 [15] call print_ln //SEG40 [17] phi from main::@5 to print_ln [phi:main::@5->print_ln] print_ln_from_b5: //SEG41 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@5->print_ln#0] -- register_copy jsr print_ln jmp breturn //SEG42 main::@return breturn: //SEG43 [16] return rts } //SEG44 print_ln // Print a newline print_ln: { //SEG45 [18] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1] b1_from_print_ln: b1_from_b1: //SEG46 [18] phi (byte*) print_line_cursor#8 = (byte*) print_line_cursor#16 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy jmp b1 //SEG47 print_ln::@1 b1: //SEG48 [19] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#8 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc print_line_cursor sta print_line_cursor bcc !+ inc print_line_cursor+1 !: //SEG49 [20] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1 lda print_line_cursor+1 cmp print_char_cursor+1 bcc b1_from_b1 bne !+ lda print_line_cursor cmp print_char_cursor bcc b1_from_b1 !: jmp breturn //SEG50 print_ln::@return breturn: //SEG51 [21] return rts } //SEG52 print_str // Print a zero-terminated string // print_str(byte* zeropage(4) str) print_str: { .label str = 4 //SEG53 [23] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1] b1_from_print_str: b1_from_b2: //SEG54 [23] phi (byte*) print_char_cursor#13 = (byte*) print_char_cursor#29 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy //SEG55 [23] phi (byte*) print_str::str#4 = (byte*) print_str::str#6 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy jmp b1 //SEG56 print_str::@1 b1: //SEG57 [24] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 -- _deref_pbuz1_neq_vbuc1_then_la1 ldy #0 lda (str),y cmp #'@' bne b2 jmp breturn //SEG58 print_str::@return breturn: //SEG59 [25] return rts //SEG60 print_str::@2 b2: //SEG61 [26] *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#4) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (str),y ldy #0 sta (print_char_cursor),y //SEG62 [27] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#13 -- pbuz1=_inc_pbuz1 inc print_char_cursor bne !+ inc print_char_cursor+1 !: //SEG63 [28] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#4 -- pbuz1=_inc_pbuz1 inc str bne !+ inc str+1 !: jmp b1_from_b2 } msg: .text "hello world! @" msg2: .text "hello c64! @" msg3: .text "hello 2017! @" REGISTER UPLIFT POTENTIAL REGISTERS Statement [8] (byte*~) print_char_cursor#31 ← (byte*) print_line_cursor#1 [ print_char_cursor#31 print_line_cursor#1 ] ( main:2 [ print_char_cursor#31 print_line_cursor#1 ] ) always clobbers reg byte a Statement [12] (byte*~) print_char_cursor#32 ← (byte*) print_line_cursor#1 [ print_line_cursor#1 print_char_cursor#32 ] ( main:2 [ print_line_cursor#1 print_char_cursor#32 ] ) always clobbers reg byte a Statement [19] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#8 + (byte) $28 [ print_line_cursor#1 print_char_cursor#13 ] ( main:2::print_ln:7 [ print_line_cursor#1 print_char_cursor#13 ] main:2::print_ln:11 [ print_line_cursor#1 print_char_cursor#13 ] main:2::print_ln:15 [ print_line_cursor#1 print_char_cursor#13 ] ) always clobbers reg byte a Statement [20] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 [ print_line_cursor#1 print_char_cursor#13 ] ( main:2::print_ln:7 [ print_line_cursor#1 print_char_cursor#13 ] main:2::print_ln:11 [ print_line_cursor#1 print_char_cursor#13 ] main:2::print_ln:15 [ print_line_cursor#1 print_char_cursor#13 ] ) always clobbers reg byte a Statement [24] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 [ print_char_cursor#13 print_str::str#4 ] ( main:2::print_str:5 [ print_char_cursor#13 print_str::str#4 ] main:2::print_str:9 [ print_line_cursor#1 print_char_cursor#13 print_str::str#4 ] main:2::print_str:13 [ print_line_cursor#1 print_char_cursor#13 print_str::str#4 ] ) always clobbers reg byte a reg byte y Statement [26] *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#4) [ print_char_cursor#13 print_str::str#4 ] ( main:2::print_str:5 [ print_char_cursor#13 print_str::str#4 ] main:2::print_str:9 [ print_line_cursor#1 print_char_cursor#13 print_str::str#4 ] main:2::print_str:13 [ print_line_cursor#1 print_char_cursor#13 print_str::str#4 ] ) always clobbers reg byte a reg byte y Potential registers zp ZP_WORD:2 [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] : zp ZP_WORD:2 , Potential registers zp ZP_WORD:4 [ print_str::str#4 print_str::str#6 print_str::str#0 ] : zp ZP_WORD:4 , Potential registers zp ZP_WORD:6 [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] : zp ZP_WORD:6 , REGISTER UPLIFT SCOPES Uplift Scope [] 33.73: zp ZP_WORD:2 [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] 28.29: zp ZP_WORD:6 [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] Uplift Scope [print_str] 35.5: zp ZP_WORD:4 [ print_str::str#4 print_str::str#6 print_str::str#0 ] Uplift Scope [print_ln] Uplift Scope [main] Uplifting [] best 1203 combination zp ZP_WORD:2 [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] zp ZP_WORD:6 [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] Uplifting [print_str] best 1203 combination zp ZP_WORD:4 [ print_str::str#4 print_str::str#6 print_str::str#0 ] Uplifting [print_ln] best 1203 combination Uplifting [main] best 1203 combination ASSEMBLER BEFORE OPTIMIZATION //SEG0 File Comments //SEG1 Basic Upstart .pc = $801 "Basic" :BasicUpstart(bbegin) .pc = $80d "Program" //SEG2 Global Constants & labels .label print_char_cursor = 6 .label print_line_cursor = 2 //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: { //SEG11 [5] call print_str //SEG12 [22] phi from main to print_str [phi:main->print_str] print_str_from_main: //SEG13 [22] phi (byte*) print_char_cursor#29 = (byte*) 1024 [phi:main->print_str#0] -- pbuz1=pbuc1 lda #<$400 sta print_char_cursor lda #>$400 sta print_char_cursor+1 //SEG14 [22] phi (byte*) print_str::str#6 = (const byte[]) msg#0 [phi:main->print_str#1] -- pbuz1=pbuc1 lda #msg sta print_str.str+1 jsr print_str //SEG15 [6] phi from main to main::@1 [phi:main->main::@1] b1_from_main: jmp b1 //SEG16 main::@1 b1: //SEG17 [7] call print_ln //SEG18 [17] phi from main::@1 to print_ln [phi:main::@1->print_ln] print_ln_from_b1: //SEG19 [17] phi (byte*) print_line_cursor#16 = (byte*) 1024 [phi:main::@1->print_ln#0] -- pbuz1=pbuc1 lda #<$400 sta print_line_cursor lda #>$400 sta print_line_cursor+1 jsr print_ln jmp b2 //SEG20 main::@2 b2: //SEG21 [8] (byte*~) print_char_cursor#31 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG22 [9] call print_str //SEG23 [22] phi from main::@2 to print_str [phi:main::@2->print_str] print_str_from_b2: //SEG24 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#31 [phi:main::@2->print_str#0] -- register_copy //SEG25 [22] phi (byte*) print_str::str#6 = (const byte[]) msg2#0 [phi:main::@2->print_str#1] -- pbuz1=pbuc1 lda #msg2 sta print_str.str+1 jsr print_str //SEG26 [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3] b3_from_b2: jmp b3 //SEG27 main::@3 b3: //SEG28 [11] call print_ln //SEG29 [17] phi from main::@3 to print_ln [phi:main::@3->print_ln] print_ln_from_b3: //SEG30 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@3->print_ln#0] -- register_copy jsr print_ln jmp b4 //SEG31 main::@4 b4: //SEG32 [12] (byte*~) print_char_cursor#32 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG33 [13] call print_str //SEG34 [22] phi from main::@4 to print_str [phi:main::@4->print_str] print_str_from_b4: //SEG35 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#32 [phi:main::@4->print_str#0] -- register_copy //SEG36 [22] phi (byte*) print_str::str#6 = (const byte[]) msg3#0 [phi:main::@4->print_str#1] -- pbuz1=pbuc1 lda #msg3 sta print_str.str+1 jsr print_str //SEG37 [14] phi from main::@4 to main::@5 [phi:main::@4->main::@5] b5_from_b4: jmp b5 //SEG38 main::@5 b5: //SEG39 [15] call print_ln //SEG40 [17] phi from main::@5 to print_ln [phi:main::@5->print_ln] print_ln_from_b5: //SEG41 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@5->print_ln#0] -- register_copy jsr print_ln jmp breturn //SEG42 main::@return breturn: //SEG43 [16] return rts } //SEG44 print_ln // Print a newline print_ln: { //SEG45 [18] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1] b1_from_print_ln: b1_from_b1: //SEG46 [18] phi (byte*) print_line_cursor#8 = (byte*) print_line_cursor#16 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy jmp b1 //SEG47 print_ln::@1 b1: //SEG48 [19] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#8 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc print_line_cursor sta print_line_cursor bcc !+ inc print_line_cursor+1 !: //SEG49 [20] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1 lda print_line_cursor+1 cmp print_char_cursor+1 bcc b1_from_b1 bne !+ lda print_line_cursor cmp print_char_cursor bcc b1_from_b1 !: jmp breturn //SEG50 print_ln::@return breturn: //SEG51 [21] return rts } //SEG52 print_str // Print a zero-terminated string // print_str(byte* zeropage(4) str) print_str: { .label str = 4 //SEG53 [23] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1] b1_from_print_str: b1_from_b2: //SEG54 [23] phi (byte*) print_char_cursor#13 = (byte*) print_char_cursor#29 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy //SEG55 [23] phi (byte*) print_str::str#4 = (byte*) print_str::str#6 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy jmp b1 //SEG56 print_str::@1 b1: //SEG57 [24] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 -- _deref_pbuz1_neq_vbuc1_then_la1 ldy #0 lda (str),y cmp #'@' bne b2 jmp breturn //SEG58 print_str::@return breturn: //SEG59 [25] return rts //SEG60 print_str::@2 b2: //SEG61 [26] *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#4) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (str),y ldy #0 sta (print_char_cursor),y //SEG62 [27] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#13 -- pbuz1=_inc_pbuz1 inc print_char_cursor bne !+ inc print_char_cursor+1 !: //SEG63 [28] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#4 -- pbuz1=_inc_pbuz1 inc str bne !+ inc str+1 !: jmp b1_from_b2 } msg: .text "hello world! @" msg2: .text "hello c64! @" msg3: .text "hello 2017! @" ASSEMBLER OPTIMIZATIONS Removing instruction jmp b1 Removing instruction jmp bend Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 Removing instruction jmp b4 Removing instruction jmp b5 Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn Removing instruction jmp b1 Removing instruction jmp breturn Succesful ASM optimization Pass5NextJumpElimination Removing instruction ldy #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination Replacing label b1_from_b1 with b1 Replacing label b1_from_b1 with b1 Replacing label b1_from_b2 with b1 Removing instruction b1_from_bbegin: Removing instruction b1: Removing instruction main_from_b1: Removing instruction bend_from_b1: Removing instruction b1_from_main: Removing instruction print_ln_from_b1: Removing instruction b3_from_b2: Removing instruction print_ln_from_b3: Removing instruction b5_from_b4: Removing instruction print_ln_from_b5: Removing instruction b1_from_print_ln: Removing instruction b1_from_b1: Removing instruction b1_from_print_str: Removing instruction b1_from_b2: Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction bend: Removing instruction print_str_from_main: Removing instruction b1: Removing instruction b2: Removing instruction print_str_from_b2: Removing instruction b3: Removing instruction b4: Removing instruction print_str_from_b4: Removing instruction b5: Removing instruction breturn: Removing instruction breturn: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination Updating BasicUpstart to call main directly Removing instruction jsr main Succesful ASM optimization Pass5SkipBegin Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (label) @1 (label) @begin (label) @end (void()) main() (label) main::@1 (label) main::@2 (label) main::@3 (label) main::@4 (label) main::@5 (label) main::@return (byte[]) msg (const byte[]) msg#0 msg = (string) "hello world! @" (byte[]) msg2 (const byte[]) msg2#0 msg2 = (string) "hello c64! @" (byte[]) msg3 (const byte[]) msg3#0 msg3 = (string) "hello 2017! @" (byte*) print_char_cursor (byte*) print_char_cursor#1 print_char_cursor zp ZP_WORD:6 11.0 (byte*) print_char_cursor#13 print_char_cursor zp ZP_WORD:6 3.2857142857142856 (byte*) print_char_cursor#29 print_char_cursor zp ZP_WORD:6 6.0 (byte*~) print_char_cursor#31 print_char_cursor zp ZP_WORD:6 4.0 (byte*~) print_char_cursor#32 print_char_cursor zp ZP_WORD:6 4.0 (byte*) print_line_cursor (byte*) print_line_cursor#1 print_line_cursor zp ZP_WORD:2 3.7272727272727275 (byte*) print_line_cursor#16 print_line_cursor zp ZP_WORD:2 6.0 (byte*) print_line_cursor#8 print_line_cursor zp ZP_WORD:2 24.0 (void()) print_ln() (label) print_ln::@1 (label) print_ln::@return (byte*) print_screen (void()) print_str((byte*) print_str::str) (label) print_str::@1 (label) print_str::@2 (label) print_str::@return (byte*) print_str::str (byte*) print_str::str#0 str zp ZP_WORD:4 22.0 (byte*) print_str::str#4 str zp ZP_WORD:4 11.5 (byte*) print_str::str#6 str zp ZP_WORD:4 2.0 zp ZP_WORD:2 [ print_line_cursor#8 print_line_cursor#16 print_line_cursor#1 ] zp ZP_WORD:4 [ print_str::str#4 print_str::str#6 print_str::str#0 ] zp ZP_WORD:6 [ print_char_cursor#13 print_char_cursor#29 print_char_cursor#31 print_char_cursor#32 print_char_cursor#1 ] FINAL ASSEMBLER Score: 1033 //SEG0 File Comments //SEG1 Basic Upstart .pc = $801 "Basic" :BasicUpstart(main) .pc = $80d "Program" //SEG2 Global Constants & labels .label print_char_cursor = 6 .label print_line_cursor = 2 //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: { //SEG11 [5] call print_str //SEG12 [22] phi from main to print_str [phi:main->print_str] //SEG13 [22] phi (byte*) print_char_cursor#29 = (byte*) 1024 [phi:main->print_str#0] -- pbuz1=pbuc1 lda #<$400 sta print_char_cursor lda #>$400 sta print_char_cursor+1 //SEG14 [22] phi (byte*) print_str::str#6 = (const byte[]) msg#0 [phi:main->print_str#1] -- pbuz1=pbuc1 lda #msg sta print_str.str+1 jsr print_str //SEG15 [6] phi from main to main::@1 [phi:main->main::@1] //SEG16 main::@1 //SEG17 [7] call print_ln //SEG18 [17] phi from main::@1 to print_ln [phi:main::@1->print_ln] //SEG19 [17] phi (byte*) print_line_cursor#16 = (byte*) 1024 [phi:main::@1->print_ln#0] -- pbuz1=pbuc1 lda #<$400 sta print_line_cursor lda #>$400 sta print_line_cursor+1 jsr print_ln //SEG20 main::@2 //SEG21 [8] (byte*~) print_char_cursor#31 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG22 [9] call print_str //SEG23 [22] phi from main::@2 to print_str [phi:main::@2->print_str] //SEG24 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#31 [phi:main::@2->print_str#0] -- register_copy //SEG25 [22] phi (byte*) print_str::str#6 = (const byte[]) msg2#0 [phi:main::@2->print_str#1] -- pbuz1=pbuc1 lda #msg2 sta print_str.str+1 jsr print_str //SEG26 [10] phi from main::@2 to main::@3 [phi:main::@2->main::@3] //SEG27 main::@3 //SEG28 [11] call print_ln //SEG29 [17] phi from main::@3 to print_ln [phi:main::@3->print_ln] //SEG30 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@3->print_ln#0] -- register_copy jsr print_ln //SEG31 main::@4 //SEG32 [12] (byte*~) print_char_cursor#32 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2 lda print_line_cursor sta print_char_cursor lda print_line_cursor+1 sta print_char_cursor+1 //SEG33 [13] call print_str //SEG34 [22] phi from main::@4 to print_str [phi:main::@4->print_str] //SEG35 [22] phi (byte*) print_char_cursor#29 = (byte*~) print_char_cursor#32 [phi:main::@4->print_str#0] -- register_copy //SEG36 [22] phi (byte*) print_str::str#6 = (const byte[]) msg3#0 [phi:main::@4->print_str#1] -- pbuz1=pbuc1 lda #msg3 sta print_str.str+1 jsr print_str //SEG37 [14] phi from main::@4 to main::@5 [phi:main::@4->main::@5] //SEG38 main::@5 //SEG39 [15] call print_ln //SEG40 [17] phi from main::@5 to print_ln [phi:main::@5->print_ln] //SEG41 [17] phi (byte*) print_line_cursor#16 = (byte*) print_line_cursor#1 [phi:main::@5->print_ln#0] -- register_copy jsr print_ln //SEG42 main::@return //SEG43 [16] return rts } //SEG44 print_ln // Print a newline print_ln: { //SEG45 [18] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1] //SEG46 [18] phi (byte*) print_line_cursor#8 = (byte*) print_line_cursor#16 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy //SEG47 print_ln::@1 b1: //SEG48 [19] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#8 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1 lda #$28 clc adc print_line_cursor sta print_line_cursor bcc !+ inc print_line_cursor+1 !: //SEG49 [20] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#13) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1 lda print_line_cursor+1 cmp print_char_cursor+1 bcc b1 bne !+ lda print_line_cursor cmp print_char_cursor bcc b1 !: //SEG50 print_ln::@return //SEG51 [21] return rts } //SEG52 print_str // Print a zero-terminated string // print_str(byte* zeropage(4) str) print_str: { .label str = 4 //SEG53 [23] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1] //SEG54 [23] phi (byte*) print_char_cursor#13 = (byte*) print_char_cursor#29 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy //SEG55 [23] phi (byte*) print_str::str#4 = (byte*) print_str::str#6 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy //SEG56 print_str::@1 b1: //SEG57 [24] if(*((byte*) print_str::str#4)!=(byte) '@') goto print_str::@2 -- _deref_pbuz1_neq_vbuc1_then_la1 ldy #0 lda (str),y cmp #'@' bne b2 //SEG58 print_str::@return //SEG59 [25] return rts //SEG60 print_str::@2 b2: //SEG61 [26] *((byte*) print_char_cursor#13) ← *((byte*) print_str::str#4) -- _deref_pbuz1=_deref_pbuz2 ldy #0 lda (str),y sta (print_char_cursor),y //SEG62 [27] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#13 -- pbuz1=_inc_pbuz1 inc print_char_cursor bne !+ inc print_char_cursor+1 !: //SEG63 [28] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#4 -- pbuz1=_inc_pbuz1 inc str bne !+ inc str+1 !: jmp b1 } msg: .text "hello world! @" msg2: .text "hello c64! @" msg3: .text "hello 2017! @"