2018-04-26 23:09:34 +00:00
|
|
|
|
2018-08-22 22:24:32 +00:00
|
|
|
CONTROL FLOW GRAPH SSA
|
2018-04-26 23:09:34 +00:00
|
|
|
@begin: scope:[] from
|
2020-04-25 18:10:49 +00:00
|
|
|
to:@1
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2020-04-25 18:10:49 +00:00
|
|
|
main: scope:[main] from @1
|
2019-06-02 22:44:46 +00:00
|
|
|
(byte) main::i#0 ← (byte) 0
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@3
|
|
|
|
(byte) main::i#2 ← phi( main/(byte) main::i#0 main::@3/(byte) main::i#1 )
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) main::$0 ← (byte) main::i#2 & (number) 1
|
|
|
|
(bool~) main::$1 ← (number~) main::$0 == (number) 0
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) isSet::i#0 ← (byte) main::i#2
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::b#0 ← (bool~) main::$1
|
2018-05-01 20:50:59 +00:00
|
|
|
call isSet
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return#0 ← (bool) isSet::return#2
|
2020-04-25 18:10:49 +00:00
|
|
|
to:main::@5
|
|
|
|
main::@5: scope:[main] from main::@1
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) main::i#6 ← phi( main::@1/(byte) main::i#2 )
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return#3 ← phi( main::@1/(bool) isSet::return#0 )
|
|
|
|
(bool~) main::$2 ← (bool) isSet::return#3
|
|
|
|
if((bool~) main::$2) goto main::@2
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@4
|
2020-04-25 18:10:49 +00:00
|
|
|
main::@2: scope:[main] from main::@5
|
|
|
|
(byte) main::i#3 ← phi( main::@5/(byte) main::i#6 )
|
2019-11-03 16:05:55 +00:00
|
|
|
*((const byte*) main::screen + (byte) main::i#3) ← (byte) '*'
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@3
|
2020-04-25 18:10:49 +00:00
|
|
|
main::@4: scope:[main] from main::@5
|
|
|
|
(byte) main::i#4 ← phi( main::@5/(byte) main::i#6 )
|
2019-11-03 16:05:55 +00:00
|
|
|
*((const byte*) main::screen + (byte) main::i#4) ← (byte) ' '
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@2 main::@4
|
|
|
|
(byte) main::i#5 ← phi( main::@2/(byte) main::i#3 main::@4/(byte) main::i#4 )
|
2019-03-08 05:54:45 +00:00
|
|
|
(byte) main::i#1 ← (byte) main::i#5 + rangenext(0,$64)
|
|
|
|
(bool~) main::$3 ← (byte) main::i#1 != rangelast(0,$64)
|
2018-04-28 06:41:05 +00:00
|
|
|
if((bool~) main::$3) goto main::@1
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
|
|
|
return
|
|
|
|
to:@return
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
|
2018-04-26 23:09:34 +00:00
|
|
|
isSet: scope:[isSet] from main::@1
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::b#1 ← phi( main::@1/(bool) isSet::b#0 )
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) isSet::i#1 ← phi( main::@1/(byte) isSet::i#0 )
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) isSet::$0 ← (byte) isSet::i#1 & (number) 8
|
|
|
|
(bool~) isSet::$1 ← (number~) isSet::$0 != (number) 0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool~) isSet::$2 ← (bool) isSet::b#1 || (bool~) isSet::$1
|
|
|
|
(bool) isSet::return#1 ← (bool~) isSet::$2
|
2018-04-26 23:09:34 +00:00
|
|
|
to:isSet::@return
|
|
|
|
isSet::@return: scope:[isSet] from isSet
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return#4 ← phi( isSet/(bool) isSet::return#1 )
|
|
|
|
(bool) isSet::return#2 ← (bool) isSet::return#4
|
2018-04-26 23:09:34 +00:00
|
|
|
return
|
|
|
|
to:@return
|
2020-04-25 18:10:49 +00:00
|
|
|
@1: scope:[] from @begin
|
2018-05-01 20:50:59 +00:00
|
|
|
call main
|
2020-04-25 18:10:49 +00:00
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
2018-04-26 23:09:34 +00:00
|
|
|
to:@end
|
2020-04-25 18:10:49 +00:00
|
|
|
@end: scope:[] from @2
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
2020-04-25 18:10:49 +00:00
|
|
|
(label) @1
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) isSet::$0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool~) isSet::$1
|
|
|
|
(bool~) isSet::$2
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) isSet::@return
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::b
|
|
|
|
(bool) isSet::b#0
|
|
|
|
(bool) isSet::b#1
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) isSet::i
|
|
|
|
(byte) isSet::i#0
|
|
|
|
(byte) isSet::i#1
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return
|
|
|
|
(bool) isSet::return#0
|
|
|
|
(bool) isSet::return#1
|
|
|
|
(bool) isSet::return#2
|
|
|
|
(bool) isSet::return#3
|
|
|
|
(bool) isSet::return#4
|
2018-04-26 23:09:34 +00:00
|
|
|
(void()) main()
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) main::$0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool~) main::$1
|
|
|
|
(bool~) main::$2
|
|
|
|
(bool~) main::$3
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@4
|
2020-04-25 18:10:49 +00:00
|
|
|
(label) main::@5
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) main::@return
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#0
|
|
|
|
(byte) main::i#1
|
|
|
|
(byte) main::i#2
|
|
|
|
(byte) main::i#3
|
|
|
|
(byte) main::i#4
|
|
|
|
(byte) main::i#5
|
|
|
|
(byte) main::i#6
|
2019-11-03 16:05:55 +00:00
|
|
|
(const byte*) main::screen = (byte*)(number) $400
|
2018-04-26 23:09:34 +00:00
|
|
|
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding number conversion cast (unumber) 1 in (number~) main::$0 ← (byte) main::i#2 & (number) 1
|
|
|
|
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::i#2 & (unumber)(number) 1
|
|
|
|
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (unumber~) main::$0 == (number) 0
|
|
|
|
Adding number conversion cast (unumber) 8 in (number~) isSet::$0 ← (byte) isSet::i#1 & (number) 8
|
|
|
|
Adding number conversion cast (unumber) isSet::$0 in (number~) isSet::$0 ← (byte) isSet::i#1 & (unumber)(number) 8
|
|
|
|
Adding number conversion cast (unumber) 0 in (bool~) isSet::$1 ← (unumber~) isSet::$0 != (number) 0
|
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Simplifying constant integer cast 8
|
|
|
|
Simplifying constant integer cast 0
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Finalized unsigned number type (byte) 8
|
|
|
|
Finalized unsigned number type (byte) 0
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
|
|
|
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::i#2 & (byte) 1
|
|
|
|
Inferred type updated to byte in (unumber~) isSet::$0 ← (byte) isSet::i#1 & (byte) 8
|
2020-03-22 21:26:39 +00:00
|
|
|
Alias isSet::b#0 = main::$1
|
|
|
|
Alias isSet::return#0 = isSet::return#3
|
|
|
|
Alias main::i#2 = main::i#6 main::i#3 main::i#4
|
|
|
|
Alias isSet::return#1 = isSet::$2 isSet::return#4 isSet::return#2
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2020-03-22 21:26:39 +00:00
|
|
|
Alias main::i#2 = main::i#5
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
Identical Phi Values (byte) isSet::i#1 (byte) isSet::i#0
|
|
|
|
Identical Phi Values (bool) isSet::b#1 (bool) isSet::b#0
|
|
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
2020-02-22 19:45:35 +00:00
|
|
|
Simple Condition (bool~) main::$3 [13] if((byte) main::i#1!=rangelast(0,$64)) goto main::@1
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
2018-04-26 23:09:34 +00:00
|
|
|
Constant (const byte) main::i#0 = 0
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2020-02-22 19:45:35 +00:00
|
|
|
Resolved ranged next value [11] main::i#1 ← ++ main::i#2 to ++
|
|
|
|
Resolved ranged comparison value [13] if(main::i#1!=rangelast(0,$64)) goto main::@1 to (number) $65
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding number conversion cast (unumber) $65 in if((byte) main::i#1!=(number) $65) goto main::@1
|
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
|
|
Simplifying constant integer cast $65
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) $65
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2018-04-26 23:09:34 +00:00
|
|
|
Inlining constant with var siblings (const byte) main::i#0
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant inlined main::i#0 = (byte) 0
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2ConstantInlining
|
2020-04-25 18:10:49 +00:00
|
|
|
Added new block during phi lifting main::@6(between main::@3 and main::@1)
|
2018-04-26 23:09:34 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2020-04-25 18:10:49 +00:00
|
|
|
Adding NOP phi() at start of @1
|
2018-04-26 23:09:34 +00:00
|
|
|
Adding NOP phi() at start of @2
|
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
CALL GRAPH
|
|
|
|
Calls in [] to main:2
|
2019-05-30 20:29:04 +00:00
|
|
|
Calls in [main] to isSet:10
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
Created 1 initial phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Coalesced [18] main::i#7 ← main::i#1
|
2018-04-26 23:09:34 +00:00
|
|
|
Coalesced down to 1 phi equivalence classes
|
2020-04-25 18:10:49 +00:00
|
|
|
Culled Empty Block (label) @2
|
|
|
|
Culled Empty Block (label) main::@6
|
2018-04-26 23:09:34 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
2019-03-31 15:10:41 +00:00
|
|
|
Adding NOP phi() at start of @1
|
2018-04-26 23:09:34 +00:00
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
2018-11-11 20:51:36 +00:00
|
|
|
[0] phi()
|
2019-03-31 15:10:41 +00:00
|
|
|
to:@1
|
|
|
|
@1: scope:[] from @begin
|
2018-11-11 20:51:36 +00:00
|
|
|
[1] phi()
|
|
|
|
[2] call main
|
2018-04-26 23:09:34 +00:00
|
|
|
to:@end
|
2019-03-31 15:10:41 +00:00
|
|
|
@end: scope:[] from @1
|
2018-11-11 20:51:36 +00:00
|
|
|
[3] phi()
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2019-03-31 15:10:41 +00:00
|
|
|
main: scope:[main] from @1
|
2018-11-11 20:51:36 +00:00
|
|
|
[4] phi()
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@3
|
2019-05-30 20:29:04 +00:00
|
|
|
[5] (byte) main::i#2 ← phi( main/(byte) 0 main::@3/(byte) main::i#1 )
|
|
|
|
[6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1
|
|
|
|
[7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0
|
2018-11-11 20:51:36 +00:00
|
|
|
[8] (byte) isSet::i#0 ← (byte) main::i#2
|
|
|
|
[9] call isSet
|
|
|
|
[10] (bool) isSet::return#0 ← (bool) isSet::return#1
|
2019-03-31 15:10:41 +00:00
|
|
|
to:main::@5
|
|
|
|
main::@5: scope:[main] from main::@1
|
2018-11-11 20:51:36 +00:00
|
|
|
[11] (bool~) main::$2 ← (bool) isSet::return#0
|
|
|
|
[12] if((bool~) main::$2) goto main::@2
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@4
|
2019-03-31 15:10:41 +00:00
|
|
|
main::@4: scope:[main] from main::@5
|
2019-09-29 20:36:00 +00:00
|
|
|
[13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' '
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@2 main::@4
|
2018-11-11 20:51:36 +00:00
|
|
|
[14] (byte) main::i#1 ← ++ (byte) main::i#2
|
2019-05-30 20:29:04 +00:00
|
|
|
[15] if((byte) main::i#1!=(byte) $65) goto main::@1
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
2018-11-11 20:51:36 +00:00
|
|
|
[16] return
|
2018-04-26 23:09:34 +00:00
|
|
|
to:@return
|
2019-03-31 15:10:41 +00:00
|
|
|
main::@2: scope:[main] from main::@5
|
2019-09-29 20:36:00 +00:00
|
|
|
[17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*'
|
2018-04-26 23:09:34 +00:00
|
|
|
to:main::@3
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
|
2018-04-26 23:09:34 +00:00
|
|
|
isSet: scope:[isSet] from main::@1
|
2019-05-30 20:29:04 +00:00
|
|
|
[18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8
|
|
|
|
[19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0
|
2018-11-11 20:51:36 +00:00
|
|
|
[20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1
|
2018-04-26 23:09:34 +00:00
|
|
|
to:isSet::@return
|
|
|
|
isSet::@return: scope:[isSet] from isSet
|
2018-11-11 20:51:36 +00:00
|
|
|
[21] return
|
2018-04-26 23:09:34 +00:00
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) isSet::$0 2002.0
|
|
|
|
(bool~) isSet::$1 2002.0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::b
|
2020-03-22 21:26:39 +00:00
|
|
|
(bool) isSet::b#0 275.5
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) isSet::i
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) isSet::i#0 1102.0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return
|
2020-03-22 21:26:39 +00:00
|
|
|
(bool) isSet::return#0 202.0
|
|
|
|
(bool) isSet::return#1 367.33333333333337
|
2018-04-26 23:09:34 +00:00
|
|
|
(void()) main()
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) main::$0 202.0
|
|
|
|
(bool~) main::$2 202.0
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) main::i
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::i#1 151.5
|
|
|
|
(byte) main::i#2 60.6
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
[ main::i#2 main::i#1 ]
|
2019-12-08 15:04:35 +00:00
|
|
|
Added variable main::$0 to live range equivalence class [ main::$0 ]
|
|
|
|
Added variable isSet::b#0 to live range equivalence class [ isSet::b#0 ]
|
|
|
|
Added variable isSet::i#0 to live range equivalence class [ isSet::i#0 ]
|
|
|
|
Added variable isSet::return#0 to live range equivalence class [ isSet::return#0 ]
|
|
|
|
Added variable main::$2 to live range equivalence class [ main::$2 ]
|
|
|
|
Added variable isSet::$0 to live range equivalence class [ isSet::$0 ]
|
|
|
|
Added variable isSet::$1 to live range equivalence class [ isSet::$1 ]
|
|
|
|
Added variable isSet::return#1 to live range equivalence class [ isSet::return#1 ]
|
2018-04-26 23:09:34 +00:00
|
|
|
Complete equivalence classes
|
|
|
|
[ main::i#2 main::i#1 ]
|
|
|
|
[ main::$0 ]
|
|
|
|
[ isSet::b#0 ]
|
|
|
|
[ isSet::i#0 ]
|
|
|
|
[ isSet::return#0 ]
|
|
|
|
[ main::$2 ]
|
|
|
|
[ isSet::$0 ]
|
|
|
|
[ isSet::$1 ]
|
|
|
|
[ isSet::return#1 ]
|
2019-10-12 09:40:36 +00:00
|
|
|
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
|
|
|
|
Allocated zp[1]:3 [ main::$0 ]
|
|
|
|
Allocated zp[1]:4 [ isSet::b#0 ]
|
|
|
|
Allocated zp[1]:5 [ isSet::i#0 ]
|
|
|
|
Allocated zp[1]:6 [ isSet::return#0 ]
|
|
|
|
Allocated zp[1]:7 [ main::$2 ]
|
|
|
|
Allocated zp[1]:8 [ isSet::$0 ]
|
|
|
|
Allocated zp[1]:9 [ isSet::$1 ]
|
|
|
|
Allocated zp[1]:10 [ isSet::return#1 ]
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
INITIAL ASM
|
2019-09-08 00:29:17 +00:00
|
|
|
Target platform is c64basic / MOS6502X
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// Test a function taking boolean parameter and returning boolean result
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-04-26 23:09:34 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-04-26 23:09:34 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
2019-09-29 21:13:37 +00:00
|
|
|
main_from___b1:
|
2018-04-26 23:09:34 +00:00
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2018-04-26 23:09:34 +00:00
|
|
|
main: {
|
|
|
|
.label screen = $400
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __0 = 3
|
|
|
|
.label __2 = 7
|
2018-04-26 23:09:34 +00:00
|
|
|
.label i = 2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from_main:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuz1=vbuz2_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #1
|
2019-08-07 19:00:19 +00:00
|
|
|
and.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __0
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboz1=vbuz2_eq_vbuc1
|
2019-09-29 21:13:37 +00:00
|
|
|
lda.z __0
|
2019-03-08 05:33:59 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
|
|
|
eor #1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z isSet.b
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte) isSet::i#0 ← (byte) main::i#2 -- vbuz1=vbuz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z i
|
|
|
|
sta.z isSet.i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [9] call isSet
|
2018-04-26 23:09:34 +00:00
|
|
|
jsr isSet
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] (bool) isSet::return#0 ← (bool) isSet::return#1 -- vboz1=vboz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z isSet.return_1
|
|
|
|
sta.z isSet.return
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b5
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@5
|
2019-09-29 21:13:37 +00:00
|
|
|
__b5:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] (bool~) main::$2 ← (bool) isSet::return#0 -- vboz1=vboz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z isSet.return
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [12] if((bool~) main::$2) goto main::@2 -- vboz1_then_la1
|
2019-09-29 21:13:37 +00:00
|
|
|
lda.z __2
|
2018-04-26 23:09:34 +00:00
|
|
|
cmp #0
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
|
|
|
jmp __b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
2019-09-29 21:13:37 +00:00
|
|
|
__b4:
|
2019-09-29 20:36:00 +00:00
|
|
|
// [13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuz1=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #' '
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z i
|
2018-04-26 23:09:34 +00:00
|
|
|
sta screen,y
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #$65
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1_from___b3
|
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [16] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-09-29 20:36:00 +00:00
|
|
|
// [17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuz1=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #'*'
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z i
|
2018-04-26 23:09:34 +00:00
|
|
|
sta screen,y
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
2018-04-26 23:09:34 +00:00
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet
|
2019-02-17 23:12:29 +00:00
|
|
|
// Determine whether to set a char to '*.
|
|
|
|
// Returns true if i&8!=0 or b=true
|
2019-12-26 08:51:41 +00:00
|
|
|
// isSet(byte zp(5) i, bool zp(4) b)
|
2018-04-26 23:09:34 +00:00
|
|
|
isSet: {
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __0 = 8
|
|
|
|
.label __1 = 9
|
2018-04-26 23:09:34 +00:00
|
|
|
.label i = 5
|
|
|
|
.label b = 4
|
|
|
|
.label return = 6
|
|
|
|
.label return_1 = $a
|
2019-07-08 14:43:09 +00:00
|
|
|
// [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuz1=vbuz2_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #8
|
2019-08-07 19:00:19 +00:00
|
|
|
and.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __0
|
2019-07-08 14:43:09 +00:00
|
|
|
// [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboz1=vbuz2_neq_vbuc1
|
2019-09-29 21:13:37 +00:00
|
|
|
lda.z __0
|
2019-03-17 21:49:02 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboz1=vboz2_or_vboz3
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z b
|
2019-09-29 21:13:37 +00:00
|
|
|
ora.z __1
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z return_1
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [21] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 [ main::i#2 isSet::b#0 ] ( main:2 [ main::i#2 isSet::b#0 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
2019-10-12 09:40:36 +00:00
|
|
|
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' ' [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
|
|
Statement [17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
|
|
Statement [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 [ isSet::b#0 isSet::$1 ] ( main:2::isSet:9 [ main::i#2 isSet::b#0 isSet::$1 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
2019-10-12 09:40:36 +00:00
|
|
|
Removing always clobbered register reg byte a as potential for zp[1]:4 [ isSet::b#0 ]
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 [ isSet::return#1 ] ( main:2::isSet:9 [ main::i#2 isSet::return#1 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
|
|
|
Statement [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 [ main::i#2 main::$0 ] ( main:2 [ main::i#2 main::$0 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
|
|
|
Statement [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 [ main::i#2 isSet::b#0 ] ( main:2 [ main::i#2 isSet::b#0 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
|
|
|
Statement [13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' ' [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
|
|
Statement [17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*' [ main::i#2 ] ( main:2 [ main::i#2 ] { } ) always clobbers reg byte a
|
|
|
|
Statement [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 [ isSet::b#0 isSet::$1 ] ( main:2::isSet:9 [ main::i#2 isSet::b#0 isSet::$1 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
|
|
|
Statement [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 [ isSet::return#1 ] ( main:2::isSet:9 [ main::i#2 isSet::return#1 ] { { isSet::i#0 = main::i#2 } { isSet::return#0 = isSet::return#1 } } ) always clobbers reg byte a
|
2019-10-12 09:40:36 +00:00
|
|
|
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:3 [ main::$0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:4 [ isSet::b#0 ] : zp[1]:4 , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:5 [ isSet::i#0 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:6 [ isSet::return#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:7 [ main::$2 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:8 [ isSet::$0 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:9 [ isSet::$1 ] : zp[1]:9 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:10 [ isSet::return#1 ] : zp[1]:10 , reg byte a , reg byte x , reg byte y ,
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplift Scope [isSet] 2,002: zp[1]:8 [ isSet::$0 ] 2,002: zp[1]:9 [ isSet::$1 ] 1,102: zp[1]:5 [ isSet::i#0 ] 367.33: zp[1]:10 [ isSet::return#1 ] 275.5: zp[1]:4 [ isSet::b#0 ] 202: zp[1]:6 [ isSet::return#0 ]
|
|
|
|
Uplift Scope [main] 212.1: zp[1]:2 [ main::i#2 main::i#1 ] 202: zp[1]:3 [ main::$0 ] 202: zp[1]:7 [ main::$2 ]
|
2018-04-26 23:09:34 +00:00
|
|
|
Uplift Scope []
|
|
|
|
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplifting [isSet] best 1103 combination reg byte a [ isSet::$0 ] reg byte a [ isSet::$1 ] reg byte a [ isSet::i#0 ] reg byte a [ isSet::return#1 ] zp[1]:4 [ isSet::b#0 ] zp[1]:6 [ isSet::return#0 ]
|
2019-10-06 20:41:21 +00:00
|
|
|
Limited combination testing to 100 combinations of 3072 possible.
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplifting [main] best 813 combination reg byte x [ main::i#2 main::i#1 ] reg byte a [ main::$0 ] reg byte a [ main::$2 ]
|
|
|
|
Uplifting [] best 813 combination
|
2019-10-12 09:40:36 +00:00
|
|
|
Attempting to uplift remaining variables inzp[1]:4 [ isSet::b#0 ]
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplifting [isSet] best 806 combination reg byte y [ isSet::b#0 ]
|
|
|
|
Attempting to uplift remaining variables inzp[1]:6 [ isSet::return#0 ]
|
|
|
|
Uplifting [isSet] best 746 combination reg byte a [ isSet::return#0 ]
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// Test a function taking boolean parameter and returning boolean result
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-04-26 23:09:34 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-04-26 23:09:34 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
2019-09-29 21:13:37 +00:00
|
|
|
__bbegin:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___bbegin:
|
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// @1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
2019-09-29 21:13:37 +00:00
|
|
|
main_from___b1:
|
2018-04-26 23:09:34 +00:00
|
|
|
jsr main
|
2019-07-08 14:43:09 +00:00
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend_from___b1:
|
|
|
|
jmp __bend
|
2019-07-08 14:43:09 +00:00
|
|
|
// @end
|
2019-09-29 21:13:37 +00:00
|
|
|
__bend:
|
2019-07-08 14:43:09 +00:00
|
|
|
// main
|
2018-04-26 23:09:34 +00:00
|
|
|
main: {
|
|
|
|
.label screen = $400
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from_main:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
ldx #0
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from___b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
txa
|
|
|
|
and #1
|
2019-10-06 19:11:56 +00:00
|
|
|
// [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboyy=vbuaa_eq_vbuc1
|
2019-03-08 05:33:59 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
|
|
|
eor #1
|
2019-10-06 19:11:56 +00:00
|
|
|
tay
|
2020-03-22 21:26:39 +00:00
|
|
|
// [8] (byte) isSet::i#0 ← (byte) main::i#2 -- vbuaa=vbuxx
|
|
|
|
txa
|
2019-07-08 14:43:09 +00:00
|
|
|
// [9] call isSet
|
2018-04-26 23:09:34 +00:00
|
|
|
jsr isSet
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] (bool) isSet::return#0 ← (bool) isSet::return#1
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b5
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@5
|
2019-09-29 21:13:37 +00:00
|
|
|
__b5:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] (bool~) main::$2 ← (bool) isSet::return#0
|
|
|
|
// [12] if((bool~) main::$2) goto main::@2 -- vboaa_then_la1
|
2018-04-26 23:09:34 +00:00
|
|
|
cmp #0
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
|
|
|
jmp __b4
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
2019-09-29 21:13:37 +00:00
|
|
|
__b4:
|
2019-09-29 20:36:00 +00:00
|
|
|
// [13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #' '
|
|
|
|
sta screen,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
2018-04-26 23:09:34 +00:00
|
|
|
inx
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
2018-04-26 23:09:34 +00:00
|
|
|
cpx #$65
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1_from___b3
|
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [16] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-09-29 20:36:00 +00:00
|
|
|
// [17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #'*'
|
|
|
|
sta screen,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
2018-04-26 23:09:34 +00:00
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet
|
2019-02-17 23:12:29 +00:00
|
|
|
// Determine whether to set a char to '*.
|
|
|
|
// Returns true if i&8!=0 or b=true
|
2020-03-22 21:26:39 +00:00
|
|
|
// isSet(byte register(A) i, bool register(Y) b)
|
2018-04-26 23:09:34 +00:00
|
|
|
isSet: {
|
2020-03-22 21:26:39 +00:00
|
|
|
// [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuaa=vbuaa_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
and #8
|
2019-07-08 14:43:09 +00:00
|
|
|
// [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboaa=vbuaa_neq_vbuc1
|
2019-03-17 21:49:02 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
2019-10-06 19:11:56 +00:00
|
|
|
// [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboaa=vboyy_or_vboaa
|
|
|
|
sty.z $ff
|
|
|
|
ora.z $ff
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [21] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __bend
|
|
|
|
Removing instruction jmp __b1
|
|
|
|
Removing instruction jmp __b5
|
|
|
|
Removing instruction jmp __b4
|
|
|
|
Removing instruction jmp __b3
|
|
|
|
Removing instruction jmp __breturn
|
|
|
|
Removing instruction jmp __breturn
|
2018-04-26 23:09:34 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Replacing label __b1_from___b3 with __b1
|
|
|
|
Removing instruction __b1_from___bbegin:
|
2020-03-03 07:58:31 +00:00
|
|
|
Removing instruction __b1:
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction main_from___b1:
|
|
|
|
Removing instruction __bend_from___b1:
|
|
|
|
Removing instruction __b1_from___b3:
|
2018-04-26 23:09:34 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
2020-05-11 00:36:37 +00:00
|
|
|
Removing instruction __bbegin:
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __bend:
|
|
|
|
Removing instruction __b1_from_main:
|
|
|
|
Removing instruction __b5:
|
|
|
|
Removing instruction __b4:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Removing instruction __breturn:
|
2018-04-26 23:09:34 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
2018-12-25 16:04:50 +00:00
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction jmp __b1
|
2018-04-26 23:09:34 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
2019-03-31 15:10:41 +00:00
|
|
|
(label) @1
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool()) isSet((byte) isSet::i , (bool) isSet::b)
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) isSet::$0 reg byte a 2002.0
|
|
|
|
(bool~) isSet::$1 reg byte a 2002.0
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) isSet::@return
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::b
|
2020-03-22 21:26:39 +00:00
|
|
|
(bool) isSet::b#0 reg byte y 275.5
|
2018-04-26 23:09:34 +00:00
|
|
|
(byte) isSet::i
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) isSet::i#0 reg byte a 1102.0
|
2018-04-28 06:41:05 +00:00
|
|
|
(bool) isSet::return
|
2020-03-22 21:26:39 +00:00
|
|
|
(bool) isSet::return#0 reg byte a 202.0
|
|
|
|
(bool) isSet::return#1 reg byte a 367.33333333333337
|
2018-04-26 23:09:34 +00:00
|
|
|
(void()) main()
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) main::$0 reg byte a 202.0
|
|
|
|
(bool~) main::$2 reg byte a 202.0
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@4
|
2019-03-31 15:10:41 +00:00
|
|
|
(label) main::@5
|
2018-04-26 23:09:34 +00:00
|
|
|
(label) main::@return
|
|
|
|
(byte) main::i
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::i#1 reg byte x 151.5
|
|
|
|
(byte) main::i#2 reg byte x 60.6
|
2019-10-13 22:51:15 +00:00
|
|
|
(const byte*) main::screen = (byte*) 1024
|
2018-04-26 23:09:34 +00:00
|
|
|
|
|
|
|
reg byte x [ main::i#2 main::i#1 ]
|
|
|
|
reg byte a [ main::$0 ]
|
2019-10-06 19:11:56 +00:00
|
|
|
reg byte y [ isSet::b#0 ]
|
2020-03-22 21:26:39 +00:00
|
|
|
reg byte a [ isSet::i#0 ]
|
2018-04-26 23:09:34 +00:00
|
|
|
reg byte a [ isSet::return#0 ]
|
|
|
|
reg byte a [ main::$2 ]
|
|
|
|
reg byte a [ isSet::$0 ]
|
|
|
|
reg byte a [ isSet::$1 ]
|
|
|
|
reg byte a [ isSet::return#1 ]
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
2020-03-22 21:26:39 +00:00
|
|
|
Score: 551
|
2018-04-26 23:09:34 +00:00
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// Test a function taking boolean parameter and returning boolean result
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-04-26 23:09:34 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
|
|
|
// @begin
|
|
|
|
// [1] phi from @begin to @1 [phi:@begin->@1]
|
|
|
|
// @1
|
|
|
|
// [2] call main
|
|
|
|
// [4] phi from @1 to main [phi:@1->main]
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
// @end
|
|
|
|
// main
|
2018-04-26 23:09:34 +00:00
|
|
|
main: {
|
|
|
|
.label screen = $400
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
|
|
|
// [5] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
ldx #0
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main::@3 to main::@1 [phi:main::@3->main::@1]
|
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@3->main::@1#0] -- register_copy
|
|
|
|
// main::@1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// i&1
|
|
|
|
// [6] (byte~) main::$0 ← (byte) main::i#2 & (byte) 1 -- vbuaa=vbuxx_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
txa
|
|
|
|
and #1
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet(i, (i&1)==0)
|
2019-10-06 19:11:56 +00:00
|
|
|
// [7] (bool) isSet::b#0 ← (byte~) main::$0 == (byte) 0 -- vboyy=vbuaa_eq_vbuc1
|
2019-03-08 05:33:59 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
|
|
|
eor #1
|
2019-10-06 19:11:56 +00:00
|
|
|
tay
|
2020-03-22 21:26:39 +00:00
|
|
|
// [8] (byte) isSet::i#0 ← (byte) main::i#2 -- vbuaa=vbuxx
|
|
|
|
txa
|
2019-07-08 14:43:09 +00:00
|
|
|
// [9] call isSet
|
2018-04-26 23:09:34 +00:00
|
|
|
jsr isSet
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] (bool) isSet::return#0 ← (bool) isSet::return#1
|
|
|
|
// main::@5
|
|
|
|
// [11] (bool~) main::$2 ← (bool) isSet::return#0
|
|
|
|
// if( isSet(i, (i&1)==0))
|
|
|
|
// [12] if((bool~) main::$2) goto main::@2 -- vboaa_then_la1
|
2018-04-26 23:09:34 +00:00
|
|
|
cmp #0
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@4
|
|
|
|
// screen[i] = ' '
|
2019-09-29 20:36:00 +00:00
|
|
|
// [13] *((const byte*) main::screen + (byte) main::i#2) ← (byte) ' ' -- pbuc1_derefidx_vbuxx=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #' '
|
|
|
|
sta screen,x
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2019-07-08 14:43:09 +00:00
|
|
|
// for(byte i: 0..100)
|
|
|
|
// [14] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx
|
2018-04-26 23:09:34 +00:00
|
|
|
inx
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] if((byte) main::i#1!=(byte) $65) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
2018-04-26 23:09:34 +00:00
|
|
|
cpx #$65
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [16] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// screen[i] = '*'
|
2019-09-29 20:36:00 +00:00
|
|
|
// [17] *((const byte*) main::screen + (byte) main::i#2) ← (byte) '*' -- pbuc1_derefidx_vbuxx=vbuc2
|
2018-04-26 23:09:34 +00:00
|
|
|
lda #'*'
|
|
|
|
sta screen,x
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b3
|
2018-04-26 23:09:34 +00:00
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet
|
2019-02-17 23:12:29 +00:00
|
|
|
// Determine whether to set a char to '*.
|
|
|
|
// Returns true if i&8!=0 or b=true
|
2020-03-22 21:26:39 +00:00
|
|
|
// isSet(byte register(A) i, bool register(Y) b)
|
2018-04-26 23:09:34 +00:00
|
|
|
isSet: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// i&8
|
2020-03-22 21:26:39 +00:00
|
|
|
// [18] (byte~) isSet::$0 ← (byte) isSet::i#0 & (byte) 8 -- vbuaa=vbuaa_band_vbuc1
|
2018-04-26 23:09:34 +00:00
|
|
|
and #8
|
2019-07-08 14:43:09 +00:00
|
|
|
// (i&8)!=0
|
|
|
|
// [19] (bool~) isSet::$1 ← (byte~) isSet::$0 != (byte) 0 -- vboaa=vbuaa_neq_vbuc1
|
2019-03-17 21:49:02 +00:00
|
|
|
eor #0
|
2018-04-26 23:09:34 +00:00
|
|
|
beq !+
|
|
|
|
lda #1
|
|
|
|
!:
|
2019-07-08 14:43:09 +00:00
|
|
|
// b || ((i&8)!=0)
|
2019-10-06 19:11:56 +00:00
|
|
|
// [20] (bool) isSet::return#1 ← (bool) isSet::b#0 || (bool~) isSet::$1 -- vboaa=vboyy_or_vboaa
|
|
|
|
sty.z $ff
|
|
|
|
ora.z $ff
|
2019-07-08 14:43:09 +00:00
|
|
|
// isSet::@return
|
|
|
|
// }
|
|
|
|
// [21] return
|
2018-04-26 23:09:34 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-04-26 23:09:34 +00:00
|
|
|
|