2018-07-21 09:13:32 +00:00
|
|
|
|
2018-08-22 22:24:32 +00:00
|
|
|
CONTROL FLOW GRAPH SSA
|
2018-07-21 09:13:32 +00:00
|
|
|
@begin: scope:[] from
|
|
|
|
to:@1
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2018-07-21 09:13:32 +00:00
|
|
|
main: scope:[main] from @1
|
2019-11-18 21:02:29 +00:00
|
|
|
(byte*) main::cur_item#0 ← (const byte*) items
|
2019-06-02 22:44:46 +00:00
|
|
|
(byte) main::item#0 ← (byte) 0
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@3
|
|
|
|
(byte*) main::cur_item#4 ← phi( main/(byte*) main::cur_item#0 main::@3/(byte*) main::cur_item#1 )
|
|
|
|
(byte) main::item#4 ← phi( main/(byte) main::item#0 main::@3/(byte) main::item#1 )
|
2019-06-02 22:44:46 +00:00
|
|
|
(byte) main::sub#0 ← (byte) 0
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1 main::@2
|
|
|
|
(byte*) main::cur_item#2 ← phi( main::@1/(byte*) main::cur_item#4 main::@2/(byte*) main::cur_item#2 )
|
|
|
|
(byte) main::sub#2 ← phi( main::@1/(byte) main::sub#0 main::@2/(byte) main::sub#1 )
|
|
|
|
(byte) main::item#2 ← phi( main::@1/(byte) main::item#4 main::@2/(byte) main::item#2 )
|
2019-11-18 21:02:29 +00:00
|
|
|
(number~) main::$0 ← (byte) main::item#2 * (number) $10
|
|
|
|
(number~) main::$1 ← (number~) main::$0 | (byte) main::sub#2
|
|
|
|
*((byte*) main::cur_item#2 + (byte) main::sub#2) ← (number~) main::$1
|
|
|
|
(byte) main::sub#1 ← (byte) main::sub#2 + rangenext(0,ITEM_SIZE-1)
|
|
|
|
(bool~) main::$2 ← (byte) main::sub#1 != rangelast(0,ITEM_SIZE-1)
|
|
|
|
if((bool~) main::$2) goto main::@2
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@2
|
|
|
|
(byte) main::item#3 ← phi( main::@2/(byte) main::item#2 )
|
|
|
|
(byte*) main::cur_item#3 ← phi( main::@2/(byte*) main::cur_item#2 )
|
2020-03-29 19:00:25 +00:00
|
|
|
(byte*) main::cur_item#1 ← (byte*) main::cur_item#3 + (const nomodify byte) ITEM_SIZE
|
2019-11-18 21:02:29 +00:00
|
|
|
(byte) main::item#1 ← (byte) main::item#3 + rangenext(0,ITEM_COUNT-1)
|
|
|
|
(bool~) main::$3 ← (byte) main::item#1 != rangelast(0,ITEM_COUNT-1)
|
|
|
|
if((bool~) main::$3) goto main::@1
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@1: scope:[] from @begin
|
|
|
|
call main
|
|
|
|
to:@2
|
|
|
|
@2: scope:[] from @1
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @2
|
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
|
|
|
(label) @1
|
|
|
|
(label) @2
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte) ITEM_COUNT = (byte) 3
|
|
|
|
(const nomodify byte) ITEM_SIZE = (byte) 5
|
|
|
|
(const byte*) items[(const nomodify byte) ITEM_COUNT*(const nomodify byte) ITEM_SIZE] = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }
|
2018-07-21 09:13:32 +00:00
|
|
|
(void()) main()
|
2019-05-30 20:29:04 +00:00
|
|
|
(number~) main::$0
|
|
|
|
(number~) main::$1
|
2019-11-18 21:02:29 +00:00
|
|
|
(bool~) main::$2
|
|
|
|
(bool~) main::$3
|
2018-07-21 09:13:32 +00:00
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@return
|
|
|
|
(byte*) main::cur_item
|
|
|
|
(byte*) main::cur_item#0
|
|
|
|
(byte*) main::cur_item#1
|
|
|
|
(byte*) main::cur_item#2
|
|
|
|
(byte*) main::cur_item#3
|
|
|
|
(byte*) main::cur_item#4
|
|
|
|
(byte) main::item
|
|
|
|
(byte) main::item#0
|
|
|
|
(byte) main::item#1
|
|
|
|
(byte) main::item#2
|
|
|
|
(byte) main::item#3
|
|
|
|
(byte) main::item#4
|
|
|
|
(byte) main::sub
|
|
|
|
(byte) main::sub#0
|
|
|
|
(byte) main::sub#1
|
|
|
|
(byte) main::sub#2
|
|
|
|
|
2019-11-18 21:02:29 +00:00
|
|
|
Adding number conversion cast (unumber) $10 in (number~) main::$0 ← (byte) main::item#2 * (number) $10
|
|
|
|
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (byte) main::item#2 * (unumber)(number) $10
|
|
|
|
Adding number conversion cast (unumber) main::$1 in (number~) main::$1 ← (unumber~) main::$0 | (byte) main::sub#2
|
|
|
|
Adding number conversion cast (unumber) 1 in (byte) main::sub#1 ← (byte) main::sub#2 + rangenext(0,ITEM_SIZE-1)
|
|
|
|
Adding number conversion cast (unumber) 1 in (byte) main::item#1 ← (byte) main::item#3 + rangenext(0,ITEM_COUNT-1)
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2019-11-18 21:02:29 +00:00
|
|
|
Simplifying constant integer cast $10
|
2019-05-30 20:29:04 +00:00
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
2019-11-18 21:02:29 +00:00
|
|
|
Finalized unsigned number type (byte) $10
|
2019-05-30 20:29:04 +00:00
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2019-11-18 21:02:29 +00:00
|
|
|
Inferred type updated to byte in (unumber~) main::$0 ← (byte) main::item#2 * (byte) $10
|
|
|
|
Inferred type updated to byte in (unumber~) main::$1 ← (byte~) main::$0 | (byte) main::sub#2
|
2020-03-22 21:26:39 +00:00
|
|
|
Alias main::cur_item#2 = main::cur_item#3
|
|
|
|
Alias main::item#2 = main::item#3
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
Identical Phi Values (byte) main::item#2 (byte) main::item#4
|
|
|
|
Identical Phi Values (byte*) main::cur_item#2 (byte*) main::cur_item#4
|
|
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
2019-11-18 21:02:29 +00:00
|
|
|
Simple Condition (bool~) main::$2 [10] if((byte) main::sub#1!=rangelast(0,ITEM_SIZE-1)) goto main::@2
|
2020-02-22 19:45:35 +00:00
|
|
|
Simple Condition (bool~) main::$3 [14] if((byte) main::item#1!=rangelast(0,ITEM_COUNT-1)) goto main::@1
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
2019-11-03 20:27:11 +00:00
|
|
|
Constant (const byte*) main::cur_item#0 = items
|
2018-07-21 09:13:32 +00:00
|
|
|
Constant (const byte) main::item#0 = 0
|
|
|
|
Constant (const byte) main::sub#0 = 0
|
2018-08-22 20:23:42 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2019-11-18 21:02:29 +00:00
|
|
|
Resolved ranged next value [8] main::sub#1 ← ++ main::sub#2 to ++
|
2020-03-29 19:00:25 +00:00
|
|
|
Resolved ranged comparison value [10] if(main::sub#1!=rangelast(0,ITEM_SIZE-1)) goto main::@2 to (const nomodify byte) ITEM_SIZE-(byte) 1+(number) 1
|
2020-02-22 19:45:35 +00:00
|
|
|
Resolved ranged next value [12] main::item#1 ← ++ main::item#4 to ++
|
2020-03-29 19:00:25 +00:00
|
|
|
Resolved ranged comparison value [14] if(main::item#1!=rangelast(0,ITEM_COUNT-1)) goto main::@1 to (const nomodify byte) ITEM_COUNT-(byte) 1+(number) 1
|
|
|
|
Adding number conversion cast (unumber) ITEM_SIZE-1+1 in if((byte) main::sub#1!=(const nomodify byte) ITEM_SIZE-(byte) 1+(number) 1) goto main::@2
|
|
|
|
Adding number conversion cast (unumber) 1 in if((byte) main::sub#1!=(unumber)(const nomodify byte) ITEM_SIZE-(byte) 1+(number) 1) goto main::@2
|
|
|
|
Adding number conversion cast (unumber) ITEM_COUNT-1+1 in if((byte) main::item#1!=(const nomodify byte) ITEM_COUNT-(byte) 1+(number) 1) goto main::@1
|
|
|
|
Adding number conversion cast (unumber) 1 in if((byte) main::item#1!=(unumber)(const nomodify byte) ITEM_COUNT-(byte) 1+(number) 1) goto main::@1
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
2020-03-29 19:00:25 +00:00
|
|
|
Simplifying constant integer cast (const nomodify byte) ITEM_SIZE-(byte) 1+(unumber)(number) 1
|
2019-05-30 20:29:04 +00:00
|
|
|
Simplifying constant integer cast 1
|
2020-03-29 19:00:25 +00:00
|
|
|
Simplifying constant integer cast (const nomodify byte) ITEM_COUNT-(byte) 1+(unumber)(number) 1
|
2019-05-30 20:29:04 +00:00
|
|
|
Simplifying constant integer cast 1
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Finalized unsigned number type (byte) 1
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2019-11-18 21:02:29 +00:00
|
|
|
Rewriting multiplication to use shift [2] (byte~) main::$0 ← (byte) main::item#4 * (byte) $10
|
2019-04-15 08:20:55 +00:00
|
|
|
Successful SSA optimization Pass2MultiplyToShiftRewriting
|
2019-11-03 20:27:11 +00:00
|
|
|
Inlining constant with var siblings (const byte*) main::cur_item#0
|
2018-07-21 09:13:32 +00:00
|
|
|
Inlining constant with var siblings (const byte) main::item#0
|
|
|
|
Inlining constant with var siblings (const byte) main::sub#0
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant inlined main::sub#0 = (byte) 0
|
2019-11-18 21:02:29 +00:00
|
|
|
Constant inlined main::cur_item#0 = (const byte*) items
|
2019-05-30 20:29:04 +00:00
|
|
|
Constant inlined main::item#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::@4(between main::@3 and main::@1)
|
|
|
|
Added new block during phi lifting main::@5(between main::@2 and main::@2)
|
2018-07-21 09:13:32 +00:00
|
|
|
Adding NOP phi() at start of @begin
|
|
|
|
Adding NOP phi() at start of @1
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of @2
|
2018-07-21 09:13:32 +00:00
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
Adding NOP phi() at start of main
|
|
|
|
CALL GRAPH
|
|
|
|
Calls in [] to main:2
|
|
|
|
|
|
|
|
Created 3 initial phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Coalesced [17] main::item#5 ← main::item#1
|
|
|
|
Coalesced [18] main::cur_item#5 ← main::cur_item#1
|
|
|
|
Coalesced [19] main::sub#3 ← main::sub#1
|
2018-07-21 09:13:32 +00:00
|
|
|
Coalesced down to 3 phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Culled Empty Block (label) @2
|
2020-04-25 18:10:49 +00:00
|
|
|
Culled Empty Block (label) main::@4
|
2018-07-21 09:13:32 +00:00
|
|
|
Culled Empty Block (label) main::@5
|
|
|
|
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
|
|
|
|
|
|
|
|
FINAL CONTROL FLOW GRAPH
|
|
|
|
@begin: scope:[] from
|
2018-11-11 20:51:36 +00:00
|
|
|
[0] phi()
|
2018-07-21 09:13:32 +00:00
|
|
|
to:@1
|
|
|
|
@1: scope:[] from @begin
|
2018-11-11 20:51:36 +00:00
|
|
|
[1] phi()
|
|
|
|
[2] call main
|
2018-07-21 09:13:32 +00:00
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @1
|
2018-11-11 20:51:36 +00:00
|
|
|
[3] phi()
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2018-07-21 09:13:32 +00:00
|
|
|
main: scope:[main] from @1
|
2018-11-11 20:51:36 +00:00
|
|
|
[4] phi()
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@3
|
2019-11-18 21:02:29 +00:00
|
|
|
[5] (byte*) main::cur_item#4 ← phi( main/(const byte*) items main::@3/(byte*) main::cur_item#1 )
|
2019-05-30 20:29:04 +00:00
|
|
|
[5] (byte) main::item#4 ← phi( main/(byte) 0 main::@3/(byte) main::item#1 )
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1 main::@2
|
2019-05-30 20:29:04 +00:00
|
|
|
[6] (byte) main::sub#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::sub#1 )
|
2019-11-18 21:02:29 +00:00
|
|
|
[7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4
|
|
|
|
[8] (byte~) main::$1 ← (byte~) main::$0 | (byte) main::sub#2
|
|
|
|
[9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$1
|
2018-11-11 20:51:36 +00:00
|
|
|
[10] (byte) main::sub#1 ← ++ (byte) main::sub#2
|
2020-03-29 19:00:25 +00:00
|
|
|
[11] if((byte) main::sub#1!=(const nomodify byte) ITEM_SIZE-(byte) 1+(byte) 1) goto main::@2
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@2
|
2020-03-29 19:00:25 +00:00
|
|
|
[12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE
|
2018-11-11 20:51:36 +00:00
|
|
|
[13] (byte) main::item#1 ← ++ (byte) main::item#4
|
2020-03-29 19:00:25 +00:00
|
|
|
[14] if((byte) main::item#1!=(const nomodify byte) ITEM_COUNT-(byte) 1+(byte) 1) goto main::@1
|
2018-07-21 09:13:32 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
2018-11-11 20:51:36 +00:00
|
|
|
[15] return
|
2018-07-21 09:13:32 +00:00
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
|
|
(void()) main()
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) main::$0 2002.0
|
|
|
|
(byte~) main::$1 2002.0
|
2018-07-21 09:13:32 +00:00
|
|
|
(byte*) main::cur_item
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte*) main::cur_item#1 67.33333333333333
|
|
|
|
(byte*) main::cur_item#4 171.85714285714283
|
2018-07-21 09:13:32 +00:00
|
|
|
(byte) main::item
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::item#1 151.5
|
|
|
|
(byte) main::item#4 150.375
|
2018-07-21 09:13:32 +00:00
|
|
|
(byte) main::sub
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::sub#1 1501.5
|
|
|
|
(byte) main::sub#2 1001.0
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
[ main::item#4 main::item#1 ]
|
|
|
|
[ main::cur_item#4 main::cur_item#1 ]
|
|
|
|
[ main::sub#2 main::sub#1 ]
|
2019-12-08 15:04:35 +00:00
|
|
|
Added variable main::$0 to live range equivalence class [ main::$0 ]
|
|
|
|
Added variable main::$1 to live range equivalence class [ main::$1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
Complete equivalence classes
|
|
|
|
[ main::item#4 main::item#1 ]
|
|
|
|
[ main::cur_item#4 main::cur_item#1 ]
|
|
|
|
[ main::sub#2 main::sub#1 ]
|
2019-11-18 21:02:29 +00:00
|
|
|
[ main::$0 ]
|
|
|
|
[ main::$1 ]
|
2019-10-12 09:40:36 +00:00
|
|
|
Allocated zp[1]:2 [ main::item#4 main::item#1 ]
|
|
|
|
Allocated zp[2]:3 [ main::cur_item#4 main::cur_item#1 ]
|
|
|
|
Allocated zp[1]:5 [ main::sub#2 main::sub#1 ]
|
2019-11-18 21:02:29 +00:00
|
|
|
Allocated zp[1]:6 [ main::$0 ]
|
|
|
|
Allocated zp[1]:7 [ main::$1 ]
|
2018-07-21 09:13:32 +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
|
|
|
// Illustrates symbolic array lengths
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-07-21 09:13:32 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-07-21 09:13:32 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2018-07-23 07:27:30 +00:00
|
|
|
.const ITEM_COUNT = 3
|
2018-07-21 09:13:32 +00:00
|
|
|
.const ITEM_SIZE = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// @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-07-21 09:13:32 +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
|
2019-02-17 23:12:29 +00:00
|
|
|
// Fills the array item by item with $is, where i is the item# and s is the sub#
|
2018-07-21 09:13:32 +00:00
|
|
|
main: {
|
2019-11-18 21:02:29 +00:00
|
|
|
.label __0 = 6
|
|
|
|
.label __1 = 7
|
2018-07-21 09:13:32 +00:00
|
|
|
.label sub = 5
|
|
|
|
.label cur_item = 3
|
|
|
|
.label item = 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-11-18 21:02:29 +00:00
|
|
|
// [5] phi (byte*) main::cur_item#4 = (const byte*) items [phi:main->main::@1#0] -- pbuz1=pbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #<items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #>items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item+1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z item
|
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::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy
|
|
|
|
// [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- 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] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2_from___b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuz1=vbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z sub
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2_from___b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-11-18 21:02:29 +00:00
|
|
|
// [7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4 -- vbuz1=vbuz2_rol_4
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z item
|
2018-07-21 09:13:32 +00:00
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2019-11-18 21:02:29 +00:00
|
|
|
sta.z __0
|
|
|
|
// [8] (byte~) main::$1 ← (byte~) main::$0 | (byte) main::sub#2 -- vbuz1=vbuz2_bor_vbuz3
|
|
|
|
lda.z __0
|
2019-08-07 19:00:19 +00:00
|
|
|
ora.z sub
|
2019-11-18 21:02:29 +00:00
|
|
|
sta.z __1
|
|
|
|
// [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$1 -- pbuz1_derefidx_vbuz2=vbuz3
|
|
|
|
lda.z __1
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z sub
|
2018-07-21 09:13:32 +00:00
|
|
|
sta (cur_item),y
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuz1=_inc_vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z sub
|
2020-03-29 19:00:25 +00:00
|
|
|
// [11] if((byte) main::sub#1!=(const nomodify byte) ITEM_SIZE-(byte) 1+(byte) 1) goto main::@2 -- vbuz1_neq_vbuc1_then_la1
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #ITEM_SIZE-1+1
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z sub
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2_from___b2
|
|
|
|
jmp __b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE -- pbuz1=pbuz1_plus_vbuc1
|
2019-03-18 01:23:29 +00:00
|
|
|
lda #ITEM_SIZE
|
2018-07-21 09:13:32 +00:00
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z cur_item
|
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z cur_item+1
|
2018-07-21 09:13:32 +00:00
|
|
|
!:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuz1=_inc_vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z item
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] if((byte) main::item#1!=(const nomodify byte) ITEM_COUNT-(byte) 1+(byte) 1) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
2019-03-26 22:49:44 +00:00
|
|
|
lda #ITEM_COUNT-1+1
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z item
|
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
|
|
|
// [15] return
|
2018-07-21 09:13:32 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-07-23 07:27:30 +00:00
|
|
|
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4 [ main::item#4 main::cur_item#4 main::sub#2 main::$0 ] ( main:2 [ main::item#4 main::cur_item#4 main::sub#2 main::$0 ] { } ) 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::item#4 main::item#1 ]
|
|
|
|
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::sub#2 main::sub#1 ]
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE [ main::item#4 main::cur_item#1 ] ( main:2 [ main::item#4 main::cur_item#1 ] { } ) always clobbers reg byte a
|
2020-03-22 23:10:07 +00:00
|
|
|
Statement [7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4 [ main::item#4 main::cur_item#4 main::sub#2 main::$0 ] ( main:2 [ main::item#4 main::cur_item#4 main::sub#2 main::$0 ] { } ) always clobbers reg byte a
|
2020-03-29 19:00:25 +00:00
|
|
|
Statement [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE [ main::item#4 main::cur_item#1 ] ( main:2 [ main::item#4 main::cur_item#1 ] { } ) always clobbers reg byte a
|
2019-10-12 09:40:36 +00:00
|
|
|
Potential registers zp[1]:2 [ main::item#4 main::item#1 ] : zp[1]:2 , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[2]:3 [ main::cur_item#4 main::cur_item#1 ] : zp[2]:3 ,
|
|
|
|
Potential registers zp[1]:5 [ main::sub#2 main::sub#1 ] : zp[1]:5 , reg byte x , reg byte y ,
|
2019-11-18 21:02:29 +00:00
|
|
|
Potential registers zp[1]:6 [ main::$0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp[1]:7 [ main::$1 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
2020-03-22 21:26:39 +00:00
|
|
|
Uplift Scope [main] 2,502.5: zp[1]:5 [ main::sub#2 main::sub#1 ] 2,002: zp[1]:6 [ main::$0 ] 2,002: zp[1]:7 [ main::$1 ] 301.88: zp[1]:2 [ main::item#4 main::item#1 ] 239.19: zp[2]:3 [ main::cur_item#4 main::cur_item#1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
Uplift Scope []
|
|
|
|
|
2019-11-18 21:02:29 +00:00
|
|
|
Uplifting [main] best 4418 combination reg byte y [ main::sub#2 main::sub#1 ] reg byte a [ main::$0 ] reg byte a [ main::$1 ] reg byte x [ main::item#4 main::item#1 ] zp[2]:3 [ main::cur_item#4 main::cur_item#1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
Limited combination testing to 100 combinations of 144 possible.
|
|
|
|
Uplifting [] best 4418 combination
|
2019-10-12 09:40:36 +00:00
|
|
|
Allocated (was zp[2]:3) zp[2]:2 [ main::cur_item#4 main::cur_item#1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// Illustrates symbolic array lengths
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-07-21 09:13:32 +00:00
|
|
|
.pc = $801 "Basic"
|
2020-05-11 00:36:37 +00:00
|
|
|
:BasicUpstart(main)
|
2018-07-21 09:13:32 +00:00
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2018-07-23 07:27:30 +00:00
|
|
|
.const ITEM_COUNT = 3
|
2018-07-21 09:13:32 +00:00
|
|
|
.const ITEM_SIZE = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// @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-07-21 09:13:32 +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
|
2019-02-17 23:12:29 +00:00
|
|
|
// Fills the array item by item with $is, where i is the item# and s is the sub#
|
2018-07-21 09:13:32 +00:00
|
|
|
main: {
|
|
|
|
.label cur_item = 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-11-18 21:02:29 +00:00
|
|
|
// [5] phi (byte*) main::cur_item#4 = (const byte*) items [phi:main->main::@1#0] -- pbuz1=pbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #<items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #>items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item+1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
2018-07-21 09:13:32 +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::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy
|
|
|
|
// [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- 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] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2_from___b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
ldy #0
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2_from___b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-11-18 21:02:29 +00:00
|
|
|
// [7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4 -- vbuaa=vbuxx_rol_4
|
2018-07-21 09:13:32 +00:00
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2019-11-18 21:02:29 +00:00
|
|
|
// [8] (byte~) main::$1 ← (byte~) main::$0 | (byte) main::sub#2 -- vbuaa=vbuaa_bor_vbuyy
|
2019-08-07 19:00:19 +00:00
|
|
|
sty.z $ff
|
|
|
|
ora.z $ff
|
2019-11-18 21:02:29 +00:00
|
|
|
// [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$1 -- pbuz1_derefidx_vbuyy=vbuaa
|
2018-07-21 09:13:32 +00:00
|
|
|
sta (cur_item),y
|
2019-07-08 14:43:09 +00:00
|
|
|
// [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuyy=_inc_vbuyy
|
2018-07-21 09:13:32 +00:00
|
|
|
iny
|
2020-03-29 19:00:25 +00:00
|
|
|
// [11] if((byte) main::sub#1!=(const nomodify byte) ITEM_SIZE-(byte) 1+(byte) 1) goto main::@2 -- vbuyy_neq_vbuc1_then_la1
|
2018-07-21 09:13:32 +00:00
|
|
|
cpy #ITEM_SIZE-1+1
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2_from___b2
|
|
|
|
jmp __b3
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
2019-09-29 21:13:37 +00:00
|
|
|
__b3:
|
2020-03-29 19:00:25 +00:00
|
|
|
// [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE -- pbuz1=pbuz1_plus_vbuc1
|
2019-03-18 01:23:29 +00:00
|
|
|
lda #ITEM_SIZE
|
2018-07-21 09:13:32 +00:00
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z cur_item
|
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z cur_item+1
|
2018-07-21 09:13:32 +00:00
|
|
|
!:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuxx=_inc_vbuxx
|
2018-07-21 09:13:32 +00:00
|
|
|
inx
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] if((byte) main::item#1!=(const nomodify byte) ITEM_COUNT-(byte) 1+(byte) 1) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
2018-07-21 09:13:32 +00:00
|
|
|
cpx #ITEM_COUNT-1+1
|
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
|
|
|
// [15] return
|
2018-07-21 09:13:32 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-07-23 07:27:30 +00:00
|
|
|
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
2018-07-21 09:13:32 +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 __b2
|
|
|
|
Removing instruction jmp __b3
|
|
|
|
Removing instruction jmp __breturn
|
2018-07-21 09:13:32 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Replacing label __b2_from___b2 with __b2
|
|
|
|
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:
|
|
|
|
Removing instruction __b2_from___b1:
|
|
|
|
Removing instruction __b2_from___b2:
|
2018-07-21 09:13:32 +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 __b3:
|
|
|
|
Removing instruction __breturn:
|
2018-07-21 09:13:32 +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
|
|
|
|
Removing instruction jmp __b2
|
2018-07-21 09:13:32 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
2020-03-29 19:00:25 +00:00
|
|
|
(const nomodify byte) ITEM_COUNT = (byte) 3
|
|
|
|
(const nomodify byte) ITEM_SIZE = (byte) 5
|
|
|
|
(const byte*) items[(const nomodify byte) ITEM_COUNT*(const nomodify byte) ITEM_SIZE] = { (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0, (byte) 0 }
|
2018-07-21 09:13:32 +00:00
|
|
|
(void()) main()
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte~) main::$0 reg byte a 2002.0
|
|
|
|
(byte~) main::$1 reg byte a 2002.0
|
2018-07-21 09:13:32 +00:00
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@return
|
|
|
|
(byte*) main::cur_item
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte*) main::cur_item#1 cur_item zp[2]:2 67.33333333333333
|
|
|
|
(byte*) main::cur_item#4 cur_item zp[2]:2 171.85714285714283
|
2018-07-21 09:13:32 +00:00
|
|
|
(byte) main::item
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::item#1 reg byte x 151.5
|
|
|
|
(byte) main::item#4 reg byte x 150.375
|
2018-07-21 09:13:32 +00:00
|
|
|
(byte) main::sub
|
2020-03-22 21:26:39 +00:00
|
|
|
(byte) main::sub#1 reg byte y 1501.5
|
|
|
|
(byte) main::sub#2 reg byte y 1001.0
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
reg byte x [ main::item#4 main::item#1 ]
|
2019-10-12 09:40:36 +00:00
|
|
|
zp[2]:2 [ main::cur_item#4 main::cur_item#1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
reg byte y [ main::sub#2 main::sub#1 ]
|
2019-11-18 21:02:29 +00:00
|
|
|
reg byte a [ main::$0 ]
|
|
|
|
reg byte a [ main::$1 ]
|
2018-07-21 09:13:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
2018-12-25 16:04:50 +00:00
|
|
|
Score: 3416
|
2018-07-21 09:13:32 +00:00
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-02-17 23:12:29 +00:00
|
|
|
// Illustrates symbolic array lengths
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2018-07-21 09:13:32 +00:00
|
|
|
.pc = $801 "Basic"
|
|
|
|
:BasicUpstart(main)
|
|
|
|
.pc = $80d "Program"
|
2019-07-08 14:43:09 +00:00
|
|
|
// Global Constants & labels
|
2018-07-23 07:27:30 +00:00
|
|
|
.const ITEM_COUNT = 3
|
2018-07-21 09:13:32 +00:00
|
|
|
.const ITEM_SIZE = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// @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
|
2019-02-17 23:12:29 +00:00
|
|
|
// Fills the array item by item with $is, where i is the item# and s is the sub#
|
2018-07-21 09:13:32 +00:00
|
|
|
main: {
|
|
|
|
.label cur_item = 2
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main to main::@1 [phi:main->main::@1]
|
2019-11-18 21:02:29 +00:00
|
|
|
// [5] phi (byte*) main::cur_item#4 = (const byte*) items [phi:main->main::@1#0] -- pbuz1=pbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #<items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
lda #>items
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z cur_item+1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::item#4 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1
|
2018-07-21 09:13:32 +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::cur_item#4 = (byte*) main::cur_item#1 [phi:main::@3->main::@1#0] -- register_copy
|
|
|
|
// [5] phi (byte) main::item#4 = (byte) main::item#1 [phi:main::@3->main::@1#1] -- register_copy
|
|
|
|
// main::@1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@1 to main::@2 [phi:main::@1->main::@2]
|
|
|
|
// [6] phi (byte) main::sub#2 = (byte) 0 [phi:main::@1->main::@2#0] -- vbuyy=vbuc1
|
2018-07-21 09:13:32 +00:00
|
|
|
ldy #0
|
2019-07-08 14:43:09 +00:00
|
|
|
// [6] phi from main::@2 to main::@2 [phi:main::@2->main::@2]
|
|
|
|
// [6] phi (byte) main::sub#2 = (byte) main::sub#1 [phi:main::@2->main::@2#0] -- register_copy
|
|
|
|
// main::@2
|
2019-09-29 21:13:37 +00:00
|
|
|
__b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// item*$10
|
2019-11-18 21:02:29 +00:00
|
|
|
// [7] (byte~) main::$0 ← (byte) main::item#4 << (byte) 4 -- vbuaa=vbuxx_rol_4
|
2018-07-21 09:13:32 +00:00
|
|
|
txa
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
2019-07-08 14:43:09 +00:00
|
|
|
// item*$10|sub
|
2019-11-18 21:02:29 +00:00
|
|
|
// [8] (byte~) main::$1 ← (byte~) main::$0 | (byte) main::sub#2 -- vbuaa=vbuaa_bor_vbuyy
|
2019-08-07 19:00:19 +00:00
|
|
|
sty.z $ff
|
|
|
|
ora.z $ff
|
2019-07-08 14:43:09 +00:00
|
|
|
// cur_item[sub] = item*$10|sub
|
2019-11-18 21:02:29 +00:00
|
|
|
// [9] *((byte*) main::cur_item#4 + (byte) main::sub#2) ← (byte~) main::$1 -- pbuz1_derefidx_vbuyy=vbuaa
|
2018-07-21 09:13:32 +00:00
|
|
|
sta (cur_item),y
|
2019-07-08 14:43:09 +00:00
|
|
|
// for( byte sub: 0..ITEM_SIZE-1)
|
|
|
|
// [10] (byte) main::sub#1 ← ++ (byte) main::sub#2 -- vbuyy=_inc_vbuyy
|
2018-07-21 09:13:32 +00:00
|
|
|
iny
|
2020-03-29 19:00:25 +00:00
|
|
|
// [11] if((byte) main::sub#1!=(const nomodify byte) ITEM_SIZE-(byte) 1+(byte) 1) goto main::@2 -- vbuyy_neq_vbuc1_then_la1
|
2018-07-21 09:13:32 +00:00
|
|
|
cpy #ITEM_SIZE-1+1
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b2
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@3
|
|
|
|
// cur_item += ITEM_SIZE
|
2020-03-29 19:00:25 +00:00
|
|
|
// [12] (byte*) main::cur_item#1 ← (byte*) main::cur_item#4 + (const nomodify byte) ITEM_SIZE -- pbuz1=pbuz1_plus_vbuc1
|
2019-03-18 01:23:29 +00:00
|
|
|
lda #ITEM_SIZE
|
2018-07-21 09:13:32 +00:00
|
|
|
clc
|
2019-08-07 19:00:19 +00:00
|
|
|
adc.z cur_item
|
|
|
|
sta.z cur_item
|
2018-07-21 09:13:32 +00:00
|
|
|
bcc !+
|
2019-08-07 19:00:19 +00:00
|
|
|
inc.z cur_item+1
|
2018-07-21 09:13:32 +00:00
|
|
|
!:
|
2019-07-08 14:43:09 +00:00
|
|
|
// for( byte item: 0..ITEM_COUNT-1)
|
|
|
|
// [13] (byte) main::item#1 ← ++ (byte) main::item#4 -- vbuxx=_inc_vbuxx
|
2018-07-21 09:13:32 +00:00
|
|
|
inx
|
2020-03-29 19:00:25 +00:00
|
|
|
// [14] if((byte) main::item#1!=(const nomodify byte) ITEM_COUNT-(byte) 1+(byte) 1) goto main::@1 -- vbuxx_neq_vbuc1_then_la1
|
2018-07-21 09:13:32 +00:00
|
|
|
cpx #ITEM_COUNT-1+1
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [15] return
|
2018-07-21 09:13:32 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2018-07-23 07:27:30 +00:00
|
|
|
items: .byte 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
2018-07-21 09:13:32 +00:00
|
|
|
|