mirror of https://gitlab.com/camelot/kickc.git
992 lines
38 KiB
Plaintext
992 lines
38 KiB
Plaintext
Inlined call call __init
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
void print_str(char *str)
|
|
print_str: scope:[print_str] from main main::@2 main::@4
|
|
print_char_cursor#36 = phi( main/print_char_cursor#34, main::@2/print_char_cursor#7, main::@4/print_char_cursor#9 )
|
|
print_str::str#7 = phi( main/print_str::str#1, main::@2/print_str::str#2, main::@4/print_str::str#3 )
|
|
to:print_str::@1
|
|
print_str::@1: scope:[print_str] from print_str print_str::@3
|
|
print_char_cursor#32 = phi( print_str/print_char_cursor#36, print_str::@3/print_char_cursor#0 )
|
|
print_str::str#4 = phi( print_str/print_str::str#7, print_str::@3/print_str::str#0 )
|
|
print_str::$1 = 0 != *print_str::str#4
|
|
if(print_str::$1) goto print_str::@2
|
|
to:print_str::@return
|
|
print_str::@2: scope:[print_str] from print_str::@1
|
|
print_char_cursor#31 = phi( print_str::@1/print_char_cursor#32 )
|
|
print_str::str#5 = phi( print_str::@1/print_str::str#4 )
|
|
print_char::ch#0 = *print_str::str#5
|
|
call print_char
|
|
to:print_str::@3
|
|
print_str::@3: scope:[print_str] from print_str::@2
|
|
print_str::str#6 = phi( print_str::@2/print_str::str#5 )
|
|
print_char_cursor#16 = phi( print_str::@2/print_char_cursor#5 )
|
|
print_char_cursor#0 = print_char_cursor#16
|
|
print_str::str#0 = ++ print_str::str#6
|
|
to:print_str::@1
|
|
print_str::@return: scope:[print_str] from print_str::@1
|
|
print_char_cursor#17 = phi( print_str::@1/print_char_cursor#32 )
|
|
print_char_cursor#1 = print_char_cursor#17
|
|
return
|
|
to:@return
|
|
|
|
void print_ln()
|
|
print_ln: scope:[print_ln] from main::@1 main::@3 main::@5
|
|
print_char_cursor#33 = phi( main::@1/print_char_cursor#6, main::@3/print_char_cursor#8, main::@5/print_char_cursor#10 )
|
|
print_line_cursor#18 = phi( main::@1/print_line_cursor#19, main::@3/print_line_cursor#20, main::@5/print_line_cursor#21 )
|
|
to:print_ln::@1
|
|
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
|
print_char_cursor#18 = phi( print_ln/print_char_cursor#33, print_ln::@1/print_char_cursor#18 )
|
|
print_line_cursor#9 = phi( print_ln/print_line_cursor#18, print_ln::@1/print_line_cursor#0 )
|
|
print_ln::$0 = print_line_cursor#9 + $28
|
|
print_line_cursor#0 = print_ln::$0
|
|
print_ln::$1 = print_line_cursor#0 < print_char_cursor#18
|
|
if(print_ln::$1) goto print_ln::@1
|
|
to:print_ln::@2
|
|
print_ln::@2: scope:[print_ln] from print_ln::@1
|
|
print_line_cursor#10 = phi( print_ln::@1/print_line_cursor#0 )
|
|
print_char_cursor#2 = print_line_cursor#10
|
|
to:print_ln::@return
|
|
print_ln::@return: scope:[print_ln] from print_ln::@2
|
|
print_char_cursor#19 = phi( print_ln::@2/print_char_cursor#2 )
|
|
print_line_cursor#11 = phi( print_ln::@2/print_line_cursor#10 )
|
|
print_line_cursor#1 = print_line_cursor#11
|
|
print_char_cursor#3 = print_char_cursor#19
|
|
return
|
|
to:@return
|
|
|
|
void print_char(char ch)
|
|
print_char: scope:[print_char] from print_str::@2
|
|
print_char_cursor#20 = phi( print_str::@2/print_char_cursor#31 )
|
|
print_char::ch#1 = phi( print_str::@2/print_char::ch#0 )
|
|
*print_char_cursor#20 = print_char::ch#1
|
|
print_char_cursor#4 = ++ print_char_cursor#20
|
|
to:print_char::@return
|
|
print_char::@return: scope:[print_char] from print_char
|
|
print_char_cursor#21 = phi( print_char/print_char_cursor#4 )
|
|
print_char_cursor#5 = print_char_cursor#21
|
|
return
|
|
to:@return
|
|
|
|
void main()
|
|
main: scope:[main] from __start::@1
|
|
print_line_cursor#23 = phi( __start::@1/print_line_cursor#22 )
|
|
print_char_cursor#34 = phi( __start::@1/print_char_cursor#35 )
|
|
print_str::str#1 = msg
|
|
call print_str
|
|
to:main::@1
|
|
main::@1: scope:[main] from main
|
|
print_line_cursor#19 = phi( main/print_line_cursor#23 )
|
|
print_char_cursor#22 = phi( main/print_char_cursor#1 )
|
|
print_char_cursor#6 = print_char_cursor#22
|
|
call print_ln
|
|
to:main::@2
|
|
main::@2: scope:[main] from main::@1
|
|
print_char_cursor#23 = phi( main::@1/print_char_cursor#3 )
|
|
print_line_cursor#12 = phi( main::@1/print_line_cursor#1 )
|
|
print_line_cursor#2 = print_line_cursor#12
|
|
print_char_cursor#7 = print_char_cursor#23
|
|
print_str::str#2 = msg2
|
|
call print_str
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
print_line_cursor#20 = phi( main::@2/print_line_cursor#2 )
|
|
print_char_cursor#24 = phi( main::@2/print_char_cursor#1 )
|
|
print_char_cursor#8 = print_char_cursor#24
|
|
call print_ln
|
|
to:main::@4
|
|
main::@4: scope:[main] from main::@3
|
|
print_char_cursor#25 = phi( main::@3/print_char_cursor#3 )
|
|
print_line_cursor#13 = phi( main::@3/print_line_cursor#1 )
|
|
print_line_cursor#3 = print_line_cursor#13
|
|
print_char_cursor#9 = print_char_cursor#25
|
|
print_str::str#3 = msg3
|
|
call print_str
|
|
to:main::@5
|
|
main::@5: scope:[main] from main::@4
|
|
print_line_cursor#21 = phi( main::@4/print_line_cursor#3 )
|
|
print_char_cursor#26 = phi( main::@4/print_char_cursor#1 )
|
|
print_char_cursor#10 = print_char_cursor#26
|
|
call print_ln
|
|
to:main::@6
|
|
main::@6: scope:[main] from main::@5
|
|
print_char_cursor#27 = phi( main::@5/print_char_cursor#3 )
|
|
print_line_cursor#14 = phi( main::@5/print_line_cursor#1 )
|
|
print_line_cursor#4 = print_line_cursor#14
|
|
print_char_cursor#11 = print_char_cursor#27
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@6
|
|
print_line_cursor#15 = phi( main::@6/print_line_cursor#4 )
|
|
print_char_cursor#28 = phi( main::@6/print_char_cursor#11 )
|
|
print_char_cursor#12 = print_char_cursor#28
|
|
print_line_cursor#5 = print_line_cursor#15
|
|
return
|
|
to:@return
|
|
|
|
void __start()
|
|
__start: scope:[__start] from
|
|
to:__start::__init1
|
|
__start::__init1: scope:[__start] from __start
|
|
print_screen#0 = (char *)$400
|
|
print_line_cursor#6 = print_screen#0
|
|
print_char_cursor#13 = print_line_cursor#6
|
|
to:__start::@1
|
|
__start::@1: scope:[__start] from __start::__init1
|
|
print_screen#4 = phi( __start::__init1/print_screen#0 )
|
|
print_line_cursor#22 = phi( __start::__init1/print_line_cursor#6 )
|
|
print_char_cursor#35 = phi( __start::__init1/print_char_cursor#13 )
|
|
call main
|
|
to:__start::@2
|
|
__start::@2: scope:[__start] from __start::@1
|
|
print_screen#3 = phi( __start::@1/print_screen#4 )
|
|
print_line_cursor#16 = phi( __start::@1/print_line_cursor#5 )
|
|
print_char_cursor#29 = phi( __start::@1/print_char_cursor#12 )
|
|
print_char_cursor#14 = print_char_cursor#29
|
|
print_line_cursor#7 = print_line_cursor#16
|
|
to:__start::@return
|
|
__start::@return: scope:[__start] from __start::@2
|
|
print_char_cursor#30 = phi( __start::@2/print_char_cursor#14 )
|
|
print_line_cursor#17 = phi( __start::@2/print_line_cursor#7 )
|
|
print_screen#2 = phi( __start::@2/print_screen#3 )
|
|
print_screen#1 = print_screen#2
|
|
print_line_cursor#8 = print_line_cursor#17
|
|
print_char_cursor#15 = print_char_cursor#30
|
|
return
|
|
to:@return
|
|
|
|
SYMBOL TABLE SSA
|
|
__constant char RADIX::BINARY = 2
|
|
__constant char RADIX::DECIMAL = $a
|
|
__constant char RADIX::HEXADECIMAL = $10
|
|
__constant char RADIX::OCTAL = 8
|
|
void __start()
|
|
void main()
|
|
__constant char msg[] = "hello world! "
|
|
__constant char msg2[] = "hello c64! "
|
|
__constant char msg3[] = "hello 2017! "
|
|
void print_char(char ch)
|
|
char print_char::ch
|
|
char print_char::ch#0
|
|
char print_char::ch#1
|
|
char *print_char_cursor
|
|
char *print_char_cursor#0
|
|
char *print_char_cursor#1
|
|
char *print_char_cursor#10
|
|
char *print_char_cursor#11
|
|
char *print_char_cursor#12
|
|
char *print_char_cursor#13
|
|
char *print_char_cursor#14
|
|
char *print_char_cursor#15
|
|
char *print_char_cursor#16
|
|
char *print_char_cursor#17
|
|
char *print_char_cursor#18
|
|
char *print_char_cursor#19
|
|
char *print_char_cursor#2
|
|
char *print_char_cursor#20
|
|
char *print_char_cursor#21
|
|
char *print_char_cursor#22
|
|
char *print_char_cursor#23
|
|
char *print_char_cursor#24
|
|
char *print_char_cursor#25
|
|
char *print_char_cursor#26
|
|
char *print_char_cursor#27
|
|
char *print_char_cursor#28
|
|
char *print_char_cursor#29
|
|
char *print_char_cursor#3
|
|
char *print_char_cursor#30
|
|
char *print_char_cursor#31
|
|
char *print_char_cursor#32
|
|
char *print_char_cursor#33
|
|
char *print_char_cursor#34
|
|
char *print_char_cursor#35
|
|
char *print_char_cursor#36
|
|
char *print_char_cursor#4
|
|
char *print_char_cursor#5
|
|
char *print_char_cursor#6
|
|
char *print_char_cursor#7
|
|
char *print_char_cursor#8
|
|
char *print_char_cursor#9
|
|
char *print_line_cursor
|
|
char *print_line_cursor#0
|
|
char *print_line_cursor#1
|
|
char *print_line_cursor#10
|
|
char *print_line_cursor#11
|
|
char *print_line_cursor#12
|
|
char *print_line_cursor#13
|
|
char *print_line_cursor#14
|
|
char *print_line_cursor#15
|
|
char *print_line_cursor#16
|
|
char *print_line_cursor#17
|
|
char *print_line_cursor#18
|
|
char *print_line_cursor#19
|
|
char *print_line_cursor#2
|
|
char *print_line_cursor#20
|
|
char *print_line_cursor#21
|
|
char *print_line_cursor#22
|
|
char *print_line_cursor#23
|
|
char *print_line_cursor#3
|
|
char *print_line_cursor#4
|
|
char *print_line_cursor#5
|
|
char *print_line_cursor#6
|
|
char *print_line_cursor#7
|
|
char *print_line_cursor#8
|
|
char *print_line_cursor#9
|
|
void print_ln()
|
|
char *print_ln::$0
|
|
bool print_ln::$1
|
|
char *print_screen
|
|
char *print_screen#0
|
|
char *print_screen#1
|
|
char *print_screen#2
|
|
char *print_screen#3
|
|
char *print_screen#4
|
|
void print_str(char *str)
|
|
bool print_str::$1
|
|
char *print_str::str
|
|
char *print_str::str#0
|
|
char *print_str::str#1
|
|
char *print_str::str#2
|
|
char *print_str::str#3
|
|
char *print_str::str#4
|
|
char *print_str::str#5
|
|
char *print_str::str#6
|
|
char *print_str::str#7
|
|
|
|
Adding number conversion cast (unumber) 0 in print_str::$1 = 0 != *print_str::str#4
|
|
Adding number conversion cast (unumber) $28 in print_ln::$0 = print_line_cursor#9 + $28
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast $28
|
|
Simplifying constant pointer cast (char *) 1024
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (char) 0
|
|
Finalized unsigned number type (char) $28
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Alias print_str::str#4 = print_str::str#5 print_str::str#6
|
|
Alias print_char_cursor#1 = print_char_cursor#31 print_char_cursor#32 print_char_cursor#17
|
|
Alias print_char_cursor#0 = print_char_cursor#16
|
|
Alias print_line_cursor#0 = print_ln::$0 print_line_cursor#10 print_char_cursor#2 print_line_cursor#11 print_char_cursor#19 print_line_cursor#1 print_char_cursor#3
|
|
Alias print_char_cursor#21 = print_char_cursor#4 print_char_cursor#5
|
|
Alias print_line_cursor#19 = print_line_cursor#23
|
|
Alias print_char_cursor#22 = print_char_cursor#6
|
|
Alias print_line_cursor#12 = print_line_cursor#2 print_line_cursor#20
|
|
Alias print_char_cursor#23 = print_char_cursor#7
|
|
Alias print_char_cursor#24 = print_char_cursor#8
|
|
Alias print_line_cursor#13 = print_line_cursor#3 print_line_cursor#21
|
|
Alias print_char_cursor#25 = print_char_cursor#9
|
|
Alias print_char_cursor#10 = print_char_cursor#26
|
|
Alias print_line_cursor#14 = print_line_cursor#4 print_line_cursor#15 print_line_cursor#5
|
|
Alias print_char_cursor#11 = print_char_cursor#27 print_char_cursor#28 print_char_cursor#12
|
|
Alias print_screen#0 = print_line_cursor#6 print_char_cursor#13 print_char_cursor#35 print_line_cursor#22 print_screen#4 print_screen#3 print_screen#2 print_screen#1
|
|
Alias print_char_cursor#14 = print_char_cursor#29 print_char_cursor#30 print_char_cursor#15
|
|
Alias print_line_cursor#16 = print_line_cursor#7 print_line_cursor#17 print_line_cursor#8
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Identical Phi Values print_char_cursor#0 print_char_cursor#21
|
|
Identical Phi Values print_char_cursor#18 print_char_cursor#33
|
|
Identical Phi Values print_char::ch#1 print_char::ch#0
|
|
Identical Phi Values print_char_cursor#20 print_char_cursor#1
|
|
Identical Phi Values print_char_cursor#34 print_screen#0
|
|
Identical Phi Values print_line_cursor#19 print_screen#0
|
|
Identical Phi Values print_char_cursor#22 print_char_cursor#1
|
|
Identical Phi Values print_line_cursor#12 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#23 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#24 print_char_cursor#1
|
|
Identical Phi Values print_line_cursor#13 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#25 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#10 print_char_cursor#1
|
|
Identical Phi Values print_line_cursor#14 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#11 print_line_cursor#0
|
|
Identical Phi Values print_char_cursor#14 print_char_cursor#11
|
|
Identical Phi Values print_line_cursor#16 print_line_cursor#14
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Identical Phi Values print_char_cursor#33 print_char_cursor#1
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Simple Condition print_str::$1 [3] if(0!=*print_str::str#4) goto print_str::@2
|
|
Simple Condition print_ln::$1 [13] if(print_line_cursor#0<print_char_cursor#1) goto print_ln::@1
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
Constant print_str::str#1 = msg
|
|
Constant print_str::str#2 = msg2
|
|
Constant print_str::str#3 = msg3
|
|
Constant print_screen#0 = (char *) 1024
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Removing unused procedure __start
|
|
Removing unused procedure block __start
|
|
Removing unused procedure block __start::__init1
|
|
Removing unused procedure block __start::@1
|
|
Removing unused procedure block __start::@2
|
|
Removing unused procedure block __start::@return
|
|
Successful SSA optimization PassNEliminateEmptyStart
|
|
Inlining constant with var siblings print_str::str#1
|
|
Inlining constant with var siblings print_str::str#2
|
|
Inlining constant with var siblings print_str::str#3
|
|
Constant inlined print_str::str#3 = msg3
|
|
Constant inlined print_str::str#2 = msg2
|
|
Constant inlined print_str::str#1 = msg
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Finalized unsigned number type (char) 2
|
|
Finalized unsigned number type (char) 8
|
|
Finalized unsigned number type (char) $a
|
|
Finalized unsigned number type (char) $10
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Added new block during phi lifting print_ln::@3(between print_ln::@1 and print_ln::@1)
|
|
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 [main] to print_str:1 print_ln:3 print_str:5 print_ln:7 print_str:9 print_ln:11
|
|
Calls in [print_str] to print_char:21
|
|
|
|
Created 6 initial phi equivalence classes
|
|
Not coalescing [4] print_char_cursor#37 = print_line_cursor#0
|
|
Coalesced [6] print_line_cursor#24 = print_line_cursor#0
|
|
Not coalescing [8] print_char_cursor#38 = print_line_cursor#0
|
|
Coalesced (already) [10] print_line_cursor#25 = print_line_cursor#0
|
|
Coalesced [15] print_str::str#8 = print_str::str#7
|
|
Coalesced [16] print_char_cursor#39 = print_char_cursor#36
|
|
Coalesced [23] print_str::str#9 = print_str::str#0
|
|
Coalesced [24] print_char_cursor#40 = print_char_cursor#21
|
|
Coalesced [26] print_line_cursor#26 = print_line_cursor#18
|
|
Coalesced (already) [32] print_line_cursor#27 = print_line_cursor#0
|
|
Coalesced down to 3 phi equivalence classes
|
|
Culled Empty Block label main::@6
|
|
Culled Empty Block label print_ln::@2
|
|
Culled Empty Block label print_ln::@3
|
|
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
|
|
|
|
void main()
|
|
main: scope:[main] from
|
|
[0] phi()
|
|
[1] call print_str
|
|
to:main::@1
|
|
main::@1: scope:[main] from main
|
|
[2] phi()
|
|
[3] call print_ln
|
|
to:main::@2
|
|
main::@2: scope:[main] from main::@1
|
|
[4] print_char_cursor#37 = print_line_cursor#0
|
|
[5] call print_str
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
[6] phi()
|
|
[7] call print_ln
|
|
to:main::@4
|
|
main::@4: scope:[main] from main::@3
|
|
[8] print_char_cursor#38 = print_line_cursor#0
|
|
[9] call print_str
|
|
to:main::@5
|
|
main::@5: scope:[main] from main::@4
|
|
[10] phi()
|
|
[11] call print_ln
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@5
|
|
[12] return
|
|
to:@return
|
|
|
|
void print_str(char *str)
|
|
print_str: scope:[print_str] from main main::@2 main::@4
|
|
[13] print_char_cursor#36 = phi( main/print_screen#0, main::@2/print_char_cursor#37, main::@4/print_char_cursor#38 )
|
|
[13] print_str::str#7 = phi( main/msg, main::@2/msg2, main::@4/msg3 )
|
|
to:print_str::@1
|
|
print_str::@1: scope:[print_str] from print_str print_str::@3
|
|
[14] print_char_cursor#1 = phi( print_str/print_char_cursor#36, print_str::@3/print_char_cursor#21 )
|
|
[14] print_str::str#4 = phi( print_str/print_str::str#7, print_str::@3/print_str::str#0 )
|
|
[15] if(0!=*print_str::str#4) goto print_str::@2
|
|
to:print_str::@return
|
|
print_str::@return: scope:[print_str] from print_str::@1
|
|
[16] return
|
|
to:@return
|
|
print_str::@2: scope:[print_str] from print_str::@1
|
|
[17] print_char::ch#0 = *print_str::str#4
|
|
[18] call print_char
|
|
to:print_str::@3
|
|
print_str::@3: scope:[print_str] from print_str::@2
|
|
[19] print_str::str#0 = ++ print_str::str#4
|
|
to:print_str::@1
|
|
|
|
void print_ln()
|
|
print_ln: scope:[print_ln] from main::@1 main::@3 main::@5
|
|
[20] print_line_cursor#18 = phi( main::@1/print_screen#0, main::@3/print_line_cursor#0, main::@5/print_line_cursor#0 )
|
|
to:print_ln::@1
|
|
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
|
[21] print_line_cursor#9 = phi( print_ln/print_line_cursor#18, print_ln::@1/print_line_cursor#0 )
|
|
[22] print_line_cursor#0 = print_line_cursor#9 + $28
|
|
[23] if(print_line_cursor#0<print_char_cursor#1) goto print_ln::@1
|
|
to:print_ln::@return
|
|
print_ln::@return: scope:[print_ln] from print_ln::@1
|
|
[24] return
|
|
to:@return
|
|
|
|
void print_char(char ch)
|
|
print_char: scope:[print_char] from print_str::@2
|
|
[25] *print_char_cursor#1 = print_char::ch#0
|
|
[26] print_char_cursor#21 = ++ print_char_cursor#1
|
|
to:print_char::@return
|
|
print_char::@return: scope:[print_char] from print_char
|
|
[27] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
void main()
|
|
void print_char(char ch)
|
|
char print_char::ch
|
|
char print_char::ch#0 // 1102.0
|
|
char *print_char_cursor
|
|
char *print_char_cursor#1 // 147.66666666666669
|
|
char *print_char_cursor#21 // 275.5
|
|
char *print_char_cursor#36 // 15.0
|
|
char *print_char_cursor#37 // 4.0
|
|
char *print_char_cursor#38 // 4.0
|
|
char *print_line_cursor
|
|
char *print_line_cursor#0 // 28.272727272727273
|
|
char *print_line_cursor#18 // 15.0
|
|
char *print_line_cursor#9 // 213.0
|
|
void print_ln()
|
|
char *print_screen
|
|
void print_str(char *str)
|
|
char *print_str::str
|
|
char *print_str::str#0 // 202.0
|
|
char *print_str::str#4 // 103.75
|
|
char *print_str::str#7 // 11.0
|
|
|
|
Initial phi equivalence classes
|
|
[ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
[ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ]
|
|
[ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
Added variable print_char::ch#0 to live range equivalence class [ print_char::ch#0 ]
|
|
Complete equivalence classes
|
|
[ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
[ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ]
|
|
[ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
[ print_char::ch#0 ]
|
|
Allocated zp[1]:2 [ print_char::ch#0 ]
|
|
Allocated zp[2]:3 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ]
|
|
Allocated zp[2]:5 [ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
Allocated zp[2]:7 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] print_char_cursor#37 = print_line_cursor#0 [ print_char_cursor#37 print_line_cursor#0 ] ( [ print_char_cursor#37 print_line_cursor#0 ] { { print_char_cursor#36 = print_char_cursor#37 } } ) always clobbers reg byte a
|
|
Statement [8] print_char_cursor#38 = print_line_cursor#0 [ print_line_cursor#0 print_char_cursor#38 ] ( [ print_line_cursor#0 print_char_cursor#38 ] { { print_char_cursor#36 = print_char_cursor#38 } } ) always clobbers reg byte a
|
|
Statement [15] if(0!=*print_str::str#4) goto print_str::@2 [ print_str::str#4 print_char_cursor#1 ] ( print_str:1 [ print_str::str#4 print_char_cursor#1 ] { } print_str:5 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 ] { { print_char_cursor#36 = print_char_cursor#37 } } print_str:9 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 ] { { print_char_cursor#36 = print_char_cursor#38 } } ) always clobbers reg byte a reg byte y
|
|
Statement [17] print_char::ch#0 = *print_str::str#4 [ print_str::str#4 print_char_cursor#1 print_char::ch#0 ] ( print_str:1 [ print_str::str#4 print_char_cursor#1 print_char::ch#0 ] { } print_str:5 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 print_char::ch#0 ] { { print_char_cursor#36 = print_char_cursor#37 } } print_str:9 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 print_char::ch#0 ] { { print_char_cursor#36 = print_char_cursor#38 } } ) always clobbers reg byte a reg byte y
|
|
Statement [22] print_line_cursor#0 = print_line_cursor#9 + $28 [ print_line_cursor#0 print_char_cursor#1 ] ( print_ln:3 [ print_line_cursor#0 print_char_cursor#1 ] { } print_ln:7 [ print_line_cursor#0 print_char_cursor#1 ] { { print_line_cursor#0 = print_line_cursor#18 } } print_ln:11 [ print_line_cursor#0 print_char_cursor#1 ] { { print_line_cursor#0 = print_line_cursor#18 } } ) always clobbers reg byte a
|
|
Statement [23] if(print_line_cursor#0<print_char_cursor#1) goto print_ln::@1 [ print_line_cursor#0 print_char_cursor#1 ] ( print_ln:3 [ print_line_cursor#0 print_char_cursor#1 ] { } print_ln:7 [ print_line_cursor#0 print_char_cursor#1 ] { { print_line_cursor#0 = print_line_cursor#18 } } print_ln:11 [ print_line_cursor#0 print_char_cursor#1 ] { { print_line_cursor#0 = print_line_cursor#18 } } ) always clobbers reg byte a
|
|
Statement [25] *print_char_cursor#1 = print_char::ch#0 [ print_char_cursor#1 ] ( print_str:1::print_char:18 [ print_str::str#4 print_char_cursor#1 ] { } print_str:5::print_char:18 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 ] { { print_char_cursor#36 = print_char_cursor#37 } } print_str:9::print_char:18 [ print_line_cursor#0 print_str::str#4 print_char_cursor#1 ] { { print_char_cursor#36 = print_char_cursor#38 } } ) always clobbers reg byte y
|
|
Potential registers zp[2]:5 [ print_str::str#4 print_str::str#7 print_str::str#0 ] : zp[2]:5 ,
|
|
Potential registers zp[2]:3 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ] : zp[2]:3 ,
|
|
Potential registers zp[2]:7 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ] : zp[2]:7 ,
|
|
Potential registers zp[1]:2 [ print_char::ch#0 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [print_char] 1,102: zp[1]:2 [ print_char::ch#0 ]
|
|
Uplift Scope [] 446.17: zp[2]:3 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ] 256.27: zp[2]:7 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
Uplift Scope [print_str] 316.75: zp[2]:5 [ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
Uplift Scope [print_ln]
|
|
Uplift Scope [RADIX]
|
|
Uplift Scope [main]
|
|
|
|
Uplifting [print_char] best 1105 combination reg byte a [ print_char::ch#0 ]
|
|
Uplifting [] best 1105 combination zp[2]:3 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ] zp[2]:7 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
Uplifting [print_str] best 1105 combination zp[2]:5 [ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
Uplifting [print_ln] best 1105 combination
|
|
Uplifting [RADIX] best 1105 combination
|
|
Uplifting [main] best 1105 combination
|
|
Allocated (was zp[2]:3) zp[2]:2 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ]
|
|
Allocated (was zp[2]:5) zp[2]:4 [ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
Allocated (was zp[2]:7) zp[2]:6 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
/// @file
|
|
/// A lightweight library for printing on the C64.
|
|
///
|
|
/// Printing with this library is done by calling print_ function for each element
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="printmsg.prg", type="prg", segments="Program"]
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
.segmentdef Basic [start=$0801]
|
|
.segmentdef Code [start=$80d]
|
|
.segmentdef Data [startAfter="Code"]
|
|
.segment Basic
|
|
:BasicUpstart(main)
|
|
// Global Constants & labels
|
|
.label print_screen = $400
|
|
.label print_char_cursor = 2
|
|
.label print_line_cursor = 6
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
// [1] call print_str
|
|
// [13] phi from main to print_str [phi:main->print_str]
|
|
print_str_from_main:
|
|
// [13] phi print_char_cursor#36 = print_screen#0 [phi:main->print_str#0] -- pbuz1=pbuc1
|
|
lda #<print_screen
|
|
sta.z print_char_cursor
|
|
lda #>print_screen
|
|
sta.z print_char_cursor+1
|
|
// [13] phi print_str::str#7 = msg [phi:main->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg
|
|
sta.z print_str.str
|
|
lda #>msg
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [2] phi from main to main::@1 [phi:main->main::@1]
|
|
__b1_from_main:
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [3] call print_ln
|
|
// [20] phi from main::@1 to print_ln [phi:main::@1->print_ln]
|
|
print_ln_from___b1:
|
|
// [20] phi print_line_cursor#18 = print_screen#0 [phi:main::@1->print_ln#0] -- pbuz1=pbuc1
|
|
lda #<print_screen
|
|
sta.z print_line_cursor
|
|
lda #>print_screen
|
|
sta.z print_line_cursor+1
|
|
jsr print_ln
|
|
jmp __b2
|
|
// main::@2
|
|
__b2:
|
|
// [4] print_char_cursor#37 = print_line_cursor#0 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// [5] call print_str
|
|
// [13] phi from main::@2 to print_str [phi:main::@2->print_str]
|
|
print_str_from___b2:
|
|
// [13] phi print_char_cursor#36 = print_char_cursor#37 [phi:main::@2->print_str#0] -- register_copy
|
|
// [13] phi print_str::str#7 = msg2 [phi:main::@2->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg2
|
|
sta.z print_str.str
|
|
lda #>msg2
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [6] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
__b3_from___b2:
|
|
jmp __b3
|
|
// main::@3
|
|
__b3:
|
|
// [7] call print_ln
|
|
// [20] phi from main::@3 to print_ln [phi:main::@3->print_ln]
|
|
print_ln_from___b3:
|
|
// [20] phi print_line_cursor#18 = print_line_cursor#0 [phi:main::@3->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
jmp __b4
|
|
// main::@4
|
|
__b4:
|
|
// [8] print_char_cursor#38 = print_line_cursor#0 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// [9] call print_str
|
|
// [13] phi from main::@4 to print_str [phi:main::@4->print_str]
|
|
print_str_from___b4:
|
|
// [13] phi print_char_cursor#36 = print_char_cursor#38 [phi:main::@4->print_str#0] -- register_copy
|
|
// [13] phi print_str::str#7 = msg3 [phi:main::@4->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg3
|
|
sta.z print_str.str
|
|
lda #>msg3
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [10] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
|
|
__b5_from___b4:
|
|
jmp __b5
|
|
// main::@5
|
|
__b5:
|
|
// [11] call print_ln
|
|
// [20] phi from main::@5 to print_ln [phi:main::@5->print_ln]
|
|
print_ln_from___b5:
|
|
// [20] phi print_line_cursor#18 = print_line_cursor#0 [phi:main::@5->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [12] return
|
|
rts
|
|
}
|
|
// print_str
|
|
// Print a zero-terminated string
|
|
// void print_str(__zp(4) char *str)
|
|
print_str: {
|
|
.label str = 4
|
|
// [14] phi from print_str print_str::@3 to print_str::@1 [phi:print_str/print_str::@3->print_str::@1]
|
|
__b1_from_print_str:
|
|
__b1_from___b3:
|
|
// [14] phi print_char_cursor#1 = print_char_cursor#36 [phi:print_str/print_str::@3->print_str::@1#0] -- register_copy
|
|
// [14] phi print_str::str#4 = print_str::str#7 [phi:print_str/print_str::@3->print_str::@1#1] -- register_copy
|
|
jmp __b1
|
|
// print_str::@1
|
|
__b1:
|
|
// [15] if(0!=*print_str::str#4) goto print_str::@2 -- 0_neq__deref_pbuz1_then_la1
|
|
ldy #0
|
|
lda (str),y
|
|
cmp #0
|
|
bne __b2
|
|
jmp __breturn
|
|
// print_str::@return
|
|
__breturn:
|
|
// [16] return
|
|
rts
|
|
// print_str::@2
|
|
__b2:
|
|
// [17] print_char::ch#0 = *print_str::str#4 -- vbuaa=_deref_pbuz1
|
|
ldy #0
|
|
lda (str),y
|
|
// [18] call print_char
|
|
jsr print_char
|
|
jmp __b3
|
|
// print_str::@3
|
|
__b3:
|
|
// [19] print_str::str#0 = ++ print_str::str#4 -- pbuz1=_inc_pbuz1
|
|
inc.z str
|
|
bne !+
|
|
inc.z str+1
|
|
!:
|
|
jmp __b1_from___b3
|
|
}
|
|
// print_ln
|
|
// Print a newline
|
|
print_ln: {
|
|
// [21] 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:
|
|
// [21] phi print_line_cursor#9 = print_line_cursor#18 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy
|
|
jmp __b1
|
|
// print_ln::@1
|
|
__b1:
|
|
// [22] print_line_cursor#0 = print_line_cursor#9 + $28 -- pbuz1=pbuz1_plus_vbuc1
|
|
lda #$28
|
|
clc
|
|
adc.z print_line_cursor
|
|
sta.z print_line_cursor
|
|
bcc !+
|
|
inc.z print_line_cursor+1
|
|
!:
|
|
// [23] if(print_line_cursor#0<print_char_cursor#1) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1
|
|
lda.z print_line_cursor+1
|
|
cmp.z print_char_cursor+1
|
|
bcc __b1_from___b1
|
|
bne !+
|
|
lda.z print_line_cursor
|
|
cmp.z print_char_cursor
|
|
bcc __b1_from___b1
|
|
!:
|
|
jmp __breturn
|
|
// print_ln::@return
|
|
__breturn:
|
|
// [24] return
|
|
rts
|
|
}
|
|
// print_char
|
|
// Print a single char
|
|
// void print_char(__register(A) char ch)
|
|
print_char: {
|
|
// [25] *print_char_cursor#1 = print_char::ch#0 -- _deref_pbuz1=vbuaa
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// [26] print_char_cursor#21 = ++ print_char_cursor#1 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
jmp __breturn
|
|
// print_char::@return
|
|
__breturn:
|
|
// [27] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
msg: .text "hello world! "
|
|
.byte 0
|
|
msg2: .text "hello c64! "
|
|
.byte 0
|
|
msg3: .text "hello 2017! "
|
|
.byte 0
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
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 __b3
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Replacing label __b1_from___b3 with __b1
|
|
Replacing label __b1_from___b1 with __b1
|
|
Replacing label __b1_from___b1 with __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_str:
|
|
Removing instruction __b1_from___b3:
|
|
Removing instruction __b1_from_print_ln:
|
|
Removing instruction __b1_from___b1:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
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 __b3:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
__constant char RADIX::BINARY = 2
|
|
__constant char RADIX::DECIMAL = $a
|
|
__constant char RADIX::HEXADECIMAL = $10
|
|
__constant char RADIX::OCTAL = 8
|
|
void main()
|
|
__constant char msg[] = "hello world! "
|
|
__constant char msg2[] = "hello c64! "
|
|
__constant char msg3[] = "hello 2017! "
|
|
void print_char(char ch)
|
|
char print_char::ch
|
|
char print_char::ch#0 // reg byte a 1102.0
|
|
char *print_char_cursor
|
|
char *print_char_cursor#1 // print_char_cursor zp[2]:2 147.66666666666669
|
|
char *print_char_cursor#21 // print_char_cursor zp[2]:2 275.5
|
|
char *print_char_cursor#36 // print_char_cursor zp[2]:2 15.0
|
|
char *print_char_cursor#37 // print_char_cursor zp[2]:2 4.0
|
|
char *print_char_cursor#38 // print_char_cursor zp[2]:2 4.0
|
|
char *print_line_cursor
|
|
char *print_line_cursor#0 // print_line_cursor zp[2]:6 28.272727272727273
|
|
char *print_line_cursor#18 // print_line_cursor zp[2]:6 15.0
|
|
char *print_line_cursor#9 // print_line_cursor zp[2]:6 213.0
|
|
void print_ln()
|
|
char *print_screen
|
|
__constant char *print_screen#0 = (char *) 1024 // print_screen
|
|
void print_str(char *str)
|
|
char *print_str::str
|
|
char *print_str::str#0 // str zp[2]:4 202.0
|
|
char *print_str::str#4 // str zp[2]:4 103.75
|
|
char *print_str::str#7 // str zp[2]:4 11.0
|
|
|
|
zp[2]:4 [ print_str::str#4 print_str::str#7 print_str::str#0 ]
|
|
zp[2]:2 [ print_char_cursor#1 print_char_cursor#36 print_char_cursor#37 print_char_cursor#38 print_char_cursor#21 ]
|
|
zp[2]:6 [ print_line_cursor#9 print_line_cursor#18 print_line_cursor#0 ]
|
|
reg byte a [ print_char::ch#0 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 934
|
|
|
|
// File Comments
|
|
/// @file
|
|
/// A lightweight library for printing on the C64.
|
|
///
|
|
/// Printing with this library is done by calling print_ function for each element
|
|
// Upstart
|
|
// Commodore 64 PRG executable file
|
|
.file [name="printmsg.prg", type="prg", segments="Program"]
|
|
.segmentdef Program [segments="Basic, Code, Data"]
|
|
.segmentdef Basic [start=$0801]
|
|
.segmentdef Code [start=$80d]
|
|
.segmentdef Data [startAfter="Code"]
|
|
.segment Basic
|
|
:BasicUpstart(main)
|
|
// Global Constants & labels
|
|
.label print_screen = $400
|
|
.label print_char_cursor = 2
|
|
.label print_line_cursor = 6
|
|
.segment Code
|
|
// main
|
|
main: {
|
|
// print_str(msg)
|
|
// [1] call print_str
|
|
// [13] phi from main to print_str [phi:main->print_str]
|
|
// [13] phi print_char_cursor#36 = print_screen#0 [phi:main->print_str#0] -- pbuz1=pbuc1
|
|
lda #<print_screen
|
|
sta.z print_char_cursor
|
|
lda #>print_screen
|
|
sta.z print_char_cursor+1
|
|
// [13] phi print_str::str#7 = msg [phi:main->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg
|
|
sta.z print_str.str
|
|
lda #>msg
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [2] phi from main to main::@1 [phi:main->main::@1]
|
|
// main::@1
|
|
// print_ln()
|
|
// [3] call print_ln
|
|
// [20] phi from main::@1 to print_ln [phi:main::@1->print_ln]
|
|
// [20] phi print_line_cursor#18 = print_screen#0 [phi:main::@1->print_ln#0] -- pbuz1=pbuc1
|
|
lda #<print_screen
|
|
sta.z print_line_cursor
|
|
lda #>print_screen
|
|
sta.z print_line_cursor+1
|
|
jsr print_ln
|
|
// main::@2
|
|
// [4] print_char_cursor#37 = print_line_cursor#0 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// print_str(msg2)
|
|
// [5] call print_str
|
|
// [13] phi from main::@2 to print_str [phi:main::@2->print_str]
|
|
// [13] phi print_char_cursor#36 = print_char_cursor#37 [phi:main::@2->print_str#0] -- register_copy
|
|
// [13] phi print_str::str#7 = msg2 [phi:main::@2->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg2
|
|
sta.z print_str.str
|
|
lda #>msg2
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [6] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
// main::@3
|
|
// print_ln()
|
|
// [7] call print_ln
|
|
// [20] phi from main::@3 to print_ln [phi:main::@3->print_ln]
|
|
// [20] phi print_line_cursor#18 = print_line_cursor#0 [phi:main::@3->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
// main::@4
|
|
// [8] print_char_cursor#38 = print_line_cursor#0 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// print_str(msg3)
|
|
// [9] call print_str
|
|
// [13] phi from main::@4 to print_str [phi:main::@4->print_str]
|
|
// [13] phi print_char_cursor#36 = print_char_cursor#38 [phi:main::@4->print_str#0] -- register_copy
|
|
// [13] phi print_str::str#7 = msg3 [phi:main::@4->print_str#1] -- pbuz1=pbuc1
|
|
lda #<msg3
|
|
sta.z print_str.str
|
|
lda #>msg3
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// [10] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
|
|
// main::@5
|
|
// print_ln()
|
|
// [11] call print_ln
|
|
// [20] phi from main::@5 to print_ln [phi:main::@5->print_ln]
|
|
// [20] phi print_line_cursor#18 = print_line_cursor#0 [phi:main::@5->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
// main::@return
|
|
// }
|
|
// [12] return
|
|
rts
|
|
}
|
|
// print_str
|
|
// Print a zero-terminated string
|
|
// void print_str(__zp(4) char *str)
|
|
print_str: {
|
|
.label str = 4
|
|
// [14] phi from print_str print_str::@3 to print_str::@1 [phi:print_str/print_str::@3->print_str::@1]
|
|
// [14] phi print_char_cursor#1 = print_char_cursor#36 [phi:print_str/print_str::@3->print_str::@1#0] -- register_copy
|
|
// [14] phi print_str::str#4 = print_str::str#7 [phi:print_str/print_str::@3->print_str::@1#1] -- register_copy
|
|
// print_str::@1
|
|
__b1:
|
|
// while(*str)
|
|
// [15] if(0!=*print_str::str#4) goto print_str::@2 -- 0_neq__deref_pbuz1_then_la1
|
|
ldy #0
|
|
lda (str),y
|
|
cmp #0
|
|
bne __b2
|
|
// print_str::@return
|
|
// }
|
|
// [16] return
|
|
rts
|
|
// print_str::@2
|
|
__b2:
|
|
// print_char(*(str++))
|
|
// [17] print_char::ch#0 = *print_str::str#4 -- vbuaa=_deref_pbuz1
|
|
ldy #0
|
|
lda (str),y
|
|
// [18] call print_char
|
|
jsr print_char
|
|
// print_str::@3
|
|
// print_char(*(str++));
|
|
// [19] print_str::str#0 = ++ print_str::str#4 -- pbuz1=_inc_pbuz1
|
|
inc.z str
|
|
bne !+
|
|
inc.z str+1
|
|
!:
|
|
jmp __b1
|
|
}
|
|
// print_ln
|
|
// Print a newline
|
|
print_ln: {
|
|
// [21] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1]
|
|
// [21] phi print_line_cursor#9 = print_line_cursor#18 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy
|
|
// print_ln::@1
|
|
__b1:
|
|
// print_line_cursor + 0x28
|
|
// [22] print_line_cursor#0 = print_line_cursor#9 + $28 -- pbuz1=pbuz1_plus_vbuc1
|
|
lda #$28
|
|
clc
|
|
adc.z print_line_cursor
|
|
sta.z print_line_cursor
|
|
bcc !+
|
|
inc.z print_line_cursor+1
|
|
!:
|
|
// while (print_line_cursor<print_char_cursor)
|
|
// [23] if(print_line_cursor#0<print_char_cursor#1) goto print_ln::@1 -- pbuz1_lt_pbuz2_then_la1
|
|
lda.z print_line_cursor+1
|
|
cmp.z print_char_cursor+1
|
|
bcc __b1
|
|
bne !+
|
|
lda.z print_line_cursor
|
|
cmp.z print_char_cursor
|
|
bcc __b1
|
|
!:
|
|
// print_ln::@return
|
|
// }
|
|
// [24] return
|
|
rts
|
|
}
|
|
// print_char
|
|
// Print a single char
|
|
// void print_char(__register(A) char ch)
|
|
print_char: {
|
|
// *(print_char_cursor++) = ch
|
|
// [25] *print_char_cursor#1 = print_char::ch#0 -- _deref_pbuz1=vbuaa
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// *(print_char_cursor++) = ch;
|
|
// [26] print_char_cursor#21 = ++ print_char_cursor#1 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
// print_char::@return
|
|
// }
|
|
// [27] return
|
|
rts
|
|
}
|
|
// File Data
|
|
.segment Data
|
|
msg: .text "hello world! "
|
|
.byte 0
|
|
msg2: .text "hello c64! "
|
|
.byte 0
|
|
msg3: .text "hello 2017! "
|
|
.byte 0
|
|
|