2019-05-30 20:29:04 +00:00
|
|
|
Culled Empty Block (label) main::@2
|
|
|
|
Culled Empty Block (label) @1
|
|
|
|
Culled Empty Block (label) sub1::@1
|
|
|
|
Culled Empty Block (label) @2
|
2019-04-19 23:44:54 +00:00
|
|
|
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
|
|
@begin: scope:[] from
|
|
|
|
to:@3
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2019-04-19 23:44:54 +00:00
|
|
|
main: scope:[main] from @3
|
2019-09-29 18:57:23 +00:00
|
|
|
(byte*) main::SCREEN ← ((byte*)) (number) $400
|
2019-06-02 22:44:46 +00:00
|
|
|
(byte) main::i#0 ← (byte) 0
|
2019-04-19 23:44:54 +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 )
|
|
|
|
(byte) sub1::i#0 ← (byte) main::i#2
|
|
|
|
call sub1
|
|
|
|
(byte) sub1::return#0 ← (byte) sub1::return#2
|
|
|
|
to:main::@3
|
|
|
|
main::@3: scope:[main] from main::@1
|
|
|
|
(byte) main::i#3 ← phi( main::@1/(byte) main::i#2 )
|
|
|
|
(byte) sub1::return#3 ← phi( main::@1/(byte) sub1::return#0 )
|
|
|
|
(byte~) main::$0 ← (byte) sub1::return#3
|
2019-09-29 18:57:23 +00:00
|
|
|
*((byte*) main::SCREEN + (byte) main::i#3) ← (byte~) main::$0
|
2019-04-19 23:44:54 +00:00
|
|
|
(byte) main::i#1 ← (byte) main::i#3 + rangenext(0,2)
|
|
|
|
(bool~) main::$1 ← (byte) main::i#1 != rangelast(0,2)
|
|
|
|
if((bool~) main::$1) goto main::@1
|
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@3
|
|
|
|
return
|
|
|
|
to:@return
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(byte()) sub1((byte) sub1::i)
|
2019-04-19 23:44:54 +00:00
|
|
|
sub1: scope:[sub1] from main::@1
|
|
|
|
(byte) sub1::i#1 ← phi( main::@1/(byte) sub1::i#0 )
|
|
|
|
(byte~) sub1::$0 ← (byte) sub1::i#1 + (byte) sub1::i#1
|
|
|
|
(byte) sub1::return#1 ← (byte~) sub1::$0
|
|
|
|
to:sub1::@return
|
|
|
|
sub1::@return: scope:[sub1] from sub1
|
|
|
|
(byte) sub1::return#4 ← phi( sub1/(byte) sub1::return#1 )
|
|
|
|
(byte) sub1::return#2 ← (byte) sub1::return#4
|
|
|
|
return
|
|
|
|
to:@return
|
|
|
|
@3: scope:[] from @begin
|
|
|
|
call main
|
|
|
|
to:@4
|
|
|
|
@4: scope:[] from @3
|
|
|
|
to:@end
|
|
|
|
@end: scope:[] from @4
|
|
|
|
|
|
|
|
SYMBOL TABLE SSA
|
|
|
|
(label) @3
|
|
|
|
(label) @4
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(void()) main()
|
|
|
|
(byte~) main::$0
|
|
|
|
(bool~) main::$1
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@3
|
|
|
|
(label) main::@return
|
|
|
|
(byte*) main::SCREEN
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#0
|
|
|
|
(byte) main::i#1
|
|
|
|
(byte) main::i#2
|
|
|
|
(byte) main::i#3
|
|
|
|
(byte()) sub1((byte) sub1::i)
|
|
|
|
(byte~) sub1::$0
|
|
|
|
(label) sub1::@return
|
|
|
|
(byte) sub1::i
|
|
|
|
(byte) sub1::i#0
|
|
|
|
(byte) sub1::i#1
|
|
|
|
(byte) sub1::return
|
|
|
|
(byte) sub1::return#0
|
|
|
|
(byte) sub1::return#1
|
|
|
|
(byte) sub1::return#2
|
|
|
|
(byte) sub1::return#3
|
|
|
|
(byte) sub1::return#4
|
|
|
|
|
2019-09-29 18:57:23 +00:00
|
|
|
Inlining cast (byte*) main::SCREEN ← (byte*)(number) $400
|
2019-05-30 20:29:04 +00:00
|
|
|
Successful SSA optimization Pass2InlineCast
|
|
|
|
Simplifying constant pointer cast (byte*) 1024
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
2019-04-19 23:44:54 +00:00
|
|
|
Alias (byte) sub1::return#0 = (byte) sub1::return#3
|
|
|
|
Alias (byte) main::i#2 = (byte) main::i#3
|
|
|
|
Alias (byte) sub1::return#1 = (byte~) sub1::$0 (byte) sub1::return#4 (byte) sub1::return#2
|
|
|
|
Successful SSA optimization Pass2AliasElimination
|
2019-05-30 20:29:04 +00:00
|
|
|
Identical Phi Values (byte) sub1::i#1 (byte) sub1::i#0
|
|
|
|
Successful SSA optimization Pass2IdenticalPhiElimination
|
2019-04-19 23:44:54 +00:00
|
|
|
Simple Condition (bool~) main::$1 [11] if((byte) main::i#1!=rangelast(0,2)) goto main::@1
|
|
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
2019-09-29 18:57:23 +00:00
|
|
|
Constant (const byte*) main::SCREEN = (byte*) 1024
|
2019-04-19 23:44:54 +00:00
|
|
|
Successful SSA optimization Pass2ConstantIdentification
|
2019-05-30 20:29:04 +00:00
|
|
|
Resolved ranged next value [9] main::i#1 ← ++ main::i#2 to ++
|
|
|
|
Resolved ranged comparison value [11] if(main::i#1!=rangelast(0,2)) goto main::@1 to (number) 3
|
|
|
|
Adding number conversion cast (unumber) 3 in if((byte) main::i#1!=(number) 3) goto main::@1
|
|
|
|
Successful SSA optimization PassNAddNumberTypeConversions
|
|
|
|
Simplifying constant integer cast 3
|
|
|
|
Successful SSA optimization PassNCastSimplification
|
|
|
|
Finalized unsigned number type (byte) 3
|
|
|
|
Successful SSA optimization PassNFinalizeNumberTypeConversions
|
2019-04-19 23:44:54 +00:00
|
|
|
Added new block during phi lifting main::@4(between main::@3 and main::@1)
|
|
|
|
Adding NOP phi() at start of @begin
|
|
|
|
Adding NOP phi() at start of @3
|
2019-05-30 20:29:04 +00:00
|
|
|
Adding NOP phi() at start of @4
|
2019-04-19 23:44:54 +00:00
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
CALL GRAPH
|
|
|
|
Calls in [] to main:2
|
2019-05-30 20:29:04 +00:00
|
|
|
Calls in [main] to sub1:9
|
2019-04-19 23:44:54 +00:00
|
|
|
|
|
|
|
Created 1 initial phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Coalesced [6] main::i#4 ← main::i#0
|
|
|
|
Coalesced [16] main::i#5 ← main::i#1
|
2019-04-19 23:44:54 +00:00
|
|
|
Coalesced down to 1 phi equivalence classes
|
2019-05-30 20:29:04 +00:00
|
|
|
Culled Empty Block (label) @4
|
2019-04-19 23:44:54 +00:00
|
|
|
Culled Empty Block (label) main::@4
|
|
|
|
Renumbering block @3 to @1
|
|
|
|
Renumbering block main::@3 to main::@2
|
|
|
|
Adding NOP phi() at start of @begin
|
|
|
|
Adding NOP phi() at start of @1
|
|
|
|
Adding NOP phi() at start of @end
|
|
|
|
|
|
|
|
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()
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(void()) main()
|
2019-04-19 23:44:54 +00:00
|
|
|
main: scope:[main] from @1
|
2019-05-30 20:29:04 +00:00
|
|
|
[4] (byte) main::i#0 ← (byte) 0
|
2019-04-19 23:44:54 +00:00
|
|
|
to:main::@1
|
|
|
|
main::@1: scope:[main] from main main::@2
|
|
|
|
[5] (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@2/(byte) main::i#1 )
|
|
|
|
[6] (byte) sub1::i#0 ← (byte) main::i#2
|
|
|
|
[7] call sub1
|
|
|
|
[8] (byte) sub1::return#0 ← (byte) sub1::return#1
|
|
|
|
to:main::@2
|
|
|
|
main::@2: scope:[main] from main::@1
|
|
|
|
[9] (byte~) main::$0 ← (byte) sub1::return#0
|
2019-09-29 18:57:23 +00:00
|
|
|
[10] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte~) main::$0
|
2019-04-19 23:44:54 +00:00
|
|
|
[11] (byte) main::i#1 ← ++ (byte) main::i#2
|
2019-05-30 20:29:04 +00:00
|
|
|
[12] if((byte) main::i#1!=(byte) 3) goto main::@1
|
2019-04-19 23:44:54 +00:00
|
|
|
to:main::@return
|
|
|
|
main::@return: scope:[main] from main::@2
|
|
|
|
[13] return
|
|
|
|
to:@return
|
2019-09-18 21:00:30 +00:00
|
|
|
|
|
|
|
(byte()) sub1((byte) sub1::i)
|
2019-04-19 23:44:54 +00:00
|
|
|
sub1: scope:[sub1] from main::@1
|
|
|
|
[14] (byte) sub1::return#1 ← (byte) sub1::i#0 + (byte) sub1::i#0
|
|
|
|
to:sub1::@return
|
|
|
|
sub1::@return: scope:[sub1] from sub1
|
|
|
|
[15] return
|
|
|
|
to:@return
|
|
|
|
|
|
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
|
|
(void()) main()
|
|
|
|
(byte~) main::$0 22.0
|
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#0 4.0
|
|
|
|
(byte) main::i#1 16.5
|
|
|
|
(byte) main::i#2 7.666666666666666
|
|
|
|
(byte()) sub1((byte) sub1::i)
|
|
|
|
(byte) sub1::i
|
|
|
|
(byte) sub1::i#0 15.0
|
|
|
|
(byte) sub1::return
|
|
|
|
(byte) sub1::return#0 22.0
|
|
|
|
(byte) sub1::return#1 4.333333333333333
|
|
|
|
|
|
|
|
Initial phi equivalence classes
|
|
|
|
[ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
Added variable sub1::i#0 to zero page equivalence class [ sub1::i#0 ]
|
|
|
|
Added variable sub1::return#0 to zero page equivalence class [ sub1::return#0 ]
|
|
|
|
Added variable main::$0 to zero page equivalence class [ main::$0 ]
|
|
|
|
Added variable sub1::return#1 to zero page equivalence class [ sub1::return#1 ]
|
|
|
|
Complete equivalence classes
|
|
|
|
[ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
[ sub1::i#0 ]
|
|
|
|
[ sub1::return#0 ]
|
|
|
|
[ main::$0 ]
|
|
|
|
[ sub1::return#1 ]
|
|
|
|
Allocated zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
Allocated zp ZP_BYTE:6 [ sub1::i#0 ]
|
|
|
|
Allocated zp ZP_BYTE:7 [ sub1::return#0 ]
|
|
|
|
Allocated zp ZP_BYTE:8 [ main::$0 ]
|
|
|
|
Allocated zp ZP_BYTE:9 [ sub1::return#1 ]
|
|
|
|
|
|
|
|
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-04-19 23:44:54 +00:00
|
|
|
// Demonstrates a procedure reserving addresses on zeropage
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-19 23:44:54 +00:00
|
|
|
.pc = $801 "Basic"
|
2019-09-29 21:13:37 +00:00
|
|
|
:BasicUpstart(__bbegin)
|
2019-04-19 23:44:54 +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
|
2019-04-19 23:44:54 +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-04-19 23:44:54 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
2019-09-29 21:13:37 +00:00
|
|
|
.label __0 = 8
|
2019-04-19 23:44:54 +00:00
|
|
|
.label i = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// [4] (byte) main::i#0 ← (byte) 0 -- vbuz1=vbuc1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from_main:
|
|
|
|
__b1_from___b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#0 [phi:main/main::@2->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) sub1::i#0 ← (byte) main::i#2 -- vbuz1=vbuz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z i
|
|
|
|
sta.z sub1.i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] call sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
jsr sub1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte) sub1::return#0 ← (byte) sub1::return#1 -- vbuz1=vbuz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z sub1.return_1
|
|
|
|
sta.z sub1.return
|
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-07-08 14:43:09 +00:00
|
|
|
// [9] (byte~) main::$0 ← (byte) sub1::return#0 -- vbuz1=vbuz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z sub1.return
|
2019-09-29 21:13:37 +00:00
|
|
|
sta.z __0
|
2019-09-29 18:57:23 +00:00
|
|
|
// [10] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuz2
|
2019-09-29 21:13:37 +00:00
|
|
|
lda.z __0
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z i
|
2019-04-19 23:44:54 +00:00
|
|
|
sta SCREEN,y
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] (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
|
|
|
// [12] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #3
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1_from___b2
|
|
|
|
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
|
|
|
// [13] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
// sub1(byte zeropage(6) i)
|
|
|
|
sub1: {
|
|
|
|
.label i = 6
|
|
|
|
.label return = 7
|
|
|
|
.label return_1 = 9
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] (byte) sub1::return#1 ← (byte) sub1::i#0 + (byte) sub1::i#0 -- vbuz1=vbuz2_plus_vbuz2
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z i
|
2019-04-19 23:44:54 +00:00
|
|
|
asl
|
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
|
|
|
// sub1::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-19 23:44:54 +00:00
|
|
|
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
2019-05-30 20:29:04 +00:00
|
|
|
Statement [4] (byte) main::i#0 ← (byte) 0 [ main::i#0 ] ( main:2 [ main::i#0 ] ) always clobbers reg byte a
|
2019-09-29 18:57:23 +00:00
|
|
|
Statement [10] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte~) main::$0 [ main::i#2 ] ( main:2 [ main::i#2 ] ) always clobbers reg byte y
|
2019-05-30 20:29:04 +00:00
|
|
|
Statement [12] if((byte) main::i#1!=(byte) 3) goto main::@1 [ main::i#1 ] ( main:2 [ main::i#1 ] ) always clobbers reg byte a
|
2019-04-19 23:44:54 +00:00
|
|
|
Statement [14] (byte) sub1::return#1 ← (byte) sub1::i#0 + (byte) sub1::i#0 [ sub1::return#1 ] ( main:2::sub1:7 [ main::i#2 sub1::return#1 ] ) always clobbers reg byte a
|
|
|
|
Potential registers zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ] : zp ZP_BYTE:5 ,
|
|
|
|
Potential registers zp ZP_BYTE:6 [ sub1::i#0 ] : zp ZP_BYTE:6 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp ZP_BYTE:7 [ sub1::return#0 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp ZP_BYTE:8 [ main::$0 ] : zp ZP_BYTE:8 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
Potential registers zp ZP_BYTE:9 [ sub1::return#1 ] : zp ZP_BYTE:9 , reg byte a , reg byte x , reg byte y ,
|
|
|
|
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
|
|
Uplift Scope [main] 28.17: zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ] 22: zp ZP_BYTE:8 [ main::$0 ]
|
|
|
|
Uplift Scope [sub1] 22: zp ZP_BYTE:7 [ sub1::return#0 ] 15: zp ZP_BYTE:6 [ sub1::i#0 ] 4.33: zp ZP_BYTE:9 [ sub1::return#1 ]
|
|
|
|
Uplift Scope []
|
|
|
|
|
|
|
|
Uplifting [main] best 545 combination zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ] reg byte a [ main::$0 ]
|
|
|
|
Uplifting [sub1] best 419 combination reg byte a [ sub1::return#0 ] reg byte a [ sub1::i#0 ] reg byte a [ sub1::return#1 ]
|
|
|
|
Uplifting [] best 419 combination
|
|
|
|
Attempting to uplift remaining variables inzp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
Uplifting [main] best 419 combination zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-04-19 23:44:54 +00:00
|
|
|
// Demonstrates a procedure reserving addresses on zeropage
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-19 23:44:54 +00:00
|
|
|
.pc = $801 "Basic"
|
2019-09-29 21:13:37 +00:00
|
|
|
:BasicUpstart(__bbegin)
|
2019-04-19 23:44:54 +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
|
2019-04-19 23:44:54 +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-04-19 23:44:54 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label i = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// [4] (byte) main::i#0 ← (byte) 0 -- vbuz1=vbuc1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1_from_main:
|
|
|
|
__b1_from___b2:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#0 [phi:main/main::@2->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) sub1::i#0 ← (byte) main::i#2 -- vbuaa=vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] call sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
jsr sub1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte) sub1::return#0 ← (byte) sub1::return#1
|
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-07-08 14:43:09 +00:00
|
|
|
// [9] (byte~) main::$0 ← (byte) sub1::return#0
|
2019-09-29 18:57:23 +00:00
|
|
|
// [10] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuaa
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z i
|
2019-04-19 23:44:54 +00:00
|
|
|
sta SCREEN,y
|
2019-07-08 14:43:09 +00:00
|
|
|
// [11] (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
|
|
|
// [12] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #3
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1_from___b2
|
|
|
|
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
|
|
|
// [13] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
// sub1(byte register(A) i)
|
|
|
|
sub1: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// [14] (byte) sub1::return#1 ← (byte) sub1::i#0 + (byte) sub1::i#0 -- vbuaa=vbuaa_plus_vbuaa
|
2019-04-19 23:44:54 +00:00
|
|
|
asl
|
2019-09-29 21:13:37 +00:00
|
|
|
jmp __breturn
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1::@return
|
2019-09-29 21:13:37 +00:00
|
|
|
__breturn:
|
2019-07-08 14:43:09 +00:00
|
|
|
// [15] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-19 23:44:54 +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 __breturn
|
|
|
|
Removing instruction jmp __breturn
|
2019-04-19 23:44:54 +00:00
|
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Replacing label __bbegin 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 __b1_from___b2:
|
2019-04-19 23:44:54 +00:00
|
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __bend:
|
|
|
|
Removing instruction __b2:
|
|
|
|
Removing instruction __breturn:
|
|
|
|
Removing instruction __breturn:
|
2019-04-19 23:44:54 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
Updating BasicUpstart to call main directly
|
|
|
|
Removing instruction jsr main
|
|
|
|
Succesful ASM optimization Pass5SkipBegin
|
2019-09-29 21:13:37 +00:00
|
|
|
Removing instruction __b1:
|
2019-04-19 23:44:54 +00:00
|
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
|
|
|
|
FINAL SYMBOL TABLE
|
|
|
|
(label) @1
|
|
|
|
(label) @begin
|
|
|
|
(label) @end
|
|
|
|
(void()) main()
|
|
|
|
(byte~) main::$0 reg byte a 22.0
|
|
|
|
(label) main::@1
|
|
|
|
(label) main::@2
|
|
|
|
(label) main::@return
|
2019-09-29 18:57:23 +00:00
|
|
|
(const byte*) main::SCREEN SCREEN = (byte*) 1024
|
2019-04-19 23:44:54 +00:00
|
|
|
(byte) main::i
|
|
|
|
(byte) main::i#0 i zp ZP_BYTE:5 4.0
|
|
|
|
(byte) main::i#1 i zp ZP_BYTE:5 16.5
|
|
|
|
(byte) main::i#2 i zp ZP_BYTE:5 7.666666666666666
|
|
|
|
(byte()) sub1((byte) sub1::i)
|
|
|
|
(label) sub1::@return
|
|
|
|
(byte) sub1::i
|
|
|
|
(byte) sub1::i#0 reg byte a 15.0
|
|
|
|
(byte) sub1::return
|
|
|
|
(byte) sub1::return#0 reg byte a 22.0
|
|
|
|
(byte) sub1::return#1 reg byte a 4.333333333333333
|
|
|
|
|
|
|
|
zp ZP_BYTE:5 [ main::i#2 main::i#0 main::i#1 ]
|
|
|
|
reg byte a [ sub1::i#0 ]
|
|
|
|
reg byte a [ sub1::return#0 ]
|
|
|
|
reg byte a [ main::$0 ]
|
|
|
|
reg byte a [ sub1::return#1 ]
|
|
|
|
|
|
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
|
|
Score: 314
|
|
|
|
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Comments
|
2019-04-19 23:44:54 +00:00
|
|
|
// Demonstrates a procedure reserving addresses on zeropage
|
2019-07-25 15:06:17 +00:00
|
|
|
// Upstart
|
2019-04-19 23:44:54 +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
|
|
|
|
// [3] phi from @1 to @end [phi:@1->@end]
|
|
|
|
// @end
|
|
|
|
// main
|
2019-04-19 23:44:54 +00:00
|
|
|
main: {
|
|
|
|
.label SCREEN = $400
|
|
|
|
.label i = 5
|
2019-07-08 14:43:09 +00:00
|
|
|
// for( volatile byte i : 0..2)
|
|
|
|
// [4] (byte) main::i#0 ← (byte) 0 -- vbuz1=vbuc1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #0
|
2019-08-07 19:00:19 +00:00
|
|
|
sta.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [5] phi from main main::@2 to main::@1 [phi:main/main::@2->main::@1]
|
|
|
|
// [5] phi (byte) main::i#2 = (byte) main::i#0 [phi:main/main::@2->main::@1#0] -- register_copy
|
|
|
|
// main::@1
|
2019-09-29 21:13:37 +00:00
|
|
|
__b1:
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1(i)
|
|
|
|
// [6] (byte) sub1::i#0 ← (byte) main::i#2 -- vbuaa=vbuz1
|
2019-08-07 19:00:19 +00:00
|
|
|
lda.z i
|
2019-07-08 14:43:09 +00:00
|
|
|
// [7] call sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
jsr sub1
|
2019-07-08 14:43:09 +00:00
|
|
|
// [8] (byte) sub1::return#0 ← (byte) sub1::return#1
|
|
|
|
// main::@2
|
|
|
|
// [9] (byte~) main::$0 ← (byte) sub1::return#0
|
|
|
|
// SCREEN[i] = sub1(i)
|
2019-09-29 18:57:23 +00:00
|
|
|
// [10] *((const byte*) main::SCREEN + (byte) main::i#2) ← (byte~) main::$0 -- pbuc1_derefidx_vbuz1=vbuaa
|
2019-08-07 19:00:19 +00:00
|
|
|
ldy.z i
|
2019-04-19 23:44:54 +00:00
|
|
|
sta SCREEN,y
|
2019-07-08 14:43:09 +00:00
|
|
|
// for( volatile byte i : 0..2)
|
|
|
|
// [11] (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
|
|
|
// [12] if((byte) main::i#1!=(byte) 3) goto main::@1 -- vbuz1_neq_vbuc1_then_la1
|
2019-04-19 23:44:54 +00:00
|
|
|
lda #3
|
2019-08-07 19:00:19 +00:00
|
|
|
cmp.z i
|
2019-09-29 21:13:37 +00:00
|
|
|
bne __b1
|
2019-07-08 14:43:09 +00:00
|
|
|
// main::@return
|
|
|
|
// }
|
|
|
|
// [13] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1
|
2019-04-19 23:44:54 +00:00
|
|
|
// sub1(byte register(A) i)
|
|
|
|
sub1: {
|
2019-07-08 14:43:09 +00:00
|
|
|
// i+i
|
|
|
|
// [14] (byte) sub1::return#1 ← (byte) sub1::i#0 + (byte) sub1::i#0 -- vbuaa=vbuaa_plus_vbuaa
|
2019-04-19 23:44:54 +00:00
|
|
|
asl
|
2019-07-08 14:43:09 +00:00
|
|
|
// sub1::@return
|
|
|
|
// }
|
|
|
|
// [15] return
|
2019-04-19 23:44:54 +00:00
|
|
|
rts
|
|
|
|
}
|
2019-07-08 14:43:09 +00:00
|
|
|
// File Data
|
2019-04-19 23:44:54 +00:00
|
|
|
|