kickc/src/test/ref/millfork-benchmarks/sieve-kc.log

2184 lines
88 KiB
Plaintext

Setting inferred volatile on symbol affected by address-of last_time
Inlined call vicSelectGfxBank::$0 = call toDd00(vicSelectGfxBank::gfx)
Inlined call call __init
CONTROL FLOW GRAPH SSA
void print_ln()
print_ln: scope:[print_ln] from end::@2
print_char_cursor#35 = phi( end::@2/print_char_cursor#10 )
print_line_cursor#18 = phi( end::@2/print_line_cursor#19 )
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#35, 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#0 = 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#0 )
print_line_cursor#11 = phi( print_ln::@2/print_line_cursor#10 )
print_line_cursor#1 = print_line_cursor#11
print_char_cursor#1 = print_char_cursor#19
return
to:@return
void print_uint(unsigned int w)
print_uint: scope:[print_uint] from end::@1
print_char_cursor#36 = phi( end::@1/print_char_cursor#38 )
print_uint::w#1 = phi( end::@1/print_uint::w#0 )
print_uint::$0 = byte1 print_uint::w#1
print_uchar::b#0 = print_uint::$0
call print_uchar
to:print_uint::@1
print_uint::@1: scope:[print_uint] from print_uint
print_uint::w#2 = phi( print_uint/print_uint::w#1 )
print_char_cursor#20 = phi( print_uint/print_char_cursor#7 )
print_char_cursor#2 = print_char_cursor#20
print_uint::$2 = byte0 print_uint::w#2
print_uchar::b#1 = print_uint::$2
call print_uchar
to:print_uint::@2
print_uint::@2: scope:[print_uint] from print_uint::@1
print_char_cursor#21 = phi( print_uint::@1/print_char_cursor#7 )
print_char_cursor#3 = print_char_cursor#21
to:print_uint::@return
print_uint::@return: scope:[print_uint] from print_uint::@2
print_char_cursor#22 = phi( print_uint::@2/print_char_cursor#3 )
print_char_cursor#4 = print_char_cursor#22
return
to:@return
void print_uchar(char b)
print_uchar: scope:[print_uchar] from print_uint print_uint::@1
print_char_cursor#37 = phi( print_uint/print_char_cursor#36, print_uint::@1/print_char_cursor#2 )
print_uchar::b#2 = phi( print_uint/print_uchar::b#0, print_uint::@1/print_uchar::b#1 )
print_uchar::$0 = print_uchar::b#2 >> 4
print_char::ch#0 = print_hextab[print_uchar::$0]
call print_char
to:print_uchar::@1
print_uchar::@1: scope:[print_uchar] from print_uchar
print_uchar::b#3 = phi( print_uchar/print_uchar::b#2 )
print_char_cursor#23 = phi( print_uchar/print_char_cursor#9 )
print_char_cursor#5 = print_char_cursor#23
print_uchar::$2 = print_uchar::b#3 & $f
print_char::ch#1 = print_hextab[print_uchar::$2]
call print_char
to:print_uchar::@2
print_uchar::@2: scope:[print_uchar] from print_uchar::@1
print_char_cursor#24 = phi( print_uchar::@1/print_char_cursor#9 )
print_char_cursor#6 = print_char_cursor#24
to:print_uchar::@return
print_uchar::@return: scope:[print_uchar] from print_uchar::@2
print_char_cursor#25 = phi( print_uchar::@2/print_char_cursor#6 )
print_char_cursor#7 = print_char_cursor#25
return
to:@return
void print_char(char ch)
print_char: scope:[print_char] from print_uchar print_uchar::@1
print_char_cursor#26 = phi( print_uchar/print_char_cursor#37, print_uchar::@1/print_char_cursor#5 )
print_char::ch#2 = phi( print_uchar/print_char::ch#0, print_uchar::@1/print_char::ch#1 )
*print_char_cursor#26 = print_char::ch#2
print_char_cursor#8 = ++ print_char_cursor#26
to:print_char::@return
print_char::@return: scope:[print_char] from print_char
print_char_cursor#27 = phi( print_char/print_char_cursor#8 )
print_char_cursor#9 = print_char_cursor#27
return
to:@return
void start()
start: scope:[start] from end main
asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 }
to:start::@return
start::@return: scope:[start] from start
return
to:@return
void end()
end: scope:[end] from main::@11
print_line_cursor#24 = phi( main::@11/print_line_cursor#20 )
print_char_cursor#41 = phi( main::@11/print_char_cursor#39 )
Ticks#0 = last_time
call start
to:end::@1
end::@1: scope:[end] from end
print_line_cursor#22 = phi( end/print_line_cursor#24 )
print_char_cursor#38 = phi( end/print_char_cursor#41 )
Ticks#8 = phi( end/Ticks#0 )
last_time = last_time - Ticks#8
Ticks#1 = last_time
print_uint::w#0 = Ticks#1
call print_uint
to:end::@2
end::@2: scope:[end] from end::@1
Ticks#17 = phi( end::@1/Ticks#1 )
print_line_cursor#19 = phi( end::@1/print_line_cursor#22 )
print_char_cursor#28 = phi( end::@1/print_char_cursor#4 )
print_char_cursor#10 = print_char_cursor#28
call print_ln
to:end::@3
end::@3: scope:[end] from end::@2
Ticks#14 = phi( end::@2/Ticks#17 )
print_char_cursor#29 = phi( end::@2/print_char_cursor#1 )
print_line_cursor#12 = phi( end::@2/print_line_cursor#1 )
print_line_cursor#2 = print_line_cursor#12
print_char_cursor#11 = print_char_cursor#29
to:end::@return
end::@return: scope:[end] from end::@3
print_line_cursor#13 = phi( end::@3/print_line_cursor#2 )
print_char_cursor#30 = phi( end::@3/print_char_cursor#11 )
Ticks#9 = phi( end::@3/Ticks#14 )
Ticks#2 = Ticks#9
print_char_cursor#12 = print_char_cursor#30
print_line_cursor#3 = print_line_cursor#13
return
to:@return
void round()
round: scope:[round] from main::@1 main::@10 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9
round::S#0 = (char *) 0
round::I#0 = 0
round::p#0 = Sieve
to:round::@1
round::@1: scope:[round] from round round::@2
round::p#2 = phi( round/round::p#0, round::@2/round::p#1 )
round::$0 = round::p#2 < Sieve+COUNT
if(round::$0) goto round::@2
to:round::@3
round::@2: scope:[round] from round::@1
round::p#3 = phi( round::@1/round::p#2 )
*round::p#3 = 0
round::p#1 = ++ round::p#3
to:round::@1
round::@3: scope:[round] from round::@1
round::I#1 = 2
to:round::@4
round::@4: scope:[round] from round::@3 round::@6
round::I#3 = phi( round::@3/round::I#1, round::@6/round::I#2 )
round::$1 = round::I#3 < SQRT_COUNT
if(round::$1) goto round::@5
to:round::@return
round::@5: scope:[round] from round::@4
round::I#4 = phi( round::@4/round::I#3 )
round::$2 = Sieve[round::I#4] == 0
round::$3 = ! round::$2
if(round::$3) goto round::@6
to:round::@9
round::@6: scope:[round] from round::@5 round::@7
round::I#5 = phi( round::@5/round::I#4, round::@7/round::I#8 )
round::I#2 = ++ round::I#5
to:round::@4
round::@9: scope:[round] from round::@5
round::I#6 = phi( round::@5/round::I#4 )
round::$4 = round::I#6 << 1
round::$5 = Sieve + round::$4
round::S#1 = round::$5
to:round::@7
round::@7: scope:[round] from round::@8 round::@9
round::I#8 = phi( round::@8/round::I#7, round::@9/round::I#6 )
round::S#3 = phi( round::@8/round::S#2, round::@9/round::S#1 )
round::$6 = round::S#3 < Sieve+COUNT
if(round::$6) goto round::@8
to:round::@6
round::@8: scope:[round] from round::@7
round::I#7 = phi( round::@7/round::I#8 )
round::S#4 = phi( round::@7/round::S#3 )
*round::S#4 = 1
round::S#2 = round::S#4 + round::I#7
to:round::@7
round::@return: scope:[round] from round::@4
return
to:@return
int main()
main: scope:[main] from __start::@1
print_line_cursor#34 = phi( __start::@1/print_line_cursor#21 )
print_char_cursor#52 = phi( __start::@1/print_char_cursor#40 )
Ticks#28 = phi( __start::@1/Ticks#16 )
call start
to:main::@1
main::@1: scope:[main] from main
print_line_cursor#33 = phi( main/print_line_cursor#34 )
print_char_cursor#51 = phi( main/print_char_cursor#52 )
Ticks#27 = phi( main/Ticks#28 )
call round
to:main::@2
main::@2: scope:[main] from main::@1
print_line_cursor#32 = phi( main::@1/print_line_cursor#33 )
print_char_cursor#50 = phi( main::@1/print_char_cursor#51 )
Ticks#26 = phi( main::@1/Ticks#27 )
call round
to:main::@3
main::@3: scope:[main] from main::@2
print_line_cursor#31 = phi( main::@2/print_line_cursor#32 )
print_char_cursor#49 = phi( main::@2/print_char_cursor#50 )
Ticks#25 = phi( main::@2/Ticks#26 )
call round
to:main::@4
main::@4: scope:[main] from main::@3
print_line_cursor#30 = phi( main::@3/print_line_cursor#31 )
print_char_cursor#48 = phi( main::@3/print_char_cursor#49 )
Ticks#24 = phi( main::@3/Ticks#25 )
call round
to:main::@5
main::@5: scope:[main] from main::@4
print_line_cursor#29 = phi( main::@4/print_line_cursor#30 )
print_char_cursor#47 = phi( main::@4/print_char_cursor#48 )
Ticks#23 = phi( main::@4/Ticks#24 )
call round
to:main::@6
main::@6: scope:[main] from main::@5
print_line_cursor#28 = phi( main::@5/print_line_cursor#29 )
print_char_cursor#46 = phi( main::@5/print_char_cursor#47 )
Ticks#22 = phi( main::@5/Ticks#23 )
call round
to:main::@7
main::@7: scope:[main] from main::@6
print_line_cursor#27 = phi( main::@6/print_line_cursor#28 )
print_char_cursor#45 = phi( main::@6/print_char_cursor#46 )
Ticks#21 = phi( main::@6/Ticks#22 )
call round
to:main::@8
main::@8: scope:[main] from main::@7
print_line_cursor#26 = phi( main::@7/print_line_cursor#27 )
print_char_cursor#44 = phi( main::@7/print_char_cursor#45 )
Ticks#20 = phi( main::@7/Ticks#21 )
call round
to:main::@9
main::@9: scope:[main] from main::@8
print_line_cursor#25 = phi( main::@8/print_line_cursor#26 )
print_char_cursor#43 = phi( main::@8/print_char_cursor#44 )
Ticks#19 = phi( main::@8/Ticks#20 )
call round
to:main::@10
main::@10: scope:[main] from main::@9
print_line_cursor#23 = phi( main::@9/print_line_cursor#25 )
print_char_cursor#42 = phi( main::@9/print_char_cursor#43 )
Ticks#18 = phi( main::@9/Ticks#19 )
call round
to:main::@11
main::@11: scope:[main] from main::@10
print_line_cursor#20 = phi( main::@10/print_line_cursor#23 )
print_char_cursor#39 = phi( main::@10/print_char_cursor#42 )
Ticks#15 = phi( main::@10/Ticks#18 )
call end
to:main::@12
main::@12: scope:[main] from main::@11
print_line_cursor#14 = phi( main::@11/print_line_cursor#3 )
print_char_cursor#31 = phi( main::@11/print_char_cursor#12 )
Ticks#10 = phi( main::@11/Ticks#2 )
Ticks#3 = Ticks#10
print_char_cursor#13 = print_char_cursor#31
print_line_cursor#4 = print_line_cursor#14
main::return#0 = 0
to:main::@return
main::@return: scope:[main] from main::@12
print_line_cursor#15 = phi( main::@12/print_line_cursor#4 )
print_char_cursor#32 = phi( main::@12/print_char_cursor#13 )
Ticks#11 = phi( main::@12/Ticks#3 )
main::return#3 = phi( main::@12/main::return#0 )
main::return#1 = main::return#3
Ticks#4 = Ticks#11
print_char_cursor#14 = print_char_cursor#32
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#15 = print_line_cursor#6
last_time = 0
Ticks#5 = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
print_screen#4 = phi( __start::__init1/print_screen#0 )
print_line_cursor#21 = phi( __start::__init1/print_line_cursor#6 )
print_char_cursor#40 = phi( __start::__init1/print_char_cursor#15 )
Ticks#16 = phi( __start::__init1/Ticks#5 )
call main
main::return#2 = main::return#1
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#33 = phi( __start::@1/print_char_cursor#14 )
Ticks#12 = phi( __start::@1/Ticks#4 )
Ticks#6 = Ticks#12
print_char_cursor#16 = print_char_cursor#33
print_line_cursor#7 = print_line_cursor#16
to:__start::@return
__start::@return: scope:[__start] from __start::@2
Ticks#13 = phi( __start::@2/Ticks#6 )
print_char_cursor#34 = phi( __start::@2/print_char_cursor#16 )
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#17 = print_char_cursor#34
Ticks#7 = Ticks#13
return
to:@return
SYMBOL TABLE SSA
__constant const unsigned int COUNT = $4000
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant const char SQRT_COUNT = $80
__constant char Sieve[COUNT] = { fill( COUNT, 0) }
unsigned int Ticks
unsigned int Ticks#0
unsigned int Ticks#1
unsigned int Ticks#10
unsigned int Ticks#11
unsigned int Ticks#12
unsigned int Ticks#13
unsigned int Ticks#14
unsigned int Ticks#15
unsigned int Ticks#16
unsigned int Ticks#17
unsigned int Ticks#18
unsigned int Ticks#19
unsigned int Ticks#2
unsigned int Ticks#20
unsigned int Ticks#21
unsigned int Ticks#22
unsigned int Ticks#23
unsigned int Ticks#24
unsigned int Ticks#25
unsigned int Ticks#26
unsigned int Ticks#27
unsigned int Ticks#28
unsigned int Ticks#3
unsigned int Ticks#4
unsigned int Ticks#5
unsigned int Ticks#6
unsigned int Ticks#7
unsigned int Ticks#8
unsigned int Ticks#9
void __start()
void end()
__loadstore volatile unsigned int last_time
int main()
int main::return
int main::return#0
int main::return#1
int main::return#2
int main::return#3
void print_char(char ch)
char print_char::ch
char print_char::ch#0
char print_char::ch#1
char print_char::ch#2
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#37
char *print_char_cursor#38
char *print_char_cursor#39
char *print_char_cursor#4
char *print_char_cursor#40
char *print_char_cursor#41
char *print_char_cursor#42
char *print_char_cursor#43
char *print_char_cursor#44
char *print_char_cursor#45
char *print_char_cursor#46
char *print_char_cursor#47
char *print_char_cursor#48
char *print_char_cursor#49
char *print_char_cursor#5
char *print_char_cursor#50
char *print_char_cursor#51
char *print_char_cursor#52
char *print_char_cursor#6
char *print_char_cursor#7
char *print_char_cursor#8
char *print_char_cursor#9
__constant const char print_hextab[] = "0123456789abcdef"z
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#24
char *print_line_cursor#25
char *print_line_cursor#26
char *print_line_cursor#27
char *print_line_cursor#28
char *print_line_cursor#29
char *print_line_cursor#3
char *print_line_cursor#30
char *print_line_cursor#31
char *print_line_cursor#32
char *print_line_cursor#33
char *print_line_cursor#34
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_uchar(char b)
char print_uchar::$0
number print_uchar::$2
char print_uchar::b
char print_uchar::b#0
char print_uchar::b#1
char print_uchar::b#2
char print_uchar::b#3
void print_uint(unsigned int w)
char print_uint::$0
char print_uint::$2
unsigned int print_uint::w
unsigned int print_uint::w#0
unsigned int print_uint::w#1
unsigned int print_uint::w#2
void round()
bool round::$0
bool round::$1
bool round::$2
bool round::$3
char round::$4
char *round::$5
bool round::$6
char round::I
char round::I#0
char round::I#1
char round::I#2
char round::I#3
char round::I#4
char round::I#5
char round::I#6
char round::I#7
char round::I#8
char *round::S
char *round::S#0
char *round::S#1
char *round::S#2
char *round::S#3
char *round::S#4
char *round::p
char *round::p#0
char *round::p#1
char *round::p#2
char *round::p#3
void start()
__constant unsigned int * const start::LAST_TIME = &last_time
Adding number conversion cast (unumber) $28 in print_ln::$0 = print_line_cursor#9 + $28
Adding number conversion cast (unumber) 4 in print_uchar::$0 = print_uchar::b#2 >> 4
Adding number conversion cast (unumber) $f in print_uchar::$2 = print_uchar::b#3 & $f
Adding number conversion cast (unumber) print_uchar::$2 in print_uchar::$2 = print_uchar::b#3 & (unumber)$f
Adding number conversion cast (unumber) 0 in *round::p#3 = 0
Adding number conversion cast (unumber) 2 in round::I#1 = 2
Adding number conversion cast (unumber) 0 in round::$2 = Sieve[round::I#4] == 0
Adding number conversion cast (unumber) 1 in round::$4 = round::I#6 << 1
Adding number conversion cast (unumber) 1 in *round::S#4 = 1
Adding number conversion cast (snumber) 0 in main::return#0 = 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *round::p#3 = (unumber)0
Inlining cast round::I#1 = (unumber)2
Inlining cast *round::S#4 = (unumber)1
Inlining cast main::return#0 = (snumber)0
Successful SSA optimization Pass2InlineCast
Simplifying constant integer cast $28
Simplifying constant integer cast 4
Simplifying constant integer cast $f
Simplifying constant integer cast 0
Simplifying constant integer cast 2
Simplifying constant integer cast 0
Simplifying constant integer cast 1
Simplifying constant integer cast 1
Simplifying constant integer cast 0
Simplifying constant pointer cast (char *) 1024
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (char) $28
Finalized unsigned number type (char) 4
Finalized unsigned number type (char) $f
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 2
Finalized unsigned number type (char) 0
Finalized unsigned number type (char) 1
Finalized unsigned number type (char) 1
Finalized signed number type (signed char) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to char in print_uchar::$2 = print_uchar::b#3 & $f
Inversing boolean not [82] round::$3 = Sieve[round::I#4] != 0 from [81] round::$2 = Sieve[round::I#4] == 0
Successful SSA optimization Pass2UnaryNotSimplification
Alias print_line_cursor#0 = print_ln::$0 print_line_cursor#10 print_char_cursor#0 print_line_cursor#11 print_char_cursor#19 print_line_cursor#1 print_char_cursor#1
Alias print_uchar::b#0 = print_uint::$0
Alias print_uint::w#1 = print_uint::w#2
Alias print_char_cursor#2 = print_char_cursor#20
Alias print_uchar::b#1 = print_uint::$2
Alias print_char_cursor#21 = print_char_cursor#3 print_char_cursor#22 print_char_cursor#4
Alias print_uchar::b#2 = print_uchar::b#3
Alias print_char_cursor#23 = print_char_cursor#5
Alias print_char_cursor#24 = print_char_cursor#6 print_char_cursor#25 print_char_cursor#7
Alias print_char_cursor#27 = print_char_cursor#8 print_char_cursor#9
Alias Ticks#0 = Ticks#8
Alias print_char_cursor#38 = print_char_cursor#41
Alias print_line_cursor#19 = print_line_cursor#22 print_line_cursor#24
Alias Ticks#1 = Ticks#17 Ticks#14 Ticks#9 Ticks#2
Alias print_char_cursor#10 = print_char_cursor#28
Alias print_line_cursor#12 = print_line_cursor#2 print_line_cursor#13 print_line_cursor#3
Alias print_char_cursor#11 = print_char_cursor#29 print_char_cursor#30 print_char_cursor#12
Alias round::p#2 = round::p#3
Alias round::I#3 = round::I#4 round::I#6
Alias round::S#1 = round::$5
Alias round::S#3 = round::S#4
Alias round::I#7 = round::I#8
Alias Ticks#15 = Ticks#27 Ticks#28 Ticks#26 Ticks#25 Ticks#24 Ticks#23 Ticks#22 Ticks#21 Ticks#20 Ticks#19 Ticks#18
Alias print_char_cursor#39 = print_char_cursor#51 print_char_cursor#52 print_char_cursor#50 print_char_cursor#49 print_char_cursor#48 print_char_cursor#47 print_char_cursor#46 print_char_cursor#45 print_char_cursor#44 print_char_cursor#43 print_char_cursor#42
Alias print_line_cursor#20 = print_line_cursor#33 print_line_cursor#34 print_line_cursor#32 print_line_cursor#31 print_line_cursor#30 print_line_cursor#29 print_line_cursor#28 print_line_cursor#27 print_line_cursor#26 print_line_cursor#25 print_line_cursor#23
Alias Ticks#10 = Ticks#3 Ticks#11 Ticks#4
Alias print_char_cursor#13 = print_char_cursor#31 print_char_cursor#32 print_char_cursor#14
Alias print_line_cursor#14 = print_line_cursor#4 print_line_cursor#15 print_line_cursor#5
Alias main::return#0 = main::return#3 main::return#1
Alias print_screen#0 = print_line_cursor#6 print_char_cursor#15 print_char_cursor#40 print_line_cursor#21 print_screen#4 print_screen#3 print_screen#2 print_screen#1
Alias Ticks#16 = Ticks#5
Alias Ticks#12 = Ticks#6 Ticks#13 Ticks#7
Alias print_char_cursor#16 = print_char_cursor#33 print_char_cursor#34 print_char_cursor#17
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_line_cursor#18 print_line_cursor#19
Identical Phi Values print_char_cursor#35 print_char_cursor#10
Identical Phi Values print_char_cursor#18 print_char_cursor#35
Identical Phi Values print_uint::w#1 print_uint::w#0
Identical Phi Values print_char_cursor#36 print_char_cursor#38
Identical Phi Values print_char_cursor#2 print_char_cursor#24
Identical Phi Values print_char_cursor#21 print_char_cursor#24
Identical Phi Values print_char_cursor#23 print_char_cursor#27
Identical Phi Values print_char_cursor#24 print_char_cursor#27
Identical Phi Values print_char_cursor#38 print_char_cursor#39
Identical Phi Values print_line_cursor#19 print_line_cursor#20
Identical Phi Values print_char_cursor#10 print_char_cursor#21
Identical Phi Values print_line_cursor#12 print_line_cursor#0
Identical Phi Values print_char_cursor#11 print_line_cursor#0
Identical Phi Values round::I#7 round::I#3
Identical Phi Values Ticks#15 Ticks#16
Identical Phi Values print_char_cursor#39 print_screen#0
Identical Phi Values print_line_cursor#20 print_screen#0
Identical Phi Values Ticks#10 Ticks#1
Identical Phi Values print_char_cursor#13 print_char_cursor#11
Identical Phi Values print_line_cursor#14 print_line_cursor#12
Identical Phi Values Ticks#12 Ticks#10
Identical Phi Values print_char_cursor#16 print_char_cursor#13
Identical Phi Values print_line_cursor#16 print_line_cursor#14
Successful SSA optimization Pass2IdenticalPhiElimination
Identical Phi Values round::I#5 round::I#3
Successful SSA optimization Pass2IdenticalPhiElimination
Simple Condition print_ln::$1 [4] if(print_line_cursor#0<print_char_cursor#27) goto print_ln::@1
Simple Condition round::$0 [46] if(round::p#2<Sieve+COUNT) goto round::@2
Simple Condition round::$1 [52] if(round::I#3<SQRT_COUNT) goto round::@5
Simple Condition round::$3 [54] if(Sieve[round::I#3]!=0) goto round::@6
Simple Condition round::$6 [61] if(round::S#3<Sieve+COUNT) goto round::@8
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant round::S#0 = (char *) 0
Constant round::I#0 = 0
Constant round::p#0 = Sieve
Constant round::I#1 = 2
Constant main::return#0 = 0
Constant print_screen#0 = (char *) 1024
Constant Ticks#16 = 0
Successful SSA optimization Pass2ConstantIdentification
Constant main::return#2 = main::return#0
Successful SSA optimization Pass2ConstantIdentification
Eliminating unused constant round::S#0
Eliminating unused constant round::I#0
Eliminating unused constant main::return#2
Eliminating unused constant Ticks#16
Successful SSA optimization PassNEliminateUnusedVars
Eliminating unused constant main::return#0
Successful SSA optimization PassNEliminateUnusedVars
Inlining constant with var siblings round::p#0
Inlining constant with var siblings round::I#1
Constant inlined round::I#1 = 2
Constant inlined round::p#0 = Sieve
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 __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of __start::@2
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of main::@6
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of main::@8
Adding NOP phi() at start of main::@9
Adding NOP phi() at start of main::@10
Adding NOP phi() at start of main::@11
Adding NOP phi() at start of main::@12
Adding NOP phi() at start of round
Adding NOP phi() at start of round::@3
Adding NOP phi() at start of end::@2
Adding NOP phi() at start of end::@3
Adding NOP phi() at start of print_uint::@2
Adding NOP phi() at start of print_ln
Adding NOP phi() at start of print_ln::@2
Adding NOP phi() at start of print_uchar::@2
CALL GRAPH
Calls in [__start] to main:3
Calls in [main] to start:7 round:9 round:11 round:13 round:15 round:17 round:19 round:21 round:23 round:25 round:27 end:29
Calls in [end] to start:56 print_uint:60 print_ln:62
Calls in [print_uint] to print_uchar:67 print_uchar:71
Calls in [print_uchar] to print_char:86 print_char:91
Created 8 initial phi equivalence classes
Coalesced [44] round::S#6 = round::S#1
Coalesced [48] round::I#9 = round::I#2
Coalesced [51] round::S#5 = round::S#2
Coalesced [54] round::p#4 = round::p#1
Coalesced [66] print_uchar::b#4 = print_uchar::b#0
Coalesced [69] print_uchar::b#5 = print_uchar::b#1
Coalesced [70] print_char_cursor#53 = print_char_cursor#27
Coalesced [80] print_line_cursor#35 = print_line_cursor#0
Coalesced [84] print_char::ch#3 = print_char::ch#0
Coalesced [85] print_char_cursor#54 = print_char_cursor#37
Coalesced [89] print_char::ch#4 = print_char::ch#1
Coalesced (already) [90] print_char_cursor#55 = print_char_cursor#27
Coalesced down to 7 phi equivalence classes
Culled Empty Block label __start::@2
Culled Empty Block label main::@12
Culled Empty Block label round::@3
Culled Empty Block label end::@3
Culled Empty Block label print_uint::@2
Culled Empty Block label print_ln::@2
Culled Empty Block label print_ln::@3
Culled Empty Block label print_uchar::@2
Renumbering block round::@4 to round::@3
Renumbering block round::@5 to round::@4
Renumbering block round::@6 to round::@5
Renumbering block round::@7 to round::@6
Renumbering block round::@8 to round::@7
Renumbering block round::@9 to round::@8
Adding NOP phi() at start of __start
Adding NOP phi() at start of __start::@1
Adding NOP phi() at start of main
Adding NOP phi() at start of main::@1
Adding NOP phi() at start of main::@2
Adding NOP phi() at start of main::@3
Adding NOP phi() at start of main::@4
Adding NOP phi() at start of main::@5
Adding NOP phi() at start of main::@6
Adding NOP phi() at start of main::@7
Adding NOP phi() at start of main::@8
Adding NOP phi() at start of main::@9
Adding NOP phi() at start of main::@10
Adding NOP phi() at start of main::@11
Adding NOP phi() at start of round
Adding NOP phi() at start of end::@2
Adding NOP phi() at start of print_ln
FINAL CONTROL FLOW GRAPH
void __start()
__start: scope:[__start] from
[0] phi()
to:__start::__init1
__start::__init1: scope:[__start] from __start
[1] last_time = 0
to:__start::@1
__start::@1: scope:[__start] from __start::__init1
[2] phi()
[3] call main
to:__start::@return
__start::@return: scope:[__start] from __start::@1
[4] return
to:@return
int main()
main: scope:[main] from __start::@1
[5] phi()
[6] call start
to:main::@1
main::@1: scope:[main] from main
[7] phi()
[8] call round
to:main::@2
main::@2: scope:[main] from main::@1
[9] phi()
[10] call round
to:main::@3
main::@3: scope:[main] from main::@2
[11] phi()
[12] call round
to:main::@4
main::@4: scope:[main] from main::@3
[13] phi()
[14] call round
to:main::@5
main::@5: scope:[main] from main::@4
[15] phi()
[16] call round
to:main::@6
main::@6: scope:[main] from main::@5
[17] phi()
[18] call round
to:main::@7
main::@7: scope:[main] from main::@6
[19] phi()
[20] call round
to:main::@8
main::@8: scope:[main] from main::@7
[21] phi()
[22] call round
to:main::@9
main::@9: scope:[main] from main::@8
[23] phi()
[24] call round
to:main::@10
main::@10: scope:[main] from main::@9
[25] phi()
[26] call round
to:main::@11
main::@11: scope:[main] from main::@10
[27] phi()
[28] call end
to:main::@return
main::@return: scope:[main] from main::@11
[29] return
to:@return
void start()
start: scope:[start] from end main
asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 }
to:start::@return
start::@return: scope:[start] from start
[31] return
to:@return
void round()
round: scope:[round] from main::@1 main::@10 main::@2 main::@3 main::@4 main::@5 main::@6 main::@7 main::@8 main::@9
[32] phi()
to:round::@1
round::@1: scope:[round] from round round::@2
[33] round::p#2 = phi( round/Sieve, round::@2/round::p#1 )
[34] if(round::p#2<Sieve+COUNT) goto round::@2
to:round::@3
round::@3: scope:[round] from round::@1 round::@5
[35] round::I#3 = phi( round::@1/2, round::@5/round::I#2 )
[36] if(round::I#3<SQRT_COUNT) goto round::@4
to:round::@return
round::@return: scope:[round] from round::@3
[37] return
to:@return
round::@4: scope:[round] from round::@3
[38] if(Sieve[round::I#3]!=0) goto round::@5
to:round::@8
round::@8: scope:[round] from round::@4
[39] round::$4 = round::I#3 << 1
[40] round::S#1 = Sieve + round::$4
to:round::@6
round::@6: scope:[round] from round::@7 round::@8
[41] round::S#3 = phi( round::@7/round::S#2, round::@8/round::S#1 )
[42] if(round::S#3<Sieve+COUNT) goto round::@7
to:round::@5
round::@5: scope:[round] from round::@4 round::@6
[43] round::I#2 = ++ round::I#3
to:round::@3
round::@7: scope:[round] from round::@6
[44] *round::S#3 = 1
[45] round::S#2 = round::S#3 + round::I#3
to:round::@6
round::@2: scope:[round] from round::@1
[46] *round::p#2 = 0
[47] round::p#1 = ++ round::p#2
to:round::@1
void end()
end: scope:[end] from main::@11
[48] Ticks#0 = last_time
[49] call start
to:end::@1
end::@1: scope:[end] from end
[50] last_time = last_time - Ticks#0
[51] Ticks#1 = last_time
[52] print_uint::w#0 = Ticks#1
[53] call print_uint
to:end::@2
end::@2: scope:[end] from end::@1
[54] phi()
[55] call print_ln
to:end::@return
end::@return: scope:[end] from end::@2
[56] return
to:@return
void print_uint(unsigned int w)
print_uint: scope:[print_uint] from end::@1
[57] print_uchar::b#0 = byte1 print_uint::w#0
[58] call print_uchar
to:print_uint::@1
print_uint::@1: scope:[print_uint] from print_uint
[59] print_uchar::b#1 = byte0 print_uint::w#0
[60] call print_uchar
to:print_uint::@return
print_uint::@return: scope:[print_uint] from print_uint::@1
[61] return
to:@return
void print_ln()
print_ln: scope:[print_ln] from end::@2
[62] phi()
to:print_ln::@1
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
[63] print_line_cursor#9 = phi( print_ln/print_screen#0, print_ln::@1/print_line_cursor#0 )
[64] print_line_cursor#0 = print_line_cursor#9 + $28
[65] if(print_line_cursor#0<print_char_cursor#27) goto print_ln::@1
to:print_ln::@return
print_ln::@return: scope:[print_ln] from print_ln::@1
[66] return
to:@return
void print_uchar(char b)
print_uchar: scope:[print_uchar] from print_uint print_uint::@1
[67] print_char_cursor#37 = phi( print_uint/print_screen#0, print_uint::@1/print_char_cursor#27 )
[67] print_uchar::b#2 = phi( print_uint/print_uchar::b#0, print_uint::@1/print_uchar::b#1 )
[68] print_uchar::$0 = print_uchar::b#2 >> 4
[69] print_char::ch#0 = print_hextab[print_uchar::$0]
[70] call print_char
to:print_uchar::@1
print_uchar::@1: scope:[print_uchar] from print_uchar
[71] print_uchar::$2 = print_uchar::b#2 & $f
[72] print_char::ch#1 = print_hextab[print_uchar::$2]
[73] call print_char
to:print_uchar::@return
print_uchar::@return: scope:[print_uchar] from print_uchar::@1
[74] return
to:@return
void print_char(char ch)
print_char: scope:[print_char] from print_uchar print_uchar::@1
[75] print_char_cursor#26 = phi( print_uchar/print_char_cursor#37, print_uchar::@1/print_char_cursor#27 )
[75] print_char::ch#2 = phi( print_uchar/print_char::ch#0, print_uchar::@1/print_char::ch#1 )
[76] *print_char_cursor#26 = print_char::ch#2
[77] print_char_cursor#27 = ++ print_char_cursor#26
to:print_char::@return
print_char::@return: scope:[print_char] from print_char
[78] return
to:@return
VARIABLE REGISTER WEIGHTS
unsigned int Ticks
unsigned int Ticks#0 // 101.0
unsigned int Ticks#1 // 202.0
void __start()
void end()
__loadstore volatile unsigned int last_time // 14.500000000000002
int main()
int main::return
void print_char(char ch)
char print_char::ch
char print_char::ch#0 // 20002.0
char print_char::ch#1 // 20002.0
char print_char::ch#2 // 120003.0
char *print_char_cursor
char *print_char_cursor#26 // 110002.0
char *print_char_cursor#27 // 7117.882352941177
char *print_char_cursor#37 // 3667.333333333333
char *print_line_cursor
char *print_line_cursor#0 // 15001.5
char *print_line_cursor#9 // 20002.0
void print_ln()
char *print_screen
void print_uchar(char b)
char print_uchar::$0 // 20002.0
char print_uchar::$2 // 20002.0
char print_uchar::b
char print_uchar::b#0 // 2002.0
char print_uchar::b#1 // 2002.0
char print_uchar::b#2 // 5501.0
void print_uint(unsigned int w)
unsigned int print_uint::w
unsigned int print_uint::w#0 // 701.0
void round()
char round::$4 // 2002.0
char round::I
char round::I#2 // 2002.0
char round::I#3 // 1667.3333333333333
char *round::S
char *round::S#1 // 2002.0
char *round::S#2 // 20002.0
char *round::S#3 // 13668.333333333332
char *round::p
char *round::p#1 // 2002.0
char *round::p#2 // 1334.6666666666667
void start()
Initial phi equivalence classes
[ round::p#2 round::p#1 ]
[ round::I#3 round::I#2 ]
[ round::S#3 round::S#2 round::S#1 ]
[ print_line_cursor#9 print_line_cursor#0 ]
[ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
[ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
[ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ]
Added variable last_time to live range equivalence class [ last_time ]
Added variable round::$4 to live range equivalence class [ round::$4 ]
Added variable Ticks#0 to live range equivalence class [ Ticks#0 ]
Added variable Ticks#1 to live range equivalence class [ Ticks#1 ]
Added variable print_uint::w#0 to live range equivalence class [ print_uint::w#0 ]
Added variable print_uchar::$0 to live range equivalence class [ print_uchar::$0 ]
Added variable print_uchar::$2 to live range equivalence class [ print_uchar::$2 ]
Complete equivalence classes
[ round::p#2 round::p#1 ]
[ round::I#3 round::I#2 ]
[ round::S#3 round::S#2 round::S#1 ]
[ print_line_cursor#9 print_line_cursor#0 ]
[ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
[ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
[ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ]
[ last_time ]
[ round::$4 ]
[ Ticks#0 ]
[ Ticks#1 ]
[ print_uint::w#0 ]
[ print_uchar::$0 ]
[ print_uchar::$2 ]
Allocated zp[1]:2 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
Allocated zp[2]:3 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ]
Allocated zp[2]:5 [ round::S#3 round::S#2 round::S#1 ]
Allocated zp[2]:7 [ print_line_cursor#9 print_line_cursor#0 ]
Allocated zp[1]:9 [ print_uchar::$0 ]
Allocated zp[1]:10 [ print_uchar::$2 ]
Allocated zp[1]:11 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Allocated zp[1]:12 [ round::I#3 round::I#2 ]
Allocated zp[2]:13 [ round::p#2 round::p#1 ]
Allocated zp[1]:15 [ round::$4 ]
Allocated zp[2]:16 [ print_uint::w#0 ]
Allocated zp[2]:18 [ Ticks#1 ]
Allocated zp[2]:20 [ Ticks#0 ]
Allocated zp[2]:22 [ last_time ]
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] last_time = 0 [ last_time ] ( [ last_time ] { } ) always clobbers reg byte a
Statement asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 } always clobbers reg byte a reg byte x reg byte y
Statement [34] if(round::p#2<Sieve+COUNT) goto round::@2 [ round::p#2 ] ( main:3::round:8 [ last_time round::p#2 ] { } main:3::round:10 [ last_time round::p#2 ] { } main:3::round:12 [ last_time round::p#2 ] { } main:3::round:14 [ last_time round::p#2 ] { } main:3::round:16 [ last_time round::p#2 ] { } main:3::round:18 [ last_time round::p#2 ] { } main:3::round:20 [ last_time round::p#2 ] { } main:3::round:22 [ last_time round::p#2 ] { } main:3::round:24 [ last_time round::p#2 ] { } main:3::round:26 [ last_time round::p#2 ] { } ) always clobbers reg byte a
Statement [38] if(Sieve[round::I#3]!=0) goto round::@5 [ round::I#3 ] ( main:3::round:8 [ last_time round::I#3 ] { } main:3::round:10 [ last_time round::I#3 ] { } main:3::round:12 [ last_time round::I#3 ] { } main:3::round:14 [ last_time round::I#3 ] { } main:3::round:16 [ last_time round::I#3 ] { } main:3::round:18 [ last_time round::I#3 ] { } main:3::round:20 [ last_time round::I#3 ] { } main:3::round:22 [ last_time round::I#3 ] { } main:3::round:24 [ last_time round::I#3 ] { } main:3::round:26 [ last_time round::I#3 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:12 [ round::I#3 round::I#2 ]
Statement [39] round::$4 = round::I#3 << 1 [ round::I#3 round::$4 ] ( main:3::round:8 [ last_time round::I#3 round::$4 ] { } main:3::round:10 [ last_time round::I#3 round::$4 ] { } main:3::round:12 [ last_time round::I#3 round::$4 ] { } main:3::round:14 [ last_time round::I#3 round::$4 ] { } main:3::round:16 [ last_time round::I#3 round::$4 ] { } main:3::round:18 [ last_time round::I#3 round::$4 ] { } main:3::round:20 [ last_time round::I#3 round::$4 ] { } main:3::round:22 [ last_time round::I#3 round::$4 ] { } main:3::round:24 [ last_time round::I#3 round::$4 ] { } main:3::round:26 [ last_time round::I#3 round::$4 ] { } ) always clobbers reg byte a
Statement [40] round::S#1 = Sieve + round::$4 [ round::I#3 round::S#1 ] ( main:3::round:8 [ last_time round::I#3 round::S#1 ] { } main:3::round:10 [ last_time round::I#3 round::S#1 ] { } main:3::round:12 [ last_time round::I#3 round::S#1 ] { } main:3::round:14 [ last_time round::I#3 round::S#1 ] { } main:3::round:16 [ last_time round::I#3 round::S#1 ] { } main:3::round:18 [ last_time round::I#3 round::S#1 ] { } main:3::round:20 [ last_time round::I#3 round::S#1 ] { } main:3::round:22 [ last_time round::I#3 round::S#1 ] { } main:3::round:24 [ last_time round::I#3 round::S#1 ] { } main:3::round:26 [ last_time round::I#3 round::S#1 ] { } ) always clobbers reg byte a
Statement [42] if(round::S#3<Sieve+COUNT) goto round::@7 [ round::I#3 round::S#3 ] ( main:3::round:8 [ last_time round::I#3 round::S#3 ] { } main:3::round:10 [ last_time round::I#3 round::S#3 ] { } main:3::round:12 [ last_time round::I#3 round::S#3 ] { } main:3::round:14 [ last_time round::I#3 round::S#3 ] { } main:3::round:16 [ last_time round::I#3 round::S#3 ] { } main:3::round:18 [ last_time round::I#3 round::S#3 ] { } main:3::round:20 [ last_time round::I#3 round::S#3 ] { } main:3::round:22 [ last_time round::I#3 round::S#3 ] { } main:3::round:24 [ last_time round::I#3 round::S#3 ] { } main:3::round:26 [ last_time round::I#3 round::S#3 ] { } ) always clobbers reg byte a
Statement [44] *round::S#3 = 1 [ round::I#3 round::S#3 ] ( main:3::round:8 [ last_time round::I#3 round::S#3 ] { } main:3::round:10 [ last_time round::I#3 round::S#3 ] { } main:3::round:12 [ last_time round::I#3 round::S#3 ] { } main:3::round:14 [ last_time round::I#3 round::S#3 ] { } main:3::round:16 [ last_time round::I#3 round::S#3 ] { } main:3::round:18 [ last_time round::I#3 round::S#3 ] { } main:3::round:20 [ last_time round::I#3 round::S#3 ] { } main:3::round:22 [ last_time round::I#3 round::S#3 ] { } main:3::round:24 [ last_time round::I#3 round::S#3 ] { } main:3::round:26 [ last_time round::I#3 round::S#3 ] { } ) always clobbers reg byte a reg byte y
Removing always clobbered register reg byte y as potential for zp[1]:12 [ round::I#3 round::I#2 ]
Statement [45] round::S#2 = round::S#3 + round::I#3 [ round::I#3 round::S#2 ] ( main:3::round:8 [ last_time round::I#3 round::S#2 ] { } main:3::round:10 [ last_time round::I#3 round::S#2 ] { } main:3::round:12 [ last_time round::I#3 round::S#2 ] { } main:3::round:14 [ last_time round::I#3 round::S#2 ] { } main:3::round:16 [ last_time round::I#3 round::S#2 ] { } main:3::round:18 [ last_time round::I#3 round::S#2 ] { } main:3::round:20 [ last_time round::I#3 round::S#2 ] { } main:3::round:22 [ last_time round::I#3 round::S#2 ] { } main:3::round:24 [ last_time round::I#3 round::S#2 ] { } main:3::round:26 [ last_time round::I#3 round::S#2 ] { } ) always clobbers reg byte a
Statement [46] *round::p#2 = 0 [ round::p#2 ] ( main:3::round:8 [ last_time round::p#2 ] { } main:3::round:10 [ last_time round::p#2 ] { } main:3::round:12 [ last_time round::p#2 ] { } main:3::round:14 [ last_time round::p#2 ] { } main:3::round:16 [ last_time round::p#2 ] { } main:3::round:18 [ last_time round::p#2 ] { } main:3::round:20 [ last_time round::p#2 ] { } main:3::round:22 [ last_time round::p#2 ] { } main:3::round:24 [ last_time round::p#2 ] { } main:3::round:26 [ last_time round::p#2 ] { } ) always clobbers reg byte a reg byte y
Statement [48] Ticks#0 = last_time [ last_time Ticks#0 ] ( main:3::end:28 [ last_time Ticks#0 ] { } ) always clobbers reg byte a
Statement [50] last_time = last_time - Ticks#0 [ last_time ] ( main:3::end:28 [ last_time ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [51] Ticks#1 = last_time [ Ticks#1 ] ( main:3::end:28 [ Ticks#1 ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [52] print_uint::w#0 = Ticks#1 [ print_uint::w#0 ] ( main:3::end:28 [ print_uint::w#0 ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [64] print_line_cursor#0 = print_line_cursor#9 + $28 [ print_line_cursor#0 print_char_cursor#27 ] ( main:3::end:28::print_ln:55 [ print_line_cursor#0 print_char_cursor#27 ] { } ) always clobbers reg byte a
Statement [65] if(print_line_cursor#0<print_char_cursor#27) goto print_ln::@1 [ print_line_cursor#0 print_char_cursor#27 ] ( main:3::end:28::print_ln:55 [ print_line_cursor#0 print_char_cursor#27 ] { } ) always clobbers reg byte a
Statement [68] print_uchar::$0 = print_uchar::b#2 >> 4 [ print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] ( main:3::end:28::print_uint:53::print_uchar:58 [ print_uint::w#0 print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#0 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#37 } } main:3::end:28::print_uint:53::print_uchar:60 [ print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#0 = print_char::ch#2 } } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:11 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Statement [71] print_uchar::$2 = print_uchar::b#2 & $f [ print_char_cursor#27 print_uchar::$2 ] ( main:3::end:28::print_uint:53::print_uchar:58 [ print_uint::w#0 print_char_cursor#27 print_uchar::$2 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#27 } } main:3::end:28::print_uint:53::print_uchar:60 [ print_char_cursor#27 print_uchar::$2 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#1 = print_char::ch#2 } } ) always clobbers reg byte a
Statement [76] *print_char_cursor#26 = print_char::ch#2 [ print_char_cursor#26 ] ( main:3::end:28::print_uint:53::print_uchar:58::print_char:70 [ print_uint::w#0 print_uchar::b#2 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#0 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#37 } } main:3::end:28::print_uint:53::print_uchar:60::print_char:70 [ print_uchar::b#2 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#0 = print_char::ch#2 } } main:3::end:28::print_uint:53::print_uchar:58::print_char:73 [ print_uint::w#0 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#27 } } main:3::end:28::print_uint:53::print_uchar:60::print_char:73 [ print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#1 = print_char::ch#2 } } ) always clobbers reg byte y
Removing always clobbered register reg byte y as potential for zp[1]:11 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Statement [1] last_time = 0 [ last_time ] ( [ last_time ] { } ) always clobbers reg byte a
Statement asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 } always clobbers reg byte a reg byte x reg byte y
Statement [34] if(round::p#2<Sieve+COUNT) goto round::@2 [ round::p#2 ] ( main:3::round:8 [ last_time round::p#2 ] { } main:3::round:10 [ last_time round::p#2 ] { } main:3::round:12 [ last_time round::p#2 ] { } main:3::round:14 [ last_time round::p#2 ] { } main:3::round:16 [ last_time round::p#2 ] { } main:3::round:18 [ last_time round::p#2 ] { } main:3::round:20 [ last_time round::p#2 ] { } main:3::round:22 [ last_time round::p#2 ] { } main:3::round:24 [ last_time round::p#2 ] { } main:3::round:26 [ last_time round::p#2 ] { } ) always clobbers reg byte a
Statement [38] if(Sieve[round::I#3]!=0) goto round::@5 [ round::I#3 ] ( main:3::round:8 [ last_time round::I#3 ] { } main:3::round:10 [ last_time round::I#3 ] { } main:3::round:12 [ last_time round::I#3 ] { } main:3::round:14 [ last_time round::I#3 ] { } main:3::round:16 [ last_time round::I#3 ] { } main:3::round:18 [ last_time round::I#3 ] { } main:3::round:20 [ last_time round::I#3 ] { } main:3::round:22 [ last_time round::I#3 ] { } main:3::round:24 [ last_time round::I#3 ] { } main:3::round:26 [ last_time round::I#3 ] { } ) always clobbers reg byte a
Statement [39] round::$4 = round::I#3 << 1 [ round::I#3 round::$4 ] ( main:3::round:8 [ last_time round::I#3 round::$4 ] { } main:3::round:10 [ last_time round::I#3 round::$4 ] { } main:3::round:12 [ last_time round::I#3 round::$4 ] { } main:3::round:14 [ last_time round::I#3 round::$4 ] { } main:3::round:16 [ last_time round::I#3 round::$4 ] { } main:3::round:18 [ last_time round::I#3 round::$4 ] { } main:3::round:20 [ last_time round::I#3 round::$4 ] { } main:3::round:22 [ last_time round::I#3 round::$4 ] { } main:3::round:24 [ last_time round::I#3 round::$4 ] { } main:3::round:26 [ last_time round::I#3 round::$4 ] { } ) always clobbers reg byte a
Statement [40] round::S#1 = Sieve + round::$4 [ round::I#3 round::S#1 ] ( main:3::round:8 [ last_time round::I#3 round::S#1 ] { } main:3::round:10 [ last_time round::I#3 round::S#1 ] { } main:3::round:12 [ last_time round::I#3 round::S#1 ] { } main:3::round:14 [ last_time round::I#3 round::S#1 ] { } main:3::round:16 [ last_time round::I#3 round::S#1 ] { } main:3::round:18 [ last_time round::I#3 round::S#1 ] { } main:3::round:20 [ last_time round::I#3 round::S#1 ] { } main:3::round:22 [ last_time round::I#3 round::S#1 ] { } main:3::round:24 [ last_time round::I#3 round::S#1 ] { } main:3::round:26 [ last_time round::I#3 round::S#1 ] { } ) always clobbers reg byte a
Statement [42] if(round::S#3<Sieve+COUNT) goto round::@7 [ round::I#3 round::S#3 ] ( main:3::round:8 [ last_time round::I#3 round::S#3 ] { } main:3::round:10 [ last_time round::I#3 round::S#3 ] { } main:3::round:12 [ last_time round::I#3 round::S#3 ] { } main:3::round:14 [ last_time round::I#3 round::S#3 ] { } main:3::round:16 [ last_time round::I#3 round::S#3 ] { } main:3::round:18 [ last_time round::I#3 round::S#3 ] { } main:3::round:20 [ last_time round::I#3 round::S#3 ] { } main:3::round:22 [ last_time round::I#3 round::S#3 ] { } main:3::round:24 [ last_time round::I#3 round::S#3 ] { } main:3::round:26 [ last_time round::I#3 round::S#3 ] { } ) always clobbers reg byte a
Statement [44] *round::S#3 = 1 [ round::I#3 round::S#3 ] ( main:3::round:8 [ last_time round::I#3 round::S#3 ] { } main:3::round:10 [ last_time round::I#3 round::S#3 ] { } main:3::round:12 [ last_time round::I#3 round::S#3 ] { } main:3::round:14 [ last_time round::I#3 round::S#3 ] { } main:3::round:16 [ last_time round::I#3 round::S#3 ] { } main:3::round:18 [ last_time round::I#3 round::S#3 ] { } main:3::round:20 [ last_time round::I#3 round::S#3 ] { } main:3::round:22 [ last_time round::I#3 round::S#3 ] { } main:3::round:24 [ last_time round::I#3 round::S#3 ] { } main:3::round:26 [ last_time round::I#3 round::S#3 ] { } ) always clobbers reg byte a reg byte y
Statement [45] round::S#2 = round::S#3 + round::I#3 [ round::I#3 round::S#2 ] ( main:3::round:8 [ last_time round::I#3 round::S#2 ] { } main:3::round:10 [ last_time round::I#3 round::S#2 ] { } main:3::round:12 [ last_time round::I#3 round::S#2 ] { } main:3::round:14 [ last_time round::I#3 round::S#2 ] { } main:3::round:16 [ last_time round::I#3 round::S#2 ] { } main:3::round:18 [ last_time round::I#3 round::S#2 ] { } main:3::round:20 [ last_time round::I#3 round::S#2 ] { } main:3::round:22 [ last_time round::I#3 round::S#2 ] { } main:3::round:24 [ last_time round::I#3 round::S#2 ] { } main:3::round:26 [ last_time round::I#3 round::S#2 ] { } ) always clobbers reg byte a
Statement [46] *round::p#2 = 0 [ round::p#2 ] ( main:3::round:8 [ last_time round::p#2 ] { } main:3::round:10 [ last_time round::p#2 ] { } main:3::round:12 [ last_time round::p#2 ] { } main:3::round:14 [ last_time round::p#2 ] { } main:3::round:16 [ last_time round::p#2 ] { } main:3::round:18 [ last_time round::p#2 ] { } main:3::round:20 [ last_time round::p#2 ] { } main:3::round:22 [ last_time round::p#2 ] { } main:3::round:24 [ last_time round::p#2 ] { } main:3::round:26 [ last_time round::p#2 ] { } ) always clobbers reg byte a reg byte y
Statement [48] Ticks#0 = last_time [ last_time Ticks#0 ] ( main:3::end:28 [ last_time Ticks#0 ] { } ) always clobbers reg byte a
Statement [50] last_time = last_time - Ticks#0 [ last_time ] ( main:3::end:28 [ last_time ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [51] Ticks#1 = last_time [ Ticks#1 ] ( main:3::end:28 [ Ticks#1 ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [52] print_uint::w#0 = Ticks#1 [ print_uint::w#0 ] ( main:3::end:28 [ print_uint::w#0 ] { { Ticks#1 = print_uint::w#0 } } ) always clobbers reg byte a
Statement [64] print_line_cursor#0 = print_line_cursor#9 + $28 [ print_line_cursor#0 print_char_cursor#27 ] ( main:3::end:28::print_ln:55 [ print_line_cursor#0 print_char_cursor#27 ] { } ) always clobbers reg byte a
Statement [65] if(print_line_cursor#0<print_char_cursor#27) goto print_ln::@1 [ print_line_cursor#0 print_char_cursor#27 ] ( main:3::end:28::print_ln:55 [ print_line_cursor#0 print_char_cursor#27 ] { } ) always clobbers reg byte a
Statement [68] print_uchar::$0 = print_uchar::b#2 >> 4 [ print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] ( main:3::end:28::print_uint:53::print_uchar:58 [ print_uint::w#0 print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#0 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#37 } } main:3::end:28::print_uint:53::print_uchar:60 [ print_uchar::b#2 print_char_cursor#37 print_uchar::$0 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#0 = print_char::ch#2 } } ) always clobbers reg byte a
Statement [71] print_uchar::$2 = print_uchar::b#2 & $f [ print_char_cursor#27 print_uchar::$2 ] ( main:3::end:28::print_uint:53::print_uchar:58 [ print_uint::w#0 print_char_cursor#27 print_uchar::$2 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#27 } } main:3::end:28::print_uint:53::print_uchar:60 [ print_char_cursor#27 print_uchar::$2 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#1 = print_char::ch#2 } } ) always clobbers reg byte a
Statement [76] *print_char_cursor#26 = print_char::ch#2 [ print_char_cursor#26 ] ( main:3::end:28::print_uint:53::print_uchar:58::print_char:70 [ print_uint::w#0 print_uchar::b#2 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#0 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#37 } } main:3::end:28::print_uint:53::print_uchar:60::print_char:70 [ print_uchar::b#2 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#0 = print_char::ch#2 } } main:3::end:28::print_uint:53::print_uchar:58::print_char:73 [ print_uint::w#0 print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#0 = print_uchar::b#2 } { print_char::ch#1 = print_char::ch#2 } { print_char_cursor#26 = print_char_cursor#27 } } main:3::end:28::print_uint:53::print_uchar:60::print_char:73 [ print_char_cursor#26 ] { { Ticks#1 = print_uint::w#0 } { print_uchar::b#1 = print_uchar::b#2 } { print_char_cursor#26 = print_char_cursor#37 print_char_cursor#27 } { print_char::ch#1 = print_char::ch#2 } } ) always clobbers reg byte y
Potential registers zp[2]:13 [ round::p#2 round::p#1 ] : zp[2]:13 ,
Potential registers zp[1]:12 [ round::I#3 round::I#2 ] : zp[1]:12 , reg byte x ,
Potential registers zp[2]:5 [ round::S#3 round::S#2 round::S#1 ] : zp[2]:5 ,
Potential registers zp[2]:7 [ print_line_cursor#9 print_line_cursor#0 ] : zp[2]:7 ,
Potential registers zp[1]:11 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ] : zp[1]:11 , reg byte x ,
Potential registers zp[1]:2 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[2]:3 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ] : zp[2]:3 ,
Potential registers zp[2]:22 [ last_time ] : zp[2]:22 ,
Potential registers zp[1]:15 [ round::$4 ] : zp[1]:15 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[2]:20 [ Ticks#0 ] : zp[2]:20 ,
Potential registers zp[2]:18 [ Ticks#1 ] : zp[2]:18 ,
Potential registers zp[2]:16 [ print_uint::w#0 ] : zp[2]:16 ,
Potential registers zp[1]:9 [ print_uchar::$0 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:10 [ print_uchar::$2 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [print_char] 160,007: zp[1]:2 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
Uplift Scope [] 120,787.22: zp[2]:3 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ] 35,003.5: zp[2]:7 [ print_line_cursor#9 print_line_cursor#0 ] 202: zp[2]:18 [ Ticks#1 ] 101: zp[2]:20 [ Ticks#0 ] 14.5: zp[2]:22 [ last_time ]
Uplift Scope [print_uchar] 20,002: zp[1]:9 [ print_uchar::$0 ] 20,002: zp[1]:10 [ print_uchar::$2 ] 9,505: zp[1]:11 [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplift Scope [round] 35,672.33: zp[2]:5 [ round::S#3 round::S#2 round::S#1 ] 3,669.33: zp[1]:12 [ round::I#3 round::I#2 ] 3,336.67: zp[2]:13 [ round::p#2 round::p#1 ] 2,002: zp[1]:15 [ round::$4 ]
Uplift Scope [print_uint] 701: zp[2]:16 [ print_uint::w#0 ]
Uplift Scope [print_ln]
Uplift Scope [RADIX]
Uplift Scope [MOS6526_CIA]
Uplift Scope [MOS6569_VICII]
Uplift Scope [MOS6581_SID]
Uplift Scope [start]
Uplift Scope [end]
Uplift Scope [main]
Uplift Scope [__start]
Uplifting [print_char] best 7716 combination reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
Uplifting [] best 7716 combination zp[2]:3 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ] zp[2]:7 [ print_line_cursor#9 print_line_cursor#0 ] zp[2]:18 [ Ticks#1 ] zp[2]:20 [ Ticks#0 ] zp[2]:22 [ last_time ]
Uplifting [print_uchar] best 7698 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [round] best 7408 combination zp[2]:5 [ round::S#3 round::S#2 round::S#1 ] reg byte x [ round::I#3 round::I#2 ] zp[2]:13 [ round::p#2 round::p#1 ] reg byte a [ round::$4 ]
Uplifting [print_uint] best 7408 combination zp[2]:16 [ print_uint::w#0 ]
Uplifting [print_ln] best 7408 combination
Uplifting [RADIX] best 7408 combination
Uplifting [MOS6526_CIA] best 7408 combination
Uplifting [MOS6569_VICII] best 7408 combination
Uplifting [MOS6581_SID] best 7408 combination
Uplifting [start] best 7408 combination
Uplifting [end] best 7408 combination
Uplifting [main] best 7408 combination
Uplifting [__start] best 7408 combination
Coalescing zero page register [ zp[2]:18 [ Ticks#1 ] ] with [ zp[2]:16 [ print_uint::w#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:7 [ print_line_cursor#9 print_line_cursor#0 ] ] with [ zp[2]:13 [ round::p#2 round::p#1 ] ]
Coalescing zero page register [ zp[2]:3 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 ] ] with [ zp[2]:5 [ round::S#3 round::S#2 round::S#1 ] ]
Allocated (was zp[2]:3) zp[2]:2 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 round::S#3 round::S#2 round::S#1 ]
Allocated (was zp[2]:7) zp[2]:4 [ print_line_cursor#9 print_line_cursor#0 round::p#2 round::p#1 ]
Allocated (was zp[2]:18) zp[2]:6 [ Ticks#1 print_uint::w#0 ]
Allocated (was zp[2]:20) zp[2]:8 [ Ticks#0 ]
Allocated (was zp[2]:22) zp[2]:10 [ last_time ]
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="sieve-kc.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(__start)
// Global Constants & labels
.const COUNT = $4000
.const SQRT_COUNT = $80
.label print_screen = $400
.label last_time = $a
.label print_line_cursor = 4
.label Ticks = 8
.label Ticks_1 = 6
.label print_char_cursor = 2
.segment Code
// __start
__start: {
jmp __init1
// __start::__init1
__init1:
// [1] last_time = 0 -- vwuz1=vwuc1
lda #<0
sta.z last_time
lda #>0
sta.z last_time+1
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
__b1_from___init1:
jmp __b1
// __start::@1
__b1:
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
main_from___b1:
jsr main
jmp __breturn
// __start::@return
__breturn:
// [4] return
rts
}
// main
main: {
// [6] call start
jsr start
// [7] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
jmp __b1
// main::@1
__b1:
// [8] call round
// [32] phi from main::@1 to round [phi:main::@1->round]
round_from___b1:
jsr round
// [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
__b2_from___b1:
jmp __b2
// main::@2
__b2:
// [10] call round
// [32] phi from main::@2 to round [phi:main::@2->round]
round_from___b2:
jsr round
// [11] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
__b3_from___b2:
jmp __b3
// main::@3
__b3:
// [12] call round
// [32] phi from main::@3 to round [phi:main::@3->round]
round_from___b3:
jsr round
// [13] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
__b4_from___b3:
jmp __b4
// main::@4
__b4:
// [14] call round
// [32] phi from main::@4 to round [phi:main::@4->round]
round_from___b4:
jsr round
// [15] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
__b5_from___b4:
jmp __b5
// main::@5
__b5:
// [16] call round
// [32] phi from main::@5 to round [phi:main::@5->round]
round_from___b5:
jsr round
// [17] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
__b6_from___b5:
jmp __b6
// main::@6
__b6:
// [18] call round
// [32] phi from main::@6 to round [phi:main::@6->round]
round_from___b6:
jsr round
// [19] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
__b7_from___b6:
jmp __b7
// main::@7
__b7:
// [20] call round
// [32] phi from main::@7 to round [phi:main::@7->round]
round_from___b7:
jsr round
// [21] phi from main::@7 to main::@8 [phi:main::@7->main::@8]
__b8_from___b7:
jmp __b8
// main::@8
__b8:
// [22] call round
// [32] phi from main::@8 to round [phi:main::@8->round]
round_from___b8:
jsr round
// [23] phi from main::@8 to main::@9 [phi:main::@8->main::@9]
__b9_from___b8:
jmp __b9
// main::@9
__b9:
// [24] call round
// [32] phi from main::@9 to round [phi:main::@9->round]
round_from___b9:
jsr round
// [25] phi from main::@9 to main::@10 [phi:main::@9->main::@10]
__b10_from___b9:
jmp __b10
// main::@10
__b10:
// [26] call round
// [32] phi from main::@10 to round [phi:main::@10->round]
round_from___b10:
jsr round
// [27] phi from main::@10 to main::@11 [phi:main::@10->main::@11]
__b11_from___b10:
jmp __b11
// main::@11
__b11:
// [28] call end
jsr end
jmp __breturn
// main::@return
__breturn:
// [29] return
rts
}
// start
start: {
.label LAST_TIME = last_time
// asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 }
jsr $ffde
sta LAST_TIME
stx LAST_TIME+1
jmp __breturn
// start::@return
__breturn:
// [31] return
rts
}
// round
round: {
.label p = 4
.label S = 2
// [33] phi from round to round::@1 [phi:round->round::@1]
__b1_from_round:
// [33] phi round::p#2 = Sieve [phi:round->round::@1#0] -- pbuz1=pbuc1
lda #<Sieve
sta.z p
lda #>Sieve
sta.z p+1
jmp __b1
// round::@1
__b1:
// [34] if(round::p#2<Sieve+COUNT) goto round::@2 -- pbuz1_lt_pbuc1_then_la1
lda.z p+1
cmp #>Sieve+COUNT
bcc __b2
bne !+
lda.z p
cmp #<Sieve+COUNT
bcc __b2
!:
// [35] phi from round::@1 to round::@3 [phi:round::@1->round::@3]
__b3_from___b1:
// [35] phi round::I#3 = 2 [phi:round::@1->round::@3#0] -- vbuxx=vbuc1
ldx #2
jmp __b3
// round::@3
__b3:
// [36] if(round::I#3<SQRT_COUNT) goto round::@4 -- vbuxx_lt_vbuc1_then_la1
cpx #SQRT_COUNT
bcc __b4
jmp __breturn
// round::@return
__breturn:
// [37] return
rts
// round::@4
__b4:
// [38] if(Sieve[round::I#3]!=0) goto round::@5 -- pbuc1_derefidx_vbuxx_neq_0_then_la1
lda Sieve,x
cmp #0
bne __b5
jmp __b8
// round::@8
__b8:
// [39] round::$4 = round::I#3 << 1 -- vbuaa=vbuxx_rol_1
txa
asl
// [40] round::S#1 = Sieve + round::$4 -- pbuz1=pbuc1_plus_vbuaa
clc
adc #<Sieve
sta.z S
lda #>Sieve
adc #0
sta.z S+1
// [41] phi from round::@7 round::@8 to round::@6 [phi:round::@7/round::@8->round::@6]
__b6_from___b7:
__b6_from___b8:
// [41] phi round::S#3 = round::S#2 [phi:round::@7/round::@8->round::@6#0] -- register_copy
jmp __b6
// round::@6
__b6:
// [42] if(round::S#3<Sieve+COUNT) goto round::@7 -- pbuz1_lt_pbuc1_then_la1
lda.z S+1
cmp #>Sieve+COUNT
bcc __b7
bne !+
lda.z S
cmp #<Sieve+COUNT
bcc __b7
!:
jmp __b5
// round::@5
__b5:
// [43] round::I#2 = ++ round::I#3 -- vbuxx=_inc_vbuxx
inx
// [35] phi from round::@5 to round::@3 [phi:round::@5->round::@3]
__b3_from___b5:
// [35] phi round::I#3 = round::I#2 [phi:round::@5->round::@3#0] -- register_copy
jmp __b3
// round::@7
__b7:
// [44] *round::S#3 = 1 -- _deref_pbuz1=vbuc1
lda #1
ldy #0
sta (S),y
// [45] round::S#2 = round::S#3 + round::I#3 -- pbuz1=pbuz1_plus_vbuxx
txa
clc
adc.z S
sta.z S
bcc !+
inc.z S+1
!:
jmp __b6_from___b7
// round::@2
__b2:
// [46] *round::p#2 = 0 -- _deref_pbuz1=vbuc1
lda #0
ldy #0
sta (p),y
// [47] round::p#1 = ++ round::p#2 -- pbuz1=_inc_pbuz1
inc.z p
bne !+
inc.z p+1
!:
// [33] phi from round::@2 to round::@1 [phi:round::@2->round::@1]
__b1_from___b2:
// [33] phi round::p#2 = round::p#1 [phi:round::@2->round::@1#0] -- register_copy
jmp __b1
}
// end
end: {
// [48] Ticks#0 = last_time -- vwuz1=vwuz2
lda.z last_time
sta.z Ticks
lda.z last_time+1
sta.z Ticks+1
// [49] call start
jsr start
jmp __b1
// end::@1
__b1:
// [50] last_time = last_time - Ticks#0 -- vwuz1=vwuz1_minus_vwuz2
lda.z last_time
sec
sbc.z Ticks
sta.z last_time
lda.z last_time+1
sbc.z Ticks+1
sta.z last_time+1
// [51] Ticks#1 = last_time -- vwuz1=vwuz2
lda.z last_time
sta.z Ticks_1
lda.z last_time+1
sta.z Ticks_1+1
// [52] print_uint::w#0 = Ticks#1
// [53] call print_uint
jsr print_uint
// [54] phi from end::@1 to end::@2 [phi:end::@1->end::@2]
__b2_from___b1:
jmp __b2
// end::@2
__b2:
// [55] call print_ln
// [62] phi from end::@2 to print_ln [phi:end::@2->print_ln]
print_ln_from___b2:
jsr print_ln
jmp __breturn
// end::@return
__breturn:
// [56] return
rts
}
// print_uint
// Print a unsigned int as HEX
// void print_uint(__zp(6) unsigned int w)
print_uint: {
.label w = 6
// [57] print_uchar::b#0 = byte1 print_uint::w#0 -- vbuxx=_byte1_vwuz1
ldx.z w+1
// [58] call print_uchar
// [67] phi from print_uint to print_uchar [phi:print_uint->print_uchar]
print_uchar_from_print_uint:
// [67] phi print_char_cursor#37 = print_screen#0 [phi:print_uint->print_uchar#0] -- pbuz1=pbuc1
lda #<print_screen
sta.z print_char_cursor
lda #>print_screen
sta.z print_char_cursor+1
// [67] phi print_uchar::b#2 = print_uchar::b#0 [phi:print_uint->print_uchar#1] -- register_copy
jsr print_uchar
jmp __b1
// print_uint::@1
__b1:
// [59] print_uchar::b#1 = byte0 print_uint::w#0 -- vbuxx=_byte0_vwuz1
ldx.z w
// [60] call print_uchar
// [67] phi from print_uint::@1 to print_uchar [phi:print_uint::@1->print_uchar]
print_uchar_from___b1:
// [67] phi print_char_cursor#37 = print_char_cursor#27 [phi:print_uint::@1->print_uchar#0] -- register_copy
// [67] phi print_uchar::b#2 = print_uchar::b#1 [phi:print_uint::@1->print_uchar#1] -- register_copy
jsr print_uchar
jmp __breturn
// print_uint::@return
__breturn:
// [61] return
rts
}
// print_ln
// Print a newline
print_ln: {
// [63] phi from print_ln to print_ln::@1 [phi:print_ln->print_ln::@1]
__b1_from_print_ln:
// [63] phi print_line_cursor#9 = print_screen#0 [phi:print_ln->print_ln::@1#0] -- pbuz1=pbuc1
lda #<print_screen
sta.z print_line_cursor
lda #>print_screen
sta.z print_line_cursor+1
jmp __b1
// [63] phi from print_ln::@1 to print_ln::@1 [phi:print_ln::@1->print_ln::@1]
__b1_from___b1:
// [63] phi print_line_cursor#9 = print_line_cursor#0 [phi:print_ln::@1->print_ln::@1#0] -- register_copy
jmp __b1
// print_ln::@1
__b1:
// [64] 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
!:
// [65] if(print_line_cursor#0<print_char_cursor#27) 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:
// [66] return
rts
}
// print_uchar
// Print a char as HEX
// void print_uchar(__register(X) char b)
print_uchar: {
// [68] print_uchar::$0 = print_uchar::b#2 >> 4 -- vbuaa=vbuxx_ror_4
txa
lsr
lsr
lsr
lsr
// [69] print_char::ch#0 = print_hextab[print_uchar::$0] -- vbuaa=pbuc1_derefidx_vbuaa
tay
lda print_hextab,y
// [70] call print_char
// Table of hexadecimal digits
// [75] phi from print_uchar to print_char [phi:print_uchar->print_char]
print_char_from_print_uchar:
// [75] phi print_char_cursor#26 = print_char_cursor#37 [phi:print_uchar->print_char#0] -- register_copy
// [75] phi print_char::ch#2 = print_char::ch#0 [phi:print_uchar->print_char#1] -- register_copy
jsr print_char
jmp __b1
// print_uchar::@1
__b1:
// [71] print_uchar::$2 = print_uchar::b#2 & $f -- vbuxx=vbuxx_band_vbuc1
lda #$f
axs #0
// [72] print_char::ch#1 = print_hextab[print_uchar::$2] -- vbuaa=pbuc1_derefidx_vbuxx
lda print_hextab,x
// [73] call print_char
// [75] phi from print_uchar::@1 to print_char [phi:print_uchar::@1->print_char]
print_char_from___b1:
// [75] phi print_char_cursor#26 = print_char_cursor#27 [phi:print_uchar::@1->print_char#0] -- register_copy
// [75] phi print_char::ch#2 = print_char::ch#1 [phi:print_uchar::@1->print_char#1] -- register_copy
jsr print_char
jmp __breturn
// print_uchar::@return
__breturn:
// [74] return
rts
}
// print_char
// Print a single char
// void print_char(__register(A) char ch)
print_char: {
// [76] *print_char_cursor#26 = print_char::ch#2 -- _deref_pbuz1=vbuaa
ldy #0
sta (print_char_cursor),y
// [77] print_char_cursor#27 = ++ print_char_cursor#26 -- pbuz1=_inc_pbuz1
inc.z print_char_cursor
bne !+
inc.z print_char_cursor+1
!:
jmp __breturn
// print_char::@return
__breturn:
// [78] return
rts
}
// File Data
.segment Data
print_hextab: .text "0123456789abcdef"
.align $100
Sieve: .fill COUNT, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __init1
Removing instruction jmp __b1
Removing instruction jmp __breturn
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 __b7
Removing instruction jmp __b8
Removing instruction jmp __b9
Removing instruction jmp __b10
Removing instruction jmp __b11
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __b8
Removing instruction jmp __b6
Removing instruction jmp __b5
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __b1
Removing instruction jmp __breturn
Removing instruction jmp __breturn
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda #>0
Replacing instruction ldy #0 with TAY
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b6_from___b7 with __b6
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Removing instruction __b1_from___init1:
Removing instruction main_from___b1:
Removing instruction __b1_from_main:
Removing instruction round_from___b1:
Removing instruction __b2_from___b1:
Removing instruction round_from___b2:
Removing instruction __b3_from___b2:
Removing instruction round_from___b3:
Removing instruction __b4_from___b3:
Removing instruction round_from___b4:
Removing instruction __b5_from___b4:
Removing instruction round_from___b5:
Removing instruction __b6_from___b5:
Removing instruction round_from___b6:
Removing instruction __b7_from___b6:
Removing instruction round_from___b7:
Removing instruction __b8_from___b7:
Removing instruction round_from___b8:
Removing instruction __b9_from___b8:
Removing instruction round_from___b9:
Removing instruction __b10_from___b9:
Removing instruction round_from___b10:
Removing instruction __b11_from___b10:
Removing instruction __b6_from___b7:
Removing instruction __b6_from___b8:
Removing instruction __b2_from___b1:
Removing instruction print_ln_from___b2:
Removing instruction __b1_from___b1:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __init1:
Removing instruction __b1:
Removing instruction __breturn:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __b3:
Removing instruction __b4:
Removing instruction __b5:
Removing instruction __b6:
Removing instruction __b7:
Removing instruction __b8:
Removing instruction __b9:
Removing instruction __b10:
Removing instruction __b11:
Removing instruction __breturn:
Removing instruction __breturn:
Removing instruction __b1_from_round:
Removing instruction __b3_from___b1:
Removing instruction __breturn:
Removing instruction __b8:
Removing instruction __b3_from___b5:
Removing instruction __b1_from___b2:
Removing instruction __b1:
Removing instruction __b2:
Removing instruction __breturn:
Removing instruction print_uchar_from_print_uint:
Removing instruction __b1:
Removing instruction print_uchar_from___b1:
Removing instruction __breturn:
Removing instruction __b1_from_print_ln:
Removing instruction __breturn:
Removing instruction print_char_from_print_uchar:
Removing instruction __b1:
Removing instruction print_char_from___b1:
Removing instruction __breturn:
Removing instruction __breturn:
Succesful ASM optimization Pass5UnusedLabelElimination
Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
FINAL SYMBOL TABLE
__constant const unsigned int COUNT = $4000
__constant char RADIX::BINARY = 2
__constant char RADIX::DECIMAL = $a
__constant char RADIX::HEXADECIMAL = $10
__constant char RADIX::OCTAL = 8
__constant const char SQRT_COUNT = $80
__constant char Sieve[COUNT] = { fill( COUNT, 0) }
unsigned int Ticks
unsigned int Ticks#0 // Ticks zp[2]:8 101.0
unsigned int Ticks#1 // Ticks_1 zp[2]:6 202.0
void __start()
void end()
__loadstore volatile unsigned int last_time // zp[2]:10 14.500000000000002
int main()
int main::return
void print_char(char ch)
char print_char::ch
char print_char::ch#0 // reg byte a 20002.0
char print_char::ch#1 // reg byte a 20002.0
char print_char::ch#2 // reg byte a 120003.0
char *print_char_cursor
char *print_char_cursor#26 // print_char_cursor zp[2]:2 110002.0
char *print_char_cursor#27 // print_char_cursor zp[2]:2 7117.882352941177
char *print_char_cursor#37 // print_char_cursor zp[2]:2 3667.333333333333
__constant const char print_hextab[] = "0123456789abcdef"z
char *print_line_cursor
char *print_line_cursor#0 // print_line_cursor zp[2]:4 15001.5
char *print_line_cursor#9 // print_line_cursor zp[2]:4 20002.0
void print_ln()
char *print_screen
__constant char *print_screen#0 = (char *) 1024 // print_screen
void print_uchar(char b)
char print_uchar::$0 // reg byte a 20002.0
char print_uchar::$2 // reg byte x 20002.0
char print_uchar::b
char print_uchar::b#0 // reg byte x 2002.0
char print_uchar::b#1 // reg byte x 2002.0
char print_uchar::b#2 // reg byte x 5501.0
void print_uint(unsigned int w)
unsigned int print_uint::w
unsigned int print_uint::w#0 // w zp[2]:6 701.0
void round()
char round::$4 // reg byte a 2002.0
char round::I
char round::I#2 // reg byte x 2002.0
char round::I#3 // reg byte x 1667.3333333333333
char *round::S
char *round::S#1 // S zp[2]:2 2002.0
char *round::S#2 // S zp[2]:2 20002.0
char *round::S#3 // S zp[2]:2 13668.333333333332
char *round::p
char *round::p#1 // p zp[2]:4 2002.0
char *round::p#2 // p zp[2]:4 1334.6666666666667
void start()
__constant unsigned int * const start::LAST_TIME = &last_time
reg byte x [ round::I#3 round::I#2 ]
zp[2]:4 [ print_line_cursor#9 print_line_cursor#0 round::p#2 round::p#1 ]
reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
zp[2]:2 [ print_char_cursor#26 print_char_cursor#37 print_char_cursor#27 round::S#3 round::S#2 round::S#1 ]
zp[2]:10 [ last_time ]
reg byte a [ round::$4 ]
zp[2]:8 [ Ticks#0 ]
zp[2]:6 [ Ticks#1 print_uint::w#0 ]
reg byte a [ print_uchar::$0 ]
reg byte x [ print_uchar::$2 ]
FINAL ASSEMBLER
Score: 6485
// 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="sieve-kc.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(__start)
// Global Constants & labels
.const COUNT = $4000
.const SQRT_COUNT = $80
.label print_screen = $400
.label last_time = $a
.label print_line_cursor = 4
.label Ticks = 8
.label Ticks_1 = 6
.label print_char_cursor = 2
.segment Code
// __start
__start: {
// __start::__init1
// unsigned int last_time
// [1] last_time = 0 -- vwuz1=vwuc1
lda #<0
sta.z last_time
sta.z last_time+1
// [2] phi from __start::__init1 to __start::@1 [phi:__start::__init1->__start::@1]
// __start::@1
// [3] call main
// [5] phi from __start::@1 to main [phi:__start::@1->main]
jsr main
// __start::@return
// [4] return
rts
}
// main
main: {
// start()
// [6] call start
jsr start
// [7] phi from main to main::@1 [phi:main->main::@1]
// main::@1
// round()
// [8] call round
// [32] phi from main::@1 to round [phi:main::@1->round]
jsr round
// [9] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
// main::@2
// round()
// [10] call round
// [32] phi from main::@2 to round [phi:main::@2->round]
jsr round
// [11] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
// main::@3
// round()
// [12] call round
// [32] phi from main::@3 to round [phi:main::@3->round]
jsr round
// [13] phi from main::@3 to main::@4 [phi:main::@3->main::@4]
// main::@4
// round()
// [14] call round
// [32] phi from main::@4 to round [phi:main::@4->round]
jsr round
// [15] phi from main::@4 to main::@5 [phi:main::@4->main::@5]
// main::@5
// round()
// [16] call round
// [32] phi from main::@5 to round [phi:main::@5->round]
jsr round
// [17] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
// main::@6
// round()
// [18] call round
// [32] phi from main::@6 to round [phi:main::@6->round]
jsr round
// [19] phi from main::@6 to main::@7 [phi:main::@6->main::@7]
// main::@7
// round()
// [20] call round
// [32] phi from main::@7 to round [phi:main::@7->round]
jsr round
// [21] phi from main::@7 to main::@8 [phi:main::@7->main::@8]
// main::@8
// round()
// [22] call round
// [32] phi from main::@8 to round [phi:main::@8->round]
jsr round
// [23] phi from main::@8 to main::@9 [phi:main::@8->main::@9]
// main::@9
// round()
// [24] call round
// [32] phi from main::@9 to round [phi:main::@9->round]
jsr round
// [25] phi from main::@9 to main::@10 [phi:main::@9->main::@10]
// main::@10
// round()
// [26] call round
// [32] phi from main::@10 to round [phi:main::@10->round]
jsr round
// [27] phi from main::@10 to main::@11 [phi:main::@10->main::@11]
// main::@11
// end()
// [28] call end
jsr end
// main::@return
// }
// [29] return
rts
}
// start
start: {
.label LAST_TIME = last_time
// asm
// asm { jsr$FFDE staLAST_TIME stxLAST_TIME+1 }
jsr $ffde
sta LAST_TIME
stx LAST_TIME+1
// start::@return
// }
// [31] return
rts
}
// round
round: {
.label p = 4
.label S = 2
// [33] phi from round to round::@1 [phi:round->round::@1]
// [33] phi round::p#2 = Sieve [phi:round->round::@1#0] -- pbuz1=pbuc1
lda #<Sieve
sta.z p
lda #>Sieve
sta.z p+1
// round::@1
__b1:
// for(char* p=Sieve;p<Sieve+COUNT;++p)
// [34] if(round::p#2<Sieve+COUNT) goto round::@2 -- pbuz1_lt_pbuc1_then_la1
lda.z p+1
cmp #>Sieve+COUNT
bcc __b2
bne !+
lda.z p
cmp #<Sieve+COUNT
bcc __b2
!:
// [35] phi from round::@1 to round::@3 [phi:round::@1->round::@3]
// [35] phi round::I#3 = 2 [phi:round::@1->round::@3#0] -- vbuxx=vbuc1
ldx #2
// round::@3
__b3:
// while (I < SQRT_COUNT)
// [36] if(round::I#3<SQRT_COUNT) goto round::@4 -- vbuxx_lt_vbuc1_then_la1
cpx #SQRT_COUNT
bcc __b4
// round::@return
// }
// [37] return
rts
// round::@4
__b4:
// if (Sieve[I] == 0)
// [38] if(Sieve[round::I#3]!=0) goto round::@5 -- pbuc1_derefidx_vbuxx_neq_0_then_la1
lda Sieve,x
cmp #0
bne __b5
// round::@8
// I<<1
// [39] round::$4 = round::I#3 << 1 -- vbuaa=vbuxx_rol_1
txa
asl
// S = Sieve + I<<1
// [40] round::S#1 = Sieve + round::$4 -- pbuz1=pbuc1_plus_vbuaa
clc
adc #<Sieve
sta.z S
lda #>Sieve
adc #0
sta.z S+1
// [41] phi from round::@7 round::@8 to round::@6 [phi:round::@7/round::@8->round::@6]
// [41] phi round::S#3 = round::S#2 [phi:round::@7/round::@8->round::@6#0] -- register_copy
// round::@6
__b6:
// while (S < Sieve + COUNT)
// [42] if(round::S#3<Sieve+COUNT) goto round::@7 -- pbuz1_lt_pbuc1_then_la1
lda.z S+1
cmp #>Sieve+COUNT
bcc __b7
bne !+
lda.z S
cmp #<Sieve+COUNT
bcc __b7
!:
// round::@5
__b5:
// ++I;
// [43] round::I#2 = ++ round::I#3 -- vbuxx=_inc_vbuxx
inx
// [35] phi from round::@5 to round::@3 [phi:round::@5->round::@3]
// [35] phi round::I#3 = round::I#2 [phi:round::@5->round::@3#0] -- register_copy
jmp __b3
// round::@7
__b7:
// *S = 1
// [44] *round::S#3 = 1 -- _deref_pbuz1=vbuc1
lda #1
ldy #0
sta (S),y
// S += I
// [45] round::S#2 = round::S#3 + round::I#3 -- pbuz1=pbuz1_plus_vbuxx
txa
clc
adc.z S
sta.z S
bcc !+
inc.z S+1
!:
jmp __b6
// round::@2
__b2:
// *p = 0
// [46] *round::p#2 = 0 -- _deref_pbuz1=vbuc1
lda #0
tay
sta (p),y
// for(char* p=Sieve;p<Sieve+COUNT;++p)
// [47] round::p#1 = ++ round::p#2 -- pbuz1=_inc_pbuz1
inc.z p
bne !+
inc.z p+1
!:
// [33] phi from round::@2 to round::@1 [phi:round::@2->round::@1]
// [33] phi round::p#2 = round::p#1 [phi:round::@2->round::@1#0] -- register_copy
jmp __b1
}
// end
end: {
// Ticks = last_time
// [48] Ticks#0 = last_time -- vwuz1=vwuz2
lda.z last_time
sta.z Ticks
lda.z last_time+1
sta.z Ticks+1
// start()
// [49] call start
jsr start
// end::@1
// last_time -= Ticks
// [50] last_time = last_time - Ticks#0 -- vwuz1=vwuz1_minus_vwuz2
lda.z last_time
sec
sbc.z Ticks
sta.z last_time
lda.z last_time+1
sbc.z Ticks+1
sta.z last_time+1
// Ticks = last_time
// [51] Ticks#1 = last_time -- vwuz1=vwuz2
lda.z last_time
sta.z Ticks_1
lda.z last_time+1
sta.z Ticks_1+1
// print_uint(Ticks)
// [52] print_uint::w#0 = Ticks#1
// [53] call print_uint
jsr print_uint
// [54] phi from end::@1 to end::@2 [phi:end::@1->end::@2]
// end::@2
// print_ln()
// [55] call print_ln
// [62] phi from end::@2 to print_ln [phi:end::@2->print_ln]
jsr print_ln
// end::@return
// }
// [56] return
rts
}
// print_uint
// Print a unsigned int as HEX
// void print_uint(__zp(6) unsigned int w)
print_uint: {
.label w = 6
// print_uchar(BYTE1(w))
// [57] print_uchar::b#0 = byte1 print_uint::w#0 -- vbuxx=_byte1_vwuz1
ldx.z w+1
// [58] call print_uchar
// [67] phi from print_uint to print_uchar [phi:print_uint->print_uchar]
// [67] phi print_char_cursor#37 = print_screen#0 [phi:print_uint->print_uchar#0] -- pbuz1=pbuc1
lda #<print_screen
sta.z print_char_cursor
lda #>print_screen
sta.z print_char_cursor+1
// [67] phi print_uchar::b#2 = print_uchar::b#0 [phi:print_uint->print_uchar#1] -- register_copy
jsr print_uchar
// print_uint::@1
// print_uchar(BYTE0(w))
// [59] print_uchar::b#1 = byte0 print_uint::w#0 -- vbuxx=_byte0_vwuz1
ldx.z w
// [60] call print_uchar
// [67] phi from print_uint::@1 to print_uchar [phi:print_uint::@1->print_uchar]
// [67] phi print_char_cursor#37 = print_char_cursor#27 [phi:print_uint::@1->print_uchar#0] -- register_copy
// [67] phi print_uchar::b#2 = print_uchar::b#1 [phi:print_uint::@1->print_uchar#1] -- register_copy
jsr print_uchar
// print_uint::@return
// }
// [61] return
rts
}
// print_ln
// Print a newline
print_ln: {
// [63] phi from print_ln to print_ln::@1 [phi:print_ln->print_ln::@1]
// [63] phi print_line_cursor#9 = print_screen#0 [phi:print_ln->print_ln::@1#0] -- pbuz1=pbuc1
lda #<print_screen
sta.z print_line_cursor
lda #>print_screen
sta.z print_line_cursor+1
// [63] phi from print_ln::@1 to print_ln::@1 [phi:print_ln::@1->print_ln::@1]
// [63] phi print_line_cursor#9 = print_line_cursor#0 [phi:print_ln::@1->print_ln::@1#0] -- register_copy
// print_ln::@1
__b1:
// print_line_cursor + 0x28
// [64] 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)
// [65] if(print_line_cursor#0<print_char_cursor#27) 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
// }
// [66] return
rts
}
// print_uchar
// Print a char as HEX
// void print_uchar(__register(X) char b)
print_uchar: {
// b>>4
// [68] print_uchar::$0 = print_uchar::b#2 >> 4 -- vbuaa=vbuxx_ror_4
txa
lsr
lsr
lsr
lsr
// print_char(print_hextab[b>>4])
// [69] print_char::ch#0 = print_hextab[print_uchar::$0] -- vbuaa=pbuc1_derefidx_vbuaa
tay
lda print_hextab,y
// [70] call print_char
// Table of hexadecimal digits
// [75] phi from print_uchar to print_char [phi:print_uchar->print_char]
// [75] phi print_char_cursor#26 = print_char_cursor#37 [phi:print_uchar->print_char#0] -- register_copy
// [75] phi print_char::ch#2 = print_char::ch#0 [phi:print_uchar->print_char#1] -- register_copy
jsr print_char
// print_uchar::@1
// b&0xf
// [71] print_uchar::$2 = print_uchar::b#2 & $f -- vbuxx=vbuxx_band_vbuc1
lda #$f
axs #0
// print_char(print_hextab[b&0xf])
// [72] print_char::ch#1 = print_hextab[print_uchar::$2] -- vbuaa=pbuc1_derefidx_vbuxx
lda print_hextab,x
// [73] call print_char
// [75] phi from print_uchar::@1 to print_char [phi:print_uchar::@1->print_char]
// [75] phi print_char_cursor#26 = print_char_cursor#27 [phi:print_uchar::@1->print_char#0] -- register_copy
// [75] phi print_char::ch#2 = print_char::ch#1 [phi:print_uchar::@1->print_char#1] -- register_copy
jsr print_char
// print_uchar::@return
// }
// [74] return
rts
}
// print_char
// Print a single char
// void print_char(__register(A) char ch)
print_char: {
// *(print_char_cursor++) = ch
// [76] *print_char_cursor#26 = print_char::ch#2 -- _deref_pbuz1=vbuaa
ldy #0
sta (print_char_cursor),y
// *(print_char_cursor++) = ch;
// [77] print_char_cursor#27 = ++ print_char_cursor#26 -- pbuz1=_inc_pbuz1
inc.z print_char_cursor
bne !+
inc.z print_char_cursor+1
!:
// print_char::@return
// }
// [78] return
rts
}
// File Data
.segment Data
print_hextab: .text "0123456789abcdef"
.align $100
Sieve: .fill COUNT, 0