1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-08-09 04:25:12 +00:00
Files
kickc/src/test/ref/string-escapes-3.log

733 lines
24 KiB
Plaintext

Warning! Adding boolean cast to non-boolean condition *((byte*) main::msg)
Identified constant variable (byte) CH
Identified constant variable (byte*) SCREEN
Culled Empty Block (label) main::@9
Culled Empty Block (label) main::@10
Culled Empty Block (label) main::@11
Culled Empty Block (label) main::@12
Culled Empty Block (label) main::@7
Culled Empty Block (label) main::@8
CONTROL FLOW GRAPH SSA
@begin: scope:[] from
to:@1
(void()) main()
main: scope:[main] from @1
(byte*) main::line#0 ← (byte*)(number) $400
(byte*) main::cursor#0 ← (byte*) main::line#0
(byte*) main::msg#0 ← (const byte*) MESSAGE
to:main::@1
main::@1: scope:[main] from main main::@6
(byte*) main::cursor#5 ← phi( main/(byte*) main::cursor#0 main::@6/(byte*) main::cursor#6 )
(byte*) main::line#4 ← phi( main/(byte*) main::line#0 main::@6/(byte*) main::line#5 )
(byte*) main::msg#2 ← phi( main/(byte*) main::msg#0 main::@6/(byte*) main::msg#1 )
(bool~) main::$1 ← (number) 0 != *((byte*) main::msg#2)
if((bool~) main::$1) goto main::@2
to:main::@3
main::@2: scope:[main] from main::@1
(byte*) main::cursor#4 ← phi( main::@1/(byte*) main::cursor#5 )
(byte*) main::line#3 ← phi( main::@1/(byte*) main::line#4 )
(byte*) main::msg#3 ← phi( main::@1/(byte*) main::msg#2 )
if(*((byte*) main::msg#3)==(byte) '
'pm) goto main::@4
to:main::@5
main::@3: scope:[main] from main::@1
*((const byte*) SCREEN + (number) $50) ← (const byte) CH
to:main::@return
main::@4: scope:[main] from main::@2
(byte*) main::msg#6 ← phi( main::@2/(byte*) main::msg#3 )
(byte*) main::line#2 ← phi( main::@2/(byte*) main::line#3 )
(byte*) main::line#1 ← (byte*) main::line#2 + (number) $28
(byte*) main::cursor#1 ← (byte*) main::line#1
to:main::@6
main::@5: scope:[main] from main::@2
(byte*) main::line#6 ← phi( main::@2/(byte*) main::line#3 )
(byte*) main::cursor#3 ← phi( main::@2/(byte*) main::cursor#4 )
(byte*) main::msg#4 ← phi( main::@2/(byte*) main::msg#3 )
(number~) main::$0 ← *((byte*) main::msg#4) & (number) $3f
*((byte*) main::cursor#3) ← (number~) main::$0
(byte*) main::cursor#2 ← ++ (byte*) main::cursor#3
to:main::@6
main::@6: scope:[main] from main::@4 main::@5
(byte*) main::cursor#6 ← phi( main::@4/(byte*) main::cursor#1 main::@5/(byte*) main::cursor#2 )
(byte*) main::line#5 ← phi( main::@4/(byte*) main::line#1 main::@5/(byte*) main::line#6 )
(byte*) main::msg#5 ← phi( main::@4/(byte*) main::msg#6 main::@5/(byte*) main::msg#4 )
(byte*) main::msg#1 ← ++ (byte*) main::msg#5
to:main::@1
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
(const byte) CH = (byte) '
'pm
(const byte*) MESSAGE[] = (byte*) "hello
world"pm
(const byte*) SCREEN = (byte*)(number) $400
(void()) main()
(number~) main::$0
(bool~) main::$1
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#0
(byte*) main::cursor#1
(byte*) main::cursor#2
(byte*) main::cursor#3
(byte*) main::cursor#4
(byte*) main::cursor#5
(byte*) main::cursor#6
(byte*) main::line
(byte*) main::line#0
(byte*) main::line#1
(byte*) main::line#2
(byte*) main::line#3
(byte*) main::line#4
(byte*) main::line#5
(byte*) main::line#6
(byte*) main::msg
(byte*) main::msg#0
(byte*) main::msg#1
(byte*) main::msg#2
(byte*) main::msg#3
(byte*) main::msg#4
(byte*) main::msg#5
(byte*) main::msg#6
Adding number conversion cast (unumber) 0 in (bool~) main::$1 ← (number) 0 != *((byte*) main::msg#2)
Adding number conversion cast (unumber) $50 in *((const byte*) SCREEN + (number) $50) ← (const byte) CH
Adding number conversion cast (unumber) $28 in (byte*) main::line#1 ← (byte*) main::line#2 + (number) $28
Adding number conversion cast (unumber) $3f in (number~) main::$0 ← *((byte*) main::msg#4) & (number) $3f
Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← *((byte*) main::msg#4) & (unumber)(number) $3f
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant pointer cast (byte*) 1024
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast 0
Simplifying constant integer cast $50
Simplifying constant integer cast $28
Simplifying constant integer cast $3f
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $50
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) $3f
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inferred type updated to byte in (unumber~) main::$0 ← *((byte*) main::msg#4) & (byte) $3f
Alias main::cursor#0 = main::line#0
Alias main::msg#2 = main::msg#3 main::msg#6 main::msg#4
Alias main::line#2 = main::line#3 main::line#4 main::line#6
Alias main::cursor#3 = main::cursor#4 main::cursor#5
Alias main::cursor#1 = main::line#1
Successful SSA optimization Pass2AliasElimination
Alias main::msg#2 = main::msg#5
Successful SSA optimization Pass2AliasElimination
Simple Condition (bool~) main::$1 [4] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::cursor#0 = (byte*) 1024
Constant (const byte*) main::msg#0 = MESSAGE
Successful SSA optimization Pass2ConstantIdentification
Inlining constant with var siblings (const byte*) main::cursor#0
Inlining constant with var siblings (const byte*) main::msg#0
Constant inlined main::cursor#0 = (byte*) 1024
Constant inlined main::msg#0 = (const byte*) MESSAGE
Successful SSA optimization Pass2ConstantInlining
Consolidated array index constant in *(SCREEN+$50)
Successful SSA optimization Pass2ConstantAdditionElimination
Adding NOP phi() at start of @begin
Adding NOP phi() at start of @1
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
Created 5 initial phi equivalence classes
Coalesced [14] main::line#9 ← main::line#2
Coalesced [15] main::cursor#9 ← main::cursor#2
Coalesced [18] main::msg#7 ← main::msg#1
Coalesced (already) [19] main::line#7 ← main::line#5
Coalesced [20] main::cursor#7 ← main::cursor#6
Not coalescing [22] main::line#8 ← main::cursor#1
Coalesced [23] main::cursor#8 ← main::cursor#1
Coalesced down to 3 phi equivalence classes
Culled Empty Block (label) @2
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
[0] phi()
to:@1
@1: scope:[] from @begin
[1] phi()
[2] call main
to:@end
@end: scope:[] from @1
[3] phi()
(void()) main()
main: scope:[main] from @1
[4] phi()
to:main::@1
main::@1: scope:[main] from main main::@6
[5] (byte*) main::cursor#3 ← phi( main/(byte*) 1024 main::@6/(byte*) main::cursor#6 )
[5] (byte*) main::line#2 ← phi( main/(byte*) 1024 main::@6/(byte*) main::line#5 )
[5] (byte*) main::msg#2 ← phi( main/(const byte*) MESSAGE main::@6/(byte*) main::msg#1 )
[6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@1
[7] *((const byte*) SCREEN+(byte) $50) ← (const byte) CH
to:main::@return
main::@return: scope:[main] from main::@3
[8] return
to:@return
main::@2: scope:[main] from main::@1
[9] if(*((byte*) main::msg#2)==(byte) '
'pm) goto main::@4
to:main::@5
main::@5: scope:[main] from main::@2
[10] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f
[11] *((byte*) main::cursor#3) ← (byte~) main::$0
[12] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3
to:main::@6
main::@6: scope:[main] from main::@4 main::@5
[13] (byte*) main::cursor#6 ← phi( main::@4/(byte*) main::cursor#1 main::@5/(byte*) main::cursor#2 )
[13] (byte*) main::line#5 ← phi( main::@4/(byte*) main::line#8 main::@5/(byte*) main::line#2 )
[14] (byte*) main::msg#1 ← ++ (byte*) main::msg#2
to:main::@1
main::@4: scope:[main] from main::@2
[15] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28
[16] (byte*) main::line#8 ← (byte*) main::cursor#1
to:main::@6
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte~) main::$0 202.0
(byte*) main::cursor
(byte*) main::cursor#1 151.5
(byte*) main::cursor#2 202.0
(byte*) main::cursor#3 60.599999999999994
(byte*) main::cursor#6 151.5
(byte*) main::line
(byte*) main::line#2 50.5
(byte*) main::line#5 151.5
(byte*) main::line#8 202.0
(byte*) main::msg
(byte*) main::msg#1 202.0
(byte*) main::msg#2 56.11111111111111
Initial phi equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::line#2 main::line#5 main::line#8 ]
[ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
Added variable main::$0 to live range equivalence class [ main::$0 ]
Complete equivalence classes
[ main::msg#2 main::msg#1 ]
[ main::line#2 main::line#5 main::line#8 ]
[ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
[ main::$0 ]
Allocated zp[2]:2 [ main::msg#2 main::msg#1 ]
Allocated zp[2]:4 [ main::line#2 main::line#5 main::line#8 ]
Allocated zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
Allocated zp[1]:8 [ main::$0 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const CH = '\n'
.label SCREEN = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label __0 = 8
.label cursor = 6
.label msg = 2
.label line = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<$400
sta.z cursor
lda #>$400
sta.z cursor+1
// [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta.z line
lda #>$400
sta.z line+1
// [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1
lda #<MESSAGE
sta.z msg
lda #>MESSAGE
sta.z msg+1
jmp __b1
// main::@1
__b1:
// [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1
ldy #0
lda (msg),y
cmp #0
bne __b2
jmp __b3
// main::@3
__b3:
// [7] *((const byte*) SCREEN+(byte) $50) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH
sta SCREEN+$50
jmp __breturn
// main::@return
__breturn:
// [8] return
rts
// main::@2
__b2:
// [9] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@4 -- _deref_pbuz1_eq_vbuc1_then_la1
lda #'\n'
ldy #0
cmp (msg),y
beq __b4
jmp __b5
// main::@5
__b5:
// [10] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuz1=_deref_pbuz2_band_vbuc1
lda #$3f
ldy #0
and (msg),y
sta.z __0
// [11] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuz2
lda.z __0
ldy #0
sta (cursor),y
// [12] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1
inc.z cursor
bne !+
inc.z cursor+1
!:
// [13] phi from main::@4 main::@5 to main::@6 [phi:main::@4/main::@5->main::@6]
__b6_from___b4:
__b6_from___b5:
// [13] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@4/main::@5->main::@6#0] -- register_copy
// [13] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@4/main::@5->main::@6#1] -- register_copy
jmp __b6
// main::@6
__b6:
// [14] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1
inc.z msg
bne !+
inc.z msg+1
!:
// [5] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
__b1_from___b6:
// [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@6->main::@1#0] -- register_copy
// [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@6->main::@1#1] -- register_copy
// [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@6->main::@1#2] -- register_copy
jmp __b1
// main::@4
__b4:
// [15] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #$28
clc
adc.z line
sta.z cursor
lda #0
adc.z line+1
sta.z cursor+1
// [16] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2
lda.z cursor
sta.z line
lda.z cursor+1
sta.z line+1
jmp __b6_from___b4
}
// File Data
MESSAGE: .text @"hello\nworld"
.byte 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] { } ) always clobbers reg byte a reg byte y
Statement [7] *((const byte*) SCREEN+(byte) $50) ← (const byte) CH [ ] ( main:2 [ ] { } ) always clobbers reg byte a
Statement [9] if(*((byte*) main::msg#2)==(byte) '
'pm) goto main::@4 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] { } ) always clobbers reg byte a reg byte y
Statement [10] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f [ main::msg#2 main::line#2 main::cursor#3 main::$0 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 main::$0 ] { } ) always clobbers reg byte a reg byte y
Statement [11] *((byte*) main::cursor#3) ← (byte~) main::$0 [ main::msg#2 main::line#2 main::cursor#3 ] ( main:2 [ main::msg#2 main::line#2 main::cursor#3 ] { } ) always clobbers reg byte y
Statement [15] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 [ main::msg#2 main::cursor#1 ] ( main:2 [ main::msg#2 main::cursor#1 ] { } ) always clobbers reg byte a
Statement [16] (byte*) main::line#8 ← (byte*) main::cursor#1 [ main::msg#2 main::line#8 main::cursor#1 ] ( main:2 [ main::msg#2 main::line#8 main::cursor#1 ] { } ) always clobbers reg byte a
Potential registers zp[2]:2 [ main::msg#2 main::msg#1 ] : zp[2]:2 ,
Potential registers zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] : zp[2]:4 ,
Potential registers zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] : zp[2]:6 ,
Potential registers zp[1]:8 [ main::$0 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 565.6: zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] 404: zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] 258.11: zp[2]:2 [ main::msg#2 main::msg#1 ] 202: zp[1]:8 [ main::$0 ]
Uplift Scope []
Uplifting [main] best 1472 combination zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ] zp[2]:4 [ main::line#2 main::line#5 main::line#8 ] zp[2]:2 [ main::msg#2 main::msg#1 ] reg byte a [ main::$0 ]
Uplifting [] best 1472 combination
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
// Upstart
.pc = $801 "Basic"
:BasicUpstart(__bbegin)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const CH = '\n'
.label SCREEN = $400
// @begin
__bbegin:
// [1] phi from @begin to @1 [phi:@begin->@1]
__b1_from___bbegin:
jmp __b1
// @1
__b1:
// [2] call main
// [4] phi from @1 to main [phi:@1->main]
main_from___b1:
jsr main
// [3] phi from @1 to @end [phi:@1->@end]
__bend_from___b1:
jmp __bend
// @end
__bend:
// main
main: {
.label cursor = 6
.label msg = 2
.label line = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
__b1_from_main:
// [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<$400
sta.z cursor
lda #>$400
sta.z cursor+1
// [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta.z line
lda #>$400
sta.z line+1
// [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1
lda #<MESSAGE
sta.z msg
lda #>MESSAGE
sta.z msg+1
jmp __b1
// main::@1
__b1:
// [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1
ldy #0
lda (msg),y
cmp #0
bne __b2
jmp __b3
// main::@3
__b3:
// [7] *((const byte*) SCREEN+(byte) $50) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH
sta SCREEN+$50
jmp __breturn
// main::@return
__breturn:
// [8] return
rts
// main::@2
__b2:
// [9] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@4 -- _deref_pbuz1_eq_vbuc1_then_la1
lda #'\n'
ldy #0
cmp (msg),y
beq __b4
jmp __b5
// main::@5
__b5:
// [10] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuaa=_deref_pbuz1_band_vbuc1
lda #$3f
ldy #0
and (msg),y
// [11] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuaa
ldy #0
sta (cursor),y
// [12] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1
inc.z cursor
bne !+
inc.z cursor+1
!:
// [13] phi from main::@4 main::@5 to main::@6 [phi:main::@4/main::@5->main::@6]
__b6_from___b4:
__b6_from___b5:
// [13] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@4/main::@5->main::@6#0] -- register_copy
// [13] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@4/main::@5->main::@6#1] -- register_copy
jmp __b6
// main::@6
__b6:
// [14] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1
inc.z msg
bne !+
inc.z msg+1
!:
// [5] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
__b1_from___b6:
// [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@6->main::@1#0] -- register_copy
// [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@6->main::@1#1] -- register_copy
// [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@6->main::@1#2] -- register_copy
jmp __b1
// main::@4
__b4:
// [15] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #$28
clc
adc.z line
sta.z cursor
lda #0
adc.z line+1
sta.z cursor+1
// [16] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2
lda.z cursor
sta.z line
lda.z cursor+1
sta.z line+1
jmp __b6_from___b4
}
// File Data
MESSAGE: .text @"hello\nworld"
.byte 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __bend
Removing instruction jmp __b1
Removing instruction jmp __b3
Removing instruction jmp __breturn
Removing instruction jmp __b5
Removing instruction jmp __b6
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b6_from___b4 with __b6
Removing instruction __b1_from___bbegin:
Removing instruction __b1:
Removing instruction main_from___b1:
Removing instruction __bend_from___b1:
Removing instruction __b6_from___b4:
Removing instruction __b6_from___b5:
Succesful ASM optimization Pass5RedundantLabelElimination
Removing instruction __bend:
Removing instruction __b1_from_main:
Removing instruction __b3:
Removing instruction __breturn:
Removing instruction __b5:
Removing instruction __b1_from___b6:
Succesful ASM optimization Pass5UnusedLabelElimination
Updating BasicUpstart to call main directly
Removing instruction jsr main
Succesful ASM optimization Pass5SkipBegin
Removing instruction ldy #0
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Removing instruction __bbegin:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(label) @1
(label) @begin
(label) @end
(const byte) CH = (byte) '
'pm
(const byte*) MESSAGE[] = (byte*) "hello
world"pm
(const byte*) SCREEN = (byte*) 1024
(void()) main()
(byte~) main::$0 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@return
(byte*) main::cursor
(byte*) main::cursor#1 cursor zp[2]:6 151.5
(byte*) main::cursor#2 cursor zp[2]:6 202.0
(byte*) main::cursor#3 cursor zp[2]:6 60.599999999999994
(byte*) main::cursor#6 cursor zp[2]:6 151.5
(byte*) main::line
(byte*) main::line#2 line zp[2]:4 50.5
(byte*) main::line#5 line zp[2]:4 151.5
(byte*) main::line#8 line zp[2]:4 202.0
(byte*) main::msg
(byte*) main::msg#1 msg zp[2]:2 202.0
(byte*) main::msg#2 msg zp[2]:2 56.11111111111111
zp[2]:2 [ main::msg#2 main::msg#1 ]
zp[2]:4 [ main::line#2 main::line#5 main::line#8 ]
zp[2]:6 [ main::cursor#3 main::cursor#6 main::cursor#1 main::cursor#2 ]
reg byte a [ main::$0 ]
FINAL ASSEMBLER
Score: 1297
// File Comments
// Test using some simple supported string escape \n in both string and char
// Uses encoding PETSCII mixed
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.encoding "petscii_mixed"
.const CH = '\n'
.label SCREEN = $400
// @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
main: {
.label cursor = 6
.label msg = 2
.label line = 4
// [5] phi from main to main::@1 [phi:main->main::@1]
// [5] phi (byte*) main::cursor#3 = (byte*) 1024 [phi:main->main::@1#0] -- pbuz1=pbuc1
lda #<$400
sta.z cursor
lda #>$400
sta.z cursor+1
// [5] phi (byte*) main::line#2 = (byte*) 1024 [phi:main->main::@1#1] -- pbuz1=pbuc1
lda #<$400
sta.z line
lda #>$400
sta.z line+1
// [5] phi (byte*) main::msg#2 = (const byte*) MESSAGE [phi:main->main::@1#2] -- pbuz1=pbuc1
lda #<MESSAGE
sta.z msg
lda #>MESSAGE
sta.z msg+1
// main::@1
__b1:
// while(*msg)
// [6] if((byte) 0!=*((byte*) main::msg#2)) goto main::@2 -- vbuc1_neq__deref_pbuz1_then_la1
ldy #0
lda (msg),y
cmp #0
bne __b2
// main::@3
// SCREEN[0x50] = CH
// [7] *((const byte*) SCREEN+(byte) $50) ← (const byte) CH -- _deref_pbuc1=vbuc2
lda #CH
sta SCREEN+$50
// main::@return
// }
// [8] return
rts
// main::@2
__b2:
// case '\n':
// line += 0x28;
// cursor = line;
// break;
// [9] if(*((byte*) main::msg#2)==(byte) ' 'pm) goto main::@4 -- _deref_pbuz1_eq_vbuc1_then_la1
lda #'\n'
ldy #0
cmp (msg),y
beq __b4
// main::@5
// *msg & 0x3f
// [10] (byte~) main::$0 ← *((byte*) main::msg#2) & (byte) $3f -- vbuaa=_deref_pbuz1_band_vbuc1
lda #$3f
and (msg),y
// *cursor++ = *msg & 0x3f
// [11] *((byte*) main::cursor#3) ← (byte~) main::$0 -- _deref_pbuz1=vbuaa
sta (cursor),y
// *cursor++ = *msg & 0x3f;
// [12] (byte*) main::cursor#2 ← ++ (byte*) main::cursor#3 -- pbuz1=_inc_pbuz1
inc.z cursor
bne !+
inc.z cursor+1
!:
// [13] phi from main::@4 main::@5 to main::@6 [phi:main::@4/main::@5->main::@6]
// [13] phi (byte*) main::cursor#6 = (byte*) main::cursor#1 [phi:main::@4/main::@5->main::@6#0] -- register_copy
// [13] phi (byte*) main::line#5 = (byte*) main::line#8 [phi:main::@4/main::@5->main::@6#1] -- register_copy
// main::@6
__b6:
// msg++;
// [14] (byte*) main::msg#1 ← ++ (byte*) main::msg#2 -- pbuz1=_inc_pbuz1
inc.z msg
bne !+
inc.z msg+1
!:
// [5] phi from main::@6 to main::@1 [phi:main::@6->main::@1]
// [5] phi (byte*) main::cursor#3 = (byte*) main::cursor#6 [phi:main::@6->main::@1#0] -- register_copy
// [5] phi (byte*) main::line#2 = (byte*) main::line#5 [phi:main::@6->main::@1#1] -- register_copy
// [5] phi (byte*) main::msg#2 = (byte*) main::msg#1 [phi:main::@6->main::@1#2] -- register_copy
jmp __b1
// main::@4
__b4:
// line += 0x28
// [15] (byte*) main::cursor#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz2_plus_vbuc1
lda #$28
clc
adc.z line
sta.z cursor
lda #0
adc.z line+1
sta.z cursor+1
// [16] (byte*) main::line#8 ← (byte*) main::cursor#1 -- pbuz1=pbuz2
lda.z cursor
sta.z line
lda.z cursor+1
sta.z line+1
jmp __b6
}
// File Data
MESSAGE: .text @"hello\nworld"
.byte 0