diff --git a/src/test/ref/address-8.cfg b/src/test/ref/address-8.cfg new file mode 100644 index 000000000..73b10e560 --- /dev/null +++ b/src/test/ref/address-8.cfg @@ -0,0 +1,8 @@ + +(void()) main() +main: scope:[main] from + [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return diff --git a/src/test/ref/address-8.log b/src/test/ref/address-8.log new file mode 100644 index 000000000..0bd7807ae --- /dev/null +++ b/src/test/ref/address-8.log @@ -0,0 +1,175 @@ + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start + *((const nomodify byte*) SCREEN + (number) 0) ← *((const byte*) DATA + (number) 0) + to:main::@return +main::@return: scope:[main] from main + return + to:@return + +(void()) _start() +_start: scope:[_start] from + call main + to:_start::@1 +_start::@1: scope:[_start] from _start + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + return + to:@return + +SYMBOL TABLE SSA +(const byte*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(void()) _start() +(label) _start::@1 +(label) _start::@return +(void()) main() +(label) main::@return + +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (number) 0) ← *((const byte*) DATA + (number) 0) +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (number) 0) ← *((const byte*) DATA + (unumber)(number) 0) +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Simplifying expression containing zero DATA in [0] *((const nomodify byte*) SCREEN + (byte) 0) ← *((const byte*) DATA + (byte) 0) +Simplifying expression containing zero SCREEN in [0] *((const nomodify byte*) SCREEN + (byte) 0) ← *((const byte*) DATA) +Successful SSA optimization PassNSimplifyExpressionWithZero +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test declaring an array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) -- _deref_pbuc1=_deref_pbuc2 + lda DATA + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill $3e8, 0 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 17 combination +Uplifting [] best 17 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test declaring an array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) -- _deref_pbuc1=_deref_pbuc2 + lda DATA + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill $3e8, 0 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const byte*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@return + + + +FINAL ASSEMBLER +Score: 14 + + // File Comments +// Test declaring an array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // SCREEN[0] = DATA[0] + // [0] *((const nomodify byte*) SCREEN) ← *((const byte*) DATA) -- _deref_pbuc1=_deref_pbuc2 + lda DATA + sta SCREEN + // main::@return + // } + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill $3e8, 0 + diff --git a/src/test/ref/address-8.sym b/src/test/ref/address-8.sym new file mode 100644 index 000000000..97e2be29f --- /dev/null +++ b/src/test/ref/address-8.sym @@ -0,0 +1,5 @@ +(const byte*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@return + diff --git a/src/test/ref/address-9.cfg b/src/test/ref/address-9.cfg new file mode 100644 index 000000000..54660e1de --- /dev/null +++ b/src/test/ref/address-9.cfg @@ -0,0 +1,8 @@ + +(void()) main() +main: scope:[main] from + [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return diff --git a/src/test/ref/address-9.log b/src/test/ref/address-9.log new file mode 100644 index 000000000..6262556d5 --- /dev/null +++ b/src/test/ref/address-9.log @@ -0,0 +1,192 @@ + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start + (number~) main::$0 ← (number) 0 * (const byte) SIZEOF_SIGNED_WORD + *((const nomodify signed word*) SCREEN + (number~) main::$0) ← *((const signed word*) DATA + (number~) main::$0) + to:main::@return +main::@return: scope:[main] from main + return + to:@return + +(void()) _start() +_start: scope:[_start] from + call main + to:_start::@1 +_start::@1: scope:[_start] from _start + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + return + to:@return + +SYMBOL TABLE SSA +(const signed word*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify signed word*) SCREEN = (signed word*)(number) $400 +(const byte) SIZEOF_SIGNED_WORD = (byte) 2 +(void()) _start() +(label) _start::@1 +(label) _start::@return +(void()) main() +(number~) main::$0 +(label) main::@return + +Adding number conversion cast (unumber) 0 in (number~) main::$0 ← (number) 0 * (const byte) SIZEOF_SIGNED_WORD +Adding number conversion cast (unumber) main::$0 in (number~) main::$0 ← (unumber)(number) 0 * (const byte) SIZEOF_SIGNED_WORD +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant pointer cast (signed word*) 1024 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to byte in (unumber~) main::$0 ← (byte) 0 * (const byte) SIZEOF_SIGNED_WORD +Constant right-side identified [0] (byte~) main::$0 ← (byte) 0 * (const byte) SIZEOF_SIGNED_WORD +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::$0 = 0*SIZEOF_SIGNED_WORD +Successful SSA optimization Pass2ConstantIdentification +Simplifying constant evaluating to zero (byte) 0*(const byte) SIZEOF_SIGNED_WORD in +Successful SSA optimization PassNSimplifyConstantZero +Simplifying expression containing zero DATA in [1] *((const nomodify signed word*) SCREEN + (const byte) main::$0) ← *((const signed word*) DATA + (const byte) main::$0) +Simplifying expression containing zero SCREEN in [1] *((const nomodify signed word*) SCREEN + (const byte) main::$0) ← *((const signed word*) DATA) +Successful SSA optimization PassNSimplifyExpressionWithZero +Eliminating unused constant (const byte) main::$0 +Eliminating unused constant (const byte) SIZEOF_SIGNED_WORD +Successful SSA optimization PassNEliminateUnusedVars +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test declaring an integer array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) -- _deref_pwsc1=_deref_pwsc2 + lda DATA + sta SCREEN + lda DATA+1 + sta SCREEN+1 + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill 2*$3e8, 0 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 25 combination +Uplifting [] best 25 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test declaring an integer array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) -- _deref_pwsc1=_deref_pwsc2 + lda DATA + sta SCREEN + lda DATA+1 + sta SCREEN+1 + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill 2*$3e8, 0 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const signed word*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify signed word*) SCREEN = (signed word*) 1024 +(void()) main() +(label) main::@return + + + +FINAL ASSEMBLER +Score: 22 + + // File Comments +// Test declaring an integer array variable as at a hard-coded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // The screen + .label SCREEN = $400 + // main +main: { + // SCREEN[0] = DATA[0] + // [0] *((const nomodify signed word*) SCREEN) ← *((const signed word*) DATA) -- _deref_pwsc1=_deref_pwsc2 + lda DATA + sta SCREEN + lda DATA+1 + sta SCREEN+1 + // main::@return + // } + // [1] return + rts +} + // File Data +.pc = $1000 "DATA" + // Data to be put on the screen + DATA: .fill 2*$3e8, 0 + diff --git a/src/test/ref/address-9.sym b/src/test/ref/address-9.sym new file mode 100644 index 000000000..f810c9f1c --- /dev/null +++ b/src/test/ref/address-9.sym @@ -0,0 +1,5 @@ +(const signed word*) DATA[(number) $3e8] = { fill( $3e8, 0) } +(const nomodify signed word*) SCREEN = (signed word*) 1024 +(void()) main() +(label) main::@return + diff --git a/src/test/ref/arrays-init-kasm-1.cfg b/src/test/ref/arrays-init-kasm-1.cfg new file mode 100644 index 000000000..9bfe86442 --- /dev/null +++ b/src/test/ref/arrays-init-kasm-1.cfg @@ -0,0 +1,8 @@ + +(void()) main() +main: scope:[main] from + [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return diff --git a/src/test/ref/arrays-init-kasm-1.log b/src/test/ref/arrays-init-kasm-1.log new file mode 100644 index 000000000..1be32f698 --- /dev/null +++ b/src/test/ref/arrays-init-kasm-1.log @@ -0,0 +1,192 @@ +Inlined call call _init + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start::@1 + *((const byte*) SCREEN + (number) 0) ← *((const byte*) SINTAB + (number) 0) + to:main::@return +main::@return: scope:[main] from main + return + to:@return + +(void()) _start() +_start: scope:[_start] from + to:_start::_init1 +_start::_init1: scope:[_start] from _start + to:_start::@1 +_start::@1: scope:[_start] from _start::_init1 + call main + to:_start::@2 +_start::@2: scope:[_start] from _start::@1 + to:_start::@return +_start::@return: scope:[_start] from _start::@2 + return + to:@return + +SYMBOL TABLE SSA +(const byte*) SCREEN = (byte*)(number) $400 +(const byte*) SINTAB[(number) $100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256) + }} +(void()) _start() +(label) _start::@1 +(label) _start::@2 +(label) _start::@return +(label) _start::_init1 +(void()) main() +(label) main::@return + +Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN + (number) 0) ← *((const byte*) SINTAB + (number) 0) +Adding number conversion cast (unumber) 0 in *((const byte*) SCREEN + (number) 0) ← *((const byte*) SINTAB + (unumber)(number) 0) +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Simplifying expression containing zero SINTAB in [0] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) SINTAB + (byte) 0) +Simplifying expression containing zero SCREEN in [0] *((const byte*) SCREEN + (byte) 0) ← *((const byte*) SINTAB) +Successful SSA optimization PassNSimplifyExpressionWithZero +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::_init1 +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@2 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test initializing array using KickAssembler +// Place array at hardcoded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + // [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) -- _deref_pbuc1=_deref_pbuc2 + lda SINTAB + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "SINTAB" +// Sinus table at an absolute address in memory +SINTAB: +.fill 256, 128 + 128*sin(i*2*PI/256) + + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 17 combination +Uplifting [] best 17 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test initializing array using KickAssembler +// Place array at hardcoded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + // [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) -- _deref_pbuc1=_deref_pbuc2 + lda SINTAB + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data +.pc = $1000 "SINTAB" +// Sinus table at an absolute address in memory +SINTAB: +.fill 256, 128 + 128*sin(i*2*PI/256) + + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const byte*) SCREEN = (byte*) 1024 +(const byte*) SINTAB[(number) $100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256) + }} +(void()) main() +(label) main::@return + + + +FINAL ASSEMBLER +Score: 14 + + // File Comments +// Test initializing array using KickAssembler +// Place array at hardcoded address + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + // SCREEN[0] = SINTAB[0] + // [0] *((const byte*) SCREEN) ← *((const byte*) SINTAB) -- _deref_pbuc1=_deref_pbuc2 + lda SINTAB + sta SCREEN + // main::@return + // } + // [1] return + rts +} + // File Data +.pc = $1000 "SINTAB" +// Sinus table at an absolute address in memory +SINTAB: +.fill 256, 128 + 128*sin(i*2*PI/256) + + diff --git a/src/test/ref/arrays-init-kasm-1.sym b/src/test/ref/arrays-init-kasm-1.sym new file mode 100644 index 000000000..dcdb4ebb4 --- /dev/null +++ b/src/test/ref/arrays-init-kasm-1.sym @@ -0,0 +1,6 @@ +(const byte*) SCREEN = (byte*) 1024 +(const byte*) SINTAB[(number) $100] = kickasm {{ .fill 256, 128 + 128*sin(i*2*PI/256) + }} +(void()) main() +(label) main::@return + diff --git a/src/test/ref/empty-function-0.cfg b/src/test/ref/empty-function-0.cfg new file mode 100644 index 000000000..9f6f51e27 --- /dev/null +++ b/src/test/ref/empty-function-0.cfg @@ -0,0 +1,11 @@ + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@1 +main::@1: scope:[main] from main + [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 + to:main::@return +main::@return: scope:[main] from main::@1 + [2] return + to:@return diff --git a/src/test/ref/empty-function-0.log b/src/test/ref/empty-function-0.log new file mode 100644 index 000000000..a6a32728f --- /dev/null +++ b/src/test/ref/empty-function-0.log @@ -0,0 +1,253 @@ +Inlined call call _init + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start::@1 + (byte) v#12 ← phi( _start::@1/(byte) v#13 ) + call set + to:main::@1 +main::@1: scope:[main] from main + (byte) v#7 ← phi( main/(byte) v#3 ) + (byte) v#0 ← (byte) v#7 + *((const nomodify byte*) SCREEN + (number) 0) ← (byte) v#0 + to:main::@return +main::@return: scope:[main] from main::@1 + (byte) v#8 ← phi( main::@1/(byte) v#0 ) + (byte) v#1 ← (byte) v#8 + return + to:@return + +(void()) set() +set: scope:[set] from main + (byte) v#2 ← (number) 7 + to:set::@return +set::@return: scope:[set] from set + (byte) v#9 ← phi( set/(byte) v#2 ) + (byte) v#3 ← (byte) v#9 + return + to:@return + +(void()) _start() +_start: scope:[_start] from + to:_start::_init1 +_start::_init1: scope:[_start] from _start + (byte) v#4 ← (byte) 0 + to:_start::@1 +_start::@1: scope:[_start] from _start::_init1 + (byte) v#13 ← phi( _start::_init1/(byte) v#4 ) + call main + to:_start::@2 +_start::@2: scope:[_start] from _start::@1 + (byte) v#10 ← phi( _start::@1/(byte) v#1 ) + (byte) v#5 ← (byte) v#10 + to:_start::@return +_start::@return: scope:[_start] from _start::@2 + (byte) v#11 ← phi( _start::@2/(byte) v#5 ) + (byte) v#6 ← (byte) v#11 + return + to:@return + +SYMBOL TABLE SSA +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(void()) _start() +(label) _start::@1 +(label) _start::@2 +(label) _start::@return +(label) _start::_init1 +(void()) main() +(label) main::@1 +(label) main::@return +(void()) set() +(label) set::@return +(byte) v +(byte) v#0 +(byte) v#1 +(byte) v#10 +(byte) v#11 +(byte) v#12 +(byte) v#13 +(byte) v#2 +(byte) v#3 +(byte) v#4 +(byte) v#5 +(byte) v#6 +(byte) v#7 +(byte) v#8 +(byte) v#9 + +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (number) 0) ← (byte) v#0 +Adding number conversion cast (unumber) 7 in (byte) v#2 ← (number) 7 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte) v#2 ← (unumber)(number) 7 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Simplifying constant integer cast 7 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 7 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Alias v#0 = v#7 v#8 v#1 +Alias v#2 = v#9 v#3 +Alias v#13 = v#4 +Alias v#10 = v#5 v#11 v#6 +Successful SSA optimization Pass2AliasElimination +Identical Phi Values (byte) v#12 (byte) v#13 +Identical Phi Values (byte) v#0 (byte) v#2 +Identical Phi Values (byte) v#10 (byte) v#0 +Successful SSA optimization Pass2IdenticalPhiElimination +Constant (const byte) v#2 = 7 +Constant (const byte) v#13 = 0 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero SCREEN in [3] *((const nomodify byte*) SCREEN + (byte) 0) ← (const byte) v#2 +Successful SSA optimization PassNSimplifyExpressionWithZero +Eliminating unused constant (const byte) v#13 +Successful SSA optimization PassNEliminateUnusedVars +Removing call to empty procedure [0] call set +Removing unused procedure set +Removing unused procedure block set +Removing unused procedure block set::@return +Successful SSA optimization PassNEliminateEmptyProcedure +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::_init1 +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@2 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +Adding NOP phi() at start of main +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@1 +main::@1: scope:[main] from main + [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 + to:main::@return +main::@return: scope:[main] from main::@1 + [2] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() +(byte) v + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .const v = 7 + .label SCREEN = $400 + // main +main: { + jmp __b1 + // main::@1 + __b1: + // [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 -- _deref_pbuc1=vbuc2 + lda #v + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [2] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 45 combination +Uplifting [] best 45 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .const v = 7 + .label SCREEN = $400 + // main +main: { + jmp __b1 + // main::@1 + __b1: + // [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 -- _deref_pbuc1=vbuc2 + lda #v + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [2] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b1: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@return +(byte) v +(const byte) v#2 v = (byte) 7 + + + +FINAL ASSEMBLER +Score: 12 + + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .const v = 7 + .label SCREEN = $400 + // main +main: { + // main::@1 + // SCREEN[0] = v + // [1] *((const nomodify byte*) SCREEN) ← (const byte) v#2 -- _deref_pbuc1=vbuc2 + lda #v + sta SCREEN + // main::@return + // } + // [2] return + rts +} + // File Data + diff --git a/src/test/ref/empty-function-0.sym b/src/test/ref/empty-function-0.sym new file mode 100644 index 000000000..725f7ed17 --- /dev/null +++ b/src/test/ref/empty-function-0.sym @@ -0,0 +1,7 @@ +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@return +(byte) v +(const byte) v#2 v = (byte) 7 + diff --git a/src/test/ref/empty-function-1.cfg b/src/test/ref/empty-function-1.cfg new file mode 100644 index 000000000..2d8347d2e --- /dev/null +++ b/src/test/ref/empty-function-1.cfg @@ -0,0 +1,11 @@ + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@1 +main::@1: scope:[main] from main + [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' + to:main::@return +main::@return: scope:[main] from main::@1 + [2] return + to:@return diff --git a/src/test/ref/empty-function-1.log b/src/test/ref/empty-function-1.log new file mode 100644 index 000000000..2126ab020 --- /dev/null +++ b/src/test/ref/empty-function-1.log @@ -0,0 +1,190 @@ + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start + call empty + to:main::@1 +main::@1: scope:[main] from main + *((const nomodify byte*) SCREEN + (number) 0) ← (byte) 'x' + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return + +(void()) empty() +empty: scope:[empty] from main + to:empty::@return +empty::@return: scope:[empty] from empty + return + to:@return + +(void()) _start() +_start: scope:[_start] from + call main + to:_start::@1 +_start::@1: scope:[_start] from _start + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + return + to:@return + +SYMBOL TABLE SSA +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(void()) _start() +(label) _start::@1 +(label) _start::@return +(void()) empty() +(label) empty::@return +(void()) main() +(label) main::@1 +(label) main::@return + +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SCREEN + (number) 0) ← (byte) 'x' +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Simplifying expression containing zero SCREEN in [1] *((const nomodify byte*) SCREEN + (byte) 0) ← (byte) 'x' +Successful SSA optimization PassNSimplifyExpressionWithZero +Removing call to empty procedure [0] call empty +Removing unused procedure empty +Removing unused procedure block empty +Removing unused procedure block empty::@return +Successful SSA optimization PassNEliminateEmptyProcedure +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +Adding NOP phi() at start of main +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@1 +main::@1: scope:[main] from main + [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' + to:main::@return +main::@return: scope:[main] from main::@1 + [2] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + jmp __b1 + // main::@1 + __b1: + // [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' -- _deref_pbuc1=vbuc2 + lda #'x' + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [2] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' [ ] ( [ ] { } ) always clobbers reg byte a + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 45 combination +Uplifting [] best 45 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + jmp __b1 + // main::@1 + __b1: + // [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' -- _deref_pbuc1=vbuc2 + lda #'x' + sta SCREEN + jmp __breturn + // main::@return + __breturn: + // [2] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b1 +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b1: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@return + + + +FINAL ASSEMBLER +Score: 12 + + // File Comments +// Test removal of empty function + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + .label SCREEN = $400 + // main +main: { + // main::@1 + // SCREEN[0] = 'x' + // [1] *((const nomodify byte*) SCREEN) ← (byte) 'x' -- _deref_pbuc1=vbuc2 + lda #'x' + sta SCREEN + // main::@return + // } + // [2] return + rts +} + // File Data + diff --git a/src/test/ref/empty-function-1.sym b/src/test/ref/empty-function-1.sym new file mode 100644 index 000000000..56e4a9bda --- /dev/null +++ b/src/test/ref/empty-function-1.sym @@ -0,0 +1,5 @@ +(const nomodify byte*) SCREEN = (byte*) 1024 +(void()) main() +(label) main::@1 +(label) main::@return + diff --git a/src/test/ref/empty-function-2.cfg b/src/test/ref/empty-function-2.cfg new file mode 100644 index 000000000..83d26add2 --- /dev/null +++ b/src/test/ref/empty-function-2.cfg @@ -0,0 +1,8 @@ + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return diff --git a/src/test/ref/empty-function-2.log b/src/test/ref/empty-function-2.log new file mode 100644 index 000000000..d066b8f1f --- /dev/null +++ b/src/test/ref/empty-function-2.log @@ -0,0 +1,156 @@ + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start + call empty + to:main::@1 +main::@1: scope:[main] from main + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return + +(void()) empty() +empty: scope:[empty] from main + to:empty::@return +empty::@return: scope:[empty] from empty + return + to:@return + +(void()) _start() +_start: scope:[_start] from + call main + to:_start::@1 +_start::@1: scope:[_start] from _start + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + return + to:@return + +SYMBOL TABLE SSA +(void()) _start() +(label) _start::@1 +(label) _start::@return +(void()) empty() +(label) empty::@return +(void()) main() +(label) main::@1 +(label) main::@return + +Removing call to empty procedure [0] call empty +Removing unused procedure empty +Removing unused procedure block empty +Removing unused procedure block empty::@return +Successful SSA optimization PassNEliminateEmptyProcedure +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@1 +CALL GRAPH + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Culled Empty Block (label) main::@1 +Adding NOP phi() at start of main + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] phi() + to:main::@return +main::@return: scope:[main] from main + [1] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) main() + +Initial phi equivalence classes +Complete equivalence classes + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Test removal of empty function +// main() should not be removed! + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // main +main: { + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS + +REGISTER UPLIFT SCOPES +Uplift Scope [main] +Uplift Scope [] + +Uplifting [main] best 36 combination +Uplifting [] best 36 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Test removal of empty function +// main() should not be removed! + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // main +main: { + jmp __breturn + // main::@return + __breturn: + // [1] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(void()) main() +(label) main::@return + + + +FINAL ASSEMBLER +Score: 6 + + // File Comments +// Test removal of empty function +// main() should not be removed! + // Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + // Global Constants & labels + // main +main: { + // main::@return + // } + // [1] return + rts +} + // File Data + diff --git a/src/test/ref/empty-function-2.sym b/src/test/ref/empty-function-2.sym new file mode 100644 index 000000000..1ad6682d3 --- /dev/null +++ b/src/test/ref/empty-function-2.sym @@ -0,0 +1,3 @@ +(void()) main() +(label) main::@return + diff --git a/src/test/ref/examples/krillload/krillload.cfg b/src/test/ref/examples/krillload/krillload.cfg new file mode 100644 index 000000000..9b1e2a2bc --- /dev/null +++ b/src/test/ref/examples/krillload/krillload.cfg @@ -0,0 +1,60 @@ + +(void()) main() +main: scope:[main] from + [0] phi() + [1] call krill_install + [2] (byte) krill_install::return#2 ← (byte) krill_install::return#0 + to:main::@6 +main::@6: scope:[main] from main + [3] (byte) main::status#0 ← (byte) krill_install::return#2 + [4] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 + to:main::@3 +main::@3: scope:[main] from main::@6 + [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 + to:main::@return +main::@return: scope:[main] from main::@3 main::@4 main::@5 + [6] return + to:@return +main::@1: scope:[main] from main::@6 + [7] phi() + [8] call krill_loadraw + [9] (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#0 + to:main::@7 +main::@7: scope:[main] from main::@1 + [10] (byte) main::status#1 ← (byte) krill_loadraw::return#2 + [11] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 + to:main::@4 +main::@4: scope:[main] from main::@7 + [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 + to:main::@return +main::@2: scope:[main] from main::@7 + [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 + to:main::toSpritePtr1 +main::toSpritePtr1: scope:[main] from main::@2 + [14] phi() + to:main::@5 +main::@5: scope:[main] from main::toSpritePtr1 + [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 + [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN + [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 + [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 + to:main::@return + +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +krill_loadraw: scope:[krill_loadraw] from main::@1 + [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename + asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + [21] (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) + to:krill_loadraw::@return +krill_loadraw::@return: scope:[krill_loadraw] from krill_loadraw + [22] return + to:@return + +(byte()) krill_install() +krill_install: scope:[krill_install] from main + asm { jsrKRILL_INSTALL stastatus } + [24] (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) + to:krill_install::@return +krill_install::@return: scope:[krill_install] from krill_install + [25] return + to:@return diff --git a/src/test/ref/examples/krillload/krillload.log b/src/test/ref/examples/krillload/krillload.log new file mode 100644 index 000000000..f32d23aa8 --- /dev/null +++ b/src/test/ref/examples/krillload/krillload.log @@ -0,0 +1,1352 @@ +Loading link script "krillload.ld" +Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx +Inlined call (byte~) main::$6 ← call toSpritePtr (const byte*) SPRITE + +CONTROL FLOW GRAPH SSA + +(byte()) krill_install() +krill_install: scope:[krill_install] from main + asm { jsrKRILL_INSTALL stastatus } + (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) + to:krill_install::@return +krill_install::@return: scope:[krill_install] from krill_install + (byte) krill_install::return#3 ← phi( krill_install/(byte) krill_install::return#0 ) + (byte) krill_install::return#1 ← (byte) krill_install::return#3 + return + to:@return + +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +krill_loadraw: scope:[krill_loadraw] from main::@1 + (byte*) krill_loadraw::filename#1 ← phi( main::@1/(byte*) krill_loadraw::filename#0 ) + *((const nomodify byte**) krill_loadraw::fname) ← (byte*) krill_loadraw::filename#1 + asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) + to:krill_loadraw::@return +krill_loadraw::@return: scope:[krill_loadraw] from krill_loadraw + (byte) krill_loadraw::return#3 ← phi( krill_loadraw/(byte) krill_loadraw::return#0 ) + (byte) krill_loadraw::return#1 ← (byte) krill_loadraw::return#3 + return + to:@return + +(void()) main() +main: scope:[main] from _start + call krill_install + (byte) krill_install::return#2 ← (byte) krill_install::return#1 + to:main::@6 +main::@6: scope:[main] from main + (byte) krill_install::return#4 ← phi( main/(byte) krill_install::return#2 ) + (byte~) main::$0 ← (byte) krill_install::return#4 + (byte) main::status#0 ← (byte~) main::$0 + (bool~) main::$1 ← (byte) main::status#0 != (const byte) KRILL_OK + (bool~) main::$2 ← ! (bool~) main::$1 + if((bool~) main::$2) goto main::@1 + to:main::@3 +main::@1: scope:[main] from main::@6 + (byte*) krill_loadraw::filename#0 ← (const byte*) main::filename + call krill_loadraw + (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#1 + to:main::@7 +main::@7: scope:[main] from main::@1 + (byte) krill_loadraw::return#4 ← phi( main::@1/(byte) krill_loadraw::return#2 ) + (byte~) main::$3 ← (byte) krill_loadraw::return#4 + (byte) main::status#1 ← (byte~) main::$3 + (bool~) main::$4 ← (byte) main::status#1 != (const byte) KRILL_OK + (bool~) main::$5 ← ! (bool~) main::$4 + if((bool~) main::$5) goto main::@2 + to:main::@4 +main::@3: scope:[main] from main::@6 + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (number) 2 + to:main::@return +main::@return: scope:[main] from main::@3 main::@4 main::@5 + return + to:@return +main::@2: scope:[main] from main::@7 + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (number) 1 + (byte*) main::toSpritePtr1_sprite#0 ← (const byte*) SPRITE + to:main::toSpritePtr1 +main::toSpritePtr1: scope:[main] from main::@2 + (byte*) main::toSpritePtr1_sprite#1 ← phi( main::@2/(byte*) main::toSpritePtr1_sprite#0 ) + (word~) main::toSpritePtr1_$1 ← (word)(byte*) main::toSpritePtr1_sprite#1 + (number~) main::toSpritePtr1_$0 ← (word~) main::toSpritePtr1_$1 / (number) $40 + (byte) main::toSpritePtr1_return#0 ← (byte)(number~) main::toSpritePtr1_$0 + to:main::toSpritePtr1_@return +main::toSpritePtr1_@return: scope:[main] from main::toSpritePtr1 + (byte) main::toSpritePtr1_return#2 ← phi( main::toSpritePtr1/(byte) main::toSpritePtr1_return#0 ) + (byte) main::toSpritePtr1_return#1 ← (byte) main::toSpritePtr1_return#2 + to:main::@5 +main::@5: scope:[main] from main::toSpritePtr1_@return + (byte) main::toSpritePtr1_return#3 ← phi( main::toSpritePtr1_@return/(byte) main::toSpritePtr1_return#1 ) + (byte~) main::$6 ← (byte) main::toSpritePtr1_return#3 + *((const nomodify byte*) SPRITES_PTR + (number) 0) ← (byte~) main::$6 + *((const nomodify byte*) SPRITES_COLOR + (number) 0) ← (const nomodify byte) GREEN + *((const nomodify byte*) SPRITES_XPOS + (number) 0) ← (number) $15 + *((const nomodify byte*) SPRITES_YPOS + (number) 0) ← (number) $33 + to:main::@return +main::@4: scope:[main] from main::@7 + *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (number) 2 + to:main::@return + +(void()) _start() +_start: scope:[_start] from + call main + to:_start::@1 +_start::@1: scope:[_start] from _start + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + return + to:@return + +SYMBOL TABLE SSA +(const nomodify byte) GREEN = (byte) 5 +(const byte*) KRILL_INSTALL[] = kickasm {{ .import c64 "install-c64.prg" + }} +(const byte*) KRILL_LOADER[] = kickasm {{ .import c64 "loader-c64.prg" + }} +(const byte) KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_DEVICE_INCOMPATIBLE = (number) $fb +(const byte) KrillStatus::KRILL_DEVICE_NOT_PRESENT = (number) $fe +(const byte) KrillStatus::KRILL_FILE_NOT_FOUND = (number) $ff +(const byte) KrillStatus::KRILL_GENERIC_KERNAL_ERROR = (number) $fd +(const byte) KrillStatus::KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_TOO_MANY_DEVICES = (number) $fc +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = (byte) $15 +(const nomodify byte*) SCREEN = (byte*)(number) $400 +(const byte*) SPRITE[(number) $40] = kickasm {{ .var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + }} +(const nomodify byte*) SPRITES_COLOR = (byte*)(number) $d027 +(const nomodify byte*) SPRITES_PTR = (const nomodify byte*) SCREEN+(const nomodify word) SPRITE_PTRS +(const nomodify byte*) SPRITES_XPOS = (byte*)(number) $d000 +(const nomodify byte*) SPRITES_YPOS = (byte*)(number) $d001 +(const nomodify word) SPRITE_PTRS = (word) $3f8 +(const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*)(number) $d000 +(void()) _start() +(label) _start::@1 +(label) _start::@return +(byte()) krill_install() +(label) krill_install::@return +(byte) krill_install::return +(byte) krill_install::return#0 +(byte) krill_install::return#1 +(byte) krill_install::return#2 +(byte) krill_install::return#3 +(byte) krill_install::return#4 +(const nomodify byte*) krill_install::status = (byte*)(number) $ff +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +(label) krill_loadraw::@return +(byte*) krill_loadraw::filename +(byte*) krill_loadraw::filename#0 +(byte*) krill_loadraw::filename#1 +(const nomodify byte**) krill_loadraw::fname = (byte**)(number) $fe +(byte) krill_loadraw::return +(byte) krill_loadraw::return#0 +(byte) krill_loadraw::return#1 +(byte) krill_loadraw::return#2 +(byte) krill_loadraw::return#3 +(byte) krill_loadraw::return#4 +(const nomodify byte*) krill_loadraw::status = (byte*)(number) $ff +(void()) main() +(byte~) main::$0 +(bool~) main::$1 +(bool~) main::$2 +(byte~) main::$3 +(bool~) main::$4 +(bool~) main::$5 +(byte~) main::$6 +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@return +(const byte*) main::filename[(byte) 7] = (byte*) "sprite"pm +(byte) main::status +(byte) main::status#0 +(byte) main::status#1 +(label) main::toSpritePtr1 +(number~) main::toSpritePtr1_$0 +(word~) main::toSpritePtr1_$1 +(label) main::toSpritePtr1_@return +(byte) main::toSpritePtr1_return +(byte) main::toSpritePtr1_return#0 +(byte) main::toSpritePtr1_return#1 +(byte) main::toSpritePtr1_return#2 +(byte) main::toSpritePtr1_return#3 +(byte*) main::toSpritePtr1_sprite +(byte*) main::toSpritePtr1_sprite#0 +(byte*) main::toSpritePtr1_sprite#1 + +Adding number conversion cast (unumber) 2 in *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (number) 2 +Adding number conversion cast (unumber) 1 in *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (number) 1 +Adding number conversion cast (unumber) $40 in (number~) main::toSpritePtr1_$0 ← (word~) main::toSpritePtr1_$1 / (number) $40 +Adding number conversion cast (unumber) main::toSpritePtr1_$0 in (number~) main::toSpritePtr1_$0 ← (word~) main::toSpritePtr1_$1 / (unumber)(number) $40 +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SPRITES_PTR + (number) 0) ← (byte~) main::$6 +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SPRITES_COLOR + (number) 0) ← (const nomodify byte) GREEN +Adding number conversion cast (unumber) $15 in *((const nomodify byte*) SPRITES_XPOS + (number) 0) ← (number) $15 +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SPRITES_XPOS + (number) 0) ← ((unumber)) (number) $15 +Adding number conversion cast (unumber) $33 in *((const nomodify byte*) SPRITES_YPOS + (number) 0) ← (number) $33 +Adding number conversion cast (unumber) 0 in *((const nomodify byte*) SPRITES_YPOS + (number) 0) ← ((unumber)) (number) $33 +Adding number conversion cast (unumber) 2 in *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (number) 2 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (unumber)(number) 2 +Inlining cast *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (unumber)(number) 1 +Inlining cast *((const nomodify byte*) SPRITES_XPOS + (unumber)(number) 0) ← (unumber)(number) $15 +Inlining cast *((const nomodify byte*) SPRITES_YPOS + (unumber)(number) 0) ← (unumber)(number) $33 +Inlining cast *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (unumber)(number) 2 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 255 +Simplifying constant pointer cast (byte*) 255 +Simplifying constant pointer cast (byte**) 254 +Simplifying constant pointer cast (byte*) 53248 +Simplifying constant pointer cast (byte*) 53249 +Simplifying constant pointer cast (byte*) 53287 +Simplifying constant pointer cast (struct MOS6569_VICII*) 53248 +Simplifying constant pointer cast (byte*) 1024 +Simplifying constant integer cast 2 +Simplifying constant integer cast 1 +Simplifying constant integer cast $40 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast $15 +Simplifying constant integer cast 0 +Simplifying constant integer cast $33 +Simplifying constant integer cast 0 +Simplifying constant integer cast 2 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) $40 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $15 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) $33 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 2 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to word in (unumber~) main::toSpritePtr1_$0 ← (word~) main::toSpritePtr1_$1 / (byte) $40 +Inversing boolean not [18] (bool~) main::$2 ← (byte) main::status#0 == (const byte) KRILL_OK from [17] (bool~) main::$1 ← (byte) main::status#0 != (const byte) KRILL_OK +Inversing boolean not [27] (bool~) main::$5 ← (byte) main::status#1 == (const byte) KRILL_OK from [26] (bool~) main::$4 ← (byte) main::status#1 != (const byte) KRILL_OK +Successful SSA optimization Pass2UnaryNotSimplification +Alias krill_install::return#0 = krill_install::return#3 krill_install::return#1 +Alias krill_loadraw::return#0 = krill_loadraw::return#3 krill_loadraw::return#1 +Alias krill_install::return#2 = krill_install::return#4 +Alias main::status#0 = main::$0 +Alias krill_loadraw::return#2 = krill_loadraw::return#4 +Alias main::status#1 = main::$3 +Alias main::toSpritePtr1_sprite#0 = main::toSpritePtr1_sprite#1 +Alias main::toSpritePtr1_return#0 = main::toSpritePtr1_return#2 main::toSpritePtr1_return#1 main::toSpritePtr1_return#3 main::$6 +Successful SSA optimization Pass2AliasElimination +Identical Phi Values (byte*) krill_loadraw::filename#1 (byte*) krill_loadraw::filename#0 +Successful SSA optimization Pass2IdenticalPhiElimination +Simple Condition (bool~) main::$2 [12] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 +Simple Condition (bool~) main::$5 [18] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) krill_loadraw::filename#0 = main::filename +Constant (const byte*) main::toSpritePtr1_sprite#0 = SPRITE +Successful SSA optimization Pass2ConstantIdentification +Constant (const word) main::toSpritePtr1_$1 = (word)main::toSpritePtr1_sprite#0 +Successful SSA optimization Pass2ConstantIdentification +Simplifying expression containing zero SPRITES_PTR in [26] *((const nomodify byte*) SPRITES_PTR + (byte) 0) ← (byte) main::toSpritePtr1_return#0 +Simplifying expression containing zero SPRITES_COLOR in [27] *((const nomodify byte*) SPRITES_COLOR + (byte) 0) ← (const nomodify byte) GREEN +Simplifying expression containing zero SPRITES_XPOS in [28] *((const nomodify byte*) SPRITES_XPOS + (byte) 0) ← (byte) $15 +Simplifying expression containing zero SPRITES_YPOS in [29] *((const nomodify byte*) SPRITES_YPOS + (byte) 0) ← (byte) $33 +Successful SSA optimization PassNSimplifyExpressionWithZero +Removing unused procedure _start +Removing unused procedure block _start +Removing unused procedure block _start::@1 +Removing unused procedure block _start::@return +Successful SSA optimization PassNEliminateEmptyStart +Constant right-side identified [18] (word~) main::toSpritePtr1_$0 ← (const word) main::toSpritePtr1_$1 / (byte) $40 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const word) main::toSpritePtr1_$0 = main::toSpritePtr1_$1/$40 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte) main::toSpritePtr1_return#0 = (byte)main::toSpritePtr1_$0 +Successful SSA optimization Pass2ConstantIdentification +Constant inlined main::toSpritePtr1_sprite#0 = (const byte*) SPRITE +Constant inlined main::toSpritePtr1_$1 = (word)(const byte*) SPRITE +Constant inlined krill_loadraw::filename#0 = (const byte*) main::filename +Constant inlined main::toSpritePtr1_$0 = (word)(const byte*) SPRITE/(byte) $40 +Successful SSA optimization Pass2ConstantInlining +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@1 +Adding NOP phi() at start of main::toSpritePtr1 +Adding NOP phi() at start of main::toSpritePtr1_@return +CALL GRAPH +Calls in [main] to krill_install:1 krill_loadraw:8 + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Culled Empty Block (label) main::toSpritePtr1_@return +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@1 +Adding NOP phi() at start of main::toSpritePtr1 + +FINAL CONTROL FLOW GRAPH + +(void()) main() +main: scope:[main] from + [0] phi() + [1] call krill_install + [2] (byte) krill_install::return#2 ← (byte) krill_install::return#0 + to:main::@6 +main::@6: scope:[main] from main + [3] (byte) main::status#0 ← (byte) krill_install::return#2 + [4] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 + to:main::@3 +main::@3: scope:[main] from main::@6 + [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 + to:main::@return +main::@return: scope:[main] from main::@3 main::@4 main::@5 + [6] return + to:@return +main::@1: scope:[main] from main::@6 + [7] phi() + [8] call krill_loadraw + [9] (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#0 + to:main::@7 +main::@7: scope:[main] from main::@1 + [10] (byte) main::status#1 ← (byte) krill_loadraw::return#2 + [11] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 + to:main::@4 +main::@4: scope:[main] from main::@7 + [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 + to:main::@return +main::@2: scope:[main] from main::@7 + [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 + to:main::toSpritePtr1 +main::toSpritePtr1: scope:[main] from main::@2 + [14] phi() + to:main::@5 +main::@5: scope:[main] from main::toSpritePtr1 + [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 + [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN + [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 + [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 + to:main::@return + +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +krill_loadraw: scope:[krill_loadraw] from main::@1 + [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename + asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + [21] (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) + to:krill_loadraw::@return +krill_loadraw::@return: scope:[krill_loadraw] from krill_loadraw + [22] return + to:@return + +(byte()) krill_install() +krill_install: scope:[krill_install] from main + asm { jsrKRILL_INSTALL stastatus } + [24] (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) + to:krill_install::@return +krill_install::@return: scope:[krill_install] from krill_install + [25] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(byte()) krill_install() +(byte) krill_install::return +(byte) krill_install::return#0 4.333333333333333 +(byte) krill_install::return#2 4.0 +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +(byte*) krill_loadraw::filename +(byte) krill_loadraw::return +(byte) krill_loadraw::return#0 4.333333333333333 +(byte) krill_loadraw::return#2 4.0 +(void()) main() +(byte) main::status +(byte) main::status#0 4.0 +(byte) main::status#1 4.0 +(byte) main::toSpritePtr1_return +(byte*) main::toSpritePtr1_sprite + +Initial phi equivalence classes +Added variable krill_install::return#2 to live range equivalence class [ krill_install::return#2 ] +Added variable main::status#0 to live range equivalence class [ main::status#0 ] +Added variable krill_loadraw::return#2 to live range equivalence class [ krill_loadraw::return#2 ] +Added variable main::status#1 to live range equivalence class [ main::status#1 ] +Added variable krill_loadraw::return#0 to live range equivalence class [ krill_loadraw::return#0 ] +Added variable krill_install::return#0 to live range equivalence class [ krill_install::return#0 ] +Complete equivalence classes +[ krill_install::return#2 ] +[ main::status#0 ] +[ krill_loadraw::return#2 ] +[ main::status#1 ] +[ krill_loadraw::return#0 ] +[ krill_install::return#0 ] +Allocated zp[1]:2 [ krill_install::return#2 ] +Allocated zp[1]:3 [ main::status#0 ] +Allocated zp[1]:4 [ krill_loadraw::return#2 ] +Allocated zp[1]:5 [ main::status#1 ] +Allocated zp[1]:6 [ krill_loadraw::return#0 ] +Allocated zp[1]:7 [ krill_install::return#0 ] + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Tests Krill Loader +// Load a file to memory using the Krill loader +// The krillload.ld link file creates a D64 disk image containing the executable and the sprite. +// To execute the program succesfully you must mount the D64 disk image and execute the krillload.PRG program + // Upstart + // Create a D64 disk containing the program and a sprite file +.disk [filename="krillload.d64", name="DISK", id=1] { + [name="KRILLLOAD", type="prg", segments="Program"], + [name="SPRITE", type="prg", segments="Sprite"] +} +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$0801] +.segmentdef Code [start=$080d] +.segmentdef Data [startAfter="Code"] +.segmentdef Sprite +.segment Basic +:BasicUpstart(main) +.segment Code + // Global Constants & labels + .const KRILL_OK = 0 + // The offset of the sprite pointers from the screen start address + .const SPRITE_PTRS = $3f8 + .const GREEN = 5 + .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15 + .label SPRITES_XPOS = $d000 + .label SPRITES_YPOS = $d001 + .label SPRITES_COLOR = $d027 + // The VIC-II MOS 6567/6569 + .label VICII = $d000 + .label SCREEN = $400 + .label SPRITES_PTR = SCREEN+SPRITE_PTRS +.segment Code + // main +main: { + .const toSpritePtr1_return = $ff&SPRITE/$40 + .label status = 3 + .label status_1 = 5 + // [1] call krill_install + jsr krill_install + // [2] (byte) krill_install::return#2 ← (byte) krill_install::return#0 -- vbuz1=vbuz2 + lda.z krill_install.return + sta.z krill_install.return_1 + jmp __b6 + // main::@6 + __b6: + // [3] (byte) main::status#0 ← (byte) krill_install::return#2 -- vbuz1=vbuz2 + lda.z krill_install.return_1 + sta.z status + // [4] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 -- vbuz1_eq_vbuc1_then_la1 + lda #KRILL_OK + cmp.z status + beq __b1_from___b6 + jmp __b3 + // main::@3 + __b3: + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // main::@return + __breturn: + // [6] return + rts + // [7] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + __b1_from___b6: + jmp __b1 + // main::@1 + __b1: + // [8] call krill_loadraw + jsr krill_loadraw + // [9] (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#0 -- vbuz1=vbuz2 + lda.z krill_loadraw.return + sta.z krill_loadraw.return_1 + jmp __b7 + // main::@7 + __b7: + // [10] (byte) main::status#1 ← (byte) krill_loadraw::return#2 -- vbuz1=vbuz2 + lda.z krill_loadraw.return_1 + sta.z status_1 + // [11] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 -- vbuz1_eq_vbuc1_then_la1 + lda #KRILL_OK + cmp.z status_1 + beq __b2 + jmp __b4 + // main::@4 + __b4: + // [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // main::@2 + __b2: + // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // Show the loaded sprite on screen + lda #1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE + // [14] phi from main::@2 to main::toSpritePtr1 [phi:main::@2->main::toSpritePtr1] + toSpritePtr1_from___b2: + jmp toSpritePtr1 + // main::toSpritePtr1 + toSpritePtr1: + jmp __b5 + // main::@5 + __b5: + // [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 -- _deref_pbuc1=vbuc2 + lda #toSpritePtr1_return + sta SPRITES_PTR + // [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN -- _deref_pbuc1=vbuc2 + lda #GREEN + sta SPRITES_COLOR + // [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 -- _deref_pbuc1=vbuc2 + lda #$15 + sta SPRITES_XPOS + // [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 -- _deref_pbuc1=vbuc2 + lda #$33 + sta SPRITES_YPOS + jmp __breturn + .segment Data + .encoding "petscii_mixed" + filename: .text "sprite" + .byte 0 +} +.segment Code + // krill_loadraw +// Load a file from the active drive without decompression. +// While loading using filenames with wildcards ("?" and "*") is not possible, +// subsequent files following the previously-loaded file can be loaded via a +// zero-length filename +// - filename - The name of the file to load (zero-terminated in petscii encoding) +// Returns the status of the load +krill_loadraw: { + .label status = $ff + .label fname = $fe + .label return = 6 + .label return_1 = 4 + // [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename -- _deref_pptc1=pbuc2 + lda #main.filename + sta fname+1 + // asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + ldx fname + ldy fname+1 + jsr KRILL_LOADER + sta status + // [21] (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) -- vbuz1=_deref_pbuc1 + lda status + sta.z return + jmp __breturn + // krill_loadraw::@return + __breturn: + // [22] return + rts +} + // krill_install +// Install drive-side code portion(s) must be installed in the active drive. +// Before the loader can operate, its drive-side code portion(s) must be installed in the drive(s). +// The drive-side portion remains resident in the drive. After successful +// installation, the install routine is not needed any more and may be overwritten. +// The KERNAL ROM may be disabled and zeropage variables clobbered. +// Returns the status of the installation +krill_install: { + .label status = $ff + .label return = 7 + .label return_1 = 2 + // asm { jsrKRILL_INSTALL stastatus } + jsr KRILL_INSTALL + sta status + // [24] (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) -- vbuz1=_deref_pbuc1 + lda status + sta.z return + jmp __breturn + // krill_install::@return + __breturn: + // [25] return + rts +} + // File Data +.segment Data +.pc = $3000 "KRILL_LOADER" +// The Krill loader routine that can load files. +KRILL_LOADER: +.import c64 "loader-c64.prg" + +.pc = $3400 "KRILL_INSTALL" +// The Krill Install routine that can install the drive-side code +KRILL_INSTALL: +.import c64 "install-c64.prg" + +.segment Sprite +.pc = $2040 "SPRITE" +// The sprite data +SPRITE: +.var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN [ ] ( [ ] { } ) always clobbers reg byte a +Statement [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 [ ] ( [ ] { } ) always clobbers reg byte a +Statement [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename [ ] ( krill_loadraw:8 [ ] { { krill_loadraw::return#0 = krill_loadraw::return#2 } } ) always clobbers reg byte a +Statement asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } always clobbers reg byte a reg byte x reg byte y +Statement asm { jsrKRILL_INSTALL stastatus } always clobbers reg byte a reg byte x reg byte y +Potential registers zp[1]:2 [ krill_install::return#2 ] : zp[1]:2 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:3 [ main::status#0 ] : zp[1]:3 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:4 [ krill_loadraw::return#2 ] : zp[1]:4 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:5 [ main::status#1 ] : zp[1]:5 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:6 [ krill_loadraw::return#0 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y , +Potential registers zp[1]:7 [ krill_install::return#0 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [krill_install] 4.33: zp[1]:7 [ krill_install::return#0 ] 4: zp[1]:2 [ krill_install::return#2 ] +Uplift Scope [krill_loadraw] 4.33: zp[1]:6 [ krill_loadraw::return#0 ] 4: zp[1]:4 [ krill_loadraw::return#2 ] +Uplift Scope [main] 4: zp[1]:3 [ main::status#0 ] 4: zp[1]:5 [ main::status#1 ] +Uplift Scope [KrillStatus] +Uplift Scope [MOS6526_CIA] +Uplift Scope [MOS6569_VICII] +Uplift Scope [MOS6581_SID] +Uplift Scope [] + +Uplifting [krill_install] best 215 combination reg byte a [ krill_install::return#0 ] reg byte a [ krill_install::return#2 ] +Uplifting [krill_loadraw] best 203 combination reg byte a [ krill_loadraw::return#0 ] reg byte a [ krill_loadraw::return#2 ] +Uplifting [main] best 191 combination reg byte a [ main::status#0 ] reg byte a [ main::status#1 ] +Uplifting [KrillStatus] best 191 combination +Uplifting [MOS6526_CIA] best 191 combination +Uplifting [MOS6569_VICII] best 191 combination +Uplifting [MOS6581_SID] best 191 combination +Uplifting [] best 191 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Tests Krill Loader +// Load a file to memory using the Krill loader +// The krillload.ld link file creates a D64 disk image containing the executable and the sprite. +// To execute the program succesfully you must mount the D64 disk image and execute the krillload.PRG program + // Upstart + // Create a D64 disk containing the program and a sprite file +.disk [filename="krillload.d64", name="DISK", id=1] { + [name="KRILLLOAD", type="prg", segments="Program"], + [name="SPRITE", type="prg", segments="Sprite"] +} +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$0801] +.segmentdef Code [start=$080d] +.segmentdef Data [startAfter="Code"] +.segmentdef Sprite +.segment Basic +:BasicUpstart(main) +.segment Code + // Global Constants & labels + .const KRILL_OK = 0 + // The offset of the sprite pointers from the screen start address + .const SPRITE_PTRS = $3f8 + .const GREEN = 5 + .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15 + .label SPRITES_XPOS = $d000 + .label SPRITES_YPOS = $d001 + .label SPRITES_COLOR = $d027 + // The VIC-II MOS 6567/6569 + .label VICII = $d000 + .label SCREEN = $400 + .label SPRITES_PTR = SCREEN+SPRITE_PTRS +.segment Code + // main +main: { + .const toSpritePtr1_return = $ff&SPRITE/$40 + // [1] call krill_install + jsr krill_install + // [2] (byte) krill_install::return#2 ← (byte) krill_install::return#0 + jmp __b6 + // main::@6 + __b6: + // [3] (byte) main::status#0 ← (byte) krill_install::return#2 + // [4] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 -- vbuaa_eq_vbuc1_then_la1 + cmp #KRILL_OK + beq __b1_from___b6 + jmp __b3 + // main::@3 + __b3: + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // main::@return + __breturn: + // [6] return + rts + // [7] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + __b1_from___b6: + jmp __b1 + // main::@1 + __b1: + // [8] call krill_loadraw + jsr krill_loadraw + // [9] (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#0 + jmp __b7 + // main::@7 + __b7: + // [10] (byte) main::status#1 ← (byte) krill_loadraw::return#2 + // [11] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 -- vbuaa_eq_vbuc1_then_la1 + cmp #KRILL_OK + beq __b2 + jmp __b4 + // main::@4 + __b4: + // [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + jmp __breturn + // main::@2 + __b2: + // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // Show the loaded sprite on screen + lda #1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE + // [14] phi from main::@2 to main::toSpritePtr1 [phi:main::@2->main::toSpritePtr1] + toSpritePtr1_from___b2: + jmp toSpritePtr1 + // main::toSpritePtr1 + toSpritePtr1: + jmp __b5 + // main::@5 + __b5: + // [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 -- _deref_pbuc1=vbuc2 + lda #toSpritePtr1_return + sta SPRITES_PTR + // [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN -- _deref_pbuc1=vbuc2 + lda #GREEN + sta SPRITES_COLOR + // [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 -- _deref_pbuc1=vbuc2 + lda #$15 + sta SPRITES_XPOS + // [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 -- _deref_pbuc1=vbuc2 + lda #$33 + sta SPRITES_YPOS + jmp __breturn + .segment Data + .encoding "petscii_mixed" + filename: .text "sprite" + .byte 0 +} +.segment Code + // krill_loadraw +// Load a file from the active drive without decompression. +// While loading using filenames with wildcards ("?" and "*") is not possible, +// subsequent files following the previously-loaded file can be loaded via a +// zero-length filename +// - filename - The name of the file to load (zero-terminated in petscii encoding) +// Returns the status of the load +krill_loadraw: { + .label status = $ff + .label fname = $fe + // [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename -- _deref_pptc1=pbuc2 + lda #main.filename + sta fname+1 + // asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + ldx fname + ldy fname+1 + jsr KRILL_LOADER + sta status + // [21] (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) -- vbuaa=_deref_pbuc1 + lda status + jmp __breturn + // krill_loadraw::@return + __breturn: + // [22] return + rts +} + // krill_install +// Install drive-side code portion(s) must be installed in the active drive. +// Before the loader can operate, its drive-side code portion(s) must be installed in the drive(s). +// The drive-side portion remains resident in the drive. After successful +// installation, the install routine is not needed any more and may be overwritten. +// The KERNAL ROM may be disabled and zeropage variables clobbered. +// Returns the status of the installation +krill_install: { + .label status = $ff + // asm { jsrKRILL_INSTALL stastatus } + jsr KRILL_INSTALL + sta status + // [24] (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) -- vbuaa=_deref_pbuc1 + lda status + jmp __breturn + // krill_install::@return + __breturn: + // [25] return + rts +} + // File Data +.segment Data +.pc = $3000 "KRILL_LOADER" +// The Krill loader routine that can load files. +KRILL_LOADER: +.import c64 "loader-c64.prg" + +.pc = $3400 "KRILL_INSTALL" +// The Krill Install routine that can install the drive-side code +KRILL_INSTALL: +.import c64 "install-c64.prg" + +.segment Sprite +.pc = $2040 "SPRITE" +// The sprite data +SPRITE: +.var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp __b6 +Removing instruction jmp __b3 +Removing instruction jmp __breturn +Removing instruction jmp __b1 +Removing instruction jmp __b7 +Removing instruction jmp __b4 +Removing instruction jmp toSpritePtr1 +Removing instruction jmp __b5 +Removing instruction jmp __breturn +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Replacing instruction ldy fname+1 with TAY +Removing instruction lda status +Removing instruction lda status +Succesful ASM optimization Pass5UnnecesaryLoadElimination +Replacing label __b1_from___b6 with __b1 +Removing instruction __b1_from___b6: +Removing instruction toSpritePtr1_from___b2: +Removing instruction toSpritePtr1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction __b6: +Removing instruction __b3: +Removing instruction __b7: +Removing instruction __b4: +Removing instruction __b5: +Removing instruction __breturn: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Replacing jump to rts with rts in jmp __breturn +Replacing jump to rts with rts in jmp __breturn +Succesful ASM optimization Pass5DoubleJumpElimination +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(const nomodify byte) GREEN = (byte) 5 +(const byte*) KRILL_INSTALL[] = kickasm {{ .import c64 "install-c64.prg" + }} +(const byte*) KRILL_LOADER[] = kickasm {{ .import c64 "loader-c64.prg" + }} +(const byte) KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_DEVICE_INCOMPATIBLE = (number) $fb +(const byte) KrillStatus::KRILL_DEVICE_NOT_PRESENT = (number) $fe +(const byte) KrillStatus::KRILL_FILE_NOT_FOUND = (number) $ff +(const byte) KrillStatus::KRILL_GENERIC_KERNAL_ERROR = (number) $fd +(const byte) KrillStatus::KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_TOO_MANY_DEVICES = (number) $fc +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = (byte) $15 +(const nomodify byte*) SCREEN = (byte*) 1024 +(const byte*) SPRITE[(number) $40] = kickasm {{ .var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + }} +(const nomodify byte*) SPRITES_COLOR = (byte*) 53287 +(const nomodify byte*) SPRITES_PTR = (const nomodify byte*) SCREEN+(const nomodify word) SPRITE_PTRS +(const nomodify byte*) SPRITES_XPOS = (byte*) 53248 +(const nomodify byte*) SPRITES_YPOS = (byte*) 53249 +(const nomodify word) SPRITE_PTRS = (word) $3f8 +(const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*) 53248 +(byte()) krill_install() +(label) krill_install::@return +(byte) krill_install::return +(byte) krill_install::return#0 reg byte a 4.333333333333333 +(byte) krill_install::return#2 reg byte a 4.0 +(const nomodify byte*) krill_install::status = (byte*) 255 +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +(label) krill_loadraw::@return +(byte*) krill_loadraw::filename +(const nomodify byte**) krill_loadraw::fname = (byte**) 254 +(byte) krill_loadraw::return +(byte) krill_loadraw::return#0 reg byte a 4.333333333333333 +(byte) krill_loadraw::return#2 reg byte a 4.0 +(const nomodify byte*) krill_loadraw::status = (byte*) 255 +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@return +(const byte*) main::filename[(byte) 7] = (byte*) "sprite"pm +(byte) main::status +(byte) main::status#0 reg byte a 4.0 +(byte) main::status#1 reg byte a 4.0 +(label) main::toSpritePtr1 +(byte) main::toSpritePtr1_return +(const byte) main::toSpritePtr1_return#0 toSpritePtr1_return = (byte)(word)(const byte*) SPRITE/(byte) $40 +(byte*) main::toSpritePtr1_sprite + +reg byte a [ krill_install::return#2 ] +reg byte a [ main::status#0 ] +reg byte a [ krill_loadraw::return#2 ] +reg byte a [ main::status#1 ] +reg byte a [ krill_loadraw::return#0 ] +reg byte a [ krill_install::return#0 ] + + +FINAL ASSEMBLER +Score: 130 + + // File Comments +// Tests Krill Loader +// Load a file to memory using the Krill loader +// The krillload.ld link file creates a D64 disk image containing the executable and the sprite. +// To execute the program succesfully you must mount the D64 disk image and execute the krillload.PRG program + // Upstart + // Create a D64 disk containing the program and a sprite file +.disk [filename="krillload.d64", name="DISK", id=1] { + [name="KRILLLOAD", type="prg", segments="Program"], + [name="SPRITE", type="prg", segments="Sprite"] +} +.segmentdef Program [segments="Basic, Code, Data"] +.segmentdef Basic [start=$0801] +.segmentdef Code [start=$080d] +.segmentdef Data [startAfter="Code"] +.segmentdef Sprite +.segment Basic +:BasicUpstart(main) +.segment Code + // Global Constants & labels + .const KRILL_OK = 0 + // The offset of the sprite pointers from the screen start address + .const SPRITE_PTRS = $3f8 + .const GREEN = 5 + .const OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = $20 + .const OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = $15 + .label SPRITES_XPOS = $d000 + .label SPRITES_YPOS = $d001 + .label SPRITES_COLOR = $d027 + // The VIC-II MOS 6567/6569 + .label VICII = $d000 + .label SCREEN = $400 + .label SPRITES_PTR = SCREEN+SPRITE_PTRS +.segment Code + // main +main: { + .const toSpritePtr1_return = $ff&SPRITE/$40 + // krill_install() + // [1] call krill_install + jsr krill_install + // [2] (byte) krill_install::return#2 ← (byte) krill_install::return#0 + // main::@6 + // status = krill_install() + // [3] (byte) main::status#0 ← (byte) krill_install::return#2 + // if(status!=KRILL_OK) + // [4] if((byte) main::status#0==(const byte) KRILL_OK) goto main::@1 -- vbuaa_eq_vbuc1_then_la1 + cmp #KRILL_OK + beq __b1 + // main::@3 + // VICII->BORDER_COLOR = 0x02 + // [5] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + // main::@return + // } + // [6] return + rts + // [7] phi from main::@6 to main::@1 [phi:main::@6->main::@1] + // main::@1 + __b1: + // krill_loadraw("sprite") + // [8] call krill_loadraw + jsr krill_loadraw + // [9] (byte) krill_loadraw::return#2 ← (byte) krill_loadraw::return#0 + // main::@7 + // status = krill_loadraw("sprite") + // [10] (byte) main::status#1 ← (byte) krill_loadraw::return#2 + // if(status!=KRILL_OK) + // [11] if((byte) main::status#1==(const byte) KRILL_OK) goto main::@2 -- vbuaa_eq_vbuc1_then_la1 + cmp #KRILL_OK + beq __b2 + // main::@4 + // VICII->BORDER_COLOR = 0x02 + // [12] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR) ← (byte) 2 -- _deref_pbuc1=vbuc2 + lda #2 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR + rts + // main::@2 + __b2: + // VICII->SPRITES_ENABLE = %00000001 + // [13] *((byte*)(const nomodify struct MOS6569_VICII*) VICII+(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE) ← (byte) 1 -- _deref_pbuc1=vbuc2 + // Show the loaded sprite on screen + lda #1 + sta VICII+OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE + // [14] phi from main::@2 to main::toSpritePtr1 [phi:main::@2->main::toSpritePtr1] + // main::toSpritePtr1 + // main::@5 + // SPRITES_PTR[0] = toSpritePtr(SPRITE) + // [15] *((const nomodify byte*) SPRITES_PTR) ← (const byte) main::toSpritePtr1_return#0 -- _deref_pbuc1=vbuc2 + lda #toSpritePtr1_return + sta SPRITES_PTR + // SPRITES_COLOR[0] = GREEN + // [16] *((const nomodify byte*) SPRITES_COLOR) ← (const nomodify byte) GREEN -- _deref_pbuc1=vbuc2 + lda #GREEN + sta SPRITES_COLOR + // SPRITES_XPOS[0] = 0x15 + // [17] *((const nomodify byte*) SPRITES_XPOS) ← (byte) $15 -- _deref_pbuc1=vbuc2 + lda #$15 + sta SPRITES_XPOS + // SPRITES_YPOS[0] = 0x33 + // [18] *((const nomodify byte*) SPRITES_YPOS) ← (byte) $33 -- _deref_pbuc1=vbuc2 + lda #$33 + sta SPRITES_YPOS + rts + .segment Data + .encoding "petscii_mixed" + filename: .text "sprite" + .byte 0 +} +.segment Code + // krill_loadraw +// Load a file from the active drive without decompression. +// While loading using filenames with wildcards ("?" and "*") is not possible, +// subsequent files following the previously-loaded file can be loaded via a +// zero-length filename +// - filename - The name of the file to load (zero-terminated in petscii encoding) +// Returns the status of the load +krill_loadraw: { + .label status = $ff + .label fname = $fe + // *fname = filename + // [19] *((const nomodify byte**) krill_loadraw::fname) ← (const byte*) main::filename -- _deref_pptc1=pbuc2 + lda #main.filename + sta fname+1 + // asm + // asm { ldxfname ldyfname+1 jsrKRILL_LOADER stastatus } + ldx fname + tay + jsr KRILL_LOADER + sta status + // return *status; + // [21] (byte) krill_loadraw::return#0 ← *((const nomodify byte*) krill_loadraw::status) -- vbuaa=_deref_pbuc1 + // krill_loadraw::@return + // } + // [22] return + rts +} + // krill_install +// Install drive-side code portion(s) must be installed in the active drive. +// Before the loader can operate, its drive-side code portion(s) must be installed in the drive(s). +// The drive-side portion remains resident in the drive. After successful +// installation, the install routine is not needed any more and may be overwritten. +// The KERNAL ROM may be disabled and zeropage variables clobbered. +// Returns the status of the installation +krill_install: { + .label status = $ff + // asm + // asm { jsrKRILL_INSTALL stastatus } + jsr KRILL_INSTALL + sta status + // return *status; + // [24] (byte) krill_install::return#0 ← *((const nomodify byte*) krill_install::status) -- vbuaa=_deref_pbuc1 + // krill_install::@return + // } + // [25] return + rts +} + // File Data +.segment Data +.pc = $3000 "KRILL_LOADER" +// The Krill loader routine that can load files. +KRILL_LOADER: +.import c64 "loader-c64.prg" + +.pc = $3400 "KRILL_INSTALL" +// The Krill Install routine that can install the drive-side code +KRILL_INSTALL: +.import c64 "install-c64.prg" + +.segment Sprite +.pc = $2040 "SPRITE" +// The sprite data +SPRITE: +.var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + + diff --git a/src/test/ref/examples/krillload/krillload.sym b/src/test/ref/examples/krillload/krillload.sym new file mode 100644 index 000000000..96ed7c6ab --- /dev/null +++ b/src/test/ref/examples/krillload/krillload.sym @@ -0,0 +1,148 @@ +(const nomodify byte) GREEN = (byte) 5 +(const byte*) KRILL_INSTALL[] = kickasm {{ .import c64 "install-c64.prg" + }} +(const byte*) KRILL_LOADER[] = kickasm {{ .import c64 "loader-c64.prg" + }} +(const byte) KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_DEVICE_INCOMPATIBLE = (number) $fb +(const byte) KrillStatus::KRILL_DEVICE_NOT_PRESENT = (number) $fe +(const byte) KrillStatus::KRILL_FILE_NOT_FOUND = (number) $ff +(const byte) KrillStatus::KRILL_GENERIC_KERNAL_ERROR = (number) $fd +(const byte) KrillStatus::KRILL_OK = (number) 0 +(const byte) KrillStatus::KRILL_TOO_MANY_DEVICES = (number) $fc +(byte) MOS6526_CIA::INTERRUPT +(byte) MOS6526_CIA::PORT_A +(byte) MOS6526_CIA::PORT_A_DDR +(byte) MOS6526_CIA::PORT_B +(byte) MOS6526_CIA::PORT_B_DDR +(byte) MOS6526_CIA::SERIAL_DATA +(word) MOS6526_CIA::TIMER_A +(byte) MOS6526_CIA::TIMER_A_CONTROL +(word) MOS6526_CIA::TIMER_B +(byte) MOS6526_CIA::TIMER_B_CONTROL +(byte) MOS6526_CIA::TOD_10THS +(byte) MOS6526_CIA::TOD_HOURS +(byte) MOS6526_CIA::TOD_MIN +(byte) MOS6526_CIA::TOD_SEC +(byte) MOS6569_VICII::BG_COLOR +(byte) MOS6569_VICII::BG_COLOR1 +(byte) MOS6569_VICII::BG_COLOR2 +(byte) MOS6569_VICII::BG_COLOR3 +(byte) MOS6569_VICII::BORDER_COLOR +(byte) MOS6569_VICII::CONTROL1 +(byte) MOS6569_VICII::CONTROL2 +(byte) MOS6569_VICII::IRQ_ENABLE +(byte) MOS6569_VICII::IRQ_STATUS +(byte) MOS6569_VICII::LIGHTPEN_X +(byte) MOS6569_VICII::LIGHTPEN_Y +(byte) MOS6569_VICII::MEMORY +(byte) MOS6569_VICII::RASTER +(byte) MOS6569_VICII::SPRITE0_COLOR +(byte) MOS6569_VICII::SPRITE0_X +(byte) MOS6569_VICII::SPRITE0_Y +(byte) MOS6569_VICII::SPRITE1_COLOR +(byte) MOS6569_VICII::SPRITE1_X +(byte) MOS6569_VICII::SPRITE1_Y +(byte) MOS6569_VICII::SPRITE2_COLOR +(byte) MOS6569_VICII::SPRITE2_X +(byte) MOS6569_VICII::SPRITE2_Y +(byte) MOS6569_VICII::SPRITE3_COLOR +(byte) MOS6569_VICII::SPRITE3_X +(byte) MOS6569_VICII::SPRITE3_Y +(byte) MOS6569_VICII::SPRITE4_COLOR +(byte) MOS6569_VICII::SPRITE4_X +(byte) MOS6569_VICII::SPRITE4_Y +(byte) MOS6569_VICII::SPRITE5_COLOR +(byte) MOS6569_VICII::SPRITE5_X +(byte) MOS6569_VICII::SPRITE5_Y +(byte) MOS6569_VICII::SPRITE6_COLOR +(byte) MOS6569_VICII::SPRITE6_X +(byte) MOS6569_VICII::SPRITE6_Y +(byte) MOS6569_VICII::SPRITE7_COLOR +(byte) MOS6569_VICII::SPRITE7_X +(byte) MOS6569_VICII::SPRITE7_Y +(byte) MOS6569_VICII::SPRITES_BG_COLLISION +(byte) MOS6569_VICII::SPRITES_COLLISION +(byte) MOS6569_VICII::SPRITES_ENABLE +(byte) MOS6569_VICII::SPRITES_EXPAND_X +(byte) MOS6569_VICII::SPRITES_EXPAND_Y +(byte) MOS6569_VICII::SPRITES_MC +(byte) MOS6569_VICII::SPRITES_MCOLOR1 +(byte) MOS6569_VICII::SPRITES_MCOLOR2 +(byte) MOS6569_VICII::SPRITES_PRIORITY +(byte) MOS6569_VICII::SPRITES_XMSB +(byte) MOS6581_SID::CH1_ATTACK_DECAY +(byte) MOS6581_SID::CH1_CONTROL +(word) MOS6581_SID::CH1_FREQ +(word) MOS6581_SID::CH1_PULSE_WIDTH +(byte) MOS6581_SID::CH1_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH2_ATTACK_DECAY +(byte) MOS6581_SID::CH2_CONTROL +(word) MOS6581_SID::CH2_FREQ +(word) MOS6581_SID::CH2_PULSE_WIDTH +(byte) MOS6581_SID::CH2_SUSTAIN_RELEASE +(byte) MOS6581_SID::CH3_ATTACK_DECAY +(byte) MOS6581_SID::CH3_CONTROL +(byte) MOS6581_SID::CH3_ENV +(word) MOS6581_SID::CH3_FREQ +(byte) MOS6581_SID::CH3_OSC +(word) MOS6581_SID::CH3_PULSE_WIDTH +(byte) MOS6581_SID::CH3_SUSTAIN_RELEASE +(byte) MOS6581_SID::FILTER_CUTOFF_HIGH +(byte) MOS6581_SID::FILTER_CUTOFF_LOW +(byte) MOS6581_SID::FILTER_SETUP +(byte) MOS6581_SID::POT_X +(byte) MOS6581_SID::POT_Y +(byte) MOS6581_SID::VOLUME_FILTER_MODE +(const byte) OFFSET_STRUCT_MOS6569_VICII_BORDER_COLOR = (byte) $20 +(const byte) OFFSET_STRUCT_MOS6569_VICII_SPRITES_ENABLE = (byte) $15 +(const nomodify byte*) SCREEN = (byte*) 1024 +(const byte*) SPRITE[(number) $40] = kickasm {{ .var pic = LoadPicture("sprite.png", List().add($000000, $ffffff)) + .for (var y=0; y<21; y++) + .for (var x=0;x<3; x++) + .byte pic.getSinglecolorByte(x,y) + }} +(const nomodify byte*) SPRITES_COLOR = (byte*) 53287 +(const nomodify byte*) SPRITES_PTR = (const nomodify byte*) SCREEN+(const nomodify word) SPRITE_PTRS +(const nomodify byte*) SPRITES_XPOS = (byte*) 53248 +(const nomodify byte*) SPRITES_YPOS = (byte*) 53249 +(const nomodify word) SPRITE_PTRS = (word) $3f8 +(const nomodify struct MOS6569_VICII*) VICII = (struct MOS6569_VICII*) 53248 +(byte()) krill_install() +(label) krill_install::@return +(byte) krill_install::return +(byte) krill_install::return#0 reg byte a 4.333333333333333 +(byte) krill_install::return#2 reg byte a 4.0 +(const nomodify byte*) krill_install::status = (byte*) 255 +(byte()) krill_loadraw((byte*) krill_loadraw::filename) +(label) krill_loadraw::@return +(byte*) krill_loadraw::filename +(const nomodify byte**) krill_loadraw::fname = (byte**) 254 +(byte) krill_loadraw::return +(byte) krill_loadraw::return#0 reg byte a 4.333333333333333 +(byte) krill_loadraw::return#2 reg byte a 4.0 +(const nomodify byte*) krill_loadraw::status = (byte*) 255 +(void()) main() +(label) main::@1 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@return +(const byte*) main::filename[(byte) 7] = (byte*) "sprite"pm +(byte) main::status +(byte) main::status#0 reg byte a 4.0 +(byte) main::status#1 reg byte a 4.0 +(label) main::toSpritePtr1 +(byte) main::toSpritePtr1_return +(const byte) main::toSpritePtr1_return#0 toSpritePtr1_return = (byte)(word)(const byte*) SPRITE/(byte) $40 +(byte*) main::toSpritePtr1_sprite + +reg byte a [ krill_install::return#2 ] +reg byte a [ main::status#0 ] +reg byte a [ krill_loadraw::return#2 ] +reg byte a [ main::status#1 ] +reg byte a [ krill_loadraw::return#0 ] +reg byte a [ krill_install::return#0 ] diff --git a/src/test/ref/test-comments-global.cfg b/src/test/ref/test-comments-global.cfg new file mode 100644 index 000000000..c4529d507 --- /dev/null +++ b/src/test/ref/test-comments-global.cfg @@ -0,0 +1,25 @@ + +(void()) _start() +_start: scope:[_start] from + [0] phi() + to:_start::_init1 +_start::_init1: scope:[_start] from _start + [1] (byte*) screen ← (byte*) 1024 + to:_start::@1 +_start::@1: scope:[_start] from _start::_init1 + [2] phi() + [3] call main + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + [4] return + to:@return + +(void()) main() +main: scope:[main] from _start::@1 + [5] *((byte*) screen) ← (byte) 'a' + [6] (byte*) screen ← ++ (byte*) screen + [7] *((byte*) screen) ← (byte) 'a' + to:main::@return +main::@return: scope:[main] from main + [8] return + to:@return diff --git a/src/test/ref/test-comments-global.log b/src/test/ref/test-comments-global.log new file mode 100644 index 000000000..168e21a63 --- /dev/null +++ b/src/test/ref/test-comments-global.log @@ -0,0 +1,309 @@ +Inlined call call _init + +CONTROL FLOW GRAPH SSA + +(void()) main() +main: scope:[main] from _start::@1 + *((byte*) screen) ← (byte) 'a' + (byte*) screen ← ++ (byte*) screen + *((byte*) screen) ← (byte) 'a' + to:main::@return +main::@return: scope:[main] from main + return + to:@return + +(void()) _start() +_start: scope:[_start] from + to:_start::_init1 +_start::_init1: scope:[_start] from _start + (byte*) screen ← (byte*)(number) $400 + to:_start::@1 +_start::@1: scope:[_start] from _start::_init1 + call main + to:_start::@2 +_start::@2: scope:[_start] from _start::@1 + to:_start::@return +_start::@return: scope:[_start] from _start::@2 + return + to:@return + +SYMBOL TABLE SSA +(void()) _start() +(label) _start::@1 +(label) _start::@2 +(label) _start::@return +(label) _start::_init1 +(void()) main() +(label) main::@return +(byte*) screen loadstore + +Simplifying constant pointer cast (byte*) 1024 +Successful SSA optimization PassNCastSimplification +Adding NOP phi() at start of _start +Adding NOP phi() at start of _start::@1 +Adding NOP phi() at start of _start::@2 +CALL GRAPH +Calls in [_start] to main:3 + +Created 0 initial phi equivalence classes +Coalesced down to 0 phi equivalence classes +Culled Empty Block (label) _start::@2 +Adding NOP phi() at start of _start +Adding NOP phi() at start of _start::@1 + +FINAL CONTROL FLOW GRAPH + +(void()) _start() +_start: scope:[_start] from + [0] phi() + to:_start::_init1 +_start::_init1: scope:[_start] from _start + [1] (byte*) screen ← (byte*) 1024 + to:_start::@1 +_start::@1: scope:[_start] from _start::_init1 + [2] phi() + [3] call main + to:_start::@return +_start::@return: scope:[_start] from _start::@1 + [4] return + to:@return + +(void()) main() +main: scope:[main] from _start::@1 + [5] *((byte*) screen) ← (byte) 'a' + [6] (byte*) screen ← ++ (byte*) screen + [7] *((byte*) screen) ← (byte) 'a' + to:main::@return +main::@return: scope:[main] from main + [8] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(void()) _start() +(void()) main() +(byte*) screen loadstore 11.5 + +Initial phi equivalence classes +Added variable screen to live range equivalence class [ screen ] +Complete equivalence classes +[ screen ] +Allocated zp[2]:2 [ screen ] + +INITIAL ASM +Target platform is c64basic / MOS6502X + // File Comments +// Tests that global variables with initializer gets their comments + // Upstart +.pc = $801 "Basic" +:BasicUpstart(_start) +.pc = $80d "Program" + // Global Constants & labels + // The screen (should become a var-comment in ASM) + .label screen = 2 + // _start +_start: { + jmp _init1 + // _start::_init1 + _init1: + // [1] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 + lda #<$400 + sta.z screen + lda #>$400 + sta.z screen+1 + // [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1] + __b1_from__init1: + jmp __b1 + // _start::@1 + __b1: + // [3] call main + jsr main + jmp __breturn + // _start::@return + __breturn: + // [4] return + rts +} + // main +// The program entry point +main: { + // [5] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // [6] (byte*) screen ← ++ (byte*) screen -- pbuz1=_inc_pbuz1 + inc.z screen + bne !+ + inc.z screen+1 + !: + // [7] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put another 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + jmp __breturn + // main::@return + __breturn: + // [8] return + rts +} + // File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [1] (byte*) screen ← (byte*) 1024 [ screen ] ( [ screen ] { } ) always clobbers reg byte a +Statement [5] *((byte*) screen) ← (byte) 'a' [ screen ] ( main:3 [ screen ] { } ) always clobbers reg byte a reg byte y +Statement [7] *((byte*) screen) ← (byte) 'a' [ ] ( main:3 [ ] { } ) always clobbers reg byte a reg byte y +Potential registers zp[2]:2 [ screen ] : zp[2]:2 , + +REGISTER UPLIFT SCOPES +Uplift Scope [] 11.5: zp[2]:2 [ screen ] +Uplift Scope [main] +Uplift Scope [_start] + +Uplifting [] best 99 combination zp[2]:2 [ screen ] +Uplifting [main] best 99 combination +Uplifting [_start] best 99 combination + +ASSEMBLER BEFORE OPTIMIZATION + // File Comments +// Tests that global variables with initializer gets their comments + // Upstart +.pc = $801 "Basic" +:BasicUpstart(_start) +.pc = $80d "Program" + // Global Constants & labels + // The screen (should become a var-comment in ASM) + .label screen = 2 + // _start +_start: { + jmp _init1 + // _start::_init1 + _init1: + // [1] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 + lda #<$400 + sta.z screen + lda #>$400 + sta.z screen+1 + // [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1] + __b1_from__init1: + jmp __b1 + // _start::@1 + __b1: + // [3] call main + jsr main + jmp __breturn + // _start::@return + __breturn: + // [4] return + rts +} + // main +// The program entry point +main: { + // [5] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // [6] (byte*) screen ← ++ (byte*) screen -- pbuz1=_inc_pbuz1 + inc.z screen + bne !+ + inc.z screen+1 + !: + // [7] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put another 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + jmp __breturn + // main::@return + __breturn: + // [8] return + rts +} + // File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp _init1 +Removing instruction jmp __b1 +Removing instruction jmp __breturn +Removing instruction jmp __breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction __b1_from__init1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction _init1: +Removing instruction __b1: +Removing instruction __breturn: +Removing instruction __breturn: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(void()) _start() +(label) _start::@1 +(label) _start::@return +(label) _start::_init1 +(void()) main() +(label) main::@return +(byte*) screen loadstore zp[2]:2 11.5 + +zp[2]:2 [ screen ] + + +FINAL ASSEMBLER +Score: 60 + + // File Comments +// Tests that global variables with initializer gets their comments + // Upstart +.pc = $801 "Basic" +:BasicUpstart(_start) +.pc = $80d "Program" + // Global Constants & labels + // The screen (should become a var-comment in ASM) + .label screen = 2 + // _start +_start: { + // _start::_init1 + // screen = 0x0400 + // [1] (byte*) screen ← (byte*) 1024 -- pbuz1=pbuc1 + lda #<$400 + sta.z screen + lda #>$400 + sta.z screen+1 + // [2] phi from _start::_init1 to _start::@1 [phi:_start::_init1->_start::@1] + // _start::@1 + // [3] call main + jsr main + // _start::@return + // [4] return + rts +} + // main +// The program entry point +main: { + // *screen = 'a' + // [5] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // screen++; + // [6] (byte*) screen ← ++ (byte*) screen -- pbuz1=_inc_pbuz1 + inc.z screen + bne !+ + inc.z screen+1 + !: + // *screen = 'a' + // [7] *((byte*) screen) ← (byte) 'a' -- _deref_pbuz1=vbuc1 + // Put another 'a' in screen + lda #'a' + ldy #0 + sta (screen),y + // main::@return + // } + // [8] return + rts +} + // File Data + diff --git a/src/test/ref/test-comments-global.sym b/src/test/ref/test-comments-global.sym new file mode 100644 index 000000000..905748b9b --- /dev/null +++ b/src/test/ref/test-comments-global.sym @@ -0,0 +1,9 @@ +(void()) _start() +(label) _start::@1 +(label) _start::@return +(label) _start::_init1 +(void()) main() +(label) main::@return +(byte*) screen loadstore zp[2]:2 11.5 + +zp[2]:2 [ screen ]