mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-20 02:32:36 +00:00
2280 lines
97 KiB
Plaintext
2280 lines
97 KiB
Plaintext
Fixing pointer addition (word*~) bsearch16u::$7 ← (word*) bsearch16u::items + (byte~) bsearch16u::$6
|
|
Fixing pointer addition (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot + (number) 1
|
|
Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1
|
|
Fixing pointer array-indexing *((word*) utoa::digit_values + (byte) utoa::digit)
|
|
Fixing pointer array-indexing *((dword*) ultoa::digit_values + (byte) ultoa::digit)
|
|
Rewriting struct pointer member access *((struct fileentry*) file).bufEdit
|
|
Rewriting struct pointer member access *((struct fileentry*) file).bufEdit
|
|
Rewriting struct pointer member access *((struct fileentry*) file).bufEdit
|
|
Warning! Adding boolean cast to non-boolean condition *((byte*) strcpy::src)
|
|
Warning! Adding boolean cast to non-boolean condition *((byte*) print_str_lines::str)
|
|
Warning! Adding boolean cast to non-boolean condition (byte) print_str_lines::ch
|
|
Warning! Adding boolean cast to non-boolean condition *((byte*) print_str::str)
|
|
Warning! Adding boolean cast to non-boolean condition *((byte*) print_str_at::str)
|
|
Warning! Adding boolean cast to non-boolean sub-expression (byte) print_str_lines::ch
|
|
Identified constant variable (byte*) HEAP_TOP
|
|
Culled Empty Block (label) @1
|
|
Culled Empty Block (label) @2
|
|
Culled Empty Block (label) memset::@7
|
|
Culled Empty Block (label) memset::@6
|
|
Culled Empty Block (label) memset::@8
|
|
Culled Empty Block (label) memset::@9
|
|
Culled Empty Block (label) memset::@3
|
|
Culled Empty Block (label) @3
|
|
Culled Empty Block (label) @4
|
|
Culled Empty Block (label) @5
|
|
Culled Empty Block (label) @6
|
|
Culled Empty Block (label) @7
|
|
Culled Empty Block (label) @8
|
|
Culled Empty Block (label) @9
|
|
Culled Empty Block (label) @10
|
|
Culled Empty Block (label) @11
|
|
Culled Empty Block (label) @13
|
|
Culled Empty Block (label) @14
|
|
Culled Empty Block (label) print_str::@4
|
|
Culled Empty Block (label) print_str::@3
|
|
Culled Empty Block (label) print_str::@5
|
|
Culled Empty Block (label) print_str::@6
|
|
Culled Empty Block (label) @15
|
|
Culled Empty Block (label) @16
|
|
Culled Empty Block (label) @17
|
|
Culled Empty Block (label) @18
|
|
Culled Empty Block (label) @19
|
|
Culled Empty Block (label) @20
|
|
Culled Empty Block (label) @21
|
|
Culled Empty Block (label) @22
|
|
Culled Empty Block (label) @23
|
|
Culled Empty Block (label) @24
|
|
Culled Empty Block (label) @25
|
|
Culled Empty Block (label) @26
|
|
Culled Empty Block (label) @27
|
|
Culled Empty Block (label) @28
|
|
Culled Empty Block (label) @30
|
|
Culled Empty Block (label) @31
|
|
Culled Empty Block (label) @32
|
|
Culled Empty Block (label) @33
|
|
Culled Empty Block (label) @34
|
|
Culled Empty Block (label) @35
|
|
Culled Empty Block (label) main::@1
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@12
|
|
|
|
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
|
|
memset: scope:[memset] from print_cls
|
|
(byte) memset::c#4 ← phi( print_cls/(byte) memset::c#0 )
|
|
(void*) memset::str#3 ← phi( print_cls/(void*) memset::str#0 )
|
|
(word) memset::num#1 ← phi( print_cls/(word) memset::num#0 )
|
|
(bool~) memset::$0 ← (word) memset::num#1 > (number) 0
|
|
(bool~) memset::$1 ← ! (bool~) memset::$0
|
|
if((bool~) memset::$1) goto memset::@1
|
|
to:memset::@2
|
|
memset::@1: scope:[memset] from memset memset::@4
|
|
(void*) memset::str#1 ← phi( memset/(void*) memset::str#3 memset::@4/(void*) memset::str#4 )
|
|
(void*) memset::return#0 ← (void*) memset::str#1
|
|
to:memset::@return
|
|
memset::@2: scope:[memset] from memset
|
|
(byte) memset::c#3 ← phi( memset/(byte) memset::c#4 )
|
|
(word) memset::num#2 ← phi( memset/(word) memset::num#1 )
|
|
(void*) memset::str#2 ← phi( memset/(void*) memset::str#3 )
|
|
(byte*~) memset::$2 ← ((byte*)) (void*) memset::str#2
|
|
(byte*~) memset::$3 ← (byte*~) memset::$2 + (word) memset::num#2
|
|
(byte*) memset::end#0 ← (byte*~) memset::$3
|
|
(byte*) memset::dst#0 ← ((byte*)) (void*) memset::str#2
|
|
to:memset::@4
|
|
memset::@4: scope:[memset] from memset::@2 memset::@5
|
|
(byte) memset::c#2 ← phi( memset::@2/(byte) memset::c#3 memset::@5/(byte) memset::c#1 )
|
|
(void*) memset::str#4 ← phi( memset::@2/(void*) memset::str#2 memset::@5/(void*) memset::str#5 )
|
|
(byte*) memset::end#1 ← phi( memset::@2/(byte*) memset::end#0 memset::@5/(byte*) memset::end#2 )
|
|
(byte*) memset::dst#2 ← phi( memset::@2/(byte*) memset::dst#0 memset::@5/(byte*) memset::dst#1 )
|
|
(bool~) memset::$4 ← (byte*) memset::dst#2 != (byte*) memset::end#1
|
|
if((bool~) memset::$4) goto memset::@5
|
|
to:memset::@1
|
|
memset::@5: scope:[memset] from memset::@4
|
|
(void*) memset::str#5 ← phi( memset::@4/(void*) memset::str#4 )
|
|
(byte*) memset::end#2 ← phi( memset::@4/(byte*) memset::end#1 )
|
|
(byte*) memset::dst#3 ← phi( memset::@4/(byte*) memset::dst#2 )
|
|
(byte) memset::c#1 ← phi( memset::@4/(byte) memset::c#2 )
|
|
*((byte*) memset::dst#3) ← (byte) memset::c#1
|
|
(byte*) memset::dst#1 ← ++ (byte*) memset::dst#3
|
|
to:memset::@4
|
|
memset::@return: scope:[memset] from memset::@1
|
|
(void*) memset::return#3 ← phi( memset::@1/(void*) memset::return#0 )
|
|
(void*) memset::return#1 ← (void*) memset::return#3
|
|
return
|
|
to:@return
|
|
@12: scope:[] from @begin
|
|
(byte*) print_screen#0 ← ((byte*)) (number) $400
|
|
(byte*) print_line_cursor#0 ← (byte*) print_screen#0
|
|
(byte*) print_char_cursor#0 ← (byte*) print_line_cursor#0
|
|
to:@29
|
|
|
|
(void()) print_str((byte*) print_str::str)
|
|
print_str: scope:[print_str] from main::@2 main::@5
|
|
(byte*) print_char_cursor#45 ← phi( main::@2/(byte*) print_char_cursor#12 main::@5/(byte*) print_char_cursor#15 )
|
|
(byte*) print_str::str#5 ← phi( main::@2/(byte*) print_str::str#1 main::@5/(byte*) print_str::str#2 )
|
|
to:print_str::@1
|
|
print_str::@1: scope:[print_str] from print_str print_str::@2
|
|
(byte*) print_char_cursor#40 ← phi( print_str/(byte*) print_char_cursor#45 print_str::@2/(byte*) print_char_cursor#1 )
|
|
(byte*) print_str::str#3 ← phi( print_str/(byte*) print_str::str#5 print_str::@2/(byte*) print_str::str#0 )
|
|
(bool~) print_str::$0 ← (number) 0 != *((byte*) print_str::str#3)
|
|
if((bool~) print_str::$0) goto print_str::@2
|
|
to:print_str::@return
|
|
print_str::@2: scope:[print_str] from print_str::@1
|
|
(byte*) print_char_cursor#21 ← phi( print_str::@1/(byte*) print_char_cursor#40 )
|
|
(byte*) print_str::str#4 ← phi( print_str::@1/(byte*) print_str::str#3 )
|
|
*((byte*) print_char_cursor#21) ← *((byte*) print_str::str#4)
|
|
(byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#21
|
|
(byte*) print_str::str#0 ← ++ (byte*) print_str::str#4
|
|
to:print_str::@1
|
|
print_str::@return: scope:[print_str] from print_str::@1
|
|
(byte*) print_char_cursor#22 ← phi( print_str::@1/(byte*) print_char_cursor#40 )
|
|
(byte*) print_char_cursor#2 ← (byte*) print_char_cursor#22
|
|
return
|
|
to:@return
|
|
|
|
(void()) print_ln()
|
|
print_ln: scope:[print_ln] from main::@4 main::@7
|
|
(byte*) print_char_cursor#41 ← phi( main::@4/(byte*) print_char_cursor#14 main::@7/(byte*) print_char_cursor#17 )
|
|
(byte*) print_line_cursor#19 ← phi( main::@4/(byte*) print_line_cursor#21 main::@7/(byte*) print_line_cursor#22 )
|
|
to:print_ln::@1
|
|
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
|
(byte*) print_char_cursor#23 ← phi( print_ln/(byte*) print_char_cursor#41 print_ln::@1/(byte*) print_char_cursor#23 )
|
|
(byte*) print_line_cursor#10 ← phi( print_ln/(byte*) print_line_cursor#19 print_ln::@1/(byte*) print_line_cursor#1 )
|
|
(byte*~) print_ln::$0 ← (byte*) print_line_cursor#10 + (number) $28
|
|
(byte*) print_line_cursor#1 ← (byte*~) print_ln::$0
|
|
(bool~) print_ln::$1 ← (byte*) print_line_cursor#1 < (byte*) print_char_cursor#23
|
|
if((bool~) print_ln::$1) goto print_ln::@1
|
|
to:print_ln::@2
|
|
print_ln::@2: scope:[print_ln] from print_ln::@1
|
|
(byte*) print_line_cursor#11 ← phi( print_ln::@1/(byte*) print_line_cursor#1 )
|
|
(byte*) print_char_cursor#3 ← (byte*) print_line_cursor#11
|
|
to:print_ln::@return
|
|
print_ln::@return: scope:[print_ln] from print_ln::@2
|
|
(byte*) print_char_cursor#24 ← phi( print_ln::@2/(byte*) print_char_cursor#3 )
|
|
(byte*) print_line_cursor#12 ← phi( print_ln::@2/(byte*) print_line_cursor#11 )
|
|
(byte*) print_line_cursor#2 ← (byte*) print_line_cursor#12
|
|
(byte*) print_char_cursor#4 ← (byte*) print_char_cursor#24
|
|
return
|
|
to:@return
|
|
@29: scope:[] from @12
|
|
(byte*) print_screen#6 ← phi( @12/(byte*) print_screen#0 )
|
|
(byte*) print_char_cursor#47 ← phi( @12/(byte*) print_char_cursor#0 )
|
|
(byte*) print_line_cursor#27 ← phi( @12/(byte*) print_line_cursor#0 )
|
|
(byte[]) print_hextab ← (const string) $0
|
|
to:@36
|
|
|
|
(void()) print_byte((byte) print_byte::b)
|
|
print_byte: scope:[print_byte] from main::@3 main::@6
|
|
(byte*) print_char_cursor#42 ← phi( main::@3/(byte*) print_char_cursor#13 main::@6/(byte*) print_char_cursor#16 )
|
|
(byte) print_byte::b#2 ← phi( main::@3/(byte) print_byte::b#0 main::@6/(byte) print_byte::b#1 )
|
|
(byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (number) 4
|
|
(byte) print_char::ch#0 ← *((byte[]) print_hextab + (byte~) print_byte::$0)
|
|
call print_char
|
|
to:print_byte::@1
|
|
print_byte::@1: scope:[print_byte] from print_byte
|
|
(byte) print_byte::b#3 ← phi( print_byte/(byte) print_byte::b#2 )
|
|
(byte*) print_char_cursor#25 ← phi( print_byte/(byte*) print_char_cursor#9 )
|
|
(byte*) print_char_cursor#5 ← (byte*) print_char_cursor#25
|
|
(number~) print_byte::$2 ← (byte) print_byte::b#3 & (number) $f
|
|
(byte) print_char::ch#1 ← *((byte[]) print_hextab + (number~) print_byte::$2)
|
|
call print_char
|
|
to:print_byte::@2
|
|
print_byte::@2: scope:[print_byte] from print_byte::@1
|
|
(byte*) print_char_cursor#26 ← phi( print_byte::@1/(byte*) print_char_cursor#9 )
|
|
(byte*) print_char_cursor#6 ← (byte*) print_char_cursor#26
|
|
to:print_byte::@return
|
|
print_byte::@return: scope:[print_byte] from print_byte::@2
|
|
(byte*) print_char_cursor#27 ← phi( print_byte::@2/(byte*) print_char_cursor#6 )
|
|
(byte*) print_char_cursor#7 ← (byte*) print_char_cursor#27
|
|
return
|
|
to:@return
|
|
|
|
(void()) print_char((byte) print_char::ch)
|
|
print_char: scope:[print_char] from print_byte print_byte::@1
|
|
(byte*) print_char_cursor#28 ← phi( print_byte/(byte*) print_char_cursor#42 print_byte::@1/(byte*) print_char_cursor#5 )
|
|
(byte) print_char::ch#2 ← phi( print_byte/(byte) print_char::ch#0 print_byte::@1/(byte) print_char::ch#1 )
|
|
*((byte*) print_char_cursor#28) ← (byte) print_char::ch#2
|
|
(byte*) print_char_cursor#8 ← ++ (byte*) print_char_cursor#28
|
|
to:print_char::@return
|
|
print_char::@return: scope:[print_char] from print_char
|
|
(byte*) print_char_cursor#29 ← phi( print_char/(byte*) print_char_cursor#8 )
|
|
(byte*) print_char_cursor#9 ← (byte*) print_char_cursor#29
|
|
return
|
|
to:@return
|
|
|
|
(void()) print_cls()
|
|
print_cls: scope:[print_cls] from main
|
|
(byte*) print_screen#1 ← phi( main/(byte*) print_screen#3 )
|
|
(void*) memset::str#0 ← (void*)(byte*) print_screen#1
|
|
(byte) memset::c#0 ← (byte) ' '
|
|
(word) memset::num#0 ← (number) $3e8
|
|
call memset
|
|
(void*) memset::return#2 ← (void*) memset::return#1
|
|
to:print_cls::@1
|
|
print_cls::@1: scope:[print_cls] from print_cls
|
|
(byte*) print_screen#2 ← phi( print_cls/(byte*) print_screen#1 )
|
|
(byte*) print_line_cursor#3 ← (byte*) print_screen#2
|
|
(byte*) print_char_cursor#10 ← (byte*) print_line_cursor#3
|
|
to:print_cls::@return
|
|
print_cls::@return: scope:[print_cls] from print_cls::@1
|
|
(byte*) print_char_cursor#30 ← phi( print_cls::@1/(byte*) print_char_cursor#10 )
|
|
(byte*) print_line_cursor#13 ← phi( print_cls::@1/(byte*) print_line_cursor#3 )
|
|
(byte*) print_line_cursor#4 ← (byte*) print_line_cursor#13
|
|
(byte*) print_char_cursor#11 ← (byte*) print_char_cursor#30
|
|
return
|
|
to:@return
|
|
@36: scope:[] from @29
|
|
(byte*) print_screen#5 ← phi( @29/(byte*) print_screen#6 )
|
|
(byte*) print_char_cursor#46 ← phi( @29/(byte*) print_char_cursor#47 )
|
|
(byte*) print_line_cursor#26 ← phi( @29/(byte*) print_line_cursor#27 )
|
|
(struct fileentry[$a]) files ← { fill( $a, 0) }
|
|
(struct fileentry*) file#0 ← (struct fileentry*) 0
|
|
to:@37
|
|
|
|
(signed word()) main()
|
|
main: scope:[main] from @37
|
|
(byte*) print_char_cursor#43 ← phi( @37/(byte*) print_char_cursor#44 )
|
|
(byte*) print_line_cursor#20 ← phi( @37/(byte*) print_line_cursor#23 )
|
|
(byte*) print_screen#3 ← phi( @37/(byte*) print_screen#4 )
|
|
(struct fileentry*) file#1 ← (struct fileentry[$a]) files
|
|
(byte**) main::$10 ← (byte**)(struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
*((byte**) main::$10) ← ((byte*)) (number) $4000
|
|
(byte**) main::$11 ← (byte**)(struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
*(*((byte**) main::$11) + (number) 3) ← (number) $aa
|
|
(byte**) main::$12 ← (byte**)(struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
(byte*~) main::$0 ← ((byte*)) *((byte**) main::$12)
|
|
*((byte*~) main::$0 + (number) 4) ← (number) $cc
|
|
call print_cls
|
|
to:main::@2
|
|
main::@2: scope:[main] from main
|
|
(struct fileentry*) file#13 ← phi( main/(struct fileentry*) file#1 )
|
|
(byte*) print_char_cursor#31 ← phi( main/(byte*) print_char_cursor#11 )
|
|
(byte*) print_line_cursor#14 ← phi( main/(byte*) print_line_cursor#4 )
|
|
(byte*) print_line_cursor#5 ← (byte*) print_line_cursor#14
|
|
(byte*) print_char_cursor#12 ← (byte*) print_char_cursor#31
|
|
(byte*) print_str::str#1 ← (const string) main::str
|
|
call print_str
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
(struct fileentry*) file#12 ← phi( main::@2/(struct fileentry*) file#13 )
|
|
(byte*) print_line_cursor#24 ← phi( main::@2/(byte*) print_line_cursor#5 )
|
|
(byte*) print_char_cursor#32 ← phi( main::@2/(byte*) print_char_cursor#2 )
|
|
(byte*) print_char_cursor#13 ← (byte*) print_char_cursor#32
|
|
(byte*~) main::$3 ← ((byte*)) (number) 0
|
|
(byte) print_byte::b#0 ← *((byte*~) main::$3)
|
|
call print_byte
|
|
to:main::@4
|
|
main::@4: scope:[main] from main::@3
|
|
(struct fileentry*) file#11 ← phi( main::@3/(struct fileentry*) file#12 )
|
|
(byte*) print_line_cursor#21 ← phi( main::@3/(byte*) print_line_cursor#24 )
|
|
(byte*) print_char_cursor#33 ← phi( main::@3/(byte*) print_char_cursor#7 )
|
|
(byte*) print_char_cursor#14 ← (byte*) print_char_cursor#33
|
|
call print_ln
|
|
to:main::@5
|
|
main::@5: scope:[main] from main::@4
|
|
(struct fileentry*) file#10 ← phi( main::@4/(struct fileentry*) file#11 )
|
|
(byte*) print_char_cursor#34 ← phi( main::@4/(byte*) print_char_cursor#4 )
|
|
(byte*) print_line_cursor#15 ← phi( main::@4/(byte*) print_line_cursor#2 )
|
|
(byte*) print_line_cursor#6 ← (byte*) print_line_cursor#15
|
|
(byte*) print_char_cursor#15 ← (byte*) print_char_cursor#34
|
|
(byte*) print_str::str#2 ← (const string) main::str1
|
|
call print_str
|
|
to:main::@6
|
|
main::@6: scope:[main] from main::@5
|
|
(struct fileentry*) file#9 ← phi( main::@5/(struct fileentry*) file#10 )
|
|
(byte*) print_line_cursor#25 ← phi( main::@5/(byte*) print_line_cursor#6 )
|
|
(byte*) print_char_cursor#35 ← phi( main::@5/(byte*) print_char_cursor#2 )
|
|
(byte*) print_char_cursor#16 ← (byte*) print_char_cursor#35
|
|
(byte*~) main::$7 ← ((byte*)) (number) $4004
|
|
(byte) print_byte::b#1 ← *((byte*~) main::$7)
|
|
call print_byte
|
|
to:main::@7
|
|
main::@7: scope:[main] from main::@6
|
|
(struct fileentry*) file#8 ← phi( main::@6/(struct fileentry*) file#9 )
|
|
(byte*) print_line_cursor#22 ← phi( main::@6/(byte*) print_line_cursor#25 )
|
|
(byte*) print_char_cursor#36 ← phi( main::@6/(byte*) print_char_cursor#7 )
|
|
(byte*) print_char_cursor#17 ← (byte*) print_char_cursor#36
|
|
call print_ln
|
|
to:main::@8
|
|
main::@8: scope:[main] from main::@7
|
|
(struct fileentry*) file#6 ← phi( main::@7/(struct fileentry*) file#8 )
|
|
(byte*) print_char_cursor#37 ← phi( main::@7/(byte*) print_char_cursor#4 )
|
|
(byte*) print_line_cursor#16 ← phi( main::@7/(byte*) print_line_cursor#2 )
|
|
(byte*) print_line_cursor#7 ← (byte*) print_line_cursor#16
|
|
(byte*) print_char_cursor#18 ← (byte*) print_char_cursor#37
|
|
(signed word) main::return#0 ← (number) 0
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@8
|
|
(byte*) print_char_cursor#38 ← phi( main::@8/(byte*) print_char_cursor#18 )
|
|
(byte*) print_line_cursor#17 ← phi( main::@8/(byte*) print_line_cursor#7 )
|
|
(struct fileentry*) file#4 ← phi( main::@8/(struct fileentry*) file#6 )
|
|
(signed word) main::return#3 ← phi( main::@8/(signed word) main::return#0 )
|
|
(signed word) main::return#1 ← (signed word) main::return#3
|
|
(struct fileentry*) file#2 ← (struct fileentry*) file#4
|
|
(byte*) print_line_cursor#8 ← (byte*) print_line_cursor#17
|
|
(byte*) print_char_cursor#19 ← (byte*) print_char_cursor#38
|
|
return
|
|
to:@return
|
|
@37: scope:[] from @36
|
|
(byte*) print_screen#4 ← phi( @36/(byte*) print_screen#5 )
|
|
(byte*) print_char_cursor#44 ← phi( @36/(byte*) print_char_cursor#46 )
|
|
(byte*) print_line_cursor#23 ← phi( @36/(byte*) print_line_cursor#26 )
|
|
(struct fileentry*) file#7 ← phi( @36/(struct fileentry*) file#0 )
|
|
call main
|
|
(signed word) main::return#2 ← (signed word) main::return#1
|
|
to:@38
|
|
@38: scope:[] from @37
|
|
(byte*) print_char_cursor#39 ← phi( @37/(byte*) print_char_cursor#19 )
|
|
(byte*) print_line_cursor#18 ← phi( @37/(byte*) print_line_cursor#8 )
|
|
(struct fileentry*) file#5 ← phi( @37/(struct fileentry*) file#2 )
|
|
(struct fileentry*) file#3 ← (struct fileentry*) file#5
|
|
(byte*) print_line_cursor#9 ← (byte*) print_line_cursor#18
|
|
(byte*) print_char_cursor#20 ← (byte*) print_char_cursor#39
|
|
to:@end
|
|
@end: scope:[] from @38
|
|
|
|
SYMBOL TABLE SSA
|
|
(const string) $0 = (string) "0123456789abcdef"z
|
|
(label) @12
|
|
(label) @29
|
|
(label) @36
|
|
(label) @37
|
|
(label) @38
|
|
(label) @begin
|
|
(label) @end
|
|
(const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT = (byte) 0
|
|
(const byte) RADIX::BINARY = (number) 2
|
|
(const byte) RADIX::DECIMAL = (number) $a
|
|
(const byte) RADIX::HEXADECIMAL = (number) $10
|
|
(const byte) RADIX::OCTAL = (number) 8
|
|
(struct fileentry*) file
|
|
(struct fileentry*) file#0
|
|
(struct fileentry*) file#1
|
|
(struct fileentry*) file#10
|
|
(struct fileentry*) file#11
|
|
(struct fileentry*) file#12
|
|
(struct fileentry*) file#13
|
|
(struct fileentry*) file#2
|
|
(struct fileentry*) file#3
|
|
(struct fileentry*) file#4
|
|
(struct fileentry*) file#5
|
|
(struct fileentry*) file#6
|
|
(struct fileentry*) file#7
|
|
(struct fileentry*) file#8
|
|
(struct fileentry*) file#9
|
|
(byte*) fileentry::bufEdit
|
|
(struct fileentry[$a]) files
|
|
(signed word()) main()
|
|
(byte*~) main::$0
|
|
(byte**) main::$10
|
|
(byte**) main::$11
|
|
(byte**) main::$12
|
|
(byte*~) main::$3
|
|
(byte*~) main::$7
|
|
(label) main::@2
|
|
(label) main::@3
|
|
(label) main::@4
|
|
(label) main::@5
|
|
(label) main::@6
|
|
(label) main::@7
|
|
(label) main::@8
|
|
(label) main::@return
|
|
(signed word) main::return
|
|
(signed word) main::return#0
|
|
(signed word) main::return#1
|
|
(signed word) main::return#2
|
|
(signed word) main::return#3
|
|
(const string) main::str = (string) "$0000="
|
|
(const string) main::str1 = (string) "$4004="
|
|
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
|
|
(bool~) memset::$0
|
|
(bool~) memset::$1
|
|
(byte*~) memset::$2
|
|
(byte*~) memset::$3
|
|
(bool~) memset::$4
|
|
(label) memset::@1
|
|
(label) memset::@2
|
|
(label) memset::@4
|
|
(label) memset::@5
|
|
(label) memset::@return
|
|
(byte) memset::c
|
|
(byte) memset::c#0
|
|
(byte) memset::c#1
|
|
(byte) memset::c#2
|
|
(byte) memset::c#3
|
|
(byte) memset::c#4
|
|
(byte*) memset::dst
|
|
(byte*) memset::dst#0
|
|
(byte*) memset::dst#1
|
|
(byte*) memset::dst#2
|
|
(byte*) memset::dst#3
|
|
(byte*) memset::end
|
|
(byte*) memset::end#0
|
|
(byte*) memset::end#1
|
|
(byte*) memset::end#2
|
|
(word) memset::num
|
|
(word) memset::num#0
|
|
(word) memset::num#1
|
|
(word) memset::num#2
|
|
(void*) memset::return
|
|
(void*) memset::return#0
|
|
(void*) memset::return#1
|
|
(void*) memset::return#2
|
|
(void*) memset::return#3
|
|
(void*) memset::str
|
|
(void*) memset::str#0
|
|
(void*) memset::str#1
|
|
(void*) memset::str#2
|
|
(void*) memset::str#3
|
|
(void*) memset::str#4
|
|
(void*) memset::str#5
|
|
(void()) print_byte((byte) print_byte::b)
|
|
(byte~) print_byte::$0
|
|
(number~) print_byte::$2
|
|
(label) print_byte::@1
|
|
(label) print_byte::@2
|
|
(label) print_byte::@return
|
|
(byte) print_byte::b
|
|
(byte) print_byte::b#0
|
|
(byte) print_byte::b#1
|
|
(byte) print_byte::b#2
|
|
(byte) print_byte::b#3
|
|
(void()) print_char((byte) print_char::ch)
|
|
(label) print_char::@return
|
|
(byte) print_char::ch
|
|
(byte) print_char::ch#0
|
|
(byte) print_char::ch#1
|
|
(byte) print_char::ch#2
|
|
(byte*) print_char_cursor
|
|
(byte*) print_char_cursor#0
|
|
(byte*) print_char_cursor#1
|
|
(byte*) print_char_cursor#10
|
|
(byte*) print_char_cursor#11
|
|
(byte*) print_char_cursor#12
|
|
(byte*) print_char_cursor#13
|
|
(byte*) print_char_cursor#14
|
|
(byte*) print_char_cursor#15
|
|
(byte*) print_char_cursor#16
|
|
(byte*) print_char_cursor#17
|
|
(byte*) print_char_cursor#18
|
|
(byte*) print_char_cursor#19
|
|
(byte*) print_char_cursor#2
|
|
(byte*) print_char_cursor#20
|
|
(byte*) print_char_cursor#21
|
|
(byte*) print_char_cursor#22
|
|
(byte*) print_char_cursor#23
|
|
(byte*) print_char_cursor#24
|
|
(byte*) print_char_cursor#25
|
|
(byte*) print_char_cursor#26
|
|
(byte*) print_char_cursor#27
|
|
(byte*) print_char_cursor#28
|
|
(byte*) print_char_cursor#29
|
|
(byte*) print_char_cursor#3
|
|
(byte*) print_char_cursor#30
|
|
(byte*) print_char_cursor#31
|
|
(byte*) print_char_cursor#32
|
|
(byte*) print_char_cursor#33
|
|
(byte*) print_char_cursor#34
|
|
(byte*) print_char_cursor#35
|
|
(byte*) print_char_cursor#36
|
|
(byte*) print_char_cursor#37
|
|
(byte*) print_char_cursor#38
|
|
(byte*) print_char_cursor#39
|
|
(byte*) print_char_cursor#4
|
|
(byte*) print_char_cursor#40
|
|
(byte*) print_char_cursor#41
|
|
(byte*) print_char_cursor#42
|
|
(byte*) print_char_cursor#43
|
|
(byte*) print_char_cursor#44
|
|
(byte*) print_char_cursor#45
|
|
(byte*) print_char_cursor#46
|
|
(byte*) print_char_cursor#47
|
|
(byte*) print_char_cursor#5
|
|
(byte*) print_char_cursor#6
|
|
(byte*) print_char_cursor#7
|
|
(byte*) print_char_cursor#8
|
|
(byte*) print_char_cursor#9
|
|
(void()) print_cls()
|
|
(label) print_cls::@1
|
|
(label) print_cls::@return
|
|
(byte[]) print_hextab
|
|
(byte*) print_line_cursor
|
|
(byte*) print_line_cursor#0
|
|
(byte*) print_line_cursor#1
|
|
(byte*) print_line_cursor#10
|
|
(byte*) print_line_cursor#11
|
|
(byte*) print_line_cursor#12
|
|
(byte*) print_line_cursor#13
|
|
(byte*) print_line_cursor#14
|
|
(byte*) print_line_cursor#15
|
|
(byte*) print_line_cursor#16
|
|
(byte*) print_line_cursor#17
|
|
(byte*) print_line_cursor#18
|
|
(byte*) print_line_cursor#19
|
|
(byte*) print_line_cursor#2
|
|
(byte*) print_line_cursor#20
|
|
(byte*) print_line_cursor#21
|
|
(byte*) print_line_cursor#22
|
|
(byte*) print_line_cursor#23
|
|
(byte*) print_line_cursor#24
|
|
(byte*) print_line_cursor#25
|
|
(byte*) print_line_cursor#26
|
|
(byte*) print_line_cursor#27
|
|
(byte*) print_line_cursor#3
|
|
(byte*) print_line_cursor#4
|
|
(byte*) print_line_cursor#5
|
|
(byte*) print_line_cursor#6
|
|
(byte*) print_line_cursor#7
|
|
(byte*) print_line_cursor#8
|
|
(byte*) print_line_cursor#9
|
|
(void()) print_ln()
|
|
(byte*~) print_ln::$0
|
|
(bool~) print_ln::$1
|
|
(label) print_ln::@1
|
|
(label) print_ln::@2
|
|
(label) print_ln::@return
|
|
(byte*) print_screen
|
|
(byte*) print_screen#0
|
|
(byte*) print_screen#1
|
|
(byte*) print_screen#2
|
|
(byte*) print_screen#3
|
|
(byte*) print_screen#4
|
|
(byte*) print_screen#5
|
|
(byte*) print_screen#6
|
|
(void()) print_str((byte*) print_str::str)
|
|
(bool~) print_str::$0
|
|
(label) print_str::@1
|
|
(label) print_str::@2
|
|
(label) print_str::@return
|
|
(byte*) print_str::str
|
|
(byte*) print_str::str#0
|
|
(byte*) print_str::str#1
|
|
(byte*) print_str::str#2
|
|
(byte*) print_str::str#3
|
|
(byte*) print_str::str#4
|
|
(byte*) print_str::str#5
|
|
|
|
Adding number conversion cast (unumber) 0 in (bool~) memset::$0 ← (word) memset::num#1 > (number) 0
|
|
Adding number conversion cast (unumber) 0 in (bool~) print_str::$0 ← (number) 0 != *((byte*) print_str::str#3)
|
|
Adding number conversion cast (unumber) $28 in (byte*~) print_ln::$0 ← (byte*) print_line_cursor#10 + (number) $28
|
|
Adding number conversion cast (unumber) 4 in (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (number) 4
|
|
Adding number conversion cast (unumber) $f in (number~) print_byte::$2 ← (byte) print_byte::b#3 & (number) $f
|
|
Adding number conversion cast (unumber) print_byte::$2 in (number~) print_byte::$2 ← (byte) print_byte::b#3 & (unumber)(number) $f
|
|
Adding number conversion cast (unumber) $3e8 in (word) memset::num#0 ← (number) $3e8
|
|
Adding number conversion cast (unumber) $aa in *(*((byte**) main::$11) + (number) 3) ← (number) $aa
|
|
Adding number conversion cast (unumber) 3 in *(*((byte**) main::$11) + (number) 3) ← ((unumber)) (number) $aa
|
|
Adding number conversion cast (unumber) $cc in *((byte*~) main::$0 + (number) 4) ← (number) $cc
|
|
Adding number conversion cast (unumber) 4 in *((byte*~) main::$0 + (number) 4) ← ((unumber)) (number) $cc
|
|
Adding number conversion cast (snumber) 0 in (signed word) main::return#0 ← (number) 0
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
Inlining cast (byte*~) memset::$2 ← (byte*)(void*) memset::str#2
|
|
Inlining cast (byte*) memset::dst#0 ← (byte*)(void*) memset::str#2
|
|
Inlining cast (byte*) print_screen#0 ← (byte*)(number) $400
|
|
Inlining cast (word) memset::num#0 ← (unumber)(number) $3e8
|
|
Inlining cast *((byte**) main::$10) ← (byte*)(number) $4000
|
|
Inlining cast *(*((byte**) main::$11) + (unumber)(number) 3) ← (unumber)(number) $aa
|
|
Inlining cast (byte*~) main::$0 ← (byte*)*((byte**) main::$12)
|
|
Inlining cast *((byte*~) main::$0 + (unumber)(number) 4) ← (unumber)(number) $cc
|
|
Inlining cast (byte*~) main::$3 ← (byte*)(number) 0
|
|
Inlining cast (byte*~) main::$7 ← (byte*)(number) $4004
|
|
Inlining cast (signed word) main::return#0 ← (snumber)(number) 0
|
|
Successful SSA optimization Pass2InlineCast
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
Simplifying constant integer cast 0
|
|
Simplifying constant integer cast $28
|
|
Simplifying constant integer cast 4
|
|
Simplifying constant integer cast $f
|
|
Simplifying constant integer cast $3e8
|
|
Simplifying constant pointer cast (byte*) 16384
|
|
Simplifying constant integer cast $aa
|
|
Simplifying constant integer cast 3
|
|
Simplifying constant integer cast *((byte**) main::$12)
|
|
Simplifying constant integer cast $cc
|
|
Simplifying constant integer cast 4
|
|
Simplifying constant pointer cast (byte*) 0
|
|
Simplifying constant pointer cast (byte*) 16388
|
|
Simplifying constant integer cast 0
|
|
Successful SSA optimization PassNCastSimplification
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) 0
|
|
Finalized unsigned number type (byte) $28
|
|
Finalized unsigned number type (byte) 4
|
|
Finalized unsigned number type (byte) $f
|
|
Finalized unsigned number type (word) $3e8
|
|
Finalized unsigned number type (byte) $aa
|
|
Finalized unsigned number type (byte) 3
|
|
Finalized unsigned number type (byte) $cc
|
|
Finalized unsigned number type (byte) 4
|
|
Finalized signed number type (signed byte) 0
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
Inferred type updated to byte in (unumber~) print_byte::$2 ← (byte) print_byte::b#3 & (byte) $f
|
|
Inversing boolean not [2] (bool~) memset::$1 ← (word) memset::num#1 <= (byte) 0 from [1] (bool~) memset::$0 ← (word) memset::num#1 > (byte) 0
|
|
Successful SSA optimization Pass2UnaryNotSimplification
|
|
Alias (void*) memset::return#0 = (void*) memset::str#1 (void*) memset::return#3 (void*) memset::return#1
|
|
Alias (void*) memset::str#2 = (void*) memset::str#3
|
|
Alias (word) memset::num#1 = (word) memset::num#2
|
|
Alias (byte) memset::c#3 = (byte) memset::c#4
|
|
Alias (byte*) memset::end#0 = (byte*~) memset::$3
|
|
Alias (byte) memset::c#1 = (byte) memset::c#2
|
|
Alias (byte*) memset::dst#2 = (byte*) memset::dst#3
|
|
Alias (byte*) memset::end#1 = (byte*) memset::end#2
|
|
Alias (void*) memset::str#4 = (void*) memset::str#5
|
|
Alias (byte*) print_line_cursor#0 = (byte*) print_screen#0 (byte*) print_char_cursor#0 (byte*) print_line_cursor#27 (byte*) print_char_cursor#47 (byte*) print_screen#6 (byte*) print_line_cursor#26 (byte*) print_char_cursor#46 (byte*) print_screen#5 (byte*) print_line_cursor#23 (byte*) print_char_cursor#44 (byte*) print_screen#4
|
|
Alias (byte*) print_str::str#3 = (byte*) print_str::str#4
|
|
Alias (byte*) print_char_cursor#2 = (byte*) print_char_cursor#21 (byte*) print_char_cursor#40 (byte*) print_char_cursor#22
|
|
Alias (byte*) print_line_cursor#1 = (byte*~) print_ln::$0 (byte*) print_line_cursor#11 (byte*) print_char_cursor#3 (byte*) print_line_cursor#12 (byte*) print_char_cursor#24 (byte*) print_line_cursor#2 (byte*) print_char_cursor#4
|
|
Alias (byte) print_byte::b#2 = (byte) print_byte::b#3
|
|
Alias (byte*) print_char_cursor#25 = (byte*) print_char_cursor#5
|
|
Alias (byte*) print_char_cursor#26 = (byte*) print_char_cursor#6 (byte*) print_char_cursor#27 (byte*) print_char_cursor#7
|
|
Alias (byte*) print_char_cursor#29 = (byte*) print_char_cursor#8 (byte*) print_char_cursor#9
|
|
Alias (byte*) print_line_cursor#13 = (byte*) print_screen#2 (byte*) print_screen#1 (byte*) print_line_cursor#3 (byte*) print_char_cursor#10 (byte*) print_char_cursor#30 (byte*) print_line_cursor#4 (byte*) print_char_cursor#11
|
|
Alias (struct fileentry*) file#1 = (struct fileentry*) file#13 (struct fileentry*) file#12 (struct fileentry*) file#11 (struct fileentry*) file#10 (struct fileentry*) file#9 (struct fileentry*) file#8 (struct fileentry*) file#6 (struct fileentry*) file#4 (struct fileentry*) file#2
|
|
Alias (byte*) print_line_cursor#14 = (byte*) print_line_cursor#5 (byte*) print_line_cursor#24 (byte*) print_line_cursor#21
|
|
Alias (byte*) print_char_cursor#12 = (byte*) print_char_cursor#31
|
|
Alias (byte*) print_char_cursor#13 = (byte*) print_char_cursor#32
|
|
Alias (byte*) print_char_cursor#14 = (byte*) print_char_cursor#33
|
|
Alias (byte*) print_line_cursor#15 = (byte*) print_line_cursor#6 (byte*) print_line_cursor#25 (byte*) print_line_cursor#22
|
|
Alias (byte*) print_char_cursor#15 = (byte*) print_char_cursor#34
|
|
Alias (byte*) print_char_cursor#16 = (byte*) print_char_cursor#35
|
|
Alias (byte*) print_char_cursor#17 = (byte*) print_char_cursor#36
|
|
Alias (byte*) print_line_cursor#16 = (byte*) print_line_cursor#7 (byte*) print_line_cursor#17 (byte*) print_line_cursor#8
|
|
Alias (byte*) print_char_cursor#18 = (byte*) print_char_cursor#37 (byte*) print_char_cursor#38 (byte*) print_char_cursor#19
|
|
Alias (signed word) main::return#0 = (signed word) main::return#3 (signed word) main::return#1
|
|
Alias (struct fileentry*) file#0 = (struct fileentry*) file#7
|
|
Alias (struct fileentry*) file#3 = (struct fileentry*) file#5
|
|
Alias (byte*) print_line_cursor#18 = (byte*) print_line_cursor#9
|
|
Alias (byte*) print_char_cursor#20 = (byte*) print_char_cursor#39
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Identical Phi Values (word) memset::num#1 (word) memset::num#0
|
|
Identical Phi Values (void*) memset::str#2 (void*) memset::str#0
|
|
Identical Phi Values (byte) memset::c#3 (byte) memset::c#0
|
|
Identical Phi Values (byte*) memset::end#1 (byte*) memset::end#0
|
|
Identical Phi Values (void*) memset::str#4 (void*) memset::str#2
|
|
Identical Phi Values (byte) memset::c#1 (byte) memset::c#3
|
|
Identical Phi Values (byte*) print_char_cursor#23 (byte*) print_char_cursor#41
|
|
Identical Phi Values (byte*) print_char_cursor#25 (byte*) print_char_cursor#29
|
|
Identical Phi Values (byte*) print_char_cursor#26 (byte*) print_char_cursor#29
|
|
Identical Phi Values (byte*) print_line_cursor#13 (byte*) print_screen#3
|
|
Identical Phi Values (byte*) print_screen#3 (byte*) print_line_cursor#0
|
|
Identical Phi Values (byte*) print_line_cursor#20 (byte*) print_line_cursor#0
|
|
Identical Phi Values (byte*) print_char_cursor#43 (byte*) print_line_cursor#0
|
|
Identical Phi Values (byte*) print_line_cursor#14 (byte*) print_line_cursor#13
|
|
Identical Phi Values (byte*) print_char_cursor#12 (byte*) print_line_cursor#13
|
|
Identical Phi Values (byte*) print_char_cursor#13 (byte*) print_char_cursor#2
|
|
Identical Phi Values (byte*) print_char_cursor#14 (byte*) print_char_cursor#26
|
|
Identical Phi Values (byte*) print_line_cursor#15 (byte*) print_line_cursor#1
|
|
Identical Phi Values (byte*) print_char_cursor#15 (byte*) print_line_cursor#1
|
|
Identical Phi Values (byte*) print_char_cursor#16 (byte*) print_char_cursor#2
|
|
Identical Phi Values (byte*) print_char_cursor#17 (byte*) print_char_cursor#26
|
|
Identical Phi Values (byte*) print_line_cursor#16 (byte*) print_line_cursor#1
|
|
Identical Phi Values (byte*) print_char_cursor#18 (byte*) print_line_cursor#1
|
|
Identical Phi Values (struct fileentry*) file#3 (struct fileentry*) file#1
|
|
Identical Phi Values (byte*) print_line_cursor#18 (byte*) print_line_cursor#16
|
|
Identical Phi Values (byte*) print_char_cursor#20 (byte*) print_char_cursor#18
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Identical Phi Values (void*) memset::return#0 (void*) memset::str#0
|
|
Identical Phi Values (byte*) print_char_cursor#41 (byte*) print_char_cursor#29
|
|
Identical Phi Values (byte*) print_char_cursor#42 (byte*) print_char_cursor#2
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
|
Simple Condition (bool~) memset::$1 [3] if((word) memset::num#0<=(byte) 0) goto memset::@1
|
|
Simple Condition (bool~) memset::$4 [13] if((byte*) memset::dst#2!=(byte*) memset::end#0) goto memset::@5
|
|
Simple Condition (bool~) print_str::$0 [26] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2
|
|
Simple Condition (bool~) print_ln::$1 [39] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) goto print_ln::@1
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
Constant right-side identified [82] (struct fileentry[$a]) files ← { fill( $a, 0) }
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant (const byte*) print_line_cursor#0 = (byte*) 1024
|
|
Constant (const byte[]) print_hextab = $0
|
|
Constant (const byte) memset::c#0 = ' '
|
|
Constant (const word) memset::num#0 = $3e8
|
|
Constant (const struct fileentry[$a]) files = { fill( $a, 0) }
|
|
Constant (const struct fileentry*) file#0 = (struct fileentry*) 0
|
|
Constant (const byte*) print_str::str#1 = main::str
|
|
Constant (const byte*) main::$3 = (byte*) 0
|
|
Constant (const byte*) print_str::str#2 = main::str1
|
|
Constant (const byte*) main::$7 = (byte*) 16388
|
|
Constant (const signed word) main::return#0 = 0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant (const struct fileentry*) file#1 = files
|
|
Constant (const signed word) main::return#2 = main::return#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant value identified (void*)print_line_cursor#0 in [69] (void*) memset::str#0 ← (void*)(const byte*) print_line_cursor#0
|
|
Constant value identified (byte**)file#1 in [86] (byte**) main::$10 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Constant value identified (byte**)file#1 in [88] (byte**) main::$11 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Constant value identified (byte**)file#1 in [90] (byte**) main::$12 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Successful SSA optimization Pass2ConstantValues
|
|
if() condition always false - eliminating [3] if((const word) memset::num#0<=(byte) 0) goto memset::@1
|
|
Successful SSA optimization Pass2ConstantIfs
|
|
Converting *(pointer+n) to pointer[n] [87] *((byte**) main::$10) ← (byte*) 16384 -- *((byte**)file#1 + OFFSET_STRUCT_FILEENTRY_BUFEDIT)
|
|
Converting *(pointer+n) to pointer[n] [89] *(*((byte**) main::$11) + (byte) 3) ← (byte) $aa -- *((byte**)file#1 + OFFSET_STRUCT_FILEENTRY_BUFEDIT)
|
|
Converting *(pointer+n) to pointer[n] [91] (byte*~) main::$0 ← *((byte**) main::$12) -- *((byte**)file#1 + OFFSET_STRUCT_FILEENTRY_BUFEDIT)
|
|
Successful SSA optimization Pass2InlineDerefIdx
|
|
Simplifying expression containing zero (byte**)file#1 in [86] (byte**) main::$10 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Simplifying expression containing zero (byte**)file#1 in [87] *((byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT) ← (byte*) 16384
|
|
Simplifying expression containing zero (byte**)file#1 in [88] (byte**) main::$11 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Simplifying expression containing zero (byte**)file#1 in [89] *(*((byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT) + (byte) 3) ← (byte) $aa
|
|
Simplifying expression containing zero (byte**)file#1 in [90] (byte**) main::$12 ← (byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Simplifying expression containing zero (byte**)file#1 in [91] (byte*~) main::$0 ← *((byte**)(const struct fileentry*) file#1 + (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT)
|
|
Successful SSA optimization PassNSimplifyExpressionWithZero
|
|
Eliminating unused variable (void*) memset::return#2 and assignment [34] (void*) memset::return#2 ← (void*) memset::str#0
|
|
Eliminating unused variable (byte**) main::$10 and assignment [36] (byte**) main::$10 ← (byte**)(const struct fileentry*) file#1
|
|
Eliminating unused variable (byte**) main::$11 and assignment [38] (byte**) main::$11 ← (byte**)(const struct fileentry*) file#1
|
|
Eliminating unused variable (byte**) main::$12 and assignment [40] (byte**) main::$12 ← (byte**)(const struct fileentry*) file#1
|
|
Eliminating unused constant (const signed word) main::return#2
|
|
Eliminating unused constant (const byte) OFFSET_STRUCT_FILEENTRY_BUFEDIT
|
|
Eliminating unused constant (const struct fileentry*) file#0
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Eliminating unused constant (const signed word) main::return#0
|
|
Successful SSA optimization PassNEliminateUnusedVars
|
|
Constant (const void*) memset::str#0 = (void*)print_line_cursor#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant value identified (byte*)memset::str#0 in [0] (byte*~) memset::$2 ← (byte*)(const void*) memset::str#0
|
|
Constant value identified (byte*)memset::str#0 in [2] (byte*) memset::dst#0 ← (byte*)(const void*) memset::str#0
|
|
Successful SSA optimization Pass2ConstantValues
|
|
Constant (const byte*) memset::$2 = (byte*)memset::str#0
|
|
Constant (const byte*) memset::dst#0 = (byte*)memset::str#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Constant right-side identified [0] (byte*) memset::end#0 ← (const byte*) memset::$2 + (const word) memset::num#0
|
|
Successful SSA optimization Pass2ConstantRValueConsolidation
|
|
Constant (const byte*) memset::end#0 = memset::$2+memset::num#0
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Inlining constant with var siblings (const byte*) memset::dst#0
|
|
Inlining constant with var siblings (const byte*) print_str::str#1
|
|
Inlining constant with var siblings (const byte*) print_str::str#2
|
|
Inlining constant with var siblings (const byte*) print_line_cursor#0
|
|
Constant inlined file#1 = (const struct fileentry[$a]) files
|
|
Constant inlined memset::$2 = (byte*)(const void*) memset::str#0
|
|
Constant inlined print_line_cursor#0 = (byte*) 1024
|
|
Constant inlined print_str::str#2 = (const string) main::str1
|
|
Constant inlined main::$3 = (byte*) 0
|
|
Constant inlined memset::dst#0 = (byte*)(const void*) memset::str#0
|
|
Constant inlined print_str::str#1 = (const string) main::str
|
|
Constant inlined $0 = (const byte[]) print_hextab
|
|
Constant inlined main::$7 = (byte*) 16388
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Added new block during phi lifting print_ln::@3(between print_ln::@1 and print_ln::@1)
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @12
|
|
Adding NOP phi() at start of @29
|
|
Adding NOP phi() at start of @36
|
|
Adding NOP phi() at start of @37
|
|
Adding NOP phi() at start of @38
|
|
Adding NOP phi() at start of @end
|
|
Adding NOP phi() at start of main::@2
|
|
Adding NOP phi() at start of main::@4
|
|
Adding NOP phi() at start of main::@8
|
|
Adding NOP phi() at start of print_ln::@2
|
|
Adding NOP phi() at start of print_byte::@2
|
|
Adding NOP phi() at start of print_cls
|
|
Adding NOP phi() at start of print_cls::@1
|
|
Adding NOP phi() at start of memset
|
|
Adding NOP phi() at start of memset::@2
|
|
Adding NOP phi() at start of memset::@1
|
|
CALL GRAPH
|
|
Calls in [] to main:5
|
|
Calls in [main] to print_cls:12 print_str:14 print_byte:17 print_ln:19 print_str:21 print_byte:24 print_ln:26
|
|
Calls in [print_byte] to print_char:42 print_char:47
|
|
Calls in [print_cls] to memset:66
|
|
|
|
Created 10 initial phi equivalence classes
|
|
Coalesced [16] print_byte::b#4 ← print_byte::b#0
|
|
Not coalescing [20] print_char_cursor#48 ← print_line_cursor#1
|
|
Coalesced [23] print_byte::b#5 ← print_byte::b#1
|
|
Coalesced [25] print_line_cursor#28 ← print_line_cursor#1
|
|
Coalesced [30] print_line_cursor#29 ← print_line_cursor#19
|
|
Coalesced (already) [36] print_line_cursor#30 ← print_line_cursor#1
|
|
Coalesced [40] print_char::ch#3 ← print_char::ch#0
|
|
Coalesced [41] print_char_cursor#51 ← print_char_cursor#2
|
|
Coalesced [45] print_char::ch#4 ← print_char::ch#1
|
|
Coalesced [46] print_char_cursor#52 ← print_char_cursor#29
|
|
Coalesced [55] print_str::str#6 ← print_str::str#5
|
|
Coalesced [56] print_char_cursor#49 ← print_char_cursor#45
|
|
Coalesced [63] print_str::str#7 ← print_str::str#0
|
|
Coalesced [64] print_char_cursor#50 ← print_char_cursor#1
|
|
Coalesced [77] memset::dst#4 ← memset::dst#1
|
|
Coalesced down to 6 phi equivalence classes
|
|
Culled Empty Block (label) @12
|
|
Culled Empty Block (label) @29
|
|
Culled Empty Block (label) @36
|
|
Culled Empty Block (label) @38
|
|
Culled Empty Block (label) main::@8
|
|
Culled Empty Block (label) print_ln::@2
|
|
Culled Empty Block (label) print_ln::@3
|
|
Culled Empty Block (label) print_byte::@2
|
|
Culled Empty Block (label) print_cls::@1
|
|
Culled Empty Block (label) memset::@2
|
|
Culled Empty Block (label) memset::@1
|
|
Renumbering block @37 to @1
|
|
Renumbering block memset::@4 to memset::@1
|
|
Renumbering block memset::@5 to memset::@2
|
|
Renumbering block main::@2 to main::@1
|
|
Renumbering block main::@3 to main::@2
|
|
Renumbering block main::@4 to main::@3
|
|
Renumbering block main::@5 to main::@4
|
|
Renumbering block main::@6 to main::@5
|
|
Renumbering block main::@7 to main::@6
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @1
|
|
Adding NOP phi() at start of @end
|
|
Adding NOP phi() at start of main::@1
|
|
Adding NOP phi() at start of main::@3
|
|
Adding NOP phi() at start of main::@6
|
|
Adding NOP phi() at start of print_cls
|
|
Adding NOP phi() at start of memset
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
@begin: scope:[] from
|
|
[0] phi()
|
|
to:@1
|
|
@1: scope:[] from @begin
|
|
[1] phi()
|
|
[2] call main
|
|
to:@end
|
|
@end: scope:[] from @1
|
|
[3] phi()
|
|
|
|
(signed word()) main()
|
|
main: scope:[main] from @1
|
|
[4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384
|
|
[5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa
|
|
[6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files)
|
|
[7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc
|
|
[8] call print_cls
|
|
to:main::@1
|
|
main::@1: scope:[main] from main
|
|
[9] phi()
|
|
[10] call print_str
|
|
to:main::@2
|
|
main::@2: scope:[main] from main::@1
|
|
[11] (byte) print_byte::b#0 ← *((byte*) 0)
|
|
[12] call print_byte
|
|
to:main::@3
|
|
main::@3: scope:[main] from main::@2
|
|
[13] phi()
|
|
[14] call print_ln
|
|
to:main::@4
|
|
main::@4: scope:[main] from main::@3
|
|
[15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1
|
|
[16] call print_str
|
|
to:main::@5
|
|
main::@5: scope:[main] from main::@4
|
|
[17] (byte) print_byte::b#1 ← *((byte*) 16388)
|
|
[18] call print_byte
|
|
to:main::@6
|
|
main::@6: scope:[main] from main::@5
|
|
[19] phi()
|
|
[20] call print_ln
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@6
|
|
[21] return
|
|
to:@return
|
|
|
|
(void()) print_ln()
|
|
print_ln: scope:[print_ln] from main::@3 main::@6
|
|
[22] (byte*) print_line_cursor#19 ← phi( main::@3/(byte*) 1024 main::@6/(byte*) print_line_cursor#1 )
|
|
to:print_ln::@1
|
|
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
|
[23] (byte*) print_line_cursor#10 ← phi( print_ln/(byte*) print_line_cursor#19 print_ln::@1/(byte*) print_line_cursor#1 )
|
|
[24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $28
|
|
[25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) goto print_ln::@1
|
|
to:print_ln::@return
|
|
print_ln::@return: scope:[print_ln] from print_ln::@1
|
|
[26] return
|
|
to:@return
|
|
|
|
(void()) print_byte((byte) print_byte::b)
|
|
print_byte: scope:[print_byte] from main::@2 main::@5
|
|
[27] (byte) print_byte::b#2 ← phi( main::@2/(byte) print_byte::b#0 main::@5/(byte) print_byte::b#1 )
|
|
[28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4
|
|
[29] (byte) print_char::ch#0 ← *((const byte[]) print_hextab + (byte~) print_byte::$0)
|
|
[30] call print_char
|
|
to:print_byte::@1
|
|
print_byte::@1: scope:[print_byte] from print_byte
|
|
[31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f
|
|
[32] (byte) print_char::ch#1 ← *((const byte[]) print_hextab + (byte~) print_byte::$2)
|
|
[33] call print_char
|
|
to:print_byte::@return
|
|
print_byte::@return: scope:[print_byte] from print_byte::@1
|
|
[34] return
|
|
to:@return
|
|
|
|
(void()) print_char((byte) print_char::ch)
|
|
print_char: scope:[print_char] from print_byte print_byte::@1
|
|
[35] (byte*) print_char_cursor#28 ← phi( print_byte/(byte*) print_char_cursor#2 print_byte::@1/(byte*) print_char_cursor#29 )
|
|
[35] (byte) print_char::ch#2 ← phi( print_byte/(byte) print_char::ch#0 print_byte::@1/(byte) print_char::ch#1 )
|
|
[36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2
|
|
[37] (byte*) print_char_cursor#29 ← ++ (byte*) print_char_cursor#28
|
|
to:print_char::@return
|
|
print_char::@return: scope:[print_char] from print_char
|
|
[38] return
|
|
to:@return
|
|
|
|
(void()) print_str((byte*) print_str::str)
|
|
print_str: scope:[print_str] from main::@1 main::@4
|
|
[39] (byte*) print_char_cursor#45 ← phi( main::@1/(byte*) 1024 main::@4/(byte*~) print_char_cursor#48 )
|
|
[39] (byte*) print_str::str#5 ← phi( main::@1/(const string) main::str main::@4/(const string) main::str1 )
|
|
to:print_str::@1
|
|
print_str::@1: scope:[print_str] from print_str print_str::@2
|
|
[40] (byte*) print_char_cursor#2 ← phi( print_str/(byte*) print_char_cursor#45 print_str::@2/(byte*) print_char_cursor#1 )
|
|
[40] (byte*) print_str::str#3 ← phi( print_str/(byte*) print_str::str#5 print_str::@2/(byte*) print_str::str#0 )
|
|
[41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2
|
|
to:print_str::@return
|
|
print_str::@return: scope:[print_str] from print_str::@1
|
|
[42] return
|
|
to:@return
|
|
print_str::@2: scope:[print_str] from print_str::@1
|
|
[43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3)
|
|
[44] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#2
|
|
[45] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#3
|
|
to:print_str::@1
|
|
|
|
(void()) print_cls()
|
|
print_cls: scope:[print_cls] from main
|
|
[46] phi()
|
|
[47] call memset
|
|
to:print_cls::@return
|
|
print_cls::@return: scope:[print_cls] from print_cls
|
|
[48] return
|
|
to:@return
|
|
|
|
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
|
|
memset: scope:[memset] from print_cls
|
|
[49] phi()
|
|
to:memset::@1
|
|
memset::@1: scope:[memset] from memset memset::@2
|
|
[50] (byte*) memset::dst#2 ← phi( memset/(byte*)(const void*) memset::str#0 memset::@2/(byte*) memset::dst#1 )
|
|
[51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2
|
|
to:memset::@return
|
|
memset::@return: scope:[memset] from memset::@1
|
|
[52] return
|
|
to:@return
|
|
memset::@2: scope:[memset] from memset::@1
|
|
[53] *((byte*) memset::dst#2) ← (const byte) memset::c#0
|
|
[54] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2
|
|
to:memset::@1
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(struct fileentry*) file
|
|
(byte*) fileentry::bufEdit
|
|
(signed word()) main()
|
|
(byte*~) main::$0 4.0
|
|
(signed word) main::return
|
|
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
|
|
(byte) memset::c
|
|
(byte*) memset::dst
|
|
(byte*) memset::dst#1 22.0
|
|
(byte*) memset::dst#2 14.666666666666666
|
|
(byte*) memset::end
|
|
(word) memset::num
|
|
(void*) memset::return
|
|
(void*) memset::str
|
|
(void()) print_byte((byte) print_byte::b)
|
|
(byte~) print_byte::$0 4.0
|
|
(byte~) print_byte::$2 4.0
|
|
(byte) print_byte::b
|
|
(byte) print_byte::b#0 4.0
|
|
(byte) print_byte::b#1 4.0
|
|
(byte) print_byte::b#2 2.0
|
|
(void()) print_char((byte) print_char::ch)
|
|
(byte) print_char::ch
|
|
(byte) print_char::ch#0 4.0
|
|
(byte) print_char::ch#1 4.0
|
|
(byte) print_char::ch#2 6.0
|
|
(byte*) print_char_cursor
|
|
(byte*) print_char_cursor#1 11.0
|
|
(byte*) print_char_cursor#2 3.3636363636363638
|
|
(byte*) print_char_cursor#28 4.0
|
|
(byte*) print_char_cursor#29 0.9999999999999999
|
|
(byte*) print_char_cursor#45 4.0
|
|
(byte*~) print_char_cursor#48 4.0
|
|
(void()) print_cls()
|
|
(byte*) print_line_cursor
|
|
(byte*) print_line_cursor#1 4.111111111111112
|
|
(byte*) print_line_cursor#10 24.0
|
|
(byte*) print_line_cursor#19 4.0
|
|
(void()) print_ln()
|
|
(byte*) print_screen
|
|
(void()) print_str((byte*) print_str::str)
|
|
(byte*) print_str::str
|
|
(byte*) print_str::str#0 22.0
|
|
(byte*) print_str::str#3 11.5
|
|
(byte*) print_str::str#5 2.0
|
|
|
|
Initial phi equivalence classes
|
|
[ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ]
|
|
[ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
[ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
[ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
[ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
[ memset::dst#2 memset::dst#1 ]
|
|
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
|
Added variable print_byte::$0 to zero page equivalence class [ print_byte::$0 ]
|
|
Added variable print_byte::$2 to zero page equivalence class [ print_byte::$2 ]
|
|
Complete equivalence classes
|
|
[ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ]
|
|
[ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
[ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
[ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
[ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
[ memset::dst#2 memset::dst#1 ]
|
|
[ main::$0 ]
|
|
[ print_byte::$0 ]
|
|
[ print_byte::$2 ]
|
|
Allocated zp ZP_WORD:2 [ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ]
|
|
Allocated zp ZP_BYTE:4 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
Allocated zp ZP_BYTE:5 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
Allocated zp ZP_WORD:6 [ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
Allocated zp ZP_WORD:8 [ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
Allocated zp ZP_WORD:10 [ memset::dst#2 memset::dst#1 ]
|
|
Allocated zp ZP_WORD:12 [ main::$0 ]
|
|
Allocated zp ZP_BYTE:14 [ print_byte::$0 ]
|
|
Allocated zp ZP_BYTE:15 [ print_byte::$2 ]
|
|
|
|
INITIAL ASM
|
|
Target platform is c64basic / MOS6502X
|
|
// File Comments
|
|
// Demonstrates problem with missing parenthesis in double-dereferencing
|
|
// https://gitlab.com/camelot/kickc/issues/270
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(__bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label print_char_cursor = 6
|
|
.label print_line_cursor = 2
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.label __0 = $c
|
|
// [4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384 -- _deref_pptc1=pbuc2
|
|
lda #<$4000
|
|
sta files
|
|
lda #>$4000
|
|
sta files+1
|
|
// [5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa -- (_deref_pptc1)_derefidx_vbuc2=vbuc3
|
|
lda #$aa
|
|
ldy #3
|
|
ldx files
|
|
stx.z $fe
|
|
ldx files+1
|
|
stx.z $ff
|
|
sta ($fe),y
|
|
// [6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files) -- pbuz1=_deref_pptc1
|
|
lda files
|
|
sta.z __0
|
|
lda files+1
|
|
sta.z __0+1
|
|
// [7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc -- pbuz1_derefidx_vbuc1=vbuc2
|
|
// writes address 0x0000 (wrong!)
|
|
lda #$cc
|
|
ldy #4
|
|
sta (__0),y
|
|
// [8] call print_cls
|
|
// [46] phi from main to print_cls [phi:main->print_cls]
|
|
print_cls_from_main:
|
|
jsr print_cls
|
|
// [9] phi from main to main::@1 [phi:main->main::@1]
|
|
__b1_from_main:
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [10] call print_str
|
|
// [39] phi from main::@1 to print_str [phi:main::@1->print_str]
|
|
print_str_from___b1:
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*) 1024 [phi:main::@1->print_str#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_char_cursor
|
|
lda #>$400
|
|
sta.z print_char_cursor+1
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str [phi:main::@1->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z print_str.str
|
|
lda #>str
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
jmp __b2
|
|
// main::@2
|
|
__b2:
|
|
// [11] (byte) print_byte::b#0 ← *((byte*) 0) -- vbuz1=_deref_pbuc1
|
|
lda 0
|
|
sta.z print_byte.b
|
|
// [12] call print_byte
|
|
// [27] phi from main::@2 to print_byte [phi:main::@2->print_byte]
|
|
print_byte_from___b2:
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#0 [phi:main::@2->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [13] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
__b3_from___b2:
|
|
jmp __b3
|
|
// main::@3
|
|
__b3:
|
|
// [14] call print_ln
|
|
// [22] phi from main::@3 to print_ln [phi:main::@3->print_ln]
|
|
print_ln_from___b3:
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) 1024 [phi:main::@3->print_ln#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_line_cursor
|
|
lda #>$400
|
|
sta.z print_line_cursor+1
|
|
jsr print_ln
|
|
jmp __b4
|
|
// main::@4
|
|
__b4:
|
|
// [15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// [16] call print_str
|
|
// [39] phi from main::@4 to print_str [phi:main::@4->print_str]
|
|
print_str_from___b4:
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*~) print_char_cursor#48 [phi:main::@4->print_str#0] -- register_copy
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str1 [phi:main::@4->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str1
|
|
sta.z print_str.str
|
|
lda #>str1
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
jmp __b5
|
|
// main::@5
|
|
__b5:
|
|
// [17] (byte) print_byte::b#1 ← *((byte*) 16388) -- vbuz1=_deref_pbuc1
|
|
lda $4004
|
|
sta.z print_byte.b
|
|
// [18] call print_byte
|
|
// [27] phi from main::@5 to print_byte [phi:main::@5->print_byte]
|
|
print_byte_from___b5:
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#1 [phi:main::@5->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [19] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
|
|
__b6_from___b5:
|
|
jmp __b6
|
|
// main::@6
|
|
__b6:
|
|
// [20] call print_ln
|
|
// [22] phi from main::@6 to print_ln [phi:main::@6->print_ln]
|
|
print_ln_from___b6:
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) print_line_cursor#1 [phi:main::@6->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [21] return
|
|
rts
|
|
str: .text "$0000="
|
|
.byte 0
|
|
str1: .text "$4004="
|
|
.byte 0
|
|
}
|
|
// print_ln
|
|
// Print a newline
|
|
print_ln: {
|
|
// [23] 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:
|
|
// [23] phi (byte*) print_line_cursor#10 = (byte*) print_line_cursor#19 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy
|
|
jmp __b1
|
|
// print_ln::@1
|
|
__b1:
|
|
// [24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $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
|
|
!:
|
|
// [25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) 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:
|
|
// [26] return
|
|
rts
|
|
}
|
|
// print_byte
|
|
// Print a byte as HEX
|
|
// print_byte(byte zeropage(4) b)
|
|
print_byte: {
|
|
.label __0 = $e
|
|
.label __2 = $f
|
|
.label b = 4
|
|
// [28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4 -- vbuz1=vbuz2_ror_4
|
|
lda.z b
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
sta.z __0
|
|
// [29] (byte) print_char::ch#0 ← *((const byte[]) print_hextab + (byte~) print_byte::$0) -- vbuz1=pbuc1_derefidx_vbuz2
|
|
ldy.z __0
|
|
lda print_hextab,y
|
|
sta.z print_char.ch
|
|
// [30] call print_char
|
|
// [35] phi from print_byte to print_char [phi:print_byte->print_char]
|
|
print_char_from_print_byte:
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#2 [phi:print_byte->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#0 [phi:print_byte->print_char#1] -- register_copy
|
|
jsr print_char
|
|
jmp __b1
|
|
// print_byte::@1
|
|
__b1:
|
|
// [31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f -- vbuz1=vbuz2_band_vbuc1
|
|
lda #$f
|
|
and.z b
|
|
sta.z __2
|
|
// [32] (byte) print_char::ch#1 ← *((const byte[]) print_hextab + (byte~) print_byte::$2) -- vbuz1=pbuc1_derefidx_vbuz2
|
|
ldy.z __2
|
|
lda print_hextab,y
|
|
sta.z print_char.ch
|
|
// [33] call print_char
|
|
// [35] phi from print_byte::@1 to print_char [phi:print_byte::@1->print_char]
|
|
print_char_from___b1:
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#29 [phi:print_byte::@1->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#1 [phi:print_byte::@1->print_char#1] -- register_copy
|
|
jsr print_char
|
|
jmp __breturn
|
|
// print_byte::@return
|
|
__breturn:
|
|
// [34] return
|
|
rts
|
|
}
|
|
// print_char
|
|
// Print a single char
|
|
// print_char(byte zeropage(5) ch)
|
|
print_char: {
|
|
.label ch = 5
|
|
// [36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2 -- _deref_pbuz1=vbuz2
|
|
lda.z ch
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// [37] (byte*) print_char_cursor#29 ← ++ (byte*) print_char_cursor#28 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
jmp __breturn
|
|
// print_char::@return
|
|
__breturn:
|
|
// [38] return
|
|
rts
|
|
}
|
|
// print_str
|
|
// Print a zero-terminated string
|
|
// print_str(byte* zeropage(8) str)
|
|
print_str: {
|
|
.label str = 8
|
|
// [40] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1]
|
|
__b1_from_print_str:
|
|
__b1_from___b2:
|
|
// [40] phi (byte*) print_char_cursor#2 = (byte*) print_char_cursor#45 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy
|
|
// [40] phi (byte*) print_str::str#3 = (byte*) print_str::str#5 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy
|
|
jmp __b1
|
|
// print_str::@1
|
|
__b1:
|
|
// [41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2 -- vbuc1_neq__deref_pbuz1_then_la1
|
|
ldy #0
|
|
lda (str),y
|
|
cmp #0
|
|
bne __b2
|
|
jmp __breturn
|
|
// print_str::@return
|
|
__breturn:
|
|
// [42] return
|
|
rts
|
|
// print_str::@2
|
|
__b2:
|
|
// [43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3) -- _deref_pbuz1=_deref_pbuz2
|
|
ldy #0
|
|
lda (str),y
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// [44] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#2 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
// [45] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#3 -- pbuz1=_inc_pbuz1
|
|
inc.z str
|
|
bne !+
|
|
inc.z str+1
|
|
!:
|
|
jmp __b1_from___b2
|
|
}
|
|
// print_cls
|
|
// Clear the screen. Also resets current line/char cursor.
|
|
print_cls: {
|
|
// [47] call memset
|
|
// [49] phi from print_cls to memset [phi:print_cls->memset]
|
|
memset_from_print_cls:
|
|
jsr memset
|
|
jmp __breturn
|
|
// print_cls::@return
|
|
__breturn:
|
|
// [48] return
|
|
rts
|
|
}
|
|
// memset
|
|
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
|
|
memset: {
|
|
.const c = ' '
|
|
.const num = $3e8
|
|
.label str = $400
|
|
.label end = str+num
|
|
.label dst = $a
|
|
// [50] phi from memset to memset::@1 [phi:memset->memset::@1]
|
|
__b1_from_memset:
|
|
// [50] phi (byte*) memset::dst#2 = (byte*)(const void*) memset::str#0 [phi:memset->memset::@1#0] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z dst
|
|
lda #>str
|
|
sta.z dst+1
|
|
jmp __b1
|
|
// memset::@1
|
|
__b1:
|
|
// [51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2 -- pbuz1_neq_pbuc1_then_la1
|
|
lda.z dst+1
|
|
cmp #>end
|
|
bne __b2
|
|
lda.z dst
|
|
cmp #<end
|
|
bne __b2
|
|
jmp __breturn
|
|
// memset::@return
|
|
__breturn:
|
|
// [52] return
|
|
rts
|
|
// memset::@2
|
|
__b2:
|
|
// [53] *((byte*) memset::dst#2) ← (const byte) memset::c#0 -- _deref_pbuz1=vbuc1
|
|
lda #c
|
|
ldy #0
|
|
sta (dst),y
|
|
// [54] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1
|
|
inc.z dst
|
|
bne !+
|
|
inc.z dst+1
|
|
!:
|
|
// [50] phi from memset::@2 to memset::@1 [phi:memset::@2->memset::@1]
|
|
__b1_from___b2:
|
|
// [50] phi (byte*) memset::dst#2 = (byte*) memset::dst#1 [phi:memset::@2->memset::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// File Data
|
|
print_hextab: .text "0123456789abcdef"
|
|
files: .fill 2*$a, 0
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
Statement [5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte x reg byte y
|
|
Statement [6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
|
|
Statement [7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
|
|
Statement [15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1 [ print_char_cursor#48 print_line_cursor#1 ] ( main:2 [ print_char_cursor#48 print_line_cursor#1 ] ) always clobbers reg byte a
|
|
Statement [24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $28 [ print_line_cursor#1 print_char_cursor#29 ] ( main:2::print_ln:14 [ print_line_cursor#1 print_char_cursor#29 ] main:2::print_ln:20 [ print_line_cursor#1 print_char_cursor#29 ] ) always clobbers reg byte a
|
|
Statement [25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) goto print_ln::@1 [ print_line_cursor#1 print_char_cursor#29 ] ( main:2::print_ln:14 [ print_line_cursor#1 print_char_cursor#29 ] main:2::print_ln:20 [ print_line_cursor#1 print_char_cursor#29 ] ) always clobbers reg byte a
|
|
Statement [28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4 [ print_byte::b#2 print_byte::$0 print_char_cursor#2 ] ( main:2::print_byte:12 [ print_byte::b#2 print_byte::$0 print_char_cursor#2 ] main:2::print_byte:18 [ print_line_cursor#1 print_byte::b#2 print_byte::$0 print_char_cursor#2 ] ) always clobbers reg byte a
|
|
Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
Statement [31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f [ print_char_cursor#29 print_byte::$2 ] ( main:2::print_byte:12 [ print_char_cursor#29 print_byte::$2 ] main:2::print_byte:18 [ print_line_cursor#1 print_char_cursor#29 print_byte::$2 ] ) always clobbers reg byte a
|
|
Statement [36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2 [ print_char_cursor#28 ] ( main:2::print_byte:12::print_char:30 [ print_byte::b#2 print_char_cursor#28 ] main:2::print_byte:18::print_char:30 [ print_line_cursor#1 print_byte::b#2 print_char_cursor#28 ] main:2::print_byte:12::print_char:33 [ print_char_cursor#28 ] main:2::print_byte:18::print_char:33 [ print_line_cursor#1 print_char_cursor#28 ] ) always clobbers reg byte y
|
|
Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
Statement [41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2 [ print_char_cursor#2 print_str::str#3 ] ( main:2::print_str:10 [ print_char_cursor#2 print_str::str#3 ] main:2::print_str:16 [ print_line_cursor#1 print_char_cursor#2 print_str::str#3 ] ) always clobbers reg byte a reg byte y
|
|
Statement [43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3) [ print_char_cursor#2 print_str::str#3 ] ( main:2::print_str:10 [ print_char_cursor#2 print_str::str#3 ] main:2::print_str:16 [ print_line_cursor#1 print_char_cursor#2 print_str::str#3 ] ) always clobbers reg byte a reg byte y
|
|
Statement [51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2 [ memset::dst#2 ] ( main:2::print_cls:8::memset:47 [ memset::dst#2 ] ) always clobbers reg byte a
|
|
Statement [53] *((byte*) memset::dst#2) ← (const byte) memset::c#0 [ memset::dst#2 ] ( main:2::print_cls:8::memset:47 [ memset::dst#2 ] ) always clobbers reg byte a reg byte y
|
|
Statement [4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384 [ ] ( main:2 [ ] ) always clobbers reg byte a
|
|
Statement [5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte x reg byte y
|
|
Statement [6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files) [ main::$0 ] ( main:2 [ main::$0 ] ) always clobbers reg byte a
|
|
Statement [7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y
|
|
Statement [15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1 [ print_char_cursor#48 print_line_cursor#1 ] ( main:2 [ print_char_cursor#48 print_line_cursor#1 ] ) always clobbers reg byte a
|
|
Statement [24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $28 [ print_line_cursor#1 print_char_cursor#29 ] ( main:2::print_ln:14 [ print_line_cursor#1 print_char_cursor#29 ] main:2::print_ln:20 [ print_line_cursor#1 print_char_cursor#29 ] ) always clobbers reg byte a
|
|
Statement [25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) goto print_ln::@1 [ print_line_cursor#1 print_char_cursor#29 ] ( main:2::print_ln:14 [ print_line_cursor#1 print_char_cursor#29 ] main:2::print_ln:20 [ print_line_cursor#1 print_char_cursor#29 ] ) always clobbers reg byte a
|
|
Statement [28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4 [ print_byte::b#2 print_byte::$0 print_char_cursor#2 ] ( main:2::print_byte:12 [ print_byte::b#2 print_byte::$0 print_char_cursor#2 ] main:2::print_byte:18 [ print_line_cursor#1 print_byte::b#2 print_byte::$0 print_char_cursor#2 ] ) always clobbers reg byte a
|
|
Statement [31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f [ print_char_cursor#29 print_byte::$2 ] ( main:2::print_byte:12 [ print_char_cursor#29 print_byte::$2 ] main:2::print_byte:18 [ print_line_cursor#1 print_char_cursor#29 print_byte::$2 ] ) always clobbers reg byte a
|
|
Statement [36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2 [ print_char_cursor#28 ] ( main:2::print_byte:12::print_char:30 [ print_byte::b#2 print_char_cursor#28 ] main:2::print_byte:18::print_char:30 [ print_line_cursor#1 print_byte::b#2 print_char_cursor#28 ] main:2::print_byte:12::print_char:33 [ print_char_cursor#28 ] main:2::print_byte:18::print_char:33 [ print_line_cursor#1 print_char_cursor#28 ] ) always clobbers reg byte y
|
|
Statement [41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2 [ print_char_cursor#2 print_str::str#3 ] ( main:2::print_str:10 [ print_char_cursor#2 print_str::str#3 ] main:2::print_str:16 [ print_line_cursor#1 print_char_cursor#2 print_str::str#3 ] ) always clobbers reg byte a reg byte y
|
|
Statement [43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3) [ print_char_cursor#2 print_str::str#3 ] ( main:2::print_str:10 [ print_char_cursor#2 print_str::str#3 ] main:2::print_str:16 [ print_line_cursor#1 print_char_cursor#2 print_str::str#3 ] ) always clobbers reg byte a reg byte y
|
|
Statement [51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2 [ memset::dst#2 ] ( main:2::print_cls:8::memset:47 [ memset::dst#2 ] ) always clobbers reg byte a
|
|
Statement [53] *((byte*) memset::dst#2) ← (const byte) memset::c#0 [ memset::dst#2 ] ( main:2::print_cls:8::memset:47 [ memset::dst#2 ] ) always clobbers reg byte a reg byte y
|
|
Potential registers zp ZP_WORD:2 [ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ] : zp ZP_WORD:2 ,
|
|
Potential registers zp ZP_BYTE:4 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] : zp ZP_BYTE:4 , reg byte x ,
|
|
Potential registers zp ZP_BYTE:5 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ] : zp ZP_BYTE:5 , reg byte a , reg byte x , reg byte y ,
|
|
Potential registers zp ZP_WORD:6 [ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ] : zp ZP_WORD:6 ,
|
|
Potential registers zp ZP_WORD:8 [ print_str::str#3 print_str::str#5 print_str::str#0 ] : zp ZP_WORD:8 ,
|
|
Potential registers zp ZP_WORD:10 [ memset::dst#2 memset::dst#1 ] : zp ZP_WORD:10 ,
|
|
Potential registers zp ZP_WORD:12 [ main::$0 ] : zp ZP_WORD:12 ,
|
|
Potential registers zp ZP_BYTE:14 [ print_byte::$0 ] : zp ZP_BYTE:14 , reg byte a , reg byte x , reg byte y ,
|
|
Potential registers zp ZP_BYTE:15 [ print_byte::$2 ] : zp ZP_BYTE:15 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [] 32.11: zp ZP_WORD:2 [ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ] 27.36: zp ZP_WORD:6 [ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
Uplift Scope [memset] 36.67: zp ZP_WORD:10 [ memset::dst#2 memset::dst#1 ]
|
|
Uplift Scope [print_str] 35.5: zp ZP_WORD:8 [ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
Uplift Scope [print_byte] 10: zp ZP_BYTE:4 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] 4: zp ZP_BYTE:14 [ print_byte::$0 ] 4: zp ZP_BYTE:15 [ print_byte::$2 ]
|
|
Uplift Scope [print_char] 14: zp ZP_BYTE:5 [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
Uplift Scope [main] 4: zp ZP_WORD:12 [ main::$0 ]
|
|
Uplift Scope [RADIX]
|
|
Uplift Scope [print_ln]
|
|
Uplift Scope [print_cls]
|
|
Uplift Scope [fileentry]
|
|
|
|
Uplifting [] best 1948 combination zp ZP_WORD:2 [ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ] zp ZP_WORD:6 [ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
Uplifting [memset] best 1948 combination zp ZP_WORD:10 [ memset::dst#2 memset::dst#1 ]
|
|
Uplifting [print_str] best 1948 combination zp ZP_WORD:8 [ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
Uplifting [print_byte] best 1930 combination reg byte x [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] reg byte a [ print_byte::$0 ] reg byte x [ print_byte::$2 ]
|
|
Uplifting [print_char] best 1921 combination reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
Uplifting [main] best 1921 combination zp ZP_WORD:12 [ main::$0 ]
|
|
Uplifting [RADIX] best 1921 combination
|
|
Uplifting [print_ln] best 1921 combination
|
|
Uplifting [print_cls] best 1921 combination
|
|
Uplifting [fileentry] best 1921 combination
|
|
Coalescing zero page register [ zp ZP_WORD:10 [ memset::dst#2 memset::dst#1 ] ] with [ zp ZP_WORD:2 [ print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ] ]
|
|
Coalescing zero page register [ zp ZP_WORD:12 [ main::$0 ] ] with [ zp ZP_WORD:6 [ print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ] ]
|
|
Allocated (was zp ZP_WORD:8) zp ZP_WORD:2 [ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
Allocated (was zp ZP_WORD:10) zp ZP_WORD:4 [ memset::dst#2 memset::dst#1 print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ]
|
|
Allocated (was zp ZP_WORD:12) zp ZP_WORD:6 [ main::$0 print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
// File Comments
|
|
// Demonstrates problem with missing parenthesis in double-dereferencing
|
|
// https://gitlab.com/camelot/kickc/issues/270
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(__bbegin)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label print_char_cursor = 6
|
|
.label print_line_cursor = 4
|
|
// @begin
|
|
__bbegin:
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
__b1_from___bbegin:
|
|
jmp __b1
|
|
// @1
|
|
__b1:
|
|
// [2] call main
|
|
jsr main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
__bend_from___b1:
|
|
jmp __bend
|
|
// @end
|
|
__bend:
|
|
// main
|
|
main: {
|
|
.label __0 = 6
|
|
// [4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384 -- _deref_pptc1=pbuc2
|
|
lda #<$4000
|
|
sta files
|
|
lda #>$4000
|
|
sta files+1
|
|
// [5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa -- (_deref_pptc1)_derefidx_vbuc2=vbuc3
|
|
lda #$aa
|
|
ldy #3
|
|
ldx files
|
|
stx.z $fe
|
|
ldx files+1
|
|
stx.z $ff
|
|
sta ($fe),y
|
|
// [6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files) -- pbuz1=_deref_pptc1
|
|
lda files
|
|
sta.z __0
|
|
lda files+1
|
|
sta.z __0+1
|
|
// [7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc -- pbuz1_derefidx_vbuc1=vbuc2
|
|
// writes address 0x0000 (wrong!)
|
|
lda #$cc
|
|
ldy #4
|
|
sta (__0),y
|
|
// [8] call print_cls
|
|
// [46] phi from main to print_cls [phi:main->print_cls]
|
|
print_cls_from_main:
|
|
jsr print_cls
|
|
// [9] phi from main to main::@1 [phi:main->main::@1]
|
|
__b1_from_main:
|
|
jmp __b1
|
|
// main::@1
|
|
__b1:
|
|
// [10] call print_str
|
|
// [39] phi from main::@1 to print_str [phi:main::@1->print_str]
|
|
print_str_from___b1:
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*) 1024 [phi:main::@1->print_str#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_char_cursor
|
|
lda #>$400
|
|
sta.z print_char_cursor+1
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str [phi:main::@1->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z print_str.str
|
|
lda #>str
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
jmp __b2
|
|
// main::@2
|
|
__b2:
|
|
// [11] (byte) print_byte::b#0 ← *((byte*) 0) -- vbuxx=_deref_pbuc1
|
|
ldx 0
|
|
// [12] call print_byte
|
|
// [27] phi from main::@2 to print_byte [phi:main::@2->print_byte]
|
|
print_byte_from___b2:
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#0 [phi:main::@2->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [13] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
__b3_from___b2:
|
|
jmp __b3
|
|
// main::@3
|
|
__b3:
|
|
// [14] call print_ln
|
|
// [22] phi from main::@3 to print_ln [phi:main::@3->print_ln]
|
|
print_ln_from___b3:
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) 1024 [phi:main::@3->print_ln#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_line_cursor
|
|
lda #>$400
|
|
sta.z print_line_cursor+1
|
|
jsr print_ln
|
|
jmp __b4
|
|
// main::@4
|
|
__b4:
|
|
// [15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1 -- pbuz1=pbuz2
|
|
lda.z print_line_cursor
|
|
sta.z print_char_cursor
|
|
lda.z print_line_cursor+1
|
|
sta.z print_char_cursor+1
|
|
// [16] call print_str
|
|
// [39] phi from main::@4 to print_str [phi:main::@4->print_str]
|
|
print_str_from___b4:
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*~) print_char_cursor#48 [phi:main::@4->print_str#0] -- register_copy
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str1 [phi:main::@4->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str1
|
|
sta.z print_str.str
|
|
lda #>str1
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
jmp __b5
|
|
// main::@5
|
|
__b5:
|
|
// [17] (byte) print_byte::b#1 ← *((byte*) 16388) -- vbuxx=_deref_pbuc1
|
|
ldx $4004
|
|
// [18] call print_byte
|
|
// [27] phi from main::@5 to print_byte [phi:main::@5->print_byte]
|
|
print_byte_from___b5:
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#1 [phi:main::@5->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [19] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
|
|
__b6_from___b5:
|
|
jmp __b6
|
|
// main::@6
|
|
__b6:
|
|
// [20] call print_ln
|
|
// [22] phi from main::@6 to print_ln [phi:main::@6->print_ln]
|
|
print_ln_from___b6:
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) print_line_cursor#1 [phi:main::@6->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
jmp __breturn
|
|
// main::@return
|
|
__breturn:
|
|
// [21] return
|
|
rts
|
|
str: .text "$0000="
|
|
.byte 0
|
|
str1: .text "$4004="
|
|
.byte 0
|
|
}
|
|
// print_ln
|
|
// Print a newline
|
|
print_ln: {
|
|
// [23] 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:
|
|
// [23] phi (byte*) print_line_cursor#10 = (byte*) print_line_cursor#19 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy
|
|
jmp __b1
|
|
// print_ln::@1
|
|
__b1:
|
|
// [24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $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
|
|
!:
|
|
// [25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) 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:
|
|
// [26] return
|
|
rts
|
|
}
|
|
// print_byte
|
|
// Print a byte as HEX
|
|
// print_byte(byte register(X) b)
|
|
print_byte: {
|
|
// [28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4 -- vbuaa=vbuxx_ror_4
|
|
txa
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
// [29] (byte) print_char::ch#0 ← *((const byte[]) print_hextab + (byte~) print_byte::$0) -- vbuaa=pbuc1_derefidx_vbuaa
|
|
tay
|
|
lda print_hextab,y
|
|
// [30] call print_char
|
|
// [35] phi from print_byte to print_char [phi:print_byte->print_char]
|
|
print_char_from_print_byte:
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#2 [phi:print_byte->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#0 [phi:print_byte->print_char#1] -- register_copy
|
|
jsr print_char
|
|
jmp __b1
|
|
// print_byte::@1
|
|
__b1:
|
|
// [31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f -- vbuxx=vbuxx_band_vbuc1
|
|
lda #$f
|
|
axs #0
|
|
// [32] (byte) print_char::ch#1 ← *((const byte[]) print_hextab + (byte~) print_byte::$2) -- vbuaa=pbuc1_derefidx_vbuxx
|
|
lda print_hextab,x
|
|
// [33] call print_char
|
|
// [35] phi from print_byte::@1 to print_char [phi:print_byte::@1->print_char]
|
|
print_char_from___b1:
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#29 [phi:print_byte::@1->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#1 [phi:print_byte::@1->print_char#1] -- register_copy
|
|
jsr print_char
|
|
jmp __breturn
|
|
// print_byte::@return
|
|
__breturn:
|
|
// [34] return
|
|
rts
|
|
}
|
|
// print_char
|
|
// Print a single char
|
|
// print_char(byte register(A) ch)
|
|
print_char: {
|
|
// [36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2 -- _deref_pbuz1=vbuaa
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// [37] (byte*) print_char_cursor#29 ← ++ (byte*) print_char_cursor#28 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
jmp __breturn
|
|
// print_char::@return
|
|
__breturn:
|
|
// [38] return
|
|
rts
|
|
}
|
|
// print_str
|
|
// Print a zero-terminated string
|
|
// print_str(byte* zeropage(2) str)
|
|
print_str: {
|
|
.label str = 2
|
|
// [40] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1]
|
|
__b1_from_print_str:
|
|
__b1_from___b2:
|
|
// [40] phi (byte*) print_char_cursor#2 = (byte*) print_char_cursor#45 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy
|
|
// [40] phi (byte*) print_str::str#3 = (byte*) print_str::str#5 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy
|
|
jmp __b1
|
|
// print_str::@1
|
|
__b1:
|
|
// [41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2 -- vbuc1_neq__deref_pbuz1_then_la1
|
|
ldy #0
|
|
lda (str),y
|
|
cmp #0
|
|
bne __b2
|
|
jmp __breturn
|
|
// print_str::@return
|
|
__breturn:
|
|
// [42] return
|
|
rts
|
|
// print_str::@2
|
|
__b2:
|
|
// [43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3) -- _deref_pbuz1=_deref_pbuz2
|
|
ldy #0
|
|
lda (str),y
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// [44] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#2 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
// [45] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#3 -- pbuz1=_inc_pbuz1
|
|
inc.z str
|
|
bne !+
|
|
inc.z str+1
|
|
!:
|
|
jmp __b1_from___b2
|
|
}
|
|
// print_cls
|
|
// Clear the screen. Also resets current line/char cursor.
|
|
print_cls: {
|
|
// [47] call memset
|
|
// [49] phi from print_cls to memset [phi:print_cls->memset]
|
|
memset_from_print_cls:
|
|
jsr memset
|
|
jmp __breturn
|
|
// print_cls::@return
|
|
__breturn:
|
|
// [48] return
|
|
rts
|
|
}
|
|
// memset
|
|
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
|
|
memset: {
|
|
.const c = ' '
|
|
.const num = $3e8
|
|
.label str = $400
|
|
.label end = str+num
|
|
.label dst = 4
|
|
// [50] phi from memset to memset::@1 [phi:memset->memset::@1]
|
|
__b1_from_memset:
|
|
// [50] phi (byte*) memset::dst#2 = (byte*)(const void*) memset::str#0 [phi:memset->memset::@1#0] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z dst
|
|
lda #>str
|
|
sta.z dst+1
|
|
jmp __b1
|
|
// memset::@1
|
|
__b1:
|
|
// [51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2 -- pbuz1_neq_pbuc1_then_la1
|
|
lda.z dst+1
|
|
cmp #>end
|
|
bne __b2
|
|
lda.z dst
|
|
cmp #<end
|
|
bne __b2
|
|
jmp __breturn
|
|
// memset::@return
|
|
__breturn:
|
|
// [52] return
|
|
rts
|
|
// memset::@2
|
|
__b2:
|
|
// [53] *((byte*) memset::dst#2) ← (const byte) memset::c#0 -- _deref_pbuz1=vbuc1
|
|
lda #c
|
|
ldy #0
|
|
sta (dst),y
|
|
// [54] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1
|
|
inc.z dst
|
|
bne !+
|
|
inc.z dst+1
|
|
!:
|
|
// [50] phi from memset::@2 to memset::@1 [phi:memset::@2->memset::@1]
|
|
__b1_from___b2:
|
|
// [50] phi (byte*) memset::dst#2 = (byte*) memset::dst#1 [phi:memset::@2->memset::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// File Data
|
|
print_hextab: .text "0123456789abcdef"
|
|
files: .fill 2*$a, 0
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __bend
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __b2
|
|
Removing instruction jmp __b3
|
|
Removing instruction jmp __b4
|
|
Removing instruction jmp __b5
|
|
Removing instruction jmp __b6
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __breturn
|
|
Removing instruction jmp __b1
|
|
Removing instruction jmp __breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction ldy #0
|
|
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
|
Replacing label __bbegin with __b1
|
|
Replacing label __b1_from___b1 with __b1
|
|
Replacing label __b1_from___b1 with __b1
|
|
Replacing label __b1_from___b2 with __b1
|
|
Removing instruction __bbegin:
|
|
Removing instruction __b1_from___bbegin:
|
|
Removing instruction __bend_from___b1:
|
|
Removing instruction __b1_from_main:
|
|
Removing instruction print_str_from___b1:
|
|
Removing instruction __b3_from___b2:
|
|
Removing instruction print_ln_from___b3:
|
|
Removing instruction __b6_from___b5:
|
|
Removing instruction print_ln_from___b6:
|
|
Removing instruction __b1_from_print_ln:
|
|
Removing instruction __b1_from___b1:
|
|
Removing instruction __b1_from_print_str:
|
|
Removing instruction __b1_from___b2:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction __bend:
|
|
Removing instruction print_cls_from_main:
|
|
Removing instruction __b1:
|
|
Removing instruction __b2:
|
|
Removing instruction print_byte_from___b2:
|
|
Removing instruction __b3:
|
|
Removing instruction __b4:
|
|
Removing instruction print_str_from___b4:
|
|
Removing instruction __b5:
|
|
Removing instruction print_byte_from___b5:
|
|
Removing instruction __b6:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Removing instruction print_char_from_print_byte:
|
|
Removing instruction __b1:
|
|
Removing instruction print_char_from___b1:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Removing instruction __breturn:
|
|
Removing instruction memset_from_print_cls:
|
|
Removing instruction __breturn:
|
|
Removing instruction __b1_from_memset:
|
|
Removing instruction __breturn:
|
|
Removing instruction __b1_from___b2:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Updating BasicUpstart to call main directly
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
Removing instruction __b1:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(const byte) RADIX::BINARY BINARY = (number) 2
|
|
(const byte) RADIX::DECIMAL DECIMAL = (number) $a
|
|
(const byte) RADIX::HEXADECIMAL HEXADECIMAL = (number) $10
|
|
(const byte) RADIX::OCTAL OCTAL = (number) 8
|
|
(struct fileentry*) file
|
|
(byte*) fileentry::bufEdit
|
|
(const struct fileentry[$a]) files files = { fill( $a, 0) }
|
|
(signed word()) main()
|
|
(byte*~) main::$0 $0 zp ZP_WORD:6 4.0
|
|
(label) main::@1
|
|
(label) main::@2
|
|
(label) main::@3
|
|
(label) main::@4
|
|
(label) main::@5
|
|
(label) main::@6
|
|
(label) main::@return
|
|
(signed word) main::return
|
|
(const string) main::str str = (string) "$0000="
|
|
(const string) main::str1 str1 = (string) "$4004="
|
|
(void*()) memset((void*) memset::str , (byte) memset::c , (word) memset::num)
|
|
(label) memset::@1
|
|
(label) memset::@2
|
|
(label) memset::@return
|
|
(byte) memset::c
|
|
(const byte) memset::c#0 c = (byte) ' '
|
|
(byte*) memset::dst
|
|
(byte*) memset::dst#1 dst zp ZP_WORD:4 22.0
|
|
(byte*) memset::dst#2 dst zp ZP_WORD:4 14.666666666666666
|
|
(byte*) memset::end
|
|
(const byte*) memset::end#0 end = (byte*)(const void*) memset::str#0+(const word) memset::num#0
|
|
(word) memset::num
|
|
(const word) memset::num#0 num = (word) $3e8
|
|
(void*) memset::return
|
|
(void*) memset::str
|
|
(const void*) memset::str#0 str = (void*)(byte*) 1024
|
|
(void()) print_byte((byte) print_byte::b)
|
|
(byte~) print_byte::$0 reg byte a 4.0
|
|
(byte~) print_byte::$2 reg byte x 4.0
|
|
(label) print_byte::@1
|
|
(label) print_byte::@return
|
|
(byte) print_byte::b
|
|
(byte) print_byte::b#0 reg byte x 4.0
|
|
(byte) print_byte::b#1 reg byte x 4.0
|
|
(byte) print_byte::b#2 reg byte x 2.0
|
|
(void()) print_char((byte) print_char::ch)
|
|
(label) print_char::@return
|
|
(byte) print_char::ch
|
|
(byte) print_char::ch#0 reg byte a 4.0
|
|
(byte) print_char::ch#1 reg byte a 4.0
|
|
(byte) print_char::ch#2 reg byte a 6.0
|
|
(byte*) print_char_cursor
|
|
(byte*) print_char_cursor#1 print_char_cursor zp ZP_WORD:6 11.0
|
|
(byte*) print_char_cursor#2 print_char_cursor zp ZP_WORD:6 3.3636363636363638
|
|
(byte*) print_char_cursor#28 print_char_cursor zp ZP_WORD:6 4.0
|
|
(byte*) print_char_cursor#29 print_char_cursor zp ZP_WORD:6 0.9999999999999999
|
|
(byte*) print_char_cursor#45 print_char_cursor zp ZP_WORD:6 4.0
|
|
(byte*~) print_char_cursor#48 print_char_cursor zp ZP_WORD:6 4.0
|
|
(void()) print_cls()
|
|
(label) print_cls::@return
|
|
(const byte[]) print_hextab print_hextab = (string) "0123456789abcdef"z
|
|
(byte*) print_line_cursor
|
|
(byte*) print_line_cursor#1 print_line_cursor zp ZP_WORD:4 4.111111111111112
|
|
(byte*) print_line_cursor#10 print_line_cursor zp ZP_WORD:4 24.0
|
|
(byte*) print_line_cursor#19 print_line_cursor zp ZP_WORD:4 4.0
|
|
(void()) print_ln()
|
|
(label) print_ln::@1
|
|
(label) print_ln::@return
|
|
(byte*) print_screen
|
|
(void()) print_str((byte*) print_str::str)
|
|
(label) print_str::@1
|
|
(label) print_str::@2
|
|
(label) print_str::@return
|
|
(byte*) print_str::str
|
|
(byte*) print_str::str#0 str zp ZP_WORD:2 22.0
|
|
(byte*) print_str::str#3 str zp ZP_WORD:2 11.5
|
|
(byte*) print_str::str#5 str zp ZP_WORD:2 2.0
|
|
|
|
reg byte x [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ]
|
|
reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ]
|
|
zp ZP_WORD:2 [ print_str::str#3 print_str::str#5 print_str::str#0 ]
|
|
zp ZP_WORD:4 [ memset::dst#2 memset::dst#1 print_line_cursor#10 print_line_cursor#19 print_line_cursor#1 ]
|
|
zp ZP_WORD:6 [ main::$0 print_char_cursor#28 print_char_cursor#2 print_char_cursor#29 print_char_cursor#45 print_char_cursor#48 print_char_cursor#1 ]
|
|
reg byte a [ print_byte::$0 ]
|
|
reg byte x [ print_byte::$2 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 1676
|
|
|
|
// File Comments
|
|
// Demonstrates problem with missing parenthesis in double-dereferencing
|
|
// https://gitlab.com/camelot/kickc/issues/270
|
|
// Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
// Global Constants & labels
|
|
.label print_char_cursor = 6
|
|
.label print_line_cursor = 4
|
|
// @begin
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
// @1
|
|
// [2] call main
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
// @end
|
|
// main
|
|
main: {
|
|
.label __0 = 6
|
|
// file->bufEdit = 0x4000
|
|
// [4] *((byte**)(const struct fileentry[$a]) files) ← (byte*) 16384 -- _deref_pptc1=pbuc2
|
|
lda #<$4000
|
|
sta files
|
|
lda #>$4000
|
|
sta files+1
|
|
// file->bufEdit[3] = 0xAA
|
|
// [5] *(*((byte**)(const struct fileentry[$a]) files) + (byte) 3) ← (byte) $aa -- (_deref_pptc1)_derefidx_vbuc2=vbuc3
|
|
lda #$aa
|
|
ldy #3
|
|
ldx files
|
|
stx.z $fe
|
|
ldx files+1
|
|
stx.z $ff
|
|
sta ($fe),y
|
|
// (char *)file->bufEdit
|
|
// [6] (byte*~) main::$0 ← *((byte**)(const struct fileentry[$a]) files) -- pbuz1=_deref_pptc1
|
|
lda files
|
|
sta.z __0
|
|
lda files+1
|
|
sta.z __0+1
|
|
// ((char *)file->bufEdit)[4] = 0xCC
|
|
// [7] *((byte*~) main::$0 + (byte) 4) ← (byte) $cc -- pbuz1_derefidx_vbuc1=vbuc2
|
|
// writes address 0x0000 (wrong!)
|
|
lda #$cc
|
|
ldy #4
|
|
sta (__0),y
|
|
// print_cls()
|
|
// [8] call print_cls
|
|
// [46] phi from main to print_cls [phi:main->print_cls]
|
|
jsr print_cls
|
|
// [9] phi from main to main::@1 [phi:main->main::@1]
|
|
// main::@1
|
|
// print_str("$0000=")
|
|
// [10] call print_str
|
|
// [39] phi from main::@1 to print_str [phi:main::@1->print_str]
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*) 1024 [phi:main::@1->print_str#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_char_cursor
|
|
lda #>$400
|
|
sta.z print_char_cursor+1
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str [phi:main::@1->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z print_str.str
|
|
lda #>str
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// main::@2
|
|
// print_byte(*(char *)0x0000)
|
|
// [11] (byte) print_byte::b#0 ← *((byte*) 0) -- vbuxx=_deref_pbuc1
|
|
ldx 0
|
|
// [12] call print_byte
|
|
// [27] phi from main::@2 to print_byte [phi:main::@2->print_byte]
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#0 [phi:main::@2->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [13] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
|
|
// main::@3
|
|
// print_ln()
|
|
// [14] call print_ln
|
|
// [22] phi from main::@3 to print_ln [phi:main::@3->print_ln]
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) 1024 [phi:main::@3->print_ln#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta.z print_line_cursor
|
|
lda #>$400
|
|
sta.z print_line_cursor+1
|
|
jsr print_ln
|
|
// main::@4
|
|
// [15] (byte*~) print_char_cursor#48 ← (byte*) print_line_cursor#1 -- 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("$4004=")
|
|
// [16] call print_str
|
|
// [39] phi from main::@4 to print_str [phi:main::@4->print_str]
|
|
// [39] phi (byte*) print_char_cursor#45 = (byte*~) print_char_cursor#48 [phi:main::@4->print_str#0] -- register_copy
|
|
// [39] phi (byte*) print_str::str#5 = (const string) main::str1 [phi:main::@4->print_str#1] -- pbuz1=pbuc1
|
|
lda #<str1
|
|
sta.z print_str.str
|
|
lda #>str1
|
|
sta.z print_str.str+1
|
|
jsr print_str
|
|
// main::@5
|
|
// print_byte(*(char *)0x4004)
|
|
// [17] (byte) print_byte::b#1 ← *((byte*) 16388) -- vbuxx=_deref_pbuc1
|
|
ldx $4004
|
|
// [18] call print_byte
|
|
// [27] phi from main::@5 to print_byte [phi:main::@5->print_byte]
|
|
// [27] phi (byte) print_byte::b#2 = (byte) print_byte::b#1 [phi:main::@5->print_byte#0] -- register_copy
|
|
jsr print_byte
|
|
// [19] phi from main::@5 to main::@6 [phi:main::@5->main::@6]
|
|
// main::@6
|
|
// print_ln()
|
|
// [20] call print_ln
|
|
// [22] phi from main::@6 to print_ln [phi:main::@6->print_ln]
|
|
// [22] phi (byte*) print_line_cursor#19 = (byte*) print_line_cursor#1 [phi:main::@6->print_ln#0] -- register_copy
|
|
jsr print_ln
|
|
// main::@return
|
|
// }
|
|
// [21] return
|
|
rts
|
|
str: .text "$0000="
|
|
.byte 0
|
|
str1: .text "$4004="
|
|
.byte 0
|
|
}
|
|
// print_ln
|
|
// Print a newline
|
|
print_ln: {
|
|
// [23] phi from print_ln print_ln::@1 to print_ln::@1 [phi:print_ln/print_ln::@1->print_ln::@1]
|
|
// [23] phi (byte*) print_line_cursor#10 = (byte*) print_line_cursor#19 [phi:print_ln/print_ln::@1->print_ln::@1#0] -- register_copy
|
|
// print_ln::@1
|
|
__b1:
|
|
// print_line_cursor + $28
|
|
// [24] (byte*) print_line_cursor#1 ← (byte*) print_line_cursor#10 + (byte) $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)
|
|
// [25] if((byte*) print_line_cursor#1<(byte*) print_char_cursor#29) 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
|
|
// }
|
|
// [26] return
|
|
rts
|
|
}
|
|
// print_byte
|
|
// Print a byte as HEX
|
|
// print_byte(byte register(X) b)
|
|
print_byte: {
|
|
// b>>4
|
|
// [28] (byte~) print_byte::$0 ← (byte) print_byte::b#2 >> (byte) 4 -- vbuaa=vbuxx_ror_4
|
|
txa
|
|
lsr
|
|
lsr
|
|
lsr
|
|
lsr
|
|
// print_char(print_hextab[b>>4])
|
|
// [29] (byte) print_char::ch#0 ← *((const byte[]) print_hextab + (byte~) print_byte::$0) -- vbuaa=pbuc1_derefidx_vbuaa
|
|
tay
|
|
lda print_hextab,y
|
|
// [30] call print_char
|
|
// [35] phi from print_byte to print_char [phi:print_byte->print_char]
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#2 [phi:print_byte->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#0 [phi:print_byte->print_char#1] -- register_copy
|
|
jsr print_char
|
|
// print_byte::@1
|
|
// b&$f
|
|
// [31] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f -- vbuxx=vbuxx_band_vbuc1
|
|
lda #$f
|
|
axs #0
|
|
// print_char(print_hextab[b&$f])
|
|
// [32] (byte) print_char::ch#1 ← *((const byte[]) print_hextab + (byte~) print_byte::$2) -- vbuaa=pbuc1_derefidx_vbuxx
|
|
lda print_hextab,x
|
|
// [33] call print_char
|
|
// [35] phi from print_byte::@1 to print_char [phi:print_byte::@1->print_char]
|
|
// [35] phi (byte*) print_char_cursor#28 = (byte*) print_char_cursor#29 [phi:print_byte::@1->print_char#0] -- register_copy
|
|
// [35] phi (byte) print_char::ch#2 = (byte) print_char::ch#1 [phi:print_byte::@1->print_char#1] -- register_copy
|
|
jsr print_char
|
|
// print_byte::@return
|
|
// }
|
|
// [34] return
|
|
rts
|
|
}
|
|
// print_char
|
|
// Print a single char
|
|
// print_char(byte register(A) ch)
|
|
print_char: {
|
|
// *(print_char_cursor++) = ch
|
|
// [36] *((byte*) print_char_cursor#28) ← (byte) print_char::ch#2 -- _deref_pbuz1=vbuaa
|
|
ldy #0
|
|
sta (print_char_cursor),y
|
|
// *(print_char_cursor++) = ch;
|
|
// [37] (byte*) print_char_cursor#29 ← ++ (byte*) print_char_cursor#28 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
// print_char::@return
|
|
// }
|
|
// [38] return
|
|
rts
|
|
}
|
|
// print_str
|
|
// Print a zero-terminated string
|
|
// print_str(byte* zeropage(2) str)
|
|
print_str: {
|
|
.label str = 2
|
|
// [40] phi from print_str print_str::@2 to print_str::@1 [phi:print_str/print_str::@2->print_str::@1]
|
|
// [40] phi (byte*) print_char_cursor#2 = (byte*) print_char_cursor#45 [phi:print_str/print_str::@2->print_str::@1#0] -- register_copy
|
|
// [40] phi (byte*) print_str::str#3 = (byte*) print_str::str#5 [phi:print_str/print_str::@2->print_str::@1#1] -- register_copy
|
|
// print_str::@1
|
|
__b1:
|
|
// while(*str)
|
|
// [41] if((byte) 0!=*((byte*) print_str::str#3)) goto print_str::@2 -- vbuc1_neq__deref_pbuz1_then_la1
|
|
ldy #0
|
|
lda (str),y
|
|
cmp #0
|
|
bne __b2
|
|
// print_str::@return
|
|
// }
|
|
// [42] return
|
|
rts
|
|
// print_str::@2
|
|
__b2:
|
|
// *(print_char_cursor++) = *(str++)
|
|
// [43] *((byte*) print_char_cursor#2) ← *((byte*) print_str::str#3) -- _deref_pbuz1=_deref_pbuz2
|
|
ldy #0
|
|
lda (str),y
|
|
sta (print_char_cursor),y
|
|
// *(print_char_cursor++) = *(str++);
|
|
// [44] (byte*) print_char_cursor#1 ← ++ (byte*) print_char_cursor#2 -- pbuz1=_inc_pbuz1
|
|
inc.z print_char_cursor
|
|
bne !+
|
|
inc.z print_char_cursor+1
|
|
!:
|
|
// [45] (byte*) print_str::str#0 ← ++ (byte*) print_str::str#3 -- pbuz1=_inc_pbuz1
|
|
inc.z str
|
|
bne !+
|
|
inc.z str+1
|
|
!:
|
|
jmp __b1
|
|
}
|
|
// print_cls
|
|
// Clear the screen. Also resets current line/char cursor.
|
|
print_cls: {
|
|
// memset(print_screen, ' ', 1000)
|
|
// [47] call memset
|
|
// [49] phi from print_cls to memset [phi:print_cls->memset]
|
|
jsr memset
|
|
// print_cls::@return
|
|
// }
|
|
// [48] return
|
|
rts
|
|
}
|
|
// memset
|
|
// Copies the character c (an unsigned char) to the first num characters of the object pointed to by the argument str.
|
|
memset: {
|
|
.const c = ' '
|
|
.const num = $3e8
|
|
.label str = $400
|
|
.label end = str+num
|
|
.label dst = 4
|
|
// [50] phi from memset to memset::@1 [phi:memset->memset::@1]
|
|
// [50] phi (byte*) memset::dst#2 = (byte*)(const void*) memset::str#0 [phi:memset->memset::@1#0] -- pbuz1=pbuc1
|
|
lda #<str
|
|
sta.z dst
|
|
lda #>str
|
|
sta.z dst+1
|
|
// memset::@1
|
|
__b1:
|
|
// for(char* dst = str; dst!=end; dst++)
|
|
// [51] if((byte*) memset::dst#2!=(const byte*) memset::end#0) goto memset::@2 -- pbuz1_neq_pbuc1_then_la1
|
|
lda.z dst+1
|
|
cmp #>end
|
|
bne __b2
|
|
lda.z dst
|
|
cmp #<end
|
|
bne __b2
|
|
// memset::@return
|
|
// }
|
|
// [52] return
|
|
rts
|
|
// memset::@2
|
|
__b2:
|
|
// *dst = c
|
|
// [53] *((byte*) memset::dst#2) ← (const byte) memset::c#0 -- _deref_pbuz1=vbuc1
|
|
lda #c
|
|
ldy #0
|
|
sta (dst),y
|
|
// for(char* dst = str; dst!=end; dst++)
|
|
// [54] (byte*) memset::dst#1 ← ++ (byte*) memset::dst#2 -- pbuz1=_inc_pbuz1
|
|
inc.z dst
|
|
bne !+
|
|
inc.z dst+1
|
|
!:
|
|
// [50] phi from memset::@2 to memset::@1 [phi:memset::@2->memset::@1]
|
|
// [50] phi (byte*) memset::dst#2 = (byte*) memset::dst#1 [phi:memset::@2->memset::@1#0] -- register_copy
|
|
jmp __b1
|
|
}
|
|
// File Data
|
|
print_hextab: .text "0123456789abcdef"
|
|
files: .fill 2*$a, 0
|
|
|