mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-08-07 22:25:13 +00:00
581 lines
18 KiB
Plaintext
581 lines
18 KiB
Plaintext
Resolved forward reference fn1 to (void()) fn1()
|
|
|
|
CONTROL FLOW GRAPH SSA
|
|
@begin: scope:[] from
|
|
to:@2
|
|
main: scope:[main] from @2
|
|
(void()*~) main::$0 ← & (void()) fn1()
|
|
(void()*) main::cls#0 ← (void()*~) main::$0
|
|
(byte*) main::cols#0 ← ((byte*)) (word/dword/signed dword) $d800
|
|
to:main::@1
|
|
main::@1: scope:[main] from main main::@1
|
|
(byte*) main::cols#2 ← phi( main/(byte*) main::cols#0 main::@1/(byte*) main::cols#1 )
|
|
(void()*) main::cls#1 ← phi( main/(void()*) main::cls#0 main::@1/(void()*) main::cls#1 )
|
|
call *((void()*) main::cls#1)
|
|
*((byte*) main::cols#2) ← ++ *((byte*) main::cols#2)
|
|
(byte*) main::cols#1 ← ++ (byte*) main::cols#2
|
|
(word/dword/signed dword~) main::$2 ← (word/dword/signed dword) $d800 + (word/signed word/dword/signed dword) $3e8
|
|
(bool~) main::$3 ← (byte*) main::cols#1 < (word/dword/signed dword~) main::$2
|
|
if((bool~) main::$3) goto main::@1
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@1
|
|
return
|
|
to:@return
|
|
fn1: scope:[fn1] from
|
|
(byte*) fn1::screen#0 ← ((byte*)) (word/signed word/dword/signed dword) $400
|
|
to:fn1::@1
|
|
fn1::@1: scope:[fn1] from fn1 fn1::@1
|
|
(byte*) fn1::screen#2 ← phi( fn1/(byte*) fn1::screen#0 fn1::@1/(byte*) fn1::screen#1 )
|
|
*((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2)
|
|
(byte*) fn1::screen#1 ← ++ (byte*) fn1::screen#2
|
|
(word/signed word/dword/signed dword~) fn1::$0 ← (word/signed word/dword/signed dword) $400 + (word/signed word/dword/signed dword) $3e8
|
|
(bool~) fn1::$1 ← (byte*) fn1::screen#1 < (word/signed word/dword/signed dword~) fn1::$0
|
|
if((bool~) fn1::$1) goto fn1::@1
|
|
to:fn1::@return
|
|
fn1::@return: scope:[fn1] from fn1::@1
|
|
return
|
|
to:@return
|
|
@2: scope:[] from @begin
|
|
call main
|
|
to:@3
|
|
@3: scope:[] from @2
|
|
to:@end
|
|
@end: scope:[] from @3
|
|
|
|
SYMBOL TABLE SSA
|
|
(label) @2
|
|
(label) @3
|
|
(label) @begin
|
|
(label) @end
|
|
(void()) fn1()
|
|
(word/signed word/dword/signed dword~) fn1::$0
|
|
(bool~) fn1::$1
|
|
(label) fn1::@1
|
|
(label) fn1::@return
|
|
(byte*) fn1::screen
|
|
(byte*) fn1::screen#0
|
|
(byte*) fn1::screen#1
|
|
(byte*) fn1::screen#2
|
|
(void()) main()
|
|
(void()*~) main::$0
|
|
(word/dword/signed dword~) main::$2
|
|
(bool~) main::$3
|
|
(label) main::@1
|
|
(label) main::@return
|
|
(void()*) main::cls
|
|
(void()*) main::cls#0
|
|
(void()*) main::cls#1
|
|
(byte*) main::cols
|
|
(byte*) main::cols#0
|
|
(byte*) main::cols#1
|
|
(byte*) main::cols#2
|
|
|
|
Culled Empty Block (label) @3
|
|
Successful SSA optimization Pass2CullEmptyBlocks
|
|
Alias (void()*) main::cls#0 = (void()*~) main::$0
|
|
Successful SSA optimization Pass2AliasElimination
|
|
Self Phi Eliminated (void()*) main::cls#1
|
|
Successful SSA optimization Pass2SelfPhiElimination
|
|
Redundant Phi (void()*) main::cls#1 (void()*) main::cls#0
|
|
Successful SSA optimization Pass2RedundantPhiElimination
|
|
Simple Condition (bool~) main::$3 [9] if((byte*) main::cols#1<(word/dword/signed dword~) main::$2) goto main::@1
|
|
Simple Condition (bool~) fn1::$1 [17] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword~) fn1::$0) goto fn1::@1
|
|
Successful SSA optimization Pass2ConditionalJumpSimplification
|
|
Constant (const void()*) main::cls#0 = &fn1
|
|
Constant (const byte*) main::cols#0 = ((byte*))$d800
|
|
Constant (const word/dword/signed dword) main::$2 = $d800+$3e8
|
|
Constant (const byte*) fn1::screen#0 = ((byte*))$400
|
|
Constant (const word/signed word/dword/signed dword) fn1::$0 = $400+$3e8
|
|
Successful SSA optimization Pass2ConstantIdentification
|
|
Inlining constant with var siblings (const byte*) main::cols#0
|
|
Inlining constant with var siblings (const byte*) fn1::screen#0
|
|
Constant inlined fn1::screen#0 = ((byte*))(word/signed word/dword/signed dword) $400
|
|
Constant inlined fn1::$0 = (word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8
|
|
Constant inlined main::$2 = (word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8
|
|
Constant inlined main::cols#0 = ((byte*))(word/dword/signed dword) $d800
|
|
Successful SSA optimization Pass2ConstantInlining
|
|
Added new block during phi lifting main::@3(between main::@1 and main::@1)
|
|
Added new block during phi lifting fn1::@3(between fn1::@1 and fn1::@1)
|
|
Adding NOP phi() at start of @begin
|
|
Adding NOP phi() at start of @2
|
|
Adding NOP phi() at start of @end
|
|
Adding NOP phi() at start of main
|
|
Adding NOP phi() at start of fn1
|
|
CALL GRAPH
|
|
Calls in [] to main:2
|
|
|
|
Created 2 initial phi equivalence classes
|
|
Coalesced [11] main::cols#3 ← main::cols#1
|
|
Coalesced [18] fn1::screen#3 ← fn1::screen#1
|
|
Coalesced down to 2 phi equivalence classes
|
|
Culled Empty Block (label) main::@3
|
|
Culled Empty Block (label) fn1::@3
|
|
Renumbering block @2 to @1
|
|
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
|
|
Adding NOP phi() at start of fn1
|
|
|
|
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()
|
|
main: scope:[main] from @1
|
|
[4] phi()
|
|
to:main::@1
|
|
main::@1: scope:[main] from main main::@1
|
|
[5] (byte*) main::cols#2 ← phi( main/((byte*))(word/dword/signed dword) $d800 main::@1/(byte*) main::cols#1 )
|
|
[6] call *((const void()*) main::cls#0)
|
|
[7] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2)
|
|
[8] (byte*) main::cols#1 ← ++ (byte*) main::cols#2
|
|
[9] if((byte*) main::cols#1<(word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8) goto main::@1
|
|
to:main::@return
|
|
main::@return: scope:[main] from main::@1
|
|
[10] return
|
|
to:@return
|
|
fn1: scope:[fn1] from
|
|
[11] phi()
|
|
to:fn1::@1
|
|
fn1::@1: scope:[fn1] from fn1 fn1::@1
|
|
[12] (byte*) fn1::screen#2 ← phi( fn1/((byte*))(word/signed word/dword/signed dword) $400 fn1::@1/(byte*) fn1::screen#1 )
|
|
[13] *((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2)
|
|
[14] (byte*) fn1::screen#1 ← ++ (byte*) fn1::screen#2
|
|
[15] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto fn1::@1
|
|
to:fn1::@return
|
|
fn1::@return: scope:[fn1] from fn1::@1
|
|
[16] return
|
|
to:@return
|
|
|
|
|
|
VARIABLE REGISTER WEIGHTS
|
|
(void()) fn1()
|
|
(byte*) fn1::screen
|
|
(byte*) fn1::screen#1 16.5
|
|
(byte*) fn1::screen#2 22.0
|
|
(void()) main()
|
|
(void()*) main::cls
|
|
(byte*) main::cols
|
|
(byte*) main::cols#1 16.5
|
|
(byte*) main::cols#2 14.666666666666666
|
|
|
|
Initial phi equivalence classes
|
|
[ main::cols#2 main::cols#1 ]
|
|
[ fn1::screen#2 fn1::screen#1 ]
|
|
Complete equivalence classes
|
|
[ main::cols#2 main::cols#1 ]
|
|
[ fn1::screen#2 fn1::screen#1 ]
|
|
Allocated zp ZP_WORD:2 [ main::cols#2 main::cols#1 ]
|
|
Allocated zp ZP_WORD:4 [ fn1::screen#2 fn1::screen#1 ]
|
|
|
|
INITIAL ASM
|
|
//SEG0 File Comments
|
|
// Tests calling into a function pointer with local variables
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
//SEG3 @begin
|
|
bbegin:
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
b1_from_bbegin:
|
|
jmp b1
|
|
//SEG5 @1
|
|
b1:
|
|
//SEG6 [2] call main
|
|
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
|
main_from_b1:
|
|
jsr main
|
|
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
|
bend_from_b1:
|
|
jmp bend
|
|
//SEG9 @end
|
|
bend:
|
|
//SEG10 main
|
|
main: {
|
|
.label cls = fn1
|
|
.label cols = 2
|
|
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
|
b1_from_main:
|
|
//SEG12 [5] phi (byte*) main::cols#2 = ((byte*))(word/dword/signed dword) $d800 [phi:main->main::@1#0] -- pbuz1=pbuc1
|
|
lda #<$d800
|
|
sta cols
|
|
lda #>$d800
|
|
sta cols+1
|
|
jmp b1
|
|
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
b1_from_b1:
|
|
//SEG14 [5] phi (byte*) main::cols#2 = (byte*) main::cols#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
jmp b1
|
|
//SEG15 main::@1
|
|
b1:
|
|
//SEG16 [6] call *((const void()*) main::cls#0)
|
|
jsr cls
|
|
//SEG17 [7] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (cols),y
|
|
clc
|
|
adc #1
|
|
ldy #0
|
|
sta (cols),y
|
|
//SEG18 [8] (byte*) main::cols#1 ← ++ (byte*) main::cols#2 -- pbuz1=_inc_pbuz1
|
|
inc cols
|
|
bne !+
|
|
inc cols+1
|
|
!:
|
|
//SEG19 [9] if((byte*) main::cols#1<(word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8) goto main::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda cols+1
|
|
cmp #>$d800+$3e8
|
|
bcc b1_from_b1
|
|
bne !+
|
|
lda cols
|
|
cmp #<$d800+$3e8
|
|
bcc b1_from_b1
|
|
!:
|
|
jmp breturn
|
|
//SEG20 main::@return
|
|
breturn:
|
|
//SEG21 [10] return
|
|
rts
|
|
}
|
|
//SEG22 fn1
|
|
fn1: {
|
|
.label screen = 4
|
|
//SEG23 [12] phi from fn1 to fn1::@1 [phi:fn1->fn1::@1]
|
|
b1_from_fn1:
|
|
//SEG24 [12] phi (byte*) fn1::screen#2 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:fn1->fn1::@1#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta screen
|
|
lda #>$400
|
|
sta screen+1
|
|
jmp b1
|
|
//SEG25 [12] phi from fn1::@1 to fn1::@1 [phi:fn1::@1->fn1::@1]
|
|
b1_from_b1:
|
|
//SEG26 [12] phi (byte*) fn1::screen#2 = (byte*) fn1::screen#1 [phi:fn1::@1->fn1::@1#0] -- register_copy
|
|
jmp b1
|
|
//SEG27 fn1::@1
|
|
b1:
|
|
//SEG28 [13] *((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (screen),y
|
|
clc
|
|
adc #1
|
|
ldy #0
|
|
sta (screen),y
|
|
//SEG29 [14] (byte*) fn1::screen#1 ← ++ (byte*) fn1::screen#2 -- pbuz1=_inc_pbuz1
|
|
inc screen
|
|
bne !+
|
|
inc screen+1
|
|
!:
|
|
//SEG30 [15] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto fn1::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda screen+1
|
|
cmp #>$400+$3e8
|
|
bcc b1_from_b1
|
|
bne !+
|
|
lda screen
|
|
cmp #<$400+$3e8
|
|
bcc b1_from_b1
|
|
!:
|
|
jmp breturn
|
|
//SEG31 fn1::@return
|
|
breturn:
|
|
//SEG32 [16] return
|
|
rts
|
|
}
|
|
|
|
REGISTER UPLIFT POTENTIAL REGISTERS
|
|
Statement [7] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) [ main::cols#2 ] ( main:2 [ main::cols#2 ] ) always clobbers reg byte a reg byte y
|
|
Statement [9] if((byte*) main::cols#1<(word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8) goto main::@1 [ main::cols#1 ] ( main:2 [ main::cols#1 ] ) always clobbers reg byte a
|
|
Statement [13] *((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2) [ fn1::screen#2 ] ( ) always clobbers reg byte a reg byte y
|
|
Statement [15] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto fn1::@1 [ fn1::screen#1 ] ( ) always clobbers reg byte a
|
|
Potential registers zp ZP_WORD:2 [ main::cols#2 main::cols#1 ] : zp ZP_WORD:2 ,
|
|
Potential registers zp ZP_WORD:4 [ fn1::screen#2 fn1::screen#1 ] : zp ZP_WORD:4 ,
|
|
|
|
REGISTER UPLIFT SCOPES
|
|
Uplift Scope [fn1] 38.5: zp ZP_WORD:4 [ fn1::screen#2 fn1::screen#1 ]
|
|
Uplift Scope [main] 31.17: zp ZP_WORD:2 [ main::cols#2 main::cols#1 ]
|
|
Uplift Scope []
|
|
|
|
Uplifting [fn1] best 1454 combination zp ZP_WORD:4 [ fn1::screen#2 fn1::screen#1 ]
|
|
Uplifting [main] best 1454 combination zp ZP_WORD:2 [ main::cols#2 main::cols#1 ]
|
|
Uplifting [] best 1454 combination
|
|
|
|
ASSEMBLER BEFORE OPTIMIZATION
|
|
//SEG0 File Comments
|
|
// Tests calling into a function pointer with local variables
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(bbegin)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
//SEG3 @begin
|
|
bbegin:
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
b1_from_bbegin:
|
|
jmp b1
|
|
//SEG5 @1
|
|
b1:
|
|
//SEG6 [2] call main
|
|
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
|
main_from_b1:
|
|
jsr main
|
|
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
|
bend_from_b1:
|
|
jmp bend
|
|
//SEG9 @end
|
|
bend:
|
|
//SEG10 main
|
|
main: {
|
|
.label cls = fn1
|
|
.label cols = 2
|
|
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
|
b1_from_main:
|
|
//SEG12 [5] phi (byte*) main::cols#2 = ((byte*))(word/dword/signed dword) $d800 [phi:main->main::@1#0] -- pbuz1=pbuc1
|
|
lda #<$d800
|
|
sta cols
|
|
lda #>$d800
|
|
sta cols+1
|
|
jmp b1
|
|
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
b1_from_b1:
|
|
//SEG14 [5] phi (byte*) main::cols#2 = (byte*) main::cols#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
jmp b1
|
|
//SEG15 main::@1
|
|
b1:
|
|
//SEG16 [6] call *((const void()*) main::cls#0)
|
|
jsr cls
|
|
//SEG17 [7] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (cols),y
|
|
clc
|
|
adc #1
|
|
ldy #0
|
|
sta (cols),y
|
|
//SEG18 [8] (byte*) main::cols#1 ← ++ (byte*) main::cols#2 -- pbuz1=_inc_pbuz1
|
|
inc cols
|
|
bne !+
|
|
inc cols+1
|
|
!:
|
|
//SEG19 [9] if((byte*) main::cols#1<(word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8) goto main::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda cols+1
|
|
cmp #>$d800+$3e8
|
|
bcc b1_from_b1
|
|
bne !+
|
|
lda cols
|
|
cmp #<$d800+$3e8
|
|
bcc b1_from_b1
|
|
!:
|
|
jmp breturn
|
|
//SEG20 main::@return
|
|
breturn:
|
|
//SEG21 [10] return
|
|
rts
|
|
}
|
|
//SEG22 fn1
|
|
fn1: {
|
|
.label screen = 4
|
|
//SEG23 [12] phi from fn1 to fn1::@1 [phi:fn1->fn1::@1]
|
|
b1_from_fn1:
|
|
//SEG24 [12] phi (byte*) fn1::screen#2 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:fn1->fn1::@1#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta screen
|
|
lda #>$400
|
|
sta screen+1
|
|
jmp b1
|
|
//SEG25 [12] phi from fn1::@1 to fn1::@1 [phi:fn1::@1->fn1::@1]
|
|
b1_from_b1:
|
|
//SEG26 [12] phi (byte*) fn1::screen#2 = (byte*) fn1::screen#1 [phi:fn1::@1->fn1::@1#0] -- register_copy
|
|
jmp b1
|
|
//SEG27 fn1::@1
|
|
b1:
|
|
//SEG28 [13] *((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (screen),y
|
|
clc
|
|
adc #1
|
|
ldy #0
|
|
sta (screen),y
|
|
//SEG29 [14] (byte*) fn1::screen#1 ← ++ (byte*) fn1::screen#2 -- pbuz1=_inc_pbuz1
|
|
inc screen
|
|
bne !+
|
|
inc screen+1
|
|
!:
|
|
//SEG30 [15] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto fn1::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda screen+1
|
|
cmp #>$400+$3e8
|
|
bcc b1_from_b1
|
|
bne !+
|
|
lda screen
|
|
cmp #<$400+$3e8
|
|
bcc b1_from_b1
|
|
!:
|
|
jmp breturn
|
|
//SEG31 fn1::@return
|
|
breturn:
|
|
//SEG32 [16] return
|
|
rts
|
|
}
|
|
|
|
ASSEMBLER OPTIMIZATIONS
|
|
Removing instruction jmp b1
|
|
Removing instruction jmp bend
|
|
Removing instruction jmp b1
|
|
Removing instruction jmp breturn
|
|
Removing instruction jmp b1
|
|
Removing instruction jmp breturn
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction ldy #0
|
|
Removing instruction ldy #0
|
|
Succesful ASM optimization Pass5UnnecesaryLoadElimination
|
|
Replacing label b1_from_b1 with b1
|
|
Replacing label b1_from_b1 with b1
|
|
Replacing label b1_from_b1 with b1
|
|
Replacing label b1_from_b1 with b1
|
|
Removing instruction b1_from_bbegin:
|
|
Removing instruction b1:
|
|
Removing instruction main_from_b1:
|
|
Removing instruction bend_from_b1:
|
|
Removing instruction b1_from_b1:
|
|
Removing instruction b1_from_b1:
|
|
Succesful ASM optimization Pass5RedundantLabelElimination
|
|
Removing instruction bend:
|
|
Removing instruction b1_from_main:
|
|
Removing instruction breturn:
|
|
Removing instruction b1_from_fn1:
|
|
Removing instruction breturn:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
Updating BasicUpstart to call main directly
|
|
Removing instruction jsr main
|
|
Succesful ASM optimization Pass5SkipBegin
|
|
Removing instruction jmp b1
|
|
Removing instruction jmp b1
|
|
Succesful ASM optimization Pass5NextJumpElimination
|
|
Removing instruction bbegin:
|
|
Succesful ASM optimization Pass5UnusedLabelElimination
|
|
|
|
FINAL SYMBOL TABLE
|
|
(label) @1
|
|
(label) @begin
|
|
(label) @end
|
|
(void()) fn1()
|
|
(label) fn1::@1
|
|
(label) fn1::@return
|
|
(byte*) fn1::screen
|
|
(byte*) fn1::screen#1 screen zp ZP_WORD:4 16.5
|
|
(byte*) fn1::screen#2 screen zp ZP_WORD:4 22.0
|
|
(void()) main()
|
|
(label) main::@1
|
|
(label) main::@return
|
|
(void()*) main::cls
|
|
(const void()*) main::cls#0 cls = &(void()) fn1()
|
|
(byte*) main::cols
|
|
(byte*) main::cols#1 cols zp ZP_WORD:2 16.5
|
|
(byte*) main::cols#2 cols zp ZP_WORD:2 14.666666666666666
|
|
|
|
zp ZP_WORD:2 [ main::cols#2 main::cols#1 ]
|
|
zp ZP_WORD:4 [ fn1::screen#2 fn1::screen#1 ]
|
|
|
|
|
|
FINAL ASSEMBLER
|
|
Score: 1222
|
|
|
|
//SEG0 File Comments
|
|
// Tests calling into a function pointer with local variables
|
|
//SEG1 Basic Upstart
|
|
.pc = $801 "Basic"
|
|
:BasicUpstart(main)
|
|
.pc = $80d "Program"
|
|
//SEG2 Global Constants & labels
|
|
//SEG3 @begin
|
|
//SEG4 [1] phi from @begin to @1 [phi:@begin->@1]
|
|
//SEG5 @1
|
|
//SEG6 [2] call main
|
|
//SEG7 [4] phi from @1 to main [phi:@1->main]
|
|
//SEG8 [3] phi from @1 to @end [phi:@1->@end]
|
|
//SEG9 @end
|
|
//SEG10 main
|
|
main: {
|
|
.label cls = fn1
|
|
.label cols = 2
|
|
//SEG11 [5] phi from main to main::@1 [phi:main->main::@1]
|
|
//SEG12 [5] phi (byte*) main::cols#2 = ((byte*))(word/dword/signed dword) $d800 [phi:main->main::@1#0] -- pbuz1=pbuc1
|
|
lda #<$d800
|
|
sta cols
|
|
lda #>$d800
|
|
sta cols+1
|
|
//SEG13 [5] phi from main::@1 to main::@1 [phi:main::@1->main::@1]
|
|
//SEG14 [5] phi (byte*) main::cols#2 = (byte*) main::cols#1 [phi:main::@1->main::@1#0] -- register_copy
|
|
//SEG15 main::@1
|
|
b1:
|
|
//SEG16 [6] call *((const void()*) main::cls#0)
|
|
jsr cls
|
|
//SEG17 [7] *((byte*) main::cols#2) ← ++ *((byte*) main::cols#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (cols),y
|
|
clc
|
|
adc #1
|
|
sta (cols),y
|
|
//SEG18 [8] (byte*) main::cols#1 ← ++ (byte*) main::cols#2 -- pbuz1=_inc_pbuz1
|
|
inc cols
|
|
bne !+
|
|
inc cols+1
|
|
!:
|
|
//SEG19 [9] if((byte*) main::cols#1<(word/dword/signed dword) $d800+(word/signed word/dword/signed dword) $3e8) goto main::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda cols+1
|
|
cmp #>$d800+$3e8
|
|
bcc b1
|
|
bne !+
|
|
lda cols
|
|
cmp #<$d800+$3e8
|
|
bcc b1
|
|
!:
|
|
//SEG20 main::@return
|
|
//SEG21 [10] return
|
|
rts
|
|
}
|
|
//SEG22 fn1
|
|
fn1: {
|
|
.label screen = 4
|
|
//SEG23 [12] phi from fn1 to fn1::@1 [phi:fn1->fn1::@1]
|
|
//SEG24 [12] phi (byte*) fn1::screen#2 = ((byte*))(word/signed word/dword/signed dword) $400 [phi:fn1->fn1::@1#0] -- pbuz1=pbuc1
|
|
lda #<$400
|
|
sta screen
|
|
lda #>$400
|
|
sta screen+1
|
|
//SEG25 [12] phi from fn1::@1 to fn1::@1 [phi:fn1::@1->fn1::@1]
|
|
//SEG26 [12] phi (byte*) fn1::screen#2 = (byte*) fn1::screen#1 [phi:fn1::@1->fn1::@1#0] -- register_copy
|
|
//SEG27 fn1::@1
|
|
b1:
|
|
//SEG28 [13] *((byte*) fn1::screen#2) ← ++ *((byte*) fn1::screen#2) -- _deref_pbuz1=_inc__deref_pbuz1
|
|
ldy #0
|
|
lda (screen),y
|
|
clc
|
|
adc #1
|
|
sta (screen),y
|
|
//SEG29 [14] (byte*) fn1::screen#1 ← ++ (byte*) fn1::screen#2 -- pbuz1=_inc_pbuz1
|
|
inc screen
|
|
bne !+
|
|
inc screen+1
|
|
!:
|
|
//SEG30 [15] if((byte*) fn1::screen#1<(word/signed word/dword/signed dword) $400+(word/signed word/dword/signed dword) $3e8) goto fn1::@1 -- pbuz1_lt_vwuc1_then_la1
|
|
lda screen+1
|
|
cmp #>$400+$3e8
|
|
bcc b1
|
|
bne !+
|
|
lda screen
|
|
cmp #<$400+$3e8
|
|
bcc b1
|
|
!:
|
|
//SEG31 fn1::@return
|
|
//SEG32 [16] return
|
|
rts
|
|
}
|
|
|