From 20ec350ca52064d1b0de48f37b6af64630e3aab4 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Sun, 23 Jun 2019 23:44:55 +0200 Subject: [PATCH] Added malloc tests. Improved cast handing in ASM fragments. Optimized screen center distance calculation (implemented table-based sqr() and sqrt() using binary search). --- .../_deref_pwuz1_le_vwuz2_then_la1.asm | 10 + src/main/fragment/pwuz1=pbuc1.asm | 4 + src/main/fragment/pwuz1=pwuz2.asm | 4 + src/main/fragment/vbuxx=vbuc1_minus_vbuaa.asm | 2 +- .../vwsz1=_deref_pwsz2_minus_vwsz3.asm | 9 + .../vwsz1=vwsz2_minus__deref_pwsz3.asm | 9 + src/main/fragment/vwsz1_neq_0_then_la1.asm | 4 + src/main/fragment/vwuz1_gt_0_then_la1.asm | 5 + .../AsmFragmentInstanceSpecFactory.java | 27 +- .../Pass0GenerateStatementSequence.java | 7 +- .../dk/camelot64/kickc/test/TestPrograms.java | 20 + src/test/kc/malloc-0.kc | 11 + src/test/kc/malloc-1.kc | 12 + src/test/kc/memory-heap.kc | 4 +- src/test/kc/screen-center-distance.kc | 86 + src/test/kc/unsigned-void-error.kc | 11 + src/test/ref/examples/3d/perspective.asm | 4 +- src/test/ref/examples/3d/perspective.log | 8 +- src/test/ref/examples/rotate/rotate.log | 18 +- src/test/ref/malloc-0.asm | 25 + src/test/ref/malloc-0.cfg | 31 + src/test/ref/malloc-0.log | 516 ++ src/test/ref/malloc-0.sym | 21 + src/test/ref/malloc-1.asm | 42 + src/test/ref/malloc-1.cfg | 33 + src/test/ref/malloc-1.log | 605 +++ src/test/ref/malloc-1.sym | 26 + src/test/ref/memory-heap.cfg | 4 +- src/test/ref/memory-heap.log | 114 +- src/test/ref/memory-heap.sym | 8 +- src/test/ref/screen-center-distance.asm | 350 ++ src/test/ref/screen-center-distance.cfg | 212 + src/test/ref/screen-center-distance.log | 4830 +++++++++++++++++ src/test/ref/screen-center-distance.sym | 225 + src/test/ref/semi-struct-2.log | 18 +- src/test/ref/typeinference-problem.asm | 2 +- src/test/ref/typeinference-problem.log | 4 +- 37 files changed, 7218 insertions(+), 103 deletions(-) create mode 100644 src/main/fragment/_deref_pwuz1_le_vwuz2_then_la1.asm create mode 100644 src/main/fragment/pwuz1=pbuc1.asm create mode 100644 src/main/fragment/pwuz1=pwuz2.asm create mode 100644 src/main/fragment/vwsz1=_deref_pwsz2_minus_vwsz3.asm create mode 100644 src/main/fragment/vwsz1=vwsz2_minus__deref_pwsz3.asm create mode 100644 src/main/fragment/vwsz1_neq_0_then_la1.asm create mode 100644 src/main/fragment/vwuz1_gt_0_then_la1.asm create mode 100644 src/test/kc/malloc-0.kc create mode 100644 src/test/kc/malloc-1.kc create mode 100644 src/test/kc/screen-center-distance.kc create mode 100644 src/test/kc/unsigned-void-error.kc create mode 100644 src/test/ref/malloc-0.asm create mode 100644 src/test/ref/malloc-0.cfg create mode 100644 src/test/ref/malloc-0.log create mode 100644 src/test/ref/malloc-0.sym create mode 100644 src/test/ref/malloc-1.asm create mode 100644 src/test/ref/malloc-1.cfg create mode 100644 src/test/ref/malloc-1.log create mode 100644 src/test/ref/malloc-1.sym create mode 100644 src/test/ref/screen-center-distance.asm create mode 100644 src/test/ref/screen-center-distance.cfg create mode 100644 src/test/ref/screen-center-distance.log create mode 100644 src/test/ref/screen-center-distance.sym diff --git a/src/main/fragment/_deref_pwuz1_le_vwuz2_then_la1.asm b/src/main/fragment/_deref_pwuz1_le_vwuz2_then_la1.asm new file mode 100644 index 000000000..c6a68569e --- /dev/null +++ b/src/main/fragment/_deref_pwuz1_le_vwuz2_then_la1.asm @@ -0,0 +1,10 @@ +ldy #1 +lda ({z1}),y +cmp {z2}+1 +bne !+ +dey +lda ({z1}),y +cmp {z2} +beq {la1} +!: +bcc {la1} diff --git a/src/main/fragment/pwuz1=pbuc1.asm b/src/main/fragment/pwuz1=pbuc1.asm new file mode 100644 index 000000000..8716dc864 --- /dev/null +++ b/src/main/fragment/pwuz1=pbuc1.asm @@ -0,0 +1,4 @@ +lda #<{c1} +sta {z1} +lda #>{c1} +sta {z1}+1 diff --git a/src/main/fragment/pwuz1=pwuz2.asm b/src/main/fragment/pwuz1=pwuz2.asm new file mode 100644 index 000000000..5b8ff5c26 --- /dev/null +++ b/src/main/fragment/pwuz1=pwuz2.asm @@ -0,0 +1,4 @@ +lda {z2} +sta {z1} +lda {z2}+1 +sta {z1}+1 diff --git a/src/main/fragment/vbuxx=vbuc1_minus_vbuaa.asm b/src/main/fragment/vbuxx=vbuc1_minus_vbuaa.asm index 71e34dd05..d126d02e7 100644 --- a/src/main/fragment/vbuxx=vbuc1_minus_vbuaa.asm +++ b/src/main/fragment/vbuxx=vbuc1_minus_vbuaa.asm @@ -1,3 +1,3 @@ eor #$ff tax -axs #{c1}+1 \ No newline at end of file +axs #-{c1}-1 \ No newline at end of file diff --git a/src/main/fragment/vwsz1=_deref_pwsz2_minus_vwsz3.asm b/src/main/fragment/vwsz1=_deref_pwsz2_minus_vwsz3.asm new file mode 100644 index 000000000..722941202 --- /dev/null +++ b/src/main/fragment/vwsz1=_deref_pwsz2_minus_vwsz3.asm @@ -0,0 +1,9 @@ +sec +ldy #0 +lda ({z2}),y +sbc {z3} +sta {z1} +iny +lda ({z2}),y +sbc {z3}+1 +sta {z1}+1 \ No newline at end of file diff --git a/src/main/fragment/vwsz1=vwsz2_minus__deref_pwsz3.asm b/src/main/fragment/vwsz1=vwsz2_minus__deref_pwsz3.asm new file mode 100644 index 000000000..cfc653a18 --- /dev/null +++ b/src/main/fragment/vwsz1=vwsz2_minus__deref_pwsz3.asm @@ -0,0 +1,9 @@ +sec +lda {z2} +ldy #0 +sbc ({z3}),y +sta {z1} +lda {z2}+1 +iny +sbc ({z3}),y +sta {z1}+1 \ No newline at end of file diff --git a/src/main/fragment/vwsz1_neq_0_then_la1.asm b/src/main/fragment/vwsz1_neq_0_then_la1.asm new file mode 100644 index 000000000..1b22ca229 --- /dev/null +++ b/src/main/fragment/vwsz1_neq_0_then_la1.asm @@ -0,0 +1,4 @@ +lda {z1}+1 +bne {la1} +lda {z1} +bne {la1} \ No newline at end of file diff --git a/src/main/fragment/vwuz1_gt_0_then_la1.asm b/src/main/fragment/vwuz1_gt_0_then_la1.asm new file mode 100644 index 000000000..db74c02f1 --- /dev/null +++ b/src/main/fragment/vwuz1_gt_0_then_la1.asm @@ -0,0 +1,5 @@ +lda {z1}+1 +bne {la1} +lda {z1} +bne {la1} +!: \ No newline at end of file diff --git a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java index 00888a1e1..9d72b1f67 100644 --- a/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java +++ b/src/main/java/dk/camelot64/kickc/fragment/AsmFragmentInstanceSpecFactory.java @@ -7,7 +7,10 @@ import dk.camelot64.kickc.model.operators.Operators; import dk.camelot64.kickc.model.statements.Statement; import dk.camelot64.kickc.model.statements.StatementAssignment; import dk.camelot64.kickc.model.statements.StatementConditionalJump; -import dk.camelot64.kickc.model.symbols.*; +import dk.camelot64.kickc.model.symbols.ConstantVar; +import dk.camelot64.kickc.model.symbols.Label; +import dk.camelot64.kickc.model.symbols.Symbol; +import dk.camelot64.kickc.model.symbols.Variable; import dk.camelot64.kickc.model.types.*; import dk.camelot64.kickc.model.values.*; @@ -223,13 +226,29 @@ public class AsmFragmentInstanceSpecFactory { if(value instanceof CastValue) { CastValue cast = (CastValue) value; SymbolType toType = cast.getToType(); - OperatorUnary castUnary = Operators.getCastUnary(toType); RValue castValue = cast.getValue(); SymbolType castValueType = SymbolTypeInference.inferType(this.program.getScope(), castValue); if(castValueType.getSizeBytes() == toType.getSizeBytes()) { - return bind(castValue, toType); + if(castType != null) { + if(castType.getSizeBytes() == toType.getSizeBytes()) { + return bind(castValue, castType); + } else { + OperatorUnary castUnary = Operators.getCastUnary(castType); + return getOperatorFragmentName(castUnary) + bind(castValue, toType); + } + } else { + return bind(castValue, toType); + } } else { - return getOperatorFragmentName(castUnary) + bind(castValue); + // Size of inner value and inner cast type mismatches - require explicit conversion + if(castType != null) { + OperatorUnary castUnaryInner = Operators.getCastUnary(toType); + OperatorUnary castUnaryOuter = Operators.getCastUnary(castType); + return getOperatorFragmentName(castUnaryOuter) + getOperatorFragmentName(castUnaryInner) + bind(castValue); + } else { + OperatorUnary castUnaryInner = Operators.getCastUnary(toType); + return getOperatorFragmentName(castUnaryInner) + bind(castValue); + } } } else if(value instanceof ConstantCastValue) { ConstantCastValue castVal = (ConstantCastValue) value; diff --git a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java index 07347128b..0df7822b7 100644 --- a/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java +++ b/src/main/java/dk/camelot64/kickc/passes/Pass0GenerateStatementSequence.java @@ -1298,7 +1298,12 @@ public class Pass0GenerateStatementSequence extends KickCBaseVisitor { } else { simpleTypeName = "int"; } - return SymbolType.get(signedness + " " + simpleTypeName); + String fullName = signedness + " " + simpleTypeName; + SymbolType symbolType = SymbolType.get(fullName); + if(symbolType==null) { + throw new CompileError("Unknown type "+fullName, new StatementSource(ctx)); + } + return symbolType; } @Override diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 470a9a59c..0e1113fcf 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -35,6 +35,16 @@ public class TestPrograms { public TestPrograms() { } + @Test + public void testUnsignedVoidError() throws IOException, URISyntaxException { + assertError("unsigned-void-error", "Unknown type unsigned void"); + } + + @Test + public void testScreenCenterDistance() throws IOException, URISyntaxException { + compileAndCompare("screen-center-distance"); + } + @Test public void testFontHexShow() throws IOException, URISyntaxException { compileAndCompare("font-hex-show"); @@ -502,6 +512,16 @@ public class TestPrograms { compileAndCompare("memory-heap"); } + @Test + public void testMalloc1() throws IOException, URISyntaxException { + compileAndCompare("malloc-1"); + } + + @Test + public void testMalloc0() throws IOException, URISyntaxException { + compileAndCompare("malloc-0"); + } + @Test public void testTernaryInference() throws IOException, URISyntaxException { compileAndCompare("ternary-inference"); diff --git a/src/test/kc/malloc-0.kc b/src/test/kc/malloc-0.kc new file mode 100644 index 000000000..434f1f030 --- /dev/null +++ b/src/test/kc/malloc-0.kc @@ -0,0 +1,11 @@ +// Experiments with malloc() - a byte array + +import "stdlib" + +byte* BYTES = malloc(0x100); + +void main() { + for( byte i: 0..255) { + BYTES[i] = i; + } +} diff --git a/src/test/kc/malloc-1.kc b/src/test/kc/malloc-1.kc new file mode 100644 index 000000000..f1656a6d5 --- /dev/null +++ b/src/test/kc/malloc-1.kc @@ -0,0 +1,12 @@ +// Experiments with malloc() - a word array + +import "stdlib" + +word* WORDS = malloc(0x200); + +void main() { + word* w = WORDS; + for( byte i: 0..255) { + *w++ = i; + } +} diff --git a/src/test/kc/memory-heap.kc b/src/test/kc/memory-heap.kc index 5c62db2fd..f0e27ee48 100644 --- a/src/test/kc/memory-heap.kc +++ b/src/test/kc/memory-heap.kc @@ -3,8 +3,8 @@ import "stdlib" void main() { - unsigned char* buf1 = (unsigned char*) malloc(100); - unsigned char* buf2 = (unsigned char*) malloc(100); + unsigned char* buf1 = malloc(100); + unsigned char* buf2 = malloc(100); for(unsigned char i:0..99) { buf1[i] = i; buf2[i] = 255-i; diff --git a/src/test/kc/screen-center-distance.kc b/src/test/kc/screen-center-distance.kc new file mode 100644 index 000000000..20687d1db --- /dev/null +++ b/src/test/kc/screen-center-distance.kc @@ -0,0 +1,86 @@ +// Calculate the distance to the center of the screen - and show it using font-hex + +import "stdlib" +import "c64" +import "font-hex" + +#reserve(08) + +const byte* CHARSET = 0x2000; +const byte* SCREEN = 0x2800; + +void main() { + init_font_hex(CHARSET); + *D018 = toD018(SCREEN, CHARSET); + NUM_SQUARES = 0x30; + init_squares(); + byte* screen = SCREEN; + for(byte y: 0..24) { + byte y2 = y*2; + byte yd = (y2>=24)?(y2-24):(24-y2); + word yds = sqr(yd); + for(byte x: 0..39) { + byte x2 = x*2; + byte xd = (x2>=39)?(x2-39):(39-x2); + word xds = sqr(xd); + word ds = xds+yds; + byte d = sqrt(ds); + *screen++ = d; + } + } +} + +// The number of squares to pre-calculate. Limits what values sqr() can calculate and the result of sqrt() +byte NUM_SQUARES = 0xff; + +// Squares for each byte value SQUARES[i] = i*i +// Initialized by init_squares() +word* SQUARES; + +// Initialize squares table +// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 +void init_squares() { + SQUARES = malloc(NUM_SQUARES*sizeof(word)); + word* squares = SQUARES; + word sqr = 0; + for( byte i: 0..NUM_SQUARES-1) { + *squares++ = sqr; + sqr += i*2+1; + } +} + +// Find the square of a byte value +// Uses a table of squares that must be initialized by calling init_squares() +word sqr(byte val) { + return SQUARES[val]; +} + +// Find the (integer) square root of a word value +// If the square is not an integer then it returns the largest integer N where N*N <= val +// Uses a table of squares that must be initialized by calling init_squares() +byte sqrt(word val) { + word* found = bsearch16u(val, SQUARES, NUM_SQUARES); + byte sqr1 = (byte)((byte*)found-(byte*)SQUARES)/2; + return sqr1; +} + +// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key. +// - key - The value to look for +// - items - Pointer to the start of the array to search in +// - num - The number of items in the array +// Returns pointer to an entry in the array that matches the search key +word* bsearch16u(word key, word* items, byte num) { + while (num > 0) { + word* pivot = items + (num >> 1); + signed word result = (signed word)key-(signed word)*pivot; + if (result == 0) + return pivot; + if (result > 0) { + items = pivot+1; + num--; + } + num >>= 1; + } + // not found - return closest lower value + return *items<=key?items:items-1; +} \ No newline at end of file diff --git a/src/test/kc/unsigned-void-error.kc b/src/test/kc/unsigned-void-error.kc new file mode 100644 index 000000000..8d5f75f27 --- /dev/null +++ b/src/test/kc/unsigned-void-error.kc @@ -0,0 +1,11 @@ +// Tests that unsigned void produces an error + +void main() { + getNull(); +} + +unsigned void* getNull() { + return (byte*) 0; +} + + diff --git a/src/test/ref/examples/3d/perspective.asm b/src/test/ref/examples/3d/perspective.asm index dd8f8e58d..ca4c3acac 100644 --- a/src/test/ref/examples/3d/perspective.asm +++ b/src/test/ref/examples/3d/perspective.asm @@ -264,13 +264,13 @@ mulf_init: { tya eor #$ff tax - axs #1+1 + axs #-1-1 lda val sta mulf_sqr2,x tya eor #$ff tax - axs #1+1 + axs #-1-1 lda val sta mulf_sqr2+$100,x lda sqr diff --git a/src/test/ref/examples/3d/perspective.log b/src/test/ref/examples/3d/perspective.log index bc06d3e57..341bae215 100644 --- a/src/test/ref/examples/3d/perspective.log +++ b/src/test/ref/examples/3d/perspective.log @@ -3003,7 +3003,7 @@ mulf_init: { tya eor #$ff tax - axs #1+1 + axs #-1-1 //SEG201 [96] *((const byte[$200]) mulf_sqr2#0 + (byte~) mulf_init::$8) ← (byte) mulf_init::val#0 -- pbuc1_derefidx_vbuxx=vbuz1 lda val sta mulf_sqr2,x @@ -3011,7 +3011,7 @@ mulf_init: { tya eor #$ff tax - axs #1+1 + axs #-1-1 //SEG203 [98] *((const byte[$200]) mulf_sqr2#0+(word) $100 + (byte~) mulf_init::$10) ← (byte) mulf_init::val#0 -- pbuc1_derefidx_vbuxx=vbuz1 lda val sta mulf_sqr2+$100,x @@ -3829,7 +3829,7 @@ mulf_init: { tya eor #$ff tax - axs #1+1 + axs #-1-1 //SEG201 [96] *((const byte[$200]) mulf_sqr2#0 + (byte~) mulf_init::$8) ← (byte) mulf_init::val#0 -- pbuc1_derefidx_vbuxx=vbuz1 lda val sta mulf_sqr2,x @@ -3837,7 +3837,7 @@ mulf_init: { tya eor #$ff tax - axs #1+1 + axs #-1-1 //SEG203 [98] *((const byte[$200]) mulf_sqr2#0+(word) $100 + (byte~) mulf_init::$10) ← (byte) mulf_init::val#0 -- pbuc1_derefidx_vbuxx=vbuz1 lda val sta mulf_sqr2+$100,x diff --git a/src/test/ref/examples/rotate/rotate.log b/src/test/ref/examples/rotate/rotate.log index ffcae3ca4..23bee19d4 100644 --- a/src/test/ref/examples/rotate/rotate.log +++ b/src/test/ref/examples/rotate/rotate.log @@ -2229,7 +2229,7 @@ anim: { jmp mulf8s_prepare1 //SEG38 anim::mulf8s_prepare1 mulf8s_prepare1: - //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuz1=pbsc1_derefidx_vbuz2 + //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuz1=pbuc1_derefidx_vbuz2 ldy angle lda COS,y sta mulf8u_prepare.a @@ -2280,7 +2280,7 @@ anim: { jmp mulf8s_prepare2 //SEG56 anim::mulf8s_prepare2 mulf8s_prepare2: - //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuz1=pbsc1_derefidx_vbuz2 + //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuz1=pbuc1_derefidx_vbuz2 ldy angle lda SIN,y sta mulf8u_prepare.a @@ -2866,14 +2866,12 @@ REGISTER UPLIFT POTENTIAL REGISTERS Equivalence Class zp ZP_BYTE:42 [ anim::$22 ] has ALU potential. Statement [12] if(*((const byte*) RASTER#0)!=(byte) $ff) goto anim::@2 [ anim::angle#6 ] ( main:3::anim:8 [ anim::angle#6 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ anim::angle#6 anim::angle#1 ] -Statement [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 mulf8u_prepare::a#3 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 mulf8u_prepare::a#3 ] ) always clobbers reg byte a +Statement [21] (signed word) anim::xr#0 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:3 [ anim::i#10 anim::i#1 ] Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ anim::sprite_msb#10 anim::sprite_msb#5 anim::sprite_msb#2 anim::sprite_msb#1 ] Removing always clobbered register reg byte a as potential for zp ZP_BYTE:24 [ anim::x#0 ] Removing always clobbered register reg byte a as potential for zp ZP_BYTE:25 [ anim::y#0 ] -Statement [21] (signed word) anim::xr#0 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ) always clobbers reg byte a Statement [24] (signed word) anim::yr#0 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 ] ) always clobbers reg byte a -Statement [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 mulf8u_prepare::a#4 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 mulf8u_prepare::a#4 ] ) always clobbers reg byte a Statement [29] (signed word~) anim::$10 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::xr#0 anim::yr#0 anim::$10 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::xr#0 anim::yr#0 anim::$10 ] ) always clobbers reg byte a Statement [30] (signed word) anim::xr#1 ← (signed word) anim::xr#0 - (signed word~) anim::$10 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::yr#0 anim::xr#1 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::yr#0 anim::xr#1 ] ) always clobbers reg byte a Statement [33] (signed word~) anim::$12 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::yr#0 anim::xr#1 anim::$12 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::yr#0 anim::xr#1 anim::$12 ] ) always clobbers reg byte a @@ -2930,10 +2928,8 @@ Statement [110] if((byte*) mulf_init::sqr2_lo#1!=(const byte[$200]) mulf_sqr2_lo Statement [111] *((const byte[$200]) mulf_sqr2_lo#0+(word) $1ff) ← *((const byte[$200]) mulf_sqr1_lo#0+(word) $100) [ ] ( main:3::init:6::mulf_init:77 [ ] ) always clobbers reg byte a Statement [112] *((const byte[$200]) mulf_sqr2_hi#0+(word) $1ff) ← *((const byte[$200]) mulf_sqr1_hi#0+(word) $100) [ ] ( main:3::init:6::mulf_init:77 [ ] ) always clobbers reg byte a Statement [12] if(*((const byte*) RASTER#0)!=(byte) $ff) goto anim::@2 [ anim::angle#6 ] ( main:3::anim:8 [ anim::angle#6 ] ) always clobbers reg byte a -Statement [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 mulf8u_prepare::a#3 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 mulf8u_prepare::a#3 ] ) always clobbers reg byte a Statement [21] (signed word) anim::xr#0 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 ] ) always clobbers reg byte a Statement [24] (signed word) anim::yr#0 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 ] ) always clobbers reg byte a -Statement [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 mulf8u_prepare::a#4 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::y#0 anim::xr#0 anim::yr#0 mulf8u_prepare::a#4 ] ) always clobbers reg byte a Statement [29] (signed word~) anim::$10 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::xr#0 anim::yr#0 anim::$10 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::xr#0 anim::yr#0 anim::$10 ] ) always clobbers reg byte a Statement [30] (signed word) anim::xr#1 ← (signed word) anim::xr#0 - (signed word~) anim::$10 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::yr#0 anim::xr#1 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::x#0 anim::yr#0 anim::xr#1 ] ) always clobbers reg byte a Statement [33] (signed word~) anim::$12 ← (signed word)(word) mulf8s_prepared::m#4 << (byte) 1 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::yr#0 anim::xr#1 anim::$12 ] ( main:3::anim:8 [ anim::angle#6 anim::i#10 anim::sprite_msb#10 anim::yr#0 anim::xr#1 anim::$12 ] ) always clobbers reg byte a @@ -3204,7 +3200,7 @@ anim: { jmp mulf8s_prepare1 //SEG38 anim::mulf8s_prepare1 mulf8s_prepare1: - //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuaa=pbsc1_derefidx_vbuz1 + //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuaa=pbuc1_derefidx_vbuz1 ldy angle lda COS,y //SEG40 [18] call mulf8u_prepare @@ -3252,7 +3248,7 @@ anim: { jmp mulf8s_prepare2 //SEG56 anim::mulf8s_prepare2 mulf8s_prepare2: - //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuaa=pbsc1_derefidx_vbuz1 + //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuaa=pbuc1_derefidx_vbuz1 ldy angle lda SIN,y //SEG58 [26] call mulf8u_prepare @@ -4237,7 +4233,7 @@ anim: { lda ys,y sta y //SEG38 anim::mulf8s_prepare1 - //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuaa=pbsc1_derefidx_vbuz1 + //SEG39 [17] (byte~) mulf8u_prepare::a#3 ← (byte)(signed byte)*((const byte*) COS#0 + (byte) anim::angle#6) -- vbuaa=pbuc1_derefidx_vbuz1 ldy angle lda COS,y //SEG40 [18] call mulf8u_prepare @@ -4274,7 +4270,7 @@ anim: { rol sta yr+1 //SEG56 anim::mulf8s_prepare2 - //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuaa=pbsc1_derefidx_vbuz1 + //SEG57 [25] (byte~) mulf8u_prepare::a#4 ← (byte)(signed byte)*((const byte*) SIN#0 + (byte) anim::angle#6) -- vbuaa=pbuc1_derefidx_vbuz1 ldy angle lda SIN,y //SEG58 [26] call mulf8u_prepare diff --git a/src/test/ref/malloc-0.asm b/src/test/ref/malloc-0.asm new file mode 100644 index 000000000..5e39301b0 --- /dev/null +++ b/src/test/ref/malloc-0.asm @@ -0,0 +1,25 @@ +// Experiments with malloc() - a byte array +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" + // Start of the heap used by malloc() + .label HEAP_START = $c000 +bbegin: + jsr malloc + jsr main + rts +main: { + ldx #0 + b1: + txa + sta HEAP_START,x + inx + cpx #0 + bne b1 + rts +} +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + rts +} diff --git a/src/test/ref/malloc-0.cfg b/src/test/ref/malloc-0.cfg new file mode 100644 index 000000000..9f1cd2b88 --- /dev/null +++ b/src/test/ref/malloc-0.cfg @@ -0,0 +1,31 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call malloc + to:@2 +@2: scope:[] from @1 + [3] phi() + [4] call main + to:@end +@end: scope:[] from @2 + [5] phi() +main: scope:[main] from @2 + [6] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [7] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) + [8] *((const byte*) HEAP_START#0 + (byte) main::i#2) ← (byte) main::i#2 + [9] (byte) main::i#1 ← ++ (byte) main::i#2 + [10] if((byte) main::i#1!=(byte) 0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return + to:@return +malloc: scope:[malloc] from @1 + [12] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [13] return + to:@return diff --git a/src/test/ref/malloc-0.log b/src/test/ref/malloc-0.log new file mode 100644 index 000000000..3653b6a51 --- /dev/null +++ b/src/test/ref/malloc-0.log @@ -0,0 +1,516 @@ +Adding pointer type conversion cast (byte*) HEAP_START in (byte*) HEAP_START ← (number) $c000 +Identified constant variable (byte*) HEAP_START +Culled Empty Block (label) malloc::@1 +Culled Empty Block (label) @1 +Culled Empty Block (label) main::@2 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) HEAP_START#0 ← ((byte*)) (number) $c000 + (byte*) heap_head#0 ← (byte*) HEAP_START#0 + to:@2 +malloc: scope:[malloc] from @2 + (word) malloc::size#1 ← phi( @2/(word) malloc::size#0 ) + (byte*) heap_head#4 ← phi( @2/(byte*) heap_head#7 ) + (byte*) malloc::mem#0 ← (byte*) heap_head#4 + (byte*) heap_head#1 ← (byte*) heap_head#4 + (word) malloc::size#1 + (byte*) malloc::return#0 ← (byte*) malloc::mem#0 + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + (byte*) heap_head#5 ← phi( malloc/(byte*) heap_head#1 ) + (byte*) malloc::return#3 ← phi( malloc/(byte*) malloc::return#0 ) + (byte*) malloc::return#1 ← (byte*) malloc::return#3 + (byte*) heap_head#2 ← (byte*) heap_head#5 + return + to:@return +@2: scope:[] from @begin + (byte*) heap_head#7 ← phi( @begin/(byte*) heap_head#0 ) + (word) malloc::size#0 ← (number) $100 + call malloc + (byte*) malloc::return#2 ← (byte*) malloc::return#1 + to:@4 +@4: scope:[] from @2 + (byte*) heap_head#6 ← phi( @2/(byte*) heap_head#2 ) + (byte*) malloc::return#4 ← phi( @2/(byte*) malloc::return#2 ) + (byte*~) $0 ← (byte*) malloc::return#4 + (byte*) heap_head#3 ← (byte*) heap_head#6 + (byte*) BYTES#0 ← (byte*~) $0 + to:@3 +main: scope:[main] from @3 + (byte*) BYTES#2 ← phi( @3/(byte*) BYTES#3 ) + (byte) main::i#0 ← (byte) 0 + to:main::@1 +main::@1: scope:[main] from main main::@1 + (byte*) BYTES#1 ← phi( main/(byte*) BYTES#2 main::@1/(byte*) BYTES#1 ) + (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 ) + *((byte*) BYTES#1 + (byte) main::i#2) ← (byte) main::i#2 + (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$ff) + (bool~) main::$0 ← (byte) main::i#1 != rangelast(0,$ff) + if((bool~) main::$0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +@3: scope:[] from @4 + (byte*) BYTES#3 ← phi( @4/(byte*) BYTES#0 ) + call main + to:@5 +@5: scope:[] from @3 + to:@end +@end: scope:[] from @5 + +SYMBOL TABLE SSA +(byte*~) $0 +(label) @2 +(label) @3 +(label) @4 +(label) @5 +(label) @begin +(label) @end +(byte*) BYTES +(byte*) BYTES#0 +(byte*) BYTES#1 +(byte*) BYTES#2 +(byte*) BYTES#3 +(byte*) HEAP_START +(byte*) HEAP_START#0 +(byte*) heap_head +(byte*) heap_head#0 +(byte*) heap_head#1 +(byte*) heap_head#2 +(byte*) heap_head#3 +(byte*) heap_head#4 +(byte*) heap_head#5 +(byte*) heap_head#6 +(byte*) heap_head#7 +(void()) main() +(bool~) main::$0 +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::mem#0 +(byte*) malloc::return +(byte*) malloc::return#0 +(byte*) malloc::return#1 +(byte*) malloc::return#2 +(byte*) malloc::return#3 +(byte*) malloc::return#4 +(word) malloc::size +(word) malloc::size#0 +(word) malloc::size#1 + +Adding number conversion cast (unumber) $100 in (word) malloc::size#0 ← (number) $100 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000 +Inlining cast (word) malloc::size#0 ← (unumber)(number) $100 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 49152 +Simplifying constant integer cast $100 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (word) $100 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#7 +Alias (byte*) malloc::return#0 = (byte*) malloc::mem#0 (byte*) malloc::return#3 (byte*) malloc::return#1 +Alias (byte*) heap_head#1 = (byte*) heap_head#5 (byte*) heap_head#2 +Alias (byte*) malloc::return#2 = (byte*) malloc::return#4 +Alias (byte*) heap_head#3 = (byte*) heap_head#6 +Alias (byte*) BYTES#0 = (byte*~) $0 (byte*) BYTES#3 +Successful SSA optimization Pass2AliasElimination +Self Phi Eliminated (byte*) BYTES#1 +Successful SSA optimization Pass2SelfPhiElimination +Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_START#0 +Identical Phi Values (word) malloc::size#1 (word) malloc::size#0 +Identical Phi Values (byte*) heap_head#3 (byte*) heap_head#1 +Identical Phi Values (byte*) BYTES#2 (byte*) BYTES#0 +Identical Phi Values (byte*) BYTES#1 (byte*) BYTES#2 +Successful SSA optimization Pass2IdenticalPhiElimination +Simple Condition (bool~) main::$0 [24] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) HEAP_START#0 = (byte*) 49152 +Constant (const word) malloc::size#0 = $100 +Constant (const byte) main::i#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#0 = HEAP_START#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#2 = malloc::return#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) BYTES#0 = malloc::return#2 +Successful SSA optimization Pass2ConstantIdentification +Resolved ranged next value [22] main::i#1 ← ++ main::i#2 to ++ +Resolved ranged comparison value [24] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0 +Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (const word) malloc::size#0 +Successful SSA optimization PassNEliminateUnusedVars +Eliminating unused constant (const word) malloc::size#0 +Successful SSA optimization PassNEliminateUnusedVars +Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inlining constant with var siblings (const byte) main::i#0 +Constant inlined main::i#0 = (byte) 0 +Constant inlined malloc::return#2 = (const byte*) HEAP_START#0 +Constant inlined BYTES#0 = (const byte*) HEAP_START#0 +Constant inlined malloc::return#0 = (const byte*) HEAP_START#0 +Successful SSA optimization Pass2ConstantInlining +Added new block during phi lifting main::@3(between main::@1 and main::@1) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @4 +Adding NOP phi() at start of @3 +Adding NOP phi() at start of @5 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of malloc +CALL GRAPH +Calls in [] to malloc:2 main:5 + +Created 1 initial phi equivalence classes +Coalesced [14] main::i#3 ← main::i#1 +Coalesced down to 1 phi equivalence classes +Culled Empty Block (label) @4 +Culled Empty Block (label) @5 +Culled Empty Block (label) main::@3 +Renumbering block @2 to @1 +Renumbering block @3 to @2 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of malloc + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call malloc + to:@2 +@2: scope:[] from @1 + [3] phi() + [4] call main + to:@end +@end: scope:[] from @2 + [5] phi() +main: scope:[main] from @2 + [6] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [7] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) + [8] *((const byte*) HEAP_START#0 + (byte) main::i#2) ← (byte) main::i#2 + [9] (byte) main::i#1 ← ++ (byte) main::i#2 + [10] if((byte) main::i#1!=(byte) 0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [11] return + to:@return +malloc: scope:[malloc] from @1 + [12] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [13] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte*) BYTES +(byte*) HEAP_START +(byte*) heap_head +(void()) main() +(byte) main::i +(byte) main::i#1 16.5 +(byte) main::i#2 22.0 +(byte*()) malloc((word) malloc::size) +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +Initial phi equivalence classes +[ main::i#2 main::i#1 ] +Complete equivalence classes +[ main::i#2 main::i#1 ] +Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] + +INITIAL ASM +//SEG0 File Comments +// Experiments with malloc() - a byte array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call malloc +//SEG7 [12] phi from @1 to malloc [phi:@1->malloc] +malloc_from_b1: + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +b2_from_b1: + jmp b2 +//SEG9 @2 +b2: +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +bend_from_b2: + jmp bend +//SEG13 @end +bend: +//SEG14 main +main: { + .label i = 2 + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG16 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuz1=vbuc1 + lda #0 + sta i + jmp b1 + //SEG17 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG18 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG19 main::@1 + b1: + //SEG20 [8] *((const byte*) HEAP_START#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuz1=vbuz1 + ldy i + tya + sta HEAP_START,y + //SEG21 [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc i + //SEG22 [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuz1_neq_0_then_la1 + lda i + cmp #0 + bne b1_from_b1 + jmp breturn + //SEG23 main::@return + breturn: + //SEG24 [11] return + rts +} +//SEG25 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG26 malloc::@return + breturn: + //SEG27 [13] return + rts +} +//SEG28 File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte a , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 38.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Uplift Scope [malloc] +Uplift Scope [] + +Uplifting [main] best 308 combination reg byte x [ main::i#2 main::i#1 ] +Uplifting [malloc] best 308 combination +Uplifting [] best 308 combination + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +// Experiments with malloc() - a byte array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call malloc +//SEG7 [12] phi from @1 to malloc [phi:@1->malloc] +malloc_from_b1: + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +b2_from_b1: + jmp b2 +//SEG9 @2 +b2: +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +bend_from_b2: + jmp bend +//SEG13 @end +bend: +//SEG14 main +main: { + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG16 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + jmp b1 + //SEG17 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG18 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + jmp b1 + //SEG19 main::@1 + b1: + //SEG20 [8] *((const byte*) HEAP_START#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx + txa + sta HEAP_START,x + //SEG21 [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG22 [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b1_from_b1 + jmp breturn + //SEG23 main::@return + breturn: + //SEG24 [11] return + rts +} +//SEG25 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG26 malloc::@return + breturn: + //SEG27 [13] return + rts +} +//SEG28 File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp breturn +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Replacing label b1_from_b1 with b1 +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction malloc_from_b1: +Removing instruction b2_from_b1: +Removing instruction main_from_b2: +Removing instruction bend_from_b2: +Removing instruction b1_from_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction b2: +Removing instruction bend: +Removing instruction b1_from_main: +Removing instruction breturn: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Adding RTS to root block +Succesful ASM optimization Pass5AddMainRts +Removing instruction jmp b1 +Succesful ASM optimization Pass5NextJumpElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @2 +(label) @begin +(label) @end +(byte*) BYTES +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(byte*) heap_head +(void()) main() +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 22.0 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +reg byte x [ main::i#2 main::i#1 ] + + +FINAL ASSEMBLER +Score: 185 + +//SEG0 File Comments +// Experiments with malloc() - a byte array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +//SEG5 @1 +//SEG6 [2] call malloc +//SEG7 [12] phi from @1 to malloc [phi:@1->malloc] + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +//SEG9 @2 +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] + jsr main + rts +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +//SEG13 @end +//SEG14 main +main: { + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + //SEG16 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG17 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG18 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG19 main::@1 + b1: + //SEG20 [8] *((const byte*) HEAP_START#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuc1_derefidx_vbuxx=vbuxx + txa + sta HEAP_START,x + //SEG21 [9] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG22 [10] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b1 + //SEG23 main::@return + //SEG24 [11] return + rts +} +//SEG25 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + //SEG26 malloc::@return + //SEG27 [13] return + rts +} +//SEG28 File Data + diff --git a/src/test/ref/malloc-0.sym b/src/test/ref/malloc-0.sym new file mode 100644 index 000000000..92f18dd8e --- /dev/null +++ b/src/test/ref/malloc-0.sym @@ -0,0 +1,21 @@ +(label) @1 +(label) @2 +(label) @begin +(label) @end +(byte*) BYTES +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(byte*) heap_head +(void()) main() +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 22.0 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +reg byte x [ main::i#2 main::i#1 ] diff --git a/src/test/ref/malloc-1.asm b/src/test/ref/malloc-1.asm new file mode 100644 index 000000000..e945df89b --- /dev/null +++ b/src/test/ref/malloc-1.asm @@ -0,0 +1,42 @@ +// Experiments with malloc() - a word array +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 +bbegin: + jsr malloc + jsr main + rts +main: { + .label w = 2 + lda #HEAP_START + sta w+1 + ldx #0 + b1: + txa + ldy #0 + sta (w),y + tya + iny + sta (w),y + lda #SIZEOF_WORD + clc + adc w + sta w + bcc !+ + inc w+1 + !: + inx + cpx #0 + bne b1 + rts +} +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + rts +} diff --git a/src/test/ref/malloc-1.cfg b/src/test/ref/malloc-1.cfg new file mode 100644 index 000000000..7dd237ee8 --- /dev/null +++ b/src/test/ref/malloc-1.cfg @@ -0,0 +1,33 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call malloc + to:@2 +@2: scope:[] from @1 + [3] phi() + [4] call main + to:@end +@end: scope:[] from @2 + [5] phi() +main: scope:[main] from @2 + [6] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [7] (word*) main::w#2 ← phi( main/(const byte*) HEAP_START#0 main::@1/(word*) main::w#1 ) + [7] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) + [8] *((word*) main::w#2) ← (byte) main::i#2 + [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD + [10] (byte) main::i#1 ← ++ (byte) main::i#2 + [11] if((byte) main::i#1!=(byte) 0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [12] return + to:@return +malloc: scope:[malloc] from @1 + [13] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [14] return + to:@return diff --git a/src/test/ref/malloc-1.log b/src/test/ref/malloc-1.log new file mode 100644 index 000000000..dcb64bea7 --- /dev/null +++ b/src/test/ref/malloc-1.log @@ -0,0 +1,605 @@ +Adding pointer type conversion cast (byte*) HEAP_START in (byte*) HEAP_START ← (number) $c000 +Fixing pointer increment (word*) main::w ← ++ (word*) main::w +Identified constant variable (byte*) HEAP_START +Culled Empty Block (label) malloc::@1 +Culled Empty Block (label) @1 +Culled Empty Block (label) main::@2 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) HEAP_START#0 ← ((byte*)) (number) $c000 + (byte*) heap_head#0 ← (byte*) HEAP_START#0 + to:@2 +malloc: scope:[malloc] from @2 + (word) malloc::size#1 ← phi( @2/(word) malloc::size#0 ) + (byte*) heap_head#4 ← phi( @2/(byte*) heap_head#7 ) + (byte*) malloc::mem#0 ← (byte*) heap_head#4 + (byte*) heap_head#1 ← (byte*) heap_head#4 + (word) malloc::size#1 + (byte*) malloc::return#0 ← (byte*) malloc::mem#0 + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + (byte*) heap_head#5 ← phi( malloc/(byte*) heap_head#1 ) + (byte*) malloc::return#3 ← phi( malloc/(byte*) malloc::return#0 ) + (byte*) malloc::return#1 ← (byte*) malloc::return#3 + (byte*) heap_head#2 ← (byte*) heap_head#5 + return + to:@return +@2: scope:[] from @begin + (byte*) heap_head#7 ← phi( @begin/(byte*) heap_head#0 ) + (word) malloc::size#0 ← (number) $200 + call malloc + (byte*) malloc::return#2 ← (byte*) malloc::return#1 + to:@4 +@4: scope:[] from @2 + (byte*) heap_head#6 ← phi( @2/(byte*) heap_head#2 ) + (byte*) malloc::return#4 ← phi( @2/(byte*) malloc::return#2 ) + (byte*~) $0 ← (byte*) malloc::return#4 + (byte*) heap_head#3 ← (byte*) heap_head#6 + (word*) WORDS#0 ← (byte*~) $0 + to:@3 +main: scope:[main] from @3 + (word*) WORDS#1 ← phi( @3/(word*) WORDS#2 ) + (word*) main::w#0 ← (word*) WORDS#1 + (byte) main::i#0 ← (byte) 0 + to:main::@1 +main::@1: scope:[main] from main main::@1 + (word*) main::w#2 ← phi( main/(word*) main::w#0 main::@1/(word*) main::w#1 ) + (byte) main::i#2 ← phi( main/(byte) main::i#0 main::@1/(byte) main::i#1 ) + *((word*) main::w#2) ← (byte) main::i#2 + (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD + (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$ff) + (bool~) main::$0 ← (byte) main::i#1 != rangelast(0,$ff) + if((bool~) main::$0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + return + to:@return +@3: scope:[] from @4 + (word*) WORDS#2 ← phi( @4/(word*) WORDS#0 ) + call main + to:@5 +@5: scope:[] from @3 + to:@end +@end: scope:[] from @5 + +SYMBOL TABLE SSA +(byte*~) $0 +(label) @2 +(label) @3 +(label) @4 +(label) @5 +(label) @begin +(label) @end +(byte*) HEAP_START +(byte*) HEAP_START#0 +(const byte) SIZEOF_WORD = (byte) 2 +(word*) WORDS +(word*) WORDS#0 +(word*) WORDS#1 +(word*) WORDS#2 +(byte*) heap_head +(byte*) heap_head#0 +(byte*) heap_head#1 +(byte*) heap_head#2 +(byte*) heap_head#3 +(byte*) heap_head#4 +(byte*) heap_head#5 +(byte*) heap_head#6 +(byte*) heap_head#7 +(void()) main() +(bool~) main::$0 +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#0 +(byte) main::i#1 +(byte) main::i#2 +(word*) main::w +(word*) main::w#0 +(word*) main::w#1 +(word*) main::w#2 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::mem#0 +(byte*) malloc::return +(byte*) malloc::return#0 +(byte*) malloc::return#1 +(byte*) malloc::return#2 +(byte*) malloc::return#3 +(byte*) malloc::return#4 +(word) malloc::size +(word) malloc::size#0 +(word) malloc::size#1 + +Adding number conversion cast (unumber) $200 in (word) malloc::size#0 ← (number) $200 +Successful SSA optimization PassNAddNumberTypeConversions +Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000 +Inlining cast (word) malloc::size#0 ← (unumber)(number) $200 +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 49152 +Simplifying constant integer cast $200 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (word) $200 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#7 +Alias (byte*) malloc::return#0 = (byte*) malloc::mem#0 (byte*) malloc::return#3 (byte*) malloc::return#1 +Alias (byte*) heap_head#1 = (byte*) heap_head#5 (byte*) heap_head#2 +Alias (byte*) malloc::return#2 = (byte*) malloc::return#4 +Alias (byte*) heap_head#3 = (byte*) heap_head#6 +Alias (word*) WORDS#0 = (byte*~) $0 (word*) WORDS#2 +Successful SSA optimization Pass2AliasElimination +Identical Phi Values (byte*) heap_head#4 (byte*) HEAP_START#0 +Identical Phi Values (word) malloc::size#1 (word) malloc::size#0 +Identical Phi Values (byte*) heap_head#3 (byte*) heap_head#1 +Identical Phi Values (word*) WORDS#1 (word*) WORDS#0 +Successful SSA optimization Pass2IdenticalPhiElimination +Simple Condition (bool~) main::$0 [26] if((byte) main::i#1!=rangelast(0,$ff)) goto main::@1 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant (const byte*) HEAP_START#0 = (byte*) 49152 +Constant (const word) malloc::size#0 = $200 +Constant (const byte) main::i#0 = 0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#0 = HEAP_START#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#2 = malloc::return#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const word*) WORDS#0 = malloc::return#2 +Successful SSA optimization Pass2ConstantIdentification +Constant (const word*) main::w#0 = WORDS#0 +Successful SSA optimization Pass2ConstantIdentification +Resolved ranged next value [24] main::i#1 ← ++ main::i#2 to ++ +Resolved ranged comparison value [26] if(main::i#1!=rangelast(0,$ff)) goto main::@1 to (number) 0 +Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (const word) malloc::size#0 +Successful SSA optimization PassNEliminateUnusedVars +Eliminating unused constant (const word) malloc::size#0 +Successful SSA optimization PassNEliminateUnusedVars +Adding number conversion cast (unumber) 0 in if((byte) main::i#1!=(number) 0) goto main::@1 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast 0 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inlining constant with var siblings (const byte) main::i#0 +Inlining constant with var siblings (const word*) main::w#0 +Constant inlined main::i#0 = (byte) 0 +Constant inlined malloc::return#2 = (const byte*) HEAP_START#0 +Constant inlined malloc::return#0 = (const byte*) HEAP_START#0 +Constant inlined main::w#0 = (const byte*) HEAP_START#0 +Constant inlined WORDS#0 = (const byte*) HEAP_START#0 +Successful SSA optimization Pass2ConstantInlining +Added new block during phi lifting main::@3(between main::@1 and main::@1) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @4 +Adding NOP phi() at start of @3 +Adding NOP phi() at start of @5 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of malloc +CALL GRAPH +Calls in [] to malloc:2 main:5 + +Created 2 initial phi equivalence classes +Coalesced [15] main::i#3 ← main::i#1 +Coalesced [16] main::w#3 ← main::w#1 +Coalesced down to 2 phi equivalence classes +Culled Empty Block (label) @4 +Culled Empty Block (label) @5 +Culled Empty Block (label) main::@3 +Renumbering block @2 to @1 +Renumbering block @3 to @2 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of malloc + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call malloc + to:@2 +@2: scope:[] from @1 + [3] phi() + [4] call main + to:@end +@end: scope:[] from @2 + [5] phi() +main: scope:[main] from @2 + [6] phi() + to:main::@1 +main::@1: scope:[main] from main main::@1 + [7] (word*) main::w#2 ← phi( main/(const byte*) HEAP_START#0 main::@1/(word*) main::w#1 ) + [7] (byte) main::i#2 ← phi( main/(byte) 0 main::@1/(byte) main::i#1 ) + [8] *((word*) main::w#2) ← (byte) main::i#2 + [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD + [10] (byte) main::i#1 ← ++ (byte) main::i#2 + [11] if((byte) main::i#1!=(byte) 0) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@1 + [12] return + to:@return +malloc: scope:[malloc] from @1 + [13] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [14] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte*) HEAP_START +(word*) WORDS +(byte*) heap_head +(void()) main() +(byte) main::i +(byte) main::i#1 16.5 +(byte) main::i#2 11.0 +(word*) main::w +(word*) main::w#1 7.333333333333333 +(word*) main::w#2 16.5 +(byte*()) malloc((word) malloc::size) +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +Initial phi equivalence classes +[ main::i#2 main::i#1 ] +[ main::w#2 main::w#1 ] +Complete equivalence classes +[ main::i#2 main::i#1 ] +[ main::w#2 main::w#1 ] +Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Allocated zp ZP_WORD:3 [ main::w#2 main::w#1 ] + +INITIAL ASM +//SEG0 File Comments +// Experiments with malloc() - a word array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call malloc +//SEG7 [13] phi from @1 to malloc [phi:@1->malloc] +malloc_from_b1: + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +b2_from_b1: + jmp b2 +//SEG9 @2 +b2: +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +bend_from_b2: + jmp bend +//SEG13 @end +bend: +//SEG14 main +main: { + .label w = 3 + .label i = 2 + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG16 [7] phi (word*) main::w#2 = (const byte*) HEAP_START#0 [phi:main->main::@1#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta w+1 + //SEG17 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuz1=vbuc1 + lda #0 + sta i + jmp b1 + //SEG18 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG19 [7] phi (word*) main::w#2 = (word*) main::w#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG20 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy + jmp b1 + //SEG21 main::@1 + b1: + //SEG22 [8] *((word*) main::w#2) ← (byte) main::i#2 -- _deref_pwuz1=vbuz2 + lda i + ldy #0 + sta (w),y + tya + iny + sta (w),y + //SEG23 [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc w + sta w + bcc !+ + inc w+1 + !: + //SEG24 [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 + inc i + //SEG25 [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuz1_neq_0_then_la1 + lda i + cmp #0 + bne b1_from_b1 + jmp breturn + //SEG26 main::@return + breturn: + //SEG27 [12] return + rts +} +//SEG28 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG29 malloc::@return + breturn: + //SEG30 [14] return + rts +} +//SEG31 File Data + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [8] *((word*) main::w#2) ← (byte) main::i#2 [ main::i#2 main::w#2 ] ( main:4 [ main::i#2 main::w#2 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ] +Statement [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD [ main::i#2 main::w#1 ] ( main:4 [ main::i#2 main::w#1 ] ) always clobbers reg byte a +Statement [8] *((word*) main::w#2) ← (byte) main::i#2 [ main::i#2 main::w#2 ] ( main:4 [ main::i#2 main::w#2 ] ) always clobbers reg byte a reg byte y +Statement [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD [ main::i#2 main::w#1 ] ( main:4 [ main::i#2 main::w#1 ] ) always clobbers reg byte a +Potential registers zp ZP_BYTE:2 [ main::i#2 main::i#1 ] : zp ZP_BYTE:2 , reg byte x , +Potential registers zp ZP_WORD:3 [ main::w#2 main::w#1 ] : zp ZP_WORD:3 , + +REGISTER UPLIFT SCOPES +Uplift Scope [main] 27.5: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 23.83: zp ZP_WORD:3 [ main::w#2 main::w#1 ] +Uplift Scope [malloc] +Uplift Scope [] + +Uplifting [main] best 713 combination reg byte x [ main::i#2 main::i#1 ] zp ZP_WORD:3 [ main::w#2 main::w#1 ] +Uplifting [malloc] best 713 combination +Uplifting [] best 713 combination +Allocated (was zp ZP_WORD:3) zp ZP_WORD:2 [ main::w#2 main::w#1 ] + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +// Experiments with malloc() - a word array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call malloc +//SEG7 [13] phi from @1 to malloc [phi:@1->malloc] +malloc_from_b1: + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +b2_from_b1: + jmp b2 +//SEG9 @2 +b2: +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] +main_from_b2: + jsr main +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +bend_from_b2: + jmp bend +//SEG13 @end +bend: +//SEG14 main +main: { + .label w = 2 + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + b1_from_main: + //SEG16 [7] phi (word*) main::w#2 = (const byte*) HEAP_START#0 [phi:main->main::@1#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta w+1 + //SEG17 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1 + ldx #0 + jmp b1 + //SEG18 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + b1_from_b1: + //SEG19 [7] phi (word*) main::w#2 = (word*) main::w#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG20 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy + jmp b1 + //SEG21 main::@1 + b1: + //SEG22 [8] *((word*) main::w#2) ← (byte) main::i#2 -- _deref_pwuz1=vbuxx + txa + ldy #0 + sta (w),y + tya + iny + sta (w),y + //SEG23 [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc w + sta w + bcc !+ + inc w+1 + !: + //SEG24 [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG25 [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b1_from_b1 + jmp breturn + //SEG26 main::@return + breturn: + //SEG27 [12] return + rts +} +//SEG28 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG29 malloc::@return + breturn: + //SEG30 [14] return + rts +} +//SEG31 File Data + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp bend +Removing instruction jmp b1 +Removing instruction jmp breturn +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Replacing label b1_from_b1 with b1 +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction malloc_from_b1: +Removing instruction b2_from_b1: +Removing instruction main_from_b2: +Removing instruction bend_from_b2: +Removing instruction b1_from_b1: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction b2: +Removing instruction bend: +Removing instruction b1_from_main: +Removing instruction breturn: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Adding RTS to root block +Succesful ASM optimization Pass5AddMainRts +Removing instruction jmp b1 +Succesful ASM optimization Pass5NextJumpElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @2 +(label) @begin +(label) @end +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 +(word*) WORDS +(byte*) heap_head +(void()) main() +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 11.0 +(word*) main::w +(word*) main::w#1 w zp ZP_WORD:2 7.333333333333333 +(word*) main::w#2 w zp ZP_WORD:2 16.5 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +reg byte x [ main::i#2 main::i#1 ] +zp ZP_WORD:2 [ main::w#2 main::w#1 ] + + +FINAL ASSEMBLER +Score: 590 + +//SEG0 File Comments +// Experiments with malloc() - a word array +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +//SEG5 @1 +//SEG6 [2] call malloc +//SEG7 [13] phi from @1 to malloc [phi:@1->malloc] + jsr malloc +//SEG8 [3] phi from @1 to @2 [phi:@1->@2] +//SEG9 @2 +//SEG10 [4] call main +//SEG11 [6] phi from @2 to main [phi:@2->main] + jsr main + rts +//SEG12 [5] phi from @2 to @end [phi:@2->@end] +//SEG13 @end +//SEG14 main +main: { + .label w = 2 + //SEG15 [7] phi from main to main::@1 [phi:main->main::@1] + //SEG16 [7] phi (word*) main::w#2 = (const byte*) HEAP_START#0 [phi:main->main::@1#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta w+1 + //SEG17 [7] phi (byte) main::i#2 = (byte) 0 [phi:main->main::@1#1] -- vbuxx=vbuc1 + ldx #0 + //SEG18 [7] phi from main::@1 to main::@1 [phi:main::@1->main::@1] + //SEG19 [7] phi (word*) main::w#2 = (word*) main::w#1 [phi:main::@1->main::@1#0] -- register_copy + //SEG20 [7] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@1->main::@1#1] -- register_copy + //SEG21 main::@1 + b1: + //SEG22 [8] *((word*) main::w#2) ← (byte) main::i#2 -- _deref_pwuz1=vbuxx + txa + ldy #0 + sta (w),y + tya + iny + sta (w),y + //SEG23 [9] (word*) main::w#1 ← (word*) main::w#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc w + sta w + bcc !+ + inc w+1 + !: + //SEG24 [10] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG25 [11] if((byte) main::i#1!=(byte) 0) goto main::@1 -- vbuxx_neq_0_then_la1 + cpx #0 + bne b1 + //SEG26 main::@return + //SEG27 [12] return + rts +} +//SEG28 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + //SEG29 malloc::@return + //SEG30 [14] return + rts +} +//SEG31 File Data + diff --git a/src/test/ref/malloc-1.sym b/src/test/ref/malloc-1.sym new file mode 100644 index 000000000..cb5fa9fc3 --- /dev/null +++ b/src/test/ref/malloc-1.sym @@ -0,0 +1,26 @@ +(label) @1 +(label) @2 +(label) @begin +(label) @end +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 +(word*) WORDS +(byte*) heap_head +(void()) main() +(label) main::@1 +(label) main::@return +(byte) main::i +(byte) main::i#1 reg byte x 16.5 +(byte) main::i#2 reg byte x 11.0 +(word*) main::w +(word*) main::w#1 w zp ZP_WORD:2 7.333333333333333 +(word*) main::w#2 w zp ZP_WORD:2 16.5 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size + +reg byte x [ main::i#2 main::i#1 ] +zp ZP_WORD:2 [ main::w#2 main::w#1 ] diff --git a/src/test/ref/memory-heap.cfg b/src/test/ref/memory-heap.cfg index 87d104679..d1151da11 100644 --- a/src/test/ref/memory-heap.cfg +++ b/src/test/ref/memory-heap.cfg @@ -23,8 +23,8 @@ main::@4: scope:[main] from main::@3 main::@1: scope:[main] from main::@1 main::@4 [11] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@4/(byte) 0 ) [12] *((byte*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 - [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 - [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$6 + [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 + [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$4 [15] (byte) main::i#1 ← ++ (byte) main::i#2 [16] if((byte) main::i#1!=(byte) $64) goto main::@1 to:main::@2 diff --git a/src/test/ref/memory-heap.log b/src/test/ref/memory-heap.log index 67a505241..dbac54f19 100644 --- a/src/test/ref/memory-heap.log +++ b/src/test/ref/memory-heap.log @@ -1,4 +1,6 @@ Adding pointer type conversion cast (byte*) HEAP_START in (byte*) HEAP_START ← (number) $c000 +Adding void pointer type conversion cast (void*) main::buf1 in (void~) main::$2 ← call free (byte*) main::buf1 +Adding void pointer type conversion cast (void*) main::buf2 in (void~) main::$3 ← call free (byte*) main::buf2 Adding pointer type conversion cast (byte*) main::screen in (byte*) main::screen ← (number) $400 Identified constant variable (byte*) HEAP_START Identified constant variable (byte*) main::screen @@ -41,8 +43,7 @@ main::@3: scope:[main] from main (byte*) malloc::return#5 ← phi( main/(byte*) malloc::return#2 ) (byte*~) main::$0 ← (byte*) malloc::return#5 (byte*) heap_head#3 ← (byte*) heap_head#9 - (byte*~) main::$1 ← ((byte*)) (byte*~) main::$0 - (byte*) main::buf1#0 ← (byte*~) main::$1 + (byte*) main::buf1#0 ← (byte*~) main::$0 (word) malloc::size#1 ← (number) $64 call malloc (byte*) malloc::return#3 ← (byte*) malloc::return#1 @@ -51,10 +52,9 @@ main::@4: scope:[main] from main::@3 (byte*) main::buf1#4 ← phi( main::@3/(byte*) main::buf1#0 ) (byte*) heap_head#10 ← phi( main::@3/(byte*) heap_head#2 ) (byte*) malloc::return#6 ← phi( main::@3/(byte*) malloc::return#3 ) - (byte*~) main::$2 ← (byte*) malloc::return#6 + (byte*~) main::$1 ← (byte*) malloc::return#6 (byte*) heap_head#4 ← (byte*) heap_head#10 - (byte*~) main::$3 ← ((byte*)) (byte*~) main::$2 - (byte*) main::buf2#0 ← (byte*~) main::$3 + (byte*) main::buf2#0 ← (byte*~) main::$1 (byte) main::i#0 ← (byte) 0 to:main::@1 main::@1: scope:[main] from main::@1 main::@4 @@ -63,24 +63,24 @@ main::@1: scope:[main] from main::@1 main::@4 (byte*) main::buf1#1 ← phi( main::@1/(byte*) main::buf1#1 main::@4/(byte*) main::buf1#4 ) (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@4/(byte) main::i#0 ) *((byte*) main::buf1#1 + (byte) main::i#2) ← (byte) main::i#2 - (number~) main::$6 ← (number) $ff - (byte) main::i#2 - *((byte*) main::buf2#1 + (byte) main::i#2) ← (number~) main::$6 + (number~) main::$4 ← (number) $ff - (byte) main::i#2 + *((byte*) main::buf2#1 + (byte) main::i#2) ← (number~) main::$4 (byte) main::i#1 ← (byte) main::i#2 + rangenext(0,$63) - (bool~) main::$7 ← (byte) main::i#1 != rangelast(0,$63) - if((bool~) main::$7) goto main::@1 + (bool~) main::$5 ← (byte) main::i#1 != rangelast(0,$63) + if((bool~) main::$5) goto main::@1 to:main::@2 main::@2: scope:[main] from main::@1 (byte*) heap_head#17 ← phi( main::@1/(byte*) heap_head#18 ) (byte*) main::buf2#4 ← phi( main::@1/(byte*) main::buf2#1 ) (byte*) main::buf1#2 ← phi( main::@1/(byte*) main::buf1#1 ) - (byte*) free::ptr#0 ← (byte*) main::buf1#2 + (void*) free::ptr#0 ← (void*)(byte*) main::buf1#2 call free to:main::@5 main::@5: scope:[main] from main::@2 (byte*) heap_head#16 ← phi( main::@2/(byte*) heap_head#17 ) (byte*) main::buf1#5 ← phi( main::@2/(byte*) main::buf1#2 ) (byte*) main::buf2#2 ← phi( main::@2/(byte*) main::buf2#4 ) - (byte*) free::ptr#1 ← (byte*) main::buf2#2 + (void*) free::ptr#1 ← (void*)(byte*) main::buf2#2 call free to:main::@6 main::@6: scope:[main] from main::@5 @@ -113,11 +113,11 @@ SYMBOL TABLE SSA (label) @end (byte*) HEAP_START (byte*) HEAP_START#0 -(void()) free((byte*) free::ptr) +(void()) free((void*) free::ptr) (label) free::@return -(byte*) free::ptr -(byte*) free::ptr#0 -(byte*) free::ptr#1 +(void*) free::ptr +(void*) free::ptr#0 +(void*) free::ptr#1 (byte*) heap_head (byte*) heap_head#0 (byte*) heap_head#1 @@ -141,10 +141,8 @@ SYMBOL TABLE SSA (void()) main() (byte*~) main::$0 (byte*~) main::$1 -(byte*~) main::$2 -(byte*~) main::$3 -(number~) main::$6 -(bool~) main::$7 +(number~) main::$4 +(bool~) main::$5 (label) main::@1 (label) main::@2 (label) main::@3 @@ -190,23 +188,19 @@ SYMBOL TABLE SSA Adding number conversion cast (unumber) $64 in (word) malloc::size#0 ← (number) $64 Adding number conversion cast (unumber) $64 in (word) malloc::size#1 ← (number) $64 -Adding number conversion cast (unumber) $ff in (number~) main::$6 ← (number) $ff - (byte) main::i#2 -Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (unumber)(number) $ff - (byte) main::i#2 +Adding number conversion cast (unumber) $ff in (number~) main::$4 ← (number) $ff - (byte) main::i#2 +Adding number conversion cast (unumber) main::$4 in (number~) main::$4 ← (unumber)(number) $ff - (byte) main::i#2 Adding number conversion cast (unumber) 0 in *((byte*) main::screen#0 + (number) 0) ← *((byte*) main::buf1#3) Adding number conversion cast (unumber) 1 in *((byte*) main::screen#0 + (number) 1) ← *((byte*) main::buf2#3) Successful SSA optimization PassNAddNumberTypeConversions Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000 Inlining cast (word) malloc::size#0 ← (unumber)(number) $64 -Inlining cast (byte*~) main::$1 ← (byte*)(byte*~) main::$0 Inlining cast (word) malloc::size#1 ← (unumber)(number) $64 -Inlining cast (byte*~) main::$3 ← (byte*)(byte*~) main::$2 Inlining cast (byte*) main::screen#0 ← (byte*)(number) $400 Successful SSA optimization Pass2InlineCast Simplifying constant pointer cast (byte*) 49152 Simplifying constant integer cast $64 -Simplifying constant integer cast (byte*~) main::$0 Simplifying constant integer cast $64 -Simplifying constant integer cast (byte*~) main::$2 Simplifying constant integer cast $ff Simplifying constant pointer cast (byte*) 1024 Simplifying constant integer cast 0 @@ -218,16 +212,16 @@ Finalized unsigned number type (byte) $ff Finalized unsigned number type (byte) 0 Finalized unsigned number type (byte) 1 Successful SSA optimization PassNFinalizeNumberTypeConversions -Inferred type updated to byte in (unumber~) main::$6 ← (byte) $ff - (byte) main::i#2 +Inferred type updated to byte in (unumber~) main::$4 ← (byte) $ff - (byte) main::i#2 Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#15 Alias (byte*) malloc::return#0 = (byte*) malloc::mem#0 (byte*) malloc::return#4 (byte*) malloc::return#1 Alias (byte*) heap_head#1 = (byte*) heap_head#8 (byte*) heap_head#2 Alias (byte*) malloc::return#2 = (byte*) malloc::return#5 Alias (byte*) heap_head#3 = (byte*) heap_head#9 -Alias (byte*) main::buf1#0 = (byte*~) main::$1 (byte*~) main::$0 (byte*) main::buf1#4 +Alias (byte*) main::buf1#0 = (byte*~) main::$0 (byte*) main::buf1#4 Alias (byte*) malloc::return#3 = (byte*) malloc::return#6 Alias (byte*) heap_head#10 = (byte*) heap_head#4 -Alias (byte*) main::buf2#0 = (byte*~) main::$3 (byte*~) main::$2 +Alias (byte*) main::buf2#0 = (byte*~) main::$1 Alias (byte*) main::buf1#1 = (byte*) main::buf1#2 (byte*) main::buf1#5 (byte*) main::buf1#3 Alias (byte*) main::buf2#1 = (byte*) main::buf2#4 (byte*) main::buf2#2 (byte*) main::buf2#3 Alias (byte*) heap_head#11 = (byte*) heap_head#17 (byte*) heap_head#18 (byte*) heap_head#16 (byte*) heap_head#14 (byte*) heap_head#5 @@ -245,7 +239,7 @@ Identical Phi Values (byte*) main::buf2#1 (byte*) main::buf2#0 Identical Phi Values (byte*) heap_head#11 (byte*) heap_head#10 Identical Phi Values (byte*) heap_head#12 (byte*) heap_head#11 Successful SSA optimization Pass2IdenticalPhiElimination -Simple Condition (bool~) main::$7 [35] if((byte) main::i#1!=rangelast(0,$63)) goto main::@1 +Simple Condition (bool~) main::$5 [33] if((byte) main::i#1!=rangelast(0,$63)) goto main::@1 Successful SSA optimization Pass2ConditionalJumpSimplification Constant (const byte*) HEAP_START#0 = (byte*) 49152 Constant (const word) malloc::size#0 = $64 @@ -253,12 +247,12 @@ Constant (const word) malloc::size#1 = $64 Constant (const byte) main::i#0 = 0 Constant (const byte*) main::screen#0 = (byte*) 1024 Successful SSA optimization Pass2ConstantIdentification -Resolved ranged next value [33] main::i#1 ← ++ main::i#2 to ++ -Resolved ranged comparison value [35] if(main::i#1!=rangelast(0,$63)) goto main::@1 to (number) $64 -Simplifying expression containing zero main::screen#0 in [44] *((const byte*) main::screen#0 + (byte) 0) ← *((byte*) main::buf1#0) +Resolved ranged next value [31] main::i#1 ← ++ main::i#2 to ++ +Resolved ranged comparison value [33] if(main::i#1!=rangelast(0,$63)) goto main::@1 to (number) $64 +Simplifying expression containing zero main::screen#0 in [42] *((const byte*) main::screen#0 + (byte) 0) ← *((byte*) main::buf1#0) Successful SSA optimization PassNSimplifyExpressionWithZero -Eliminating unused variable (byte*) free::ptr#0 and assignment [17] (byte*) free::ptr#0 ← (byte*) main::buf1#0 -Eliminating unused variable (byte*) free::ptr#1 and assignment [19] (byte*) free::ptr#1 ← (byte*) main::buf2#0 +Eliminating unused variable (void*) free::ptr#0 and assignment [17] (void*) free::ptr#0 ← (void*)(byte*) main::buf1#0 +Eliminating unused variable (void*) free::ptr#1 and assignment [19] (void*) free::ptr#1 ← (void*)(byte*) main::buf2#0 Successful SSA optimization PassNEliminateUnusedVars Adding number conversion cast (unumber) $64 in if((byte) main::i#1!=(number) $64) goto main::@1 Successful SSA optimization PassNAddNumberTypeConversions @@ -331,8 +325,8 @@ main::@4: scope:[main] from main::@3 main::@1: scope:[main] from main::@1 main::@4 [11] (byte) main::i#2 ← phi( main::@1/(byte) main::i#1 main::@4/(byte) 0 ) [12] *((byte*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 - [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 - [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$6 + [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 + [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$4 [15] (byte) main::i#1 ← ++ (byte) main::i#2 [16] if((byte) main::i#1!=(byte) $64) goto main::@1 to:main::@2 @@ -369,13 +363,13 @@ malloc::@return: scope:[malloc] from malloc VARIABLE REGISTER WEIGHTS (byte*) HEAP_START -(void()) free((byte*) free::ptr) -(byte*) free::ptr +(void()) free((void*) free::ptr) +(void*) free::ptr (byte*) heap_head (byte*) heap_head#1 0.8 (byte*) heap_head#7 3.0 (void()) main() -(byte~) main::$6 22.0 +(byte~) main::$4 22.0 (byte*) main::buf1 (byte*) main::buf1#0 1.0714285714285714 (byte*) main::buf2 @@ -399,7 +393,7 @@ Added variable malloc::return#2 to zero page equivalence class [ malloc::return# Added variable main::buf1#0 to zero page equivalence class [ main::buf1#0 ] Added variable malloc::return#3 to zero page equivalence class [ malloc::return#3 ] Added variable main::buf2#0 to zero page equivalence class [ main::buf2#0 ] -Added variable main::$6 to zero page equivalence class [ main::$6 ] +Added variable main::$4 to zero page equivalence class [ main::$4 ] Added variable malloc::return#0 to zero page equivalence class [ malloc::return#0 ] Complete equivalence classes [ main::i#2 main::i#1 ] @@ -408,7 +402,7 @@ Complete equivalence classes [ main::buf1#0 ] [ malloc::return#3 ] [ main::buf2#0 ] -[ main::$6 ] +[ main::$4 ] [ malloc::return#0 ] Allocated zp ZP_BYTE:2 [ main::i#2 main::i#1 ] Allocated zp ZP_WORD:3 [ heap_head#7 heap_head#1 ] @@ -416,7 +410,7 @@ Allocated zp ZP_WORD:5 [ malloc::return#2 ] Allocated zp ZP_WORD:7 [ main::buf1#0 ] Allocated zp ZP_WORD:9 [ malloc::return#3 ] Allocated zp ZP_WORD:11 [ main::buf2#0 ] -Allocated zp ZP_BYTE:13 [ main::$6 ] +Allocated zp ZP_BYTE:13 [ main::$4 ] Allocated zp ZP_WORD:14 [ malloc::return#0 ] INITIAL ASM @@ -449,7 +443,7 @@ bend: //SEG10 main main: { .label screen = $400 - .label _6 = $d + .label _4 = $d .label buf1 = 7 .label buf2 = $b .label i = 2 @@ -509,13 +503,13 @@ main: { lda i tay sta (buf1),y - //SEG29 [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 -- vbuz1=vbuc1_minus_vbuz2 + //SEG29 [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 -- vbuz1=vbuc1_minus_vbuz2 lda #$ff sec sbc i - sta _6 - //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$6 -- pbuz1_derefidx_vbuz2=vbuz3 - lda _6 + sta _4 + //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$4 -- pbuz1_derefidx_vbuz2=vbuz3 + lda _4 ldy i sta (buf2),y //SEG31 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1 @@ -602,7 +596,7 @@ Statement [6] (byte*) malloc::return#2 ← (byte*) malloc::return#0 [ malloc::re Statement [7] (byte*) main::buf1#0 ← (byte*) malloc::return#2 [ main::buf1#0 heap_head#1 ] ( main:2 [ main::buf1#0 heap_head#1 ] ) always clobbers reg byte a Statement [9] (byte*) malloc::return#3 ← (byte*) malloc::return#0 [ main::buf1#0 malloc::return#3 ] ( main:2 [ main::buf1#0 malloc::return#3 ] ) always clobbers reg byte a Statement [10] (byte*) main::buf2#0 ← (byte*) malloc::return#3 [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a -Statement [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 main::$6 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 main::$6 ] ) always clobbers reg byte a +Statement [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::i#2 main::i#1 ] Statement [21] *((const byte*) main::screen#0) ← *((byte*) main::buf1#0) [ main::buf2#0 ] ( main:2 [ main::buf2#0 ] ) always clobbers reg byte a reg byte y Statement [22] *((const byte*) main::screen#0+(byte) 1) ← *((byte*) main::buf2#0) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y @@ -613,7 +607,7 @@ Statement [7] (byte*) main::buf1#0 ← (byte*) malloc::return#2 [ main::buf1#0 h Statement [9] (byte*) malloc::return#3 ← (byte*) malloc::return#0 [ main::buf1#0 malloc::return#3 ] ( main:2 [ main::buf1#0 malloc::return#3 ] ) always clobbers reg byte a Statement [10] (byte*) main::buf2#0 ← (byte*) malloc::return#3 [ main::buf1#0 main::buf2#0 ] ( main:2 [ main::buf1#0 main::buf2#0 ] ) always clobbers reg byte a Statement [12] *((byte*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 ] ) always clobbers reg byte a -Statement [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 main::$6 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 main::$6 ] ) always clobbers reg byte a +Statement [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ( main:2 [ main::buf1#0 main::buf2#0 main::i#2 main::$4 ] ) always clobbers reg byte a Statement [21] *((const byte*) main::screen#0) ← *((byte*) main::buf1#0) [ main::buf2#0 ] ( main:2 [ main::buf2#0 ] ) always clobbers reg byte a reg byte y Statement [22] *((const byte*) main::screen#0+(byte) 1) ← *((byte*) main::buf2#0) [ ] ( main:2 [ ] ) always clobbers reg byte a reg byte y Statement [27] (byte*) malloc::return#0 ← (byte*) heap_head#7 [ malloc::return#0 heap_head#7 ] ( main:2::malloc:5 [ malloc::return#0 heap_head#7 ] main:2::malloc:8 [ main::buf1#0 malloc::return#0 heap_head#7 ] ) always clobbers reg byte a @@ -624,16 +618,16 @@ Potential registers zp ZP_WORD:5 [ malloc::return#2 ] : zp ZP_WORD:5 , Potential registers zp ZP_WORD:7 [ main::buf1#0 ] : zp ZP_WORD:7 , Potential registers zp ZP_WORD:9 [ malloc::return#3 ] : zp ZP_WORD:9 , Potential registers zp ZP_WORD:11 [ main::buf2#0 ] : zp ZP_WORD:11 , -Potential registers zp ZP_BYTE:13 [ main::$6 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:13 [ main::$4 ] : zp ZP_BYTE:13 , reg byte a , reg byte x , reg byte y , Potential registers zp ZP_WORD:14 [ malloc::return#0 ] : zp ZP_WORD:14 , REGISTER UPLIFT SCOPES -Uplift Scope [main] 33: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:13 [ main::$6 ] 1.25: zp ZP_WORD:11 [ main::buf2#0 ] 1.07: zp ZP_WORD:7 [ main::buf1#0 ] +Uplift Scope [main] 33: zp ZP_BYTE:2 [ main::i#2 main::i#1 ] 22: zp ZP_BYTE:13 [ main::$4 ] 1.25: zp ZP_WORD:11 [ main::buf2#0 ] 1.07: zp ZP_WORD:7 [ main::buf1#0 ] Uplift Scope [malloc] 4: zp ZP_WORD:5 [ malloc::return#2 ] 4: zp ZP_WORD:9 [ malloc::return#3 ] 1.2: zp ZP_WORD:14 [ malloc::return#0 ] Uplift Scope [] 3.8: zp ZP_WORD:3 [ heap_head#7 heap_head#1 ] Uplift Scope [free] -Uplifting [main] best 579 combination reg byte y [ main::i#2 main::i#1 ] reg byte a [ main::$6 ] zp ZP_WORD:11 [ main::buf2#0 ] zp ZP_WORD:7 [ main::buf1#0 ] +Uplifting [main] best 579 combination reg byte y [ main::i#2 main::i#1 ] reg byte a [ main::$4 ] zp ZP_WORD:11 [ main::buf2#0 ] zp ZP_WORD:7 [ main::buf1#0 ] Uplifting [malloc] best 579 combination zp ZP_WORD:5 [ malloc::return#2 ] zp ZP_WORD:9 [ malloc::return#3 ] zp ZP_WORD:14 [ malloc::return#0 ] Uplifting [] best 579 combination zp ZP_WORD:3 [ heap_head#7 heap_head#1 ] Uplifting [free] best 579 combination @@ -718,12 +712,12 @@ main: { //SEG28 [12] *((byte*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuz1_derefidx_vbuyy=vbuyy tya sta (buf1),y - //SEG29 [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 -- vbuaa=vbuc1_minus_vbuyy + //SEG29 [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 -- vbuaa=vbuc1_minus_vbuyy tya eor #$ff clc adc #$ff+1 - //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$6 -- pbuz1_derefidx_vbuyy=vbuaa + //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$4 -- pbuz1_derefidx_vbuyy=vbuaa sta (buf2),y //SEG31 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy iny @@ -855,14 +849,14 @@ FINAL SYMBOL TABLE (label) @end (byte*) HEAP_START (const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 -(void()) free((byte*) free::ptr) +(void()) free((void*) free::ptr) (label) free::@return -(byte*) free::ptr +(void*) free::ptr (byte*) heap_head (byte*) heap_head#1 heap_head zp ZP_WORD:2 0.8 (byte*) heap_head#7 heap_head zp ZP_WORD:2 3.0 (void()) main() -(byte~) main::$6 reg byte a 22.0 +(byte~) main::$4 reg byte a 22.0 (label) main::@1 (label) main::@2 (label) main::@3 @@ -892,7 +886,7 @@ reg byte y [ main::i#2 main::i#1 ] zp ZP_WORD:2 [ heap_head#7 heap_head#1 ] zp ZP_WORD:4 [ malloc::return#2 main::buf1#0 ] zp ZP_WORD:6 [ malloc::return#3 main::buf2#0 malloc::return#0 ] -reg byte a [ main::$6 ] +reg byte a [ main::$4 ] FINAL ASSEMBLER @@ -952,12 +946,12 @@ main: { //SEG28 [12] *((byte*) main::buf1#0 + (byte) main::i#2) ← (byte) main::i#2 -- pbuz1_derefidx_vbuyy=vbuyy tya sta (buf1),y - //SEG29 [13] (byte~) main::$6 ← (byte) $ff - (byte) main::i#2 -- vbuaa=vbuc1_minus_vbuyy + //SEG29 [13] (byte~) main::$4 ← (byte) $ff - (byte) main::i#2 -- vbuaa=vbuc1_minus_vbuyy tya eor #$ff clc adc #$ff+1 - //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$6 -- pbuz1_derefidx_vbuyy=vbuaa + //SEG30 [14] *((byte*) main::buf2#0 + (byte) main::i#2) ← (byte~) main::$4 -- pbuz1_derefidx_vbuyy=vbuaa sta (buf2),y //SEG31 [15] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuyy=_inc_vbuyy iny diff --git a/src/test/ref/memory-heap.sym b/src/test/ref/memory-heap.sym index 58fefc305..45269ff43 100644 --- a/src/test/ref/memory-heap.sym +++ b/src/test/ref/memory-heap.sym @@ -3,14 +3,14 @@ (label) @end (byte*) HEAP_START (const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 -(void()) free((byte*) free::ptr) +(void()) free((void*) free::ptr) (label) free::@return -(byte*) free::ptr +(void*) free::ptr (byte*) heap_head (byte*) heap_head#1 heap_head zp ZP_WORD:2 0.8 (byte*) heap_head#7 heap_head zp ZP_WORD:2 3.0 (void()) main() -(byte~) main::$6 reg byte a 22.0 +(byte~) main::$4 reg byte a 22.0 (label) main::@1 (label) main::@2 (label) main::@3 @@ -40,4 +40,4 @@ reg byte y [ main::i#2 main::i#1 ] zp ZP_WORD:2 [ heap_head#7 heap_head#1 ] zp ZP_WORD:4 [ malloc::return#2 main::buf1#0 ] zp ZP_WORD:6 [ malloc::return#3 main::buf2#0 malloc::return#0 ] -reg byte a [ main::$6 ] +reg byte a [ main::$4 ] diff --git a/src/test/ref/screen-center-distance.asm b/src/test/ref/screen-center-distance.asm new file mode 100644 index 000000000..30787d808 --- /dev/null +++ b/src/test/ref/screen-center-distance.asm @@ -0,0 +1,350 @@ +// Calculate the distance to the center of the screen - and show it using font-hex +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 + .label D018 = $d018 + .label CHARSET = $2000 + .label SCREEN = $2800 + .const NUM_SQUARES = $30 +main: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label yds = $16 + .label xds = $18 + .label ds = $18 + .label screen = 4 + .label x = 3 + .label y = 2 + jsr init_font_hex + lda #toD0181_return + sta D018 + jsr init_squares + lda #SCREEN + sta screen+1 + lda #0 + sta y + b1: + lda y + asl + cmp #$18 + bcs b2 + eor #$ff + clc + adc #$18+1 + b4: + jsr sqr + lda sqr.return_2 + sta sqr.return + lda sqr.return_2+1 + sta sqr.return+1 + lda #0 + sta x + b5: + lda x + asl + cmp #$27 + bcs b6 + eor #$ff + clc + adc #$27+1 + b8: + jsr sqr + lda ds + clc + adc yds + sta ds + lda ds+1 + adc yds+1 + sta ds+1 + jsr sqrt + ldy #0 + sta (screen),y + inc screen + bne !+ + inc screen+1 + !: + inc x + lda #$28 + cmp x + bne b5 + inc y + lda #$19 + cmp y + bne b1 + rts + b6: + sec + sbc #$27 + jmp b8 + b2: + sec + sbc #$18 + jmp b4 +} +// Find the (integer) square root of a word value +// If the square is not an integer then it returns the largest integer N where N*N <= val +// Uses a table of squares that must be initialized by calling init_squares() +// sqrt(word zeropage($18) val) +sqrt: { + .label _3 = 6 + .label val = $18 + .label found = 6 + jsr bsearch16u + lda _3 + sec + sbc #HEAP_START + sta _3+1 + lda _3 + lsr + rts +} +// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key. +// - key - The value to look for +// - items - Pointer to the start of the array to search in +// - num - The number of items in the array +// Returns pointer to an entry in the array that matches the search key +// bsearch16u(word zeropage($18) key, word* zeropage(6) items, byte register(X) num) +bsearch16u: { + .label _2 = 6 + .label key = $18 + .label return = 6 + .label pivot = $1a + .label result = $1c + .label items = 6 + lda #HEAP_START + sta items+1 + ldx #NUM_SQUARES + b3: + cpx #0 + bne b4 + ldy #1 + lda (items),y + cmp key+1 + bne !+ + dey + lda (items),y + cmp key + beq b2 + !: + bcc b2 + lda _2 + sec + sbc #<1*SIZEOF_WORD + sta _2 + lda _2+1 + sbc #>1*SIZEOF_WORD + sta _2+1 + b2: + rts + b4: + txa + lsr + asl + clc + adc items + sta pivot + lda #0 + adc items+1 + sta pivot+1 + sec + lda key + ldy #0 + sbc (pivot),y + sta result + lda key+1 + iny + sbc (pivot),y + sta result+1 + bne b6 + lda result + bne b6 + lda pivot + sta return + lda pivot+1 + sta return+1 + rts + b6: + lda result+1 + bmi b7 + bne !+ + lda result + beq b7 + !: + lda #1*SIZEOF_WORD + clc + adc pivot + sta items + lda #0 + adc pivot+1 + sta items+1 + dex + b7: + txa + lsr + tax + jmp b3 +} +// Find the square of a byte value +// Uses a table of squares that must be initialized by calling init_squares() +// sqr(byte register(A) val) +sqr: { + .label return = $16 + .label return_1 = $18 + .label return_2 = $18 + asl + tay + lda HEAP_START,y + sta return_2 + lda #0 + sta return_2+1 + rts +} +// Initialize squares table +// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 +init_squares: { + .label squares = $b + .label sqr = 9 + jsr malloc + ldx #0 + lda #HEAP_START + sta squares+1 + txa + sta sqr + sta sqr+1 + b1: + ldy #0 + lda sqr + sta (squares),y + iny + lda sqr+1 + sta (squares),y + lda #SIZEOF_WORD + clc + adc squares + sta squares + bcc !+ + inc squares+1 + !: + txa + asl + clc + adc #1 + clc + adc sqr + sta sqr + bcc !+ + inc sqr+1 + !: + inx + cpx #NUM_SQUARES-1+1 + bne b1 + rts +} +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + rts +} +// Make charset from proto chars +// init_font_hex(byte* zeropage($10) charset) +init_font_hex: { + .label _0 = $1e + .label idx = $15 + .label proto_lo = $12 + .label charset = $10 + .label c1 = $14 + .label proto_hi = $d + .label c = $f + lda #0 + sta c + lda #FONT_HEX_PROTO + sta proto_hi+1 + lda #CHARSET + sta charset+1 + b1: + lda #0 + sta c1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + b2: + lda #0 + tay + sta (charset),y + lda #1 + sta idx + ldx #0 + b3: + txa + tay + lda (proto_hi),y + asl + asl + asl + asl + sta _0 + txa + tay + lda (proto_lo),y + asl + ora _0 + ldy idx + sta (charset),y + inc idx + inx + cpx #5 + bne b3 + lda #0 + ldy idx + sta (charset),y + iny + sta (charset),y + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + inc c1 + lda #$10 + cmp c1 + bne b2 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + inc c + lda #$10 + cmp c + bne b1 + rts +} + // Bit patterns for symbols 0-f (3x5 pixels) used in font hex + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4 diff --git a/src/test/ref/screen-center-distance.cfg b/src/test/ref/screen-center-distance.cfg new file mode 100644 index 000000000..dbdfc24a3 --- /dev/null +++ b/src/test/ref/screen-center-distance.cfg @@ -0,0 +1,212 @@ +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() +main: scope:[main] from @1 + [4] phi() + [5] call init_font_hex + to:main::toD0181 +main::toD0181: scope:[main] from main + [6] phi() + to:main::@10 +main::@10: scope:[main] from main::toD0181 + [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 + [8] call init_squares + to:main::@1 +main::@1: scope:[main] from main::@10 main::@9 + [9] (byte*) main::screen#10 ← phi( main::@9/(byte*) main::screen#1 main::@10/(const byte*) SCREEN#0 ) + [9] (byte) main::y#10 ← phi( main::@9/(byte) main::y#1 main::@10/(byte) 0 ) + [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 + [11] if((byte) main::y2#0>=(byte) $18) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 + [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 + to:main::@4 +main::@4: scope:[main] from main::@2 main::@3 + [13] (byte) main::yd#0 ← phi( main::@2/(byte~) main::$8 main::@3/(byte~) main::$6 ) + [14] (byte) sqr::val#0 ← (byte) main::yd#0 + [15] call sqr + [16] (word) sqr::return#0 ← (word) sqr::return#2 + to:main::@11 +main::@11: scope:[main] from main::@4 + [17] (word) main::yds#0 ← (word) sqr::return#0 + to:main::@5 +main::@5: scope:[main] from main::@11 main::@13 + [18] (byte*) main::screen#2 ← phi( main::@11/(byte*) main::screen#10 main::@13/(byte*) main::screen#1 ) + [18] (byte) main::x#2 ← phi( main::@11/(byte) 0 main::@13/(byte) main::x#1 ) + [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 + [20] if((byte) main::x2#0>=(byte) $27) goto main::@6 + to:main::@7 +main::@7: scope:[main] from main::@5 + [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 + to:main::@8 +main::@8: scope:[main] from main::@6 main::@7 + [22] (byte) main::xd#0 ← phi( main::@6/(byte~) main::$16 main::@7/(byte~) main::$14 ) + [23] (byte) sqr::val#1 ← (byte) main::xd#0 + [24] call sqr + [25] (word) sqr::return#1 ← (word) sqr::return#2 + to:main::@12 +main::@12: scope:[main] from main::@8 + [26] (word) main::xds#0 ← (word) sqr::return#1 + [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 + [28] (word) sqrt::val#0 ← (word) main::ds#0 + [29] call sqrt + [30] (byte) sqrt::return#0 ← (byte) sqrt::return#1 + to:main::@13 +main::@13: scope:[main] from main::@12 + [31] (byte) main::d#0 ← (byte) sqrt::return#0 + [32] *((byte*) main::screen#2) ← (byte) main::d#0 + [33] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 + [34] (byte) main::x#1 ← ++ (byte) main::x#2 + [35] if((byte) main::x#1!=(byte) $28) goto main::@5 + to:main::@9 +main::@9: scope:[main] from main::@13 + [36] (byte) main::y#1 ← ++ (byte) main::y#10 + [37] if((byte) main::y#1!=(byte) $19) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@9 + [38] return + to:@return +main::@6: scope:[main] from main::@5 + [39] (byte~) main::$16 ← (byte) main::x2#0 - (byte) $27 + to:main::@8 +main::@2: scope:[main] from main::@1 + [40] (byte~) main::$8 ← (byte) main::y2#0 - (byte) $18 + to:main::@4 +sqrt: scope:[sqrt] from main::@12 + [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 + [42] call bsearch16u + [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 + to:sqrt::@1 +sqrt::@1: scope:[sqrt] from sqrt + [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 + [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 + [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 + [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 + to:sqrt::@return +sqrt::@return: scope:[sqrt] from sqrt::@1 + [48] return + to:@return +bsearch16u: scope:[bsearch16u] from sqrt + [49] phi() + to:bsearch16u::@3 +bsearch16u::@3: scope:[bsearch16u] from bsearch16u bsearch16u::@7 + [50] (word*) bsearch16u::items#2 ← phi( bsearch16u/(const byte*) HEAP_START#0 bsearch16u::@7/(word*) bsearch16u::items#8 ) + [50] (byte) bsearch16u::num#3 ← phi( bsearch16u/(const byte) NUM_SQUARES#0 bsearch16u::@7/(byte) bsearch16u::num#1 ) + [51] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4 + to:bsearch16u::@5 +bsearch16u::@5: scope:[bsearch16u] from bsearch16u::@3 + [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 + to:bsearch16u::@1 +bsearch16u::@1: scope:[bsearch16u] from bsearch16u::@5 + [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD + to:bsearch16u::@2 +bsearch16u::@2: scope:[bsearch16u] from bsearch16u::@1 bsearch16u::@5 + [54] (word*) bsearch16u::return#3 ← phi( bsearch16u::@5/(word*) bsearch16u::items#2 bsearch16u::@1/(word*~) bsearch16u::$2 ) + to:bsearch16u::@return +bsearch16u::@return: scope:[bsearch16u] from bsearch16u::@2 bsearch16u::@8 + [55] (word*) bsearch16u::return#2 ← phi( bsearch16u::@8/(word*~) bsearch16u::return#6 bsearch16u::@2/(word*) bsearch16u::return#3 ) + [56] return + to:@return +bsearch16u::@4: scope:[bsearch16u] from bsearch16u::@3 + [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 + [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 + [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 + [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) + [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 + to:bsearch16u::@8 +bsearch16u::@8: scope:[bsearch16u] from bsearch16u::@4 + [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 + to:bsearch16u::@return +bsearch16u::@6: scope:[bsearch16u] from bsearch16u::@4 + [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 + to:bsearch16u::@9 +bsearch16u::@9: scope:[bsearch16u] from bsearch16u::@6 + [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD + [65] (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#3 + to:bsearch16u::@7 +bsearch16u::@7: scope:[bsearch16u] from bsearch16u::@6 bsearch16u::@9 + [66] (word*) bsearch16u::items#8 ← phi( bsearch16u::@9/(word*) bsearch16u::items#1 bsearch16u::@6/(word*) bsearch16u::items#2 ) + [66] (byte) bsearch16u::num#5 ← phi( bsearch16u::@9/(byte) bsearch16u::num#2 bsearch16u::@6/(byte) bsearch16u::num#3 ) + [67] (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (byte) 1 + to:bsearch16u::@3 +sqr: scope:[sqr] from main::@4 main::@8 + [68] (byte) sqr::val#2 ← phi( main::@4/(byte) sqr::val#0 main::@8/(byte) sqr::val#1 ) + [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 + [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) + to:sqr::@return +sqr::@return: scope:[sqr] from sqr + [71] return + to:@return +init_squares: scope:[init_squares] from main::@10 + [72] phi() + [73] call malloc + to:init_squares::@1 +init_squares::@1: scope:[init_squares] from init_squares init_squares::@1 + [74] (byte) init_squares::i#2 ← phi( init_squares::@1/(byte) init_squares::i#1 init_squares/(byte) 0 ) + [74] (word*) init_squares::squares#2 ← phi( init_squares::@1/(word*) init_squares::squares#1 init_squares/(const byte*) HEAP_START#0 ) + [74] (word) init_squares::sqr#2 ← phi( init_squares::@1/(word) init_squares::sqr#1 init_squares/(byte) 0 ) + [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 + [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD + [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 + [78] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 + [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 + [80] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2 + [81] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#0-(byte) 1+(byte) 1) goto init_squares::@1 + to:init_squares::@return +init_squares::@return: scope:[init_squares] from init_squares::@1 + [82] return + to:@return +malloc: scope:[malloc] from init_squares + [83] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [84] return + to:@return +init_font_hex: scope:[init_font_hex] from main + [85] phi() + to:init_font_hex::@1 +init_font_hex::@1: scope:[init_font_hex] from init_font_hex init_font_hex::@5 + [86] (byte) init_font_hex::c#6 ← phi( init_font_hex/(byte) 0 init_font_hex::@5/(byte) init_font_hex::c#1 ) + [86] (byte*) init_font_hex::proto_hi#6 ← phi( init_font_hex/(const byte[]) FONT_HEX_PROTO#0 init_font_hex::@5/(byte*) init_font_hex::proto_hi#1 ) + [86] (byte*) init_font_hex::charset#5 ← phi( init_font_hex/(const byte*) CHARSET#0 init_font_hex::@5/(byte*) init_font_hex::charset#0 ) + to:init_font_hex::@2 +init_font_hex::@2: scope:[init_font_hex] from init_font_hex::@1 init_font_hex::@4 + [87] (byte) init_font_hex::c1#4 ← phi( init_font_hex::@1/(byte) 0 init_font_hex::@4/(byte) init_font_hex::c1#1 ) + [87] (byte*) init_font_hex::proto_lo#4 ← phi( init_font_hex::@1/(const byte[]) FONT_HEX_PROTO#0 init_font_hex::@4/(byte*) init_font_hex::proto_lo#1 ) + [87] (byte*) init_font_hex::charset#2 ← phi( init_font_hex::@1/(byte*) init_font_hex::charset#5 init_font_hex::@4/(byte*) init_font_hex::charset#0 ) + [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 + to:init_font_hex::@3 +init_font_hex::@3: scope:[init_font_hex] from init_font_hex::@2 init_font_hex::@3 + [89] (byte) init_font_hex::idx#5 ← phi( init_font_hex::@2/(byte) 1 init_font_hex::@3/(byte) init_font_hex::idx#2 ) + [89] (byte) init_font_hex::i#2 ← phi( init_font_hex::@2/(byte) 0 init_font_hex::@3/(byte) init_font_hex::i#1 ) + [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 + [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 + [92] (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 + [93] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 + [94] (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 + [95] (byte) init_font_hex::i#1 ← ++ (byte) init_font_hex::i#2 + [96] if((byte) init_font_hex::i#1!=(byte) 5) goto init_font_hex::@3 + to:init_font_hex::@4 +init_font_hex::@4: scope:[init_font_hex] from init_font_hex::@3 + [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 + [98] (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#2 + [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 + [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 + [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 + [102] (byte) init_font_hex::c1#1 ← ++ (byte) init_font_hex::c1#4 + [103] if((byte) init_font_hex::c1#1!=(byte) $10) goto init_font_hex::@2 + to:init_font_hex::@5 +init_font_hex::@5: scope:[init_font_hex] from init_font_hex::@4 + [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 + [105] (byte) init_font_hex::c#1 ← ++ (byte) init_font_hex::c#6 + [106] if((byte) init_font_hex::c#1!=(byte) $10) goto init_font_hex::@1 + to:init_font_hex::@return +init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 + [107] return + to:@return diff --git a/src/test/ref/screen-center-distance.log b/src/test/ref/screen-center-distance.log new file mode 100644 index 000000000..6075ee95f --- /dev/null +++ b/src/test/ref/screen-center-distance.log @@ -0,0 +1,4830 @@ +Resolved forward reference FONT_HEX_PROTO to (byte[]) FONT_HEX_PROTO +Resolved forward reference FONT_HEX_PROTO to (byte[]) FONT_HEX_PROTO +Resolved forward reference NUM_SQUARES to (byte) NUM_SQUARES +Adding pointer type conversion cast (byte*) HEAP_START in (byte*) HEAP_START ← (number) $c000 +Adding pointer type conversion cast (byte*) PROCPORT_DDR in (byte*) PROCPORT_DDR ← (number) 0 +Adding pointer type conversion cast (byte*) PROCPORT in (byte*) PROCPORT ← (number) 1 +Adding pointer type conversion cast (byte*) CHARGEN in (byte*) CHARGEN ← (number) $d000 +Adding pointer type conversion cast (byte*) SPRITES_XPOS in (byte*) SPRITES_XPOS ← (number) $d000 +Adding pointer type conversion cast (byte*) SPRITES_YPOS in (byte*) SPRITES_YPOS ← (number) $d001 +Adding pointer type conversion cast (byte*) SPRITES_XMSB in (byte*) SPRITES_XMSB ← (number) $d010 +Adding pointer type conversion cast (byte*) RASTER in (byte*) RASTER ← (number) $d012 +Adding pointer type conversion cast (byte*) SPRITES_ENABLE in (byte*) SPRITES_ENABLE ← (number) $d015 +Adding pointer type conversion cast (byte*) SPRITES_EXPAND_Y in (byte*) SPRITES_EXPAND_Y ← (number) $d017 +Adding pointer type conversion cast (byte*) SPRITES_PRIORITY in (byte*) SPRITES_PRIORITY ← (number) $d01b +Adding pointer type conversion cast (byte*) SPRITES_MC in (byte*) SPRITES_MC ← (number) $d01c +Adding pointer type conversion cast (byte*) SPRITES_EXPAND_X in (byte*) SPRITES_EXPAND_X ← (number) $d01d +Adding pointer type conversion cast (byte*) BORDERCOL in (byte*) BORDERCOL ← (number) $d020 +Adding pointer type conversion cast (byte*) BGCOL in (byte*) BGCOL ← (number) $d021 +Adding pointer type conversion cast (byte*) BGCOL1 in (byte*) BGCOL1 ← (number) $d021 +Adding pointer type conversion cast (byte*) BGCOL2 in (byte*) BGCOL2 ← (number) $d022 +Adding pointer type conversion cast (byte*) BGCOL3 in (byte*) BGCOL3 ← (number) $d023 +Adding pointer type conversion cast (byte*) BGCOL4 in (byte*) BGCOL4 ← (number) $d024 +Adding pointer type conversion cast (byte*) SPRITES_MC1 in (byte*) SPRITES_MC1 ← (number) $d025 +Adding pointer type conversion cast (byte*) SPRITES_MC2 in (byte*) SPRITES_MC2 ← (number) $d026 +Adding pointer type conversion cast (byte*) SPRITES_COLS in (byte*) SPRITES_COLS ← (number) $d027 +Adding pointer type conversion cast (byte*) VIC_CONTROL in (byte*) VIC_CONTROL ← (number) $d011 +Adding pointer type conversion cast (byte*) D011 in (byte*) D011 ← (number) $d011 +Adding pointer type conversion cast (byte*) VIC_CONTROL2 in (byte*) VIC_CONTROL2 ← (number) $d016 +Adding pointer type conversion cast (byte*) D016 in (byte*) D016 ← (number) $d016 +Adding pointer type conversion cast (byte*) D018 in (byte*) D018 ← (number) $d018 +Adding pointer type conversion cast (byte*) VIC_MEMORY in (byte*) VIC_MEMORY ← (number) $d018 +Adding pointer type conversion cast (byte*) LIGHTPEN_X in (byte*) LIGHTPEN_X ← (number) $d013 +Adding pointer type conversion cast (byte*) LIGHTPEN_Y in (byte*) LIGHTPEN_Y ← (number) $d014 +Adding pointer type conversion cast (byte*) IRQ_STATUS in (byte*) IRQ_STATUS ← (number) $d019 +Adding pointer type conversion cast (byte*) IRQ_ENABLE in (byte*) IRQ_ENABLE ← (number) $d01a +Adding pointer type conversion cast (byte*) COLS in (byte*) COLS ← (number) $d800 +Adding pointer type conversion cast (byte*) CIA1_PORT_A in (byte*) CIA1_PORT_A ← (number) $dc00 +Adding pointer type conversion cast (byte*) CIA1_PORT_B in (byte*) CIA1_PORT_B ← (number) $dc01 +Adding pointer type conversion cast (byte*) CIA1_PORT_A_DDR in (byte*) CIA1_PORT_A_DDR ← (number) $dc02 +Adding pointer type conversion cast (byte*) CIA1_PORT_B_DDR in (byte*) CIA1_PORT_B_DDR ← (number) $dc03 +Adding pointer type conversion cast (byte*) CIA1_INTERRUPT in (byte*) CIA1_INTERRUPT ← (number) $dc0d +Adding pointer type conversion cast (byte*) CIA2_PORT_A in (byte*) CIA2_PORT_A ← (number) $dd00 +Adding pointer type conversion cast (byte*) CIA2_PORT_B in (byte*) CIA2_PORT_B ← (number) $dd01 +Adding pointer type conversion cast (byte*) CIA2_PORT_A_DDR in (byte*) CIA2_PORT_A_DDR ← (number) $dd02 +Adding pointer type conversion cast (byte*) CIA2_PORT_B_DDR in (byte*) CIA2_PORT_B_DDR ← (number) $dd03 +Adding pointer type conversion cast (byte*) CIA2_INTERRUPT in (byte*) CIA2_INTERRUPT ← (number) $dd0d +Adding pointer type conversion cast (void()**) KERNEL_IRQ in (void()**) KERNEL_IRQ ← (number) $314 +Adding pointer type conversion cast (void()**) HARDWARE_IRQ in (void()**) HARDWARE_IRQ ← (number) $fffe +Adding pointer type conversion cast (byte*) CHARSET in (byte*) CHARSET ← (number) $2000 +Adding pointer type conversion cast (byte*) SCREEN in (byte*) SCREEN ← (number) $2800 +Fixing pointer increment (word*) init_squares::squares ← ++ (word*) init_squares::squares +Fixing pointer addition (word*~) bsearch16u::$7 ← (word*) bsearch16u::items + (byte~) bsearch16u::$6 +Fixing pointer addition (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot + (number) 1 +Fixing pointer addition (word*~) bsearch16u::$1 ← (word*) bsearch16u::items - (number) 1 +Fixing pointer array-indexing *((word*) SQUARES + (byte) sqr::val) +Identified constant variable (byte*) HEAP_START +Inlined call (byte~) vicSelectGfxBank::$0 ← call toDd00 (byte*) vicSelectGfxBank::gfx +Inlined call (byte~) main::$1 ← call toD018 (byte*) SCREEN (byte*) CHARSET +Culled Empty Block (label) malloc::@1 +Culled Empty Block (label) @1 +Culled Empty Block (label) @3 +Culled Empty Block (label) @4 +Culled Empty Block (label) @5 +Culled Empty Block (label) @6 +Culled Empty Block (label) init_font_hex::@6 +Culled Empty Block (label) main::toD0181_@1 +Culled Empty Block (label) main::@13 +Culled Empty Block (label) main::@14 +Culled Empty Block (label) main::@9 +Culled Empty Block (label) main::@10 +Culled Empty Block (label) main::@12 +Culled Empty Block (label) init_squares::@2 +Culled Empty Block (label) @9 +Culled Empty Block (label) sqr::@1 +Culled Empty Block (label) @10 +Culled Empty Block (label) sqrt::@1 +Culled Empty Block (label) @11 +Culled Empty Block (label) bsearch16u::@11 +Culled Empty Block (label) bsearch16u::@12 +Culled Empty Block (label) bsearch16u::@14 +Culled Empty Block (label) bsearch16u::@16 +Culled Empty Block (label) bsearch16u::@17 +Culled Empty Block (label) bsearch16u::@4 +Culled Empty Block (label) bsearch16u::@5 + +CONTROL FLOW GRAPH SSA +@begin: scope:[] from + (byte*) HEAP_START#0 ← ((byte*)) (number) $c000 + (byte*) heap_head#0 ← (byte*) HEAP_START#0 + to:@2 +malloc: scope:[malloc] from init_squares + (word) malloc::size#1 ← phi( init_squares/(word) malloc::size#0 ) + (byte*) heap_head#8 ← phi( init_squares/(byte*) heap_head#15 ) + (byte*) malloc::mem#0 ← (byte*) heap_head#8 + (byte*) heap_head#1 ← (byte*) heap_head#8 + (word) malloc::size#1 + (byte*) malloc::return#0 ← (byte*) malloc::mem#0 + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + (byte*) heap_head#9 ← phi( malloc/(byte*) heap_head#1 ) + (byte*) malloc::return#3 ← phi( malloc/(byte*) malloc::return#0 ) + (byte*) malloc::return#1 ← (byte*) malloc::return#3 + (byte*) heap_head#2 ← (byte*) heap_head#9 + return + to:@return +@2: scope:[] from @begin + (byte*) heap_head#26 ← phi( @begin/(byte*) heap_head#0 ) + (byte*) D018#0 ← ((byte*)) (number) $d018 + to:@7 +init_font_hex: scope:[init_font_hex] from main + (byte*) init_font_hex::charset#6 ← phi( main/(byte*) init_font_hex::charset#1 ) + (byte*) init_font_hex::proto_hi#0 ← (byte[]) FONT_HEX_PROTO#0 + (byte) init_font_hex::c#0 ← (byte) 0 + to:init_font_hex::@1 +init_font_hex::@1: scope:[init_font_hex] from init_font_hex init_font_hex::@5 + (byte) init_font_hex::c#6 ← phi( init_font_hex/(byte) init_font_hex::c#0 init_font_hex::@5/(byte) init_font_hex::c#1 ) + (byte*) init_font_hex::proto_hi#6 ← phi( init_font_hex/(byte*) init_font_hex::proto_hi#0 init_font_hex::@5/(byte*) init_font_hex::proto_hi#1 ) + (byte*) init_font_hex::charset#5 ← phi( init_font_hex/(byte*) init_font_hex::charset#6 init_font_hex::@5/(byte*) init_font_hex::charset#7 ) + (byte*) init_font_hex::proto_lo#0 ← (byte[]) FONT_HEX_PROTO#0 + (byte) init_font_hex::c1#0 ← (byte) 0 + to:init_font_hex::@2 +init_font_hex::@2: scope:[init_font_hex] from init_font_hex::@1 init_font_hex::@4 + (byte) init_font_hex::c#5 ← phi( init_font_hex::@1/(byte) init_font_hex::c#6 init_font_hex::@4/(byte) init_font_hex::c#3 ) + (byte) init_font_hex::c1#4 ← phi( init_font_hex::@1/(byte) init_font_hex::c1#0 init_font_hex::@4/(byte) init_font_hex::c1#1 ) + (byte*) init_font_hex::proto_lo#4 ← phi( init_font_hex::@1/(byte*) init_font_hex::proto_lo#0 init_font_hex::@4/(byte*) init_font_hex::proto_lo#1 ) + (byte*) init_font_hex::proto_hi#4 ← phi( init_font_hex::@1/(byte*) init_font_hex::proto_hi#6 init_font_hex::@4/(byte*) init_font_hex::proto_hi#5 ) + (byte*) init_font_hex::charset#2 ← phi( init_font_hex::@1/(byte*) init_font_hex::charset#5 init_font_hex::@4/(byte*) init_font_hex::charset#0 ) + (byte) init_font_hex::idx#0 ← (number) 0 + *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#0) ← (number) 0 + (byte) init_font_hex::idx#1 ← ++ (byte) init_font_hex::idx#0 + (byte) init_font_hex::i#0 ← (byte) 0 + to:init_font_hex::@3 +init_font_hex::@3: scope:[init_font_hex] from init_font_hex::@2 init_font_hex::@3 + (byte) init_font_hex::c#4 ← phi( init_font_hex::@2/(byte) init_font_hex::c#5 init_font_hex::@3/(byte) init_font_hex::c#4 ) + (byte) init_font_hex::c1#3 ← phi( init_font_hex::@2/(byte) init_font_hex::c1#4 init_font_hex::@3/(byte) init_font_hex::c1#3 ) + (byte) init_font_hex::idx#5 ← phi( init_font_hex::@2/(byte) init_font_hex::idx#1 init_font_hex::@3/(byte) init_font_hex::idx#2 ) + (byte*) init_font_hex::charset#3 ← phi( init_font_hex::@2/(byte*) init_font_hex::charset#2 init_font_hex::@3/(byte*) init_font_hex::charset#3 ) + (byte*) init_font_hex::proto_lo#2 ← phi( init_font_hex::@2/(byte*) init_font_hex::proto_lo#4 init_font_hex::@3/(byte*) init_font_hex::proto_lo#2 ) + (byte) init_font_hex::i#2 ← phi( init_font_hex::@2/(byte) init_font_hex::i#0 init_font_hex::@3/(byte) init_font_hex::i#1 ) + (byte*) init_font_hex::proto_hi#2 ← phi( init_font_hex::@2/(byte*) init_font_hex::proto_hi#4 init_font_hex::@3/(byte*) init_font_hex::proto_hi#2 ) + (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#2 + (byte) init_font_hex::i#2) << (number) 4 + (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#2 + (byte) init_font_hex::i#2) << (number) 1 + (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 + *((byte*) init_font_hex::charset#3 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 + (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 + (byte) init_font_hex::i#1 ← (byte) init_font_hex::i#2 + rangenext(0,4) + (bool~) init_font_hex::$3 ← (byte) init_font_hex::i#1 != rangelast(0,4) + if((bool~) init_font_hex::$3) goto init_font_hex::@3 + to:init_font_hex::@4 +init_font_hex::@4: scope:[init_font_hex] from init_font_hex::@3 + (byte) init_font_hex::c#3 ← phi( init_font_hex::@3/(byte) init_font_hex::c#4 ) + (byte*) init_font_hex::proto_hi#5 ← phi( init_font_hex::@3/(byte*) init_font_hex::proto_hi#2 ) + (byte) init_font_hex::c1#2 ← phi( init_font_hex::@3/(byte) init_font_hex::c1#3 ) + (byte*) init_font_hex::proto_lo#3 ← phi( init_font_hex::@3/(byte*) init_font_hex::proto_lo#2 ) + (byte) init_font_hex::idx#6 ← phi( init_font_hex::@3/(byte) init_font_hex::idx#2 ) + (byte*) init_font_hex::charset#4 ← phi( init_font_hex::@3/(byte*) init_font_hex::charset#3 ) + *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#6) ← (number) 0 + (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#6 + *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#3) ← (number) 0 + (byte) init_font_hex::idx#4 ← ++ (byte) init_font_hex::idx#3 + (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#3 + (number) 5 + (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#4 + (number) 8 + (byte) init_font_hex::c1#1 ← (byte) init_font_hex::c1#2 + rangenext(0,$f) + (bool~) init_font_hex::$4 ← (byte) init_font_hex::c1#1 != rangelast(0,$f) + if((bool~) init_font_hex::$4) goto init_font_hex::@2 + to:init_font_hex::@5 +init_font_hex::@5: scope:[init_font_hex] from init_font_hex::@4 + (byte*) init_font_hex::charset#7 ← phi( init_font_hex::@4/(byte*) init_font_hex::charset#0 ) + (byte) init_font_hex::c#2 ← phi( init_font_hex::@4/(byte) init_font_hex::c#3 ) + (byte*) init_font_hex::proto_hi#3 ← phi( init_font_hex::@4/(byte*) init_font_hex::proto_hi#5 ) + (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#3 + (number) 5 + (byte) init_font_hex::c#1 ← (byte) init_font_hex::c#2 + rangenext(0,$f) + (bool~) init_font_hex::$5 ← (byte) init_font_hex::c#1 != rangelast(0,$f) + if((bool~) init_font_hex::$5) goto init_font_hex::@1 + to:init_font_hex::@return +init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 + return + to:@return +@7: scope:[] from @2 + (byte*) heap_head#25 ← phi( @2/(byte*) heap_head#26 ) + (byte[]) FONT_HEX_PROTO#0 ← { (number) 2, (number) 5, (number) 5, (number) 5, (number) 2, (number) 6, (number) 2, (number) 2, (number) 2, (number) 7, (number) 6, (number) 1, (number) 2, (number) 4, (number) 7, (number) 6, (number) 1, (number) 2, (number) 1, (number) 6, (number) 5, (number) 5, (number) 7, (number) 1, (number) 1, (number) 7, (number) 4, (number) 6, (number) 1, (number) 6, (number) 3, (number) 4, (number) 6, (number) 5, (number) 2, (number) 7, (number) 1, (number) 1, (number) 1, (number) 1, (number) 2, (number) 5, (number) 2, (number) 5, (number) 2, (number) 2, (number) 5, (number) 3, (number) 1, (number) 1, (number) 2, (number) 5, (number) 7, (number) 5, (number) 5, (number) 6, (number) 5, (number) 6, (number) 5, (number) 6, (number) 2, (number) 5, (number) 4, (number) 5, (number) 2, (number) 6, (number) 5, (number) 5, (number) 5, (number) 6, (number) 7, (number) 4, (number) 6, (number) 4, (number) 7, (number) 7, (number) 4, (number) 6, (number) 4, (number) 4 } + (byte*) CHARSET#0 ← ((byte*)) (number) $2000 + (byte*) SCREEN#0 ← ((byte*)) (number) $2800 + to:@8 +main: scope:[main] from @12 + (word*) SQUARES#31 ← phi( @12/(word*) SQUARES#19 ) + (byte*) heap_head#29 ← phi( @12/(byte*) heap_head#19 ) + (byte*) init_font_hex::charset#1 ← (byte*) CHARSET#0 + call init_font_hex + to:main::@16 +main::@16: scope:[main] from main + (word*) SQUARES#29 ← phi( main/(word*) SQUARES#31 ) + (byte*) heap_head#27 ← phi( main/(byte*) heap_head#29 ) + (byte*) main::toD0181_screen#0 ← (byte*) SCREEN#0 + (byte*) main::toD0181_gfx#0 ← (byte*) CHARSET#0 + to:main::toD0181 +main::toD0181: scope:[main] from main::@16 + (word*) SQUARES#26 ← phi( main::@16/(word*) SQUARES#29 ) + (byte*) heap_head#23 ← phi( main::@16/(byte*) heap_head#27 ) + (byte*) main::toD0181_gfx#1 ← phi( main::@16/(byte*) main::toD0181_gfx#0 ) + (byte*) main::toD0181_screen#1 ← phi( main::@16/(byte*) main::toD0181_screen#0 ) + (word~) main::toD0181_$0#0 ← ((word)) (byte*) main::toD0181_screen#1 + (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (number) $3fff + (number~) main::toD0181_$2#0 ← (number~) main::toD0181_$1#0 * (number) 4 + (number~) main::toD0181_$3#0 ← > (number~) main::toD0181_$2#0 + (word~) main::toD0181_$4#0 ← ((word)) (byte*) main::toD0181_gfx#1 + (byte~) main::toD0181_$5#0 ← > (word~) main::toD0181_$4#0 + (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (number) 4 + (number~) main::toD0181_$7#0 ← (number~) main::toD0181_$6#0 & (number) $f + (number~) main::toD0181_$8#0 ← (number~) main::toD0181_$3#0 | (number~) main::toD0181_$7#0 + (byte) main::toD0181_return#0 ← (number~) main::toD0181_$8#0 + to:main::toD0181_@return +main::toD0181_@return: scope:[main] from main::toD0181 + (word*) SQUARES#20 ← phi( main::toD0181/(word*) SQUARES#26 ) + (byte*) heap_head#20 ← phi( main::toD0181/(byte*) heap_head#23 ) + (byte) main::toD0181_return#2 ← phi( main::toD0181/(byte) main::toD0181_return#0 ) + (byte) main::toD0181_return#1 ← (byte) main::toD0181_return#2 + to:main::@15 +main::@15: scope:[main] from main::toD0181_@return + (word*) SQUARES#13 ← phi( main::toD0181_@return/(word*) SQUARES#20 ) + (byte*) heap_head#16 ← phi( main::toD0181_@return/(byte*) heap_head#20 ) + (byte) main::toD0181_return#3 ← phi( main::toD0181_@return/(byte) main::toD0181_return#1 ) + (byte~) main::$1 ← (byte) main::toD0181_return#3 + *((byte*) D018#0) ← (byte~) main::$1 + (byte) NUM_SQUARES#0 ← (number) $30 + call init_squares + to:main::@17 +main::@17: scope:[main] from main::@15 + (byte) NUM_SQUARES#22 ← phi( main::@15/(byte) NUM_SQUARES#0 ) + (word*) SQUARES#6 ← phi( main::@15/(word*) SQUARES#4 ) + (byte*) heap_head#10 ← phi( main::@15/(byte*) heap_head#6 ) + (byte*) heap_head#3 ← (byte*) heap_head#10 + (word*) SQUARES#0 ← (word*) SQUARES#6 + (byte*) main::screen#0 ← (byte*) SCREEN#0 + (byte) main::y#0 ← (byte) 0 + to:main::@1 +main::@1: scope:[main] from main::@11 main::@17 + (byte*) heap_head#37 ← phi( main::@11/(byte*) heap_head#17 main::@17/(byte*) heap_head#3 ) + (byte) NUM_SQUARES#21 ← phi( main::@11/(byte) NUM_SQUARES#9 main::@17/(byte) NUM_SQUARES#22 ) + (byte*) main::screen#12 ← phi( main::@11/(byte*) main::screen#13 main::@17/(byte*) main::screen#0 ) + (word*) SQUARES#27 ← phi( main::@11/(word*) SQUARES#14 main::@17/(word*) SQUARES#0 ) + (byte) main::y#2 ← phi( main::@11/(byte) main::y#1 main::@17/(byte) main::y#0 ) + (number~) main::$3 ← (byte) main::y#2 * (number) 2 + (byte) main::y2#0 ← (number~) main::$3 + (bool~) main::$4 ← (byte) main::y2#0 >= (number) $18 + if((bool~) main::$4) goto main::@2 + to:main::@3 +main::@2: scope:[main] from main::@1 + (byte*) heap_head#35 ← phi( main::@1/(byte*) heap_head#37 ) + (byte) main::y#12 ← phi( main::@1/(byte) main::y#2 ) + (byte) NUM_SQUARES#19 ← phi( main::@1/(byte) NUM_SQUARES#21 ) + (byte*) main::screen#10 ← phi( main::@1/(byte*) main::screen#12 ) + (word*) SQUARES#21 ← phi( main::@1/(word*) SQUARES#27 ) + (byte) main::y2#1 ← phi( main::@1/(byte) main::y2#0 ) + (number~) main::$7 ← (byte) main::y2#1 - (number) $18 + (number~) main::$8 ← (number~) main::$7 + to:main::@4 +main::@3: scope:[main] from main::@1 + (byte*) heap_head#36 ← phi( main::@1/(byte*) heap_head#37 ) + (byte) main::y#13 ← phi( main::@1/(byte) main::y#2 ) + (byte) NUM_SQUARES#20 ← phi( main::@1/(byte) NUM_SQUARES#21 ) + (byte*) main::screen#11 ← phi( main::@1/(byte*) main::screen#12 ) + (word*) SQUARES#22 ← phi( main::@1/(word*) SQUARES#27 ) + (byte) main::y2#2 ← phi( main::@1/(byte) main::y2#0 ) + (number~) main::$5 ← (number) $18 - (byte) main::y2#2 + (number~) main::$6 ← (number~) main::$5 + to:main::@4 +main::@4: scope:[main] from main::@2 main::@3 + (byte*) heap_head#34 ← phi( main::@2/(byte*) heap_head#35 main::@3/(byte*) heap_head#36 ) + (byte) main::y#11 ← phi( main::@2/(byte) main::y#12 main::@3/(byte) main::y#13 ) + (byte) NUM_SQUARES#18 ← phi( main::@2/(byte) NUM_SQUARES#19 main::@3/(byte) NUM_SQUARES#20 ) + (byte*) main::screen#9 ← phi( main::@2/(byte*) main::screen#10 main::@3/(byte*) main::screen#11 ) + (word*) SQUARES#16 ← phi( main::@2/(word*) SQUARES#21 main::@3/(word*) SQUARES#22 ) + (number~) main::$9 ← phi( main::@2/(number~) main::$8 main::@3/(number~) main::$6 ) + (byte) main::yd#0 ← (number~) main::$9 + (byte) sqr::val#0 ← (byte) main::yd#0 + call sqr + (word) sqr::return#0 ← (word) sqr::return#3 + to:main::@18 +main::@18: scope:[main] from main::@4 + (byte*) heap_head#33 ← phi( main::@4/(byte*) heap_head#34 ) + (byte) main::y#10 ← phi( main::@4/(byte) main::y#11 ) + (byte) NUM_SQUARES#17 ← phi( main::@4/(byte) NUM_SQUARES#18 ) + (byte*) main::screen#8 ← phi( main::@4/(byte*) main::screen#9 ) + (word*) SQUARES#30 ← phi( main::@4/(word*) SQUARES#16 ) + (word) sqr::return#4 ← phi( main::@4/(word) sqr::return#0 ) + (word~) main::$10 ← (word) sqr::return#4 + (word) main::yds#0 ← (word~) main::$10 + (byte) main::x#0 ← (byte) 0 + to:main::@5 +main::@5: scope:[main] from main::@18 main::@20 + (byte*) heap_head#32 ← phi( main::@18/(byte*) heap_head#33 main::@20/(byte*) heap_head#21 ) + (byte) main::y#9 ← phi( main::@18/(byte) main::y#10 main::@20/(byte) main::y#4 ) + (byte) NUM_SQUARES#16 ← phi( main::@18/(byte) NUM_SQUARES#17 main::@20/(byte) NUM_SQUARES#13 ) + (byte*) main::screen#7 ← phi( main::@18/(byte*) main::screen#8 main::@20/(byte*) main::screen#1 ) + (word*) SQUARES#28 ← phi( main::@18/(word*) SQUARES#30 main::@20/(word*) SQUARES#25 ) + (word) main::yds#5 ← phi( main::@18/(word) main::yds#0 main::@20/(word) main::yds#6 ) + (byte) main::x#2 ← phi( main::@18/(byte) main::x#0 main::@20/(byte) main::x#1 ) + (number~) main::$11 ← (byte) main::x#2 * (number) 2 + (byte) main::x2#0 ← (number~) main::$11 + (bool~) main::$12 ← (byte) main::x2#0 >= (number) $27 + if((bool~) main::$12) goto main::@6 + to:main::@7 +main::@6: scope:[main] from main::@5 + (byte*) heap_head#30 ← phi( main::@5/(byte*) heap_head#32 ) + (byte) main::y#7 ← phi( main::@5/(byte) main::y#9 ) + (byte) NUM_SQUARES#14 ← phi( main::@5/(byte) NUM_SQUARES#16 ) + (byte) main::x#6 ← phi( main::@5/(byte) main::x#2 ) + (byte*) main::screen#5 ← phi( main::@5/(byte*) main::screen#7 ) + (word*) SQUARES#23 ← phi( main::@5/(word*) SQUARES#28 ) + (word) main::yds#3 ← phi( main::@5/(word) main::yds#5 ) + (byte) main::x2#1 ← phi( main::@5/(byte) main::x2#0 ) + (number~) main::$15 ← (byte) main::x2#1 - (number) $27 + (number~) main::$16 ← (number~) main::$15 + to:main::@8 +main::@7: scope:[main] from main::@5 + (byte*) heap_head#31 ← phi( main::@5/(byte*) heap_head#32 ) + (byte) main::y#8 ← phi( main::@5/(byte) main::y#9 ) + (byte) NUM_SQUARES#15 ← phi( main::@5/(byte) NUM_SQUARES#16 ) + (byte) main::x#7 ← phi( main::@5/(byte) main::x#2 ) + (byte*) main::screen#6 ← phi( main::@5/(byte*) main::screen#7 ) + (word*) SQUARES#24 ← phi( main::@5/(word*) SQUARES#28 ) + (word) main::yds#4 ← phi( main::@5/(word) main::yds#5 ) + (byte) main::x2#2 ← phi( main::@5/(byte) main::x2#0 ) + (number~) main::$13 ← (number) $27 - (byte) main::x2#2 + (number~) main::$14 ← (number~) main::$13 + to:main::@8 +main::@8: scope:[main] from main::@6 main::@7 + (byte*) heap_head#28 ← phi( main::@6/(byte*) heap_head#30 main::@7/(byte*) heap_head#31 ) + (byte) main::y#6 ← phi( main::@6/(byte) main::y#7 main::@7/(byte) main::y#8 ) + (byte) NUM_SQUARES#12 ← phi( main::@6/(byte) NUM_SQUARES#14 main::@7/(byte) NUM_SQUARES#15 ) + (byte) main::x#5 ← phi( main::@6/(byte) main::x#6 main::@7/(byte) main::x#7 ) + (byte*) main::screen#4 ← phi( main::@6/(byte*) main::screen#5 main::@7/(byte*) main::screen#6 ) + (word*) SQUARES#17 ← phi( main::@6/(word*) SQUARES#23 main::@7/(word*) SQUARES#24 ) + (word) main::yds#2 ← phi( main::@6/(word) main::yds#3 main::@7/(word) main::yds#4 ) + (number~) main::$17 ← phi( main::@6/(number~) main::$16 main::@7/(number~) main::$14 ) + (byte) main::xd#0 ← (number~) main::$17 + (byte) sqr::val#1 ← (byte) main::xd#0 + call sqr + (word) sqr::return#1 ← (word) sqr::return#3 + to:main::@19 +main::@19: scope:[main] from main::@8 + (byte*) heap_head#24 ← phi( main::@8/(byte*) heap_head#28 ) + (byte) main::y#5 ← phi( main::@8/(byte) main::y#6 ) + (byte) NUM_SQUARES#10 ← phi( main::@8/(byte) NUM_SQUARES#12 ) + (word*) SQUARES#18 ← phi( main::@8/(word*) SQUARES#17 ) + (byte) main::x#4 ← phi( main::@8/(byte) main::x#5 ) + (byte*) main::screen#3 ← phi( main::@8/(byte*) main::screen#4 ) + (word) main::yds#1 ← phi( main::@8/(word) main::yds#2 ) + (word) sqr::return#5 ← phi( main::@8/(word) sqr::return#1 ) + (word~) main::$18 ← (word) sqr::return#5 + (word) main::xds#0 ← (word~) main::$18 + (word~) main::$19 ← (word) main::xds#0 + (word) main::yds#1 + (word) main::ds#0 ← (word~) main::$19 + (word) sqrt::val#0 ← (word) main::ds#0 + call sqrt + (byte) sqrt::return#0 ← (byte) sqrt::return#2 + to:main::@20 +main::@20: scope:[main] from main::@19 + (word) main::yds#6 ← phi( main::@19/(word) main::yds#1 ) + (word*) SQUARES#25 ← phi( main::@19/(word*) SQUARES#18 ) + (byte*) heap_head#21 ← phi( main::@19/(byte*) heap_head#24 ) + (byte) NUM_SQUARES#13 ← phi( main::@19/(byte) NUM_SQUARES#10 ) + (byte) main::y#4 ← phi( main::@19/(byte) main::y#5 ) + (byte) main::x#3 ← phi( main::@19/(byte) main::x#4 ) + (byte*) main::screen#2 ← phi( main::@19/(byte*) main::screen#3 ) + (byte) sqrt::return#3 ← phi( main::@19/(byte) sqrt::return#0 ) + (byte~) main::$20 ← (byte) sqrt::return#3 + (byte) main::d#0 ← (byte~) main::$20 + *((byte*) main::screen#2) ← (byte) main::d#0 + (byte*) main::screen#1 ← ++ (byte*) main::screen#2 + (byte) main::x#1 ← (byte) main::x#3 + rangenext(0,$27) + (bool~) main::$21 ← (byte) main::x#1 != rangelast(0,$27) + if((bool~) main::$21) goto main::@5 + to:main::@11 +main::@11: scope:[main] from main::@20 + (byte*) main::screen#13 ← phi( main::@20/(byte*) main::screen#1 ) + (word*) SQUARES#14 ← phi( main::@20/(word*) SQUARES#25 ) + (byte*) heap_head#17 ← phi( main::@20/(byte*) heap_head#21 ) + (byte) NUM_SQUARES#9 ← phi( main::@20/(byte) NUM_SQUARES#13 ) + (byte) main::y#3 ← phi( main::@20/(byte) main::y#4 ) + (byte) main::y#1 ← (byte) main::y#3 + rangenext(0,$18) + (bool~) main::$22 ← (byte) main::y#1 != rangelast(0,$18) + if((bool~) main::$22) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@11 + (word*) SQUARES#7 ← phi( main::@11/(word*) SQUARES#14 ) + (byte*) heap_head#11 ← phi( main::@11/(byte*) heap_head#17 ) + (byte) NUM_SQUARES#4 ← phi( main::@11/(byte) NUM_SQUARES#9 ) + (byte) NUM_SQUARES#1 ← (byte) NUM_SQUARES#4 + (byte*) heap_head#4 ← (byte*) heap_head#11 + (word*) SQUARES#1 ← (word*) SQUARES#7 + return + to:@return +@8: scope:[] from @7 + (byte*) heap_head#22 ← phi( @7/(byte*) heap_head#25 ) + (byte) NUM_SQUARES#2 ← (number) $ff + (word*) SQUARES#2 ← (word*) 0 + to:@12 +init_squares: scope:[init_squares] from main::@15 + (byte*) heap_head#15 ← phi( main::@15/(byte*) heap_head#16 ) + (byte) NUM_SQUARES#5 ← phi( main::@15/(byte) NUM_SQUARES#0 ) + (byte~) init_squares::$0 ← (byte) NUM_SQUARES#5 * (const byte) SIZEOF_WORD + (word) malloc::size#0 ← (byte~) init_squares::$0 + call malloc + (byte*) malloc::return#2 ← (byte*) malloc::return#1 + to:init_squares::@3 +init_squares::@3: scope:[init_squares] from init_squares + (byte) NUM_SQUARES#6 ← phi( init_squares/(byte) NUM_SQUARES#5 ) + (byte*) heap_head#12 ← phi( init_squares/(byte*) heap_head#2 ) + (byte*) malloc::return#4 ← phi( init_squares/(byte*) malloc::return#2 ) + (byte*~) init_squares::$1 ← (byte*) malloc::return#4 + (byte*) heap_head#5 ← (byte*) heap_head#12 + (word*) SQUARES#3 ← (byte*~) init_squares::$1 + (word*) init_squares::squares#0 ← (word*) SQUARES#3 + (word) init_squares::sqr#0 ← (number) 0 + (number~) init_squares::$2 ← (byte) NUM_SQUARES#6 - (number) 1 + (byte) init_squares::i#0 ← (byte) 0 + to:init_squares::@1 +init_squares::@1: scope:[init_squares] from init_squares::@1 init_squares::@3 + (word*) SQUARES#15 ← phi( init_squares::@1/(word*) SQUARES#15 init_squares::@3/(word*) SQUARES#3 ) + (byte*) heap_head#18 ← phi( init_squares::@1/(byte*) heap_head#18 init_squares::@3/(byte*) heap_head#5 ) + (byte) init_squares::i#2 ← phi( init_squares::@1/(byte) init_squares::i#1 init_squares::@3/(byte) init_squares::i#0 ) + (word*) init_squares::squares#2 ← phi( init_squares::@1/(word*) init_squares::squares#1 init_squares::@3/(word*) init_squares::squares#0 ) + (word) init_squares::sqr#2 ← phi( init_squares::@1/(word) init_squares::sqr#1 init_squares::@3/(word) init_squares::sqr#0 ) + *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 + (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD + (number~) init_squares::$3 ← (byte) init_squares::i#2 * (number) 2 + (number~) init_squares::$4 ← (number~) init_squares::$3 + (number) 1 + (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (number~) init_squares::$4 + (byte) init_squares::i#1 ← (byte) init_squares::i#2 + rangenext(0,init_squares::$2) + (bool~) init_squares::$5 ← (byte) init_squares::i#1 != rangelast(0,init_squares::$2) + if((bool~) init_squares::$5) goto init_squares::@1 + to:init_squares::@return +init_squares::@return: scope:[init_squares] from init_squares::@1 + (word*) SQUARES#8 ← phi( init_squares::@1/(word*) SQUARES#15 ) + (byte*) heap_head#13 ← phi( init_squares::@1/(byte*) heap_head#18 ) + (byte*) heap_head#6 ← (byte*) heap_head#13 + (word*) SQUARES#4 ← (word*) SQUARES#8 + return + to:@return +sqr: scope:[sqr] from main::@4 main::@8 + (word*) SQUARES#9 ← phi( main::@4/(word*) SQUARES#16 main::@8/(word*) SQUARES#17 ) + (byte) sqr::val#2 ← phi( main::@4/(byte) sqr::val#0 main::@8/(byte) sqr::val#1 ) + (byte~) sqr::$0 ← (byte) sqr::val#2 * (const byte) SIZEOF_WORD + (word) sqr::return#2 ← *((word*) SQUARES#9 + (byte~) sqr::$0) + to:sqr::@return +sqr::@return: scope:[sqr] from sqr + (word) sqr::return#6 ← phi( sqr/(word) sqr::return#2 ) + (word) sqr::return#3 ← (word) sqr::return#6 + return + to:@return +sqrt: scope:[sqrt] from main::@19 + (byte) NUM_SQUARES#7 ← phi( main::@19/(byte) NUM_SQUARES#10 ) + (word*) SQUARES#10 ← phi( main::@19/(word*) SQUARES#18 ) + (word) sqrt::val#1 ← phi( main::@19/(word) sqrt::val#0 ) + (word) bsearch16u::key#0 ← (word) sqrt::val#1 + (word*) bsearch16u::items#0 ← (word*) SQUARES#10 + (byte) bsearch16u::num#0 ← (byte) NUM_SQUARES#7 + call bsearch16u + (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 + to:sqrt::@2 +sqrt::@2: scope:[sqrt] from sqrt + (word*) SQUARES#11 ← phi( sqrt/(word*) SQUARES#10 ) + (word*) bsearch16u::return#4 ← phi( sqrt/(word*) bsearch16u::return#0 ) + (word*~) sqrt::$0 ← (word*) bsearch16u::return#4 + (word*) sqrt::found#0 ← (word*~) sqrt::$0 + (byte*~) sqrt::$1 ← ((byte*)) (word*) sqrt::found#0 + (byte*~) sqrt::$2 ← ((byte*)) (word*) SQUARES#11 + (word~) sqrt::$3 ← (byte*~) sqrt::$1 - (byte*~) sqrt::$2 + (byte~) sqrt::$4 ← ((byte)) (word~) sqrt::$3 + (number~) sqrt::$5 ← (byte~) sqrt::$4 / (number) 2 + (byte) sqrt::sqr1#0 ← (number~) sqrt::$5 + (byte) sqrt::return#1 ← (byte) sqrt::sqr1#0 + to:sqrt::@return +sqrt::@return: scope:[sqrt] from sqrt::@2 + (byte) sqrt::return#4 ← phi( sqrt::@2/(byte) sqrt::return#1 ) + (byte) sqrt::return#2 ← (byte) sqrt::return#4 + return + to:@return +bsearch16u: scope:[bsearch16u] from sqrt + (word) bsearch16u::key#4 ← phi( sqrt/(word) bsearch16u::key#0 ) + (word*) bsearch16u::items#7 ← phi( sqrt/(word*) bsearch16u::items#0 ) + (byte) bsearch16u::num#7 ← phi( sqrt/(byte) bsearch16u::num#0 ) + to:bsearch16u::@6 +bsearch16u::@6: scope:[bsearch16u] from bsearch16u bsearch16u::@10 + (word) bsearch16u::key#3 ← phi( bsearch16u/(word) bsearch16u::key#4 bsearch16u::@10/(word) bsearch16u::key#5 ) + (word*) bsearch16u::items#6 ← phi( bsearch16u/(word*) bsearch16u::items#7 bsearch16u::@10/(word*) bsearch16u::items#8 ) + (byte) bsearch16u::num#3 ← phi( bsearch16u/(byte) bsearch16u::num#7 bsearch16u::@10/(byte) bsearch16u::num#1 ) + (bool~) bsearch16u::$5 ← (byte) bsearch16u::num#3 > (number) 0 + if((bool~) bsearch16u::$5) goto bsearch16u::@7 + to:bsearch16u::@8 +bsearch16u::@7: scope:[bsearch16u] from bsearch16u::@6 + (word) bsearch16u::key#1 ← phi( bsearch16u::@6/(word) bsearch16u::key#3 ) + (word*) bsearch16u::items#2 ← phi( bsearch16u::@6/(word*) bsearch16u::items#6 ) + (byte) bsearch16u::num#4 ← phi( bsearch16u::@6/(byte) bsearch16u::num#3 ) + (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#4 >> (number) 1 + (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 * (const byte) SIZEOF_WORD + (word*~) bsearch16u::$7 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 + (word*) bsearch16u::pivot#0 ← (word*~) bsearch16u::$7 + (signed word~) bsearch16u::$8 ← ((signed word)) (word) bsearch16u::key#1 + (signed word~) bsearch16u::$9 ← ((signed word)) *((word*) bsearch16u::pivot#0) + (signed word~) bsearch16u::$10 ← (signed word~) bsearch16u::$8 - (signed word~) bsearch16u::$9 + (signed word) bsearch16u::result#0 ← (signed word~) bsearch16u::$10 + (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (number) 0 + (bool~) bsearch16u::$12 ← ! (bool~) bsearch16u::$11 + if((bool~) bsearch16u::$12) goto bsearch16u::@9 + to:bsearch16u::@13 +bsearch16u::@8: scope:[bsearch16u] from bsearch16u::@6 + (word) bsearch16u::key#2 ← phi( bsearch16u::@6/(word) bsearch16u::key#3 ) + (word*) bsearch16u::items#3 ← phi( bsearch16u::@6/(word*) bsearch16u::items#6 ) + (bool~) bsearch16u::$0 ← *((word*) bsearch16u::items#3) <= (word) bsearch16u::key#2 + if((bool~) bsearch16u::$0) goto bsearch16u::@1 + to:bsearch16u::@2 +bsearch16u::@9: scope:[bsearch16u] from bsearch16u::@7 + (word) bsearch16u::key#7 ← phi( bsearch16u::@7/(word) bsearch16u::key#1 ) + (word*) bsearch16u::items#9 ← phi( bsearch16u::@7/(word*) bsearch16u::items#2 ) + (word*) bsearch16u::pivot#3 ← phi( bsearch16u::@7/(word*) bsearch16u::pivot#0 ) + (byte) bsearch16u::num#8 ← phi( bsearch16u::@7/(byte) bsearch16u::num#4 ) + (signed word) bsearch16u::result#1 ← phi( bsearch16u::@7/(signed word) bsearch16u::result#0 ) + (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (number) 0 + (bool~) bsearch16u::$14 ← ! (bool~) bsearch16u::$13 + if((bool~) bsearch16u::$14) goto bsearch16u::@10 + to:bsearch16u::@15 +bsearch16u::@13: scope:[bsearch16u] from bsearch16u::@7 + (word*) bsearch16u::pivot#1 ← phi( bsearch16u::@7/(word*) bsearch16u::pivot#0 ) + (word*) bsearch16u::return#1 ← (word*) bsearch16u::pivot#1 + to:bsearch16u::@return +bsearch16u::@return: scope:[bsearch16u] from bsearch16u::@13 bsearch16u::@3 + (word*) bsearch16u::return#5 ← phi( bsearch16u::@13/(word*) bsearch16u::return#1 bsearch16u::@3/(word*) bsearch16u::return#3 ) + (word*) bsearch16u::return#2 ← (word*) bsearch16u::return#5 + return + to:@return +bsearch16u::@10: scope:[bsearch16u] from bsearch16u::@15 bsearch16u::@9 + (word) bsearch16u::key#5 ← phi( bsearch16u::@15/(word) bsearch16u::key#6 bsearch16u::@9/(word) bsearch16u::key#7 ) + (word*) bsearch16u::items#8 ← phi( bsearch16u::@15/(word*) bsearch16u::items#1 bsearch16u::@9/(word*) bsearch16u::items#9 ) + (byte) bsearch16u::num#5 ← phi( bsearch16u::@15/(byte) bsearch16u::num#2 bsearch16u::@9/(byte) bsearch16u::num#8 ) + (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (number) 1 + to:bsearch16u::@6 +bsearch16u::@15: scope:[bsearch16u] from bsearch16u::@9 + (word) bsearch16u::key#6 ← phi( bsearch16u::@9/(word) bsearch16u::key#7 ) + (byte) bsearch16u::num#6 ← phi( bsearch16u::@9/(byte) bsearch16u::num#8 ) + (word*) bsearch16u::pivot#2 ← phi( bsearch16u::@9/(word*) bsearch16u::pivot#3 ) + (number~) bsearch16u::$17 ← (number) 1 * (const byte) SIZEOF_WORD + (word*~) bsearch16u::$15 ← (word*) bsearch16u::pivot#2 + (number~) bsearch16u::$17 + (word*) bsearch16u::items#1 ← (word*~) bsearch16u::$15 + (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#6 + to:bsearch16u::@10 +bsearch16u::@1: scope:[bsearch16u] from bsearch16u::@8 + (word*) bsearch16u::items#4 ← phi( bsearch16u::@8/(word*) bsearch16u::items#3 ) + (word*~) bsearch16u::$3 ← (word*) bsearch16u::items#4 + to:bsearch16u::@3 +bsearch16u::@2: scope:[bsearch16u] from bsearch16u::@8 + (word*) bsearch16u::items#5 ← phi( bsearch16u::@8/(word*) bsearch16u::items#3 ) + (number~) bsearch16u::$18 ← (number) 1 * (const byte) SIZEOF_WORD + (word*~) bsearch16u::$1 ← (word*) bsearch16u::items#5 - (number~) bsearch16u::$18 + (word*~) bsearch16u::$2 ← (word*~) bsearch16u::$1 + to:bsearch16u::@3 +bsearch16u::@3: scope:[bsearch16u] from bsearch16u::@1 bsearch16u::@2 + (word*~) bsearch16u::$4 ← phi( bsearch16u::@1/(word*~) bsearch16u::$3 bsearch16u::@2/(word*~) bsearch16u::$2 ) + (word*) bsearch16u::return#3 ← (word*~) bsearch16u::$4 + to:bsearch16u::@return +@12: scope:[] from @8 + (word*) SQUARES#19 ← phi( @8/(word*) SQUARES#2 ) + (byte*) heap_head#19 ← phi( @8/(byte*) heap_head#22 ) + (byte) NUM_SQUARES#11 ← phi( @8/(byte) NUM_SQUARES#2 ) + call main + to:@13 +@13: scope:[] from @12 + (word*) SQUARES#12 ← phi( @12/(word*) SQUARES#1 ) + (byte*) heap_head#14 ← phi( @12/(byte*) heap_head#4 ) + (byte) NUM_SQUARES#8 ← phi( @12/(byte) NUM_SQUARES#1 ) + (byte) NUM_SQUARES#3 ← (byte) NUM_SQUARES#8 + (byte*) heap_head#7 ← (byte*) heap_head#14 + (word*) SQUARES#5 ← (word*) SQUARES#12 + to:@end +@end: scope:[] from @13 + +SYMBOL TABLE SSA +(label) @12 +(label) @13 +(label) @2 +(label) @7 +(label) @8 +(label) @begin +(label) @end +(byte*) CHARSET +(byte*) CHARSET#0 +(byte*) D018 +(byte*) D018#0 +(byte[]) FONT_HEX_PROTO +(byte[]) FONT_HEX_PROTO#0 +(byte*) HEAP_START +(byte*) HEAP_START#0 +(byte) NUM_SQUARES +(byte) NUM_SQUARES#0 +(byte) NUM_SQUARES#1 +(byte) NUM_SQUARES#10 +(byte) NUM_SQUARES#11 +(byte) NUM_SQUARES#12 +(byte) NUM_SQUARES#13 +(byte) NUM_SQUARES#14 +(byte) NUM_SQUARES#15 +(byte) NUM_SQUARES#16 +(byte) NUM_SQUARES#17 +(byte) NUM_SQUARES#18 +(byte) NUM_SQUARES#19 +(byte) NUM_SQUARES#2 +(byte) NUM_SQUARES#20 +(byte) NUM_SQUARES#21 +(byte) NUM_SQUARES#22 +(byte) NUM_SQUARES#3 +(byte) NUM_SQUARES#4 +(byte) NUM_SQUARES#5 +(byte) NUM_SQUARES#6 +(byte) NUM_SQUARES#7 +(byte) NUM_SQUARES#8 +(byte) NUM_SQUARES#9 +(byte*) SCREEN +(byte*) SCREEN#0 +(const byte) SIZEOF_WORD = (byte) 2 +(word*) SQUARES +(word*) SQUARES#0 +(word*) SQUARES#1 +(word*) SQUARES#10 +(word*) SQUARES#11 +(word*) SQUARES#12 +(word*) SQUARES#13 +(word*) SQUARES#14 +(word*) SQUARES#15 +(word*) SQUARES#16 +(word*) SQUARES#17 +(word*) SQUARES#18 +(word*) SQUARES#19 +(word*) SQUARES#2 +(word*) SQUARES#20 +(word*) SQUARES#21 +(word*) SQUARES#22 +(word*) SQUARES#23 +(word*) SQUARES#24 +(word*) SQUARES#25 +(word*) SQUARES#26 +(word*) SQUARES#27 +(word*) SQUARES#28 +(word*) SQUARES#29 +(word*) SQUARES#3 +(word*) SQUARES#30 +(word*) SQUARES#31 +(word*) SQUARES#4 +(word*) SQUARES#5 +(word*) SQUARES#6 +(word*) SQUARES#7 +(word*) SQUARES#8 +(word*) SQUARES#9 +(word*()) bsearch16u((word) bsearch16u::key , (word*) bsearch16u::items , (byte) bsearch16u::num) +(bool~) bsearch16u::$0 +(word*~) bsearch16u::$1 +(signed word~) bsearch16u::$10 +(bool~) bsearch16u::$11 +(bool~) bsearch16u::$12 +(bool~) bsearch16u::$13 +(bool~) bsearch16u::$14 +(word*~) bsearch16u::$15 +(byte~) bsearch16u::$16 +(number~) bsearch16u::$17 +(number~) bsearch16u::$18 +(word*~) bsearch16u::$2 +(word*~) bsearch16u::$3 +(word*~) bsearch16u::$4 +(bool~) bsearch16u::$5 +(byte~) bsearch16u::$6 +(word*~) bsearch16u::$7 +(signed word~) bsearch16u::$8 +(signed word~) bsearch16u::$9 +(label) bsearch16u::@1 +(label) bsearch16u::@10 +(label) bsearch16u::@13 +(label) bsearch16u::@15 +(label) bsearch16u::@2 +(label) bsearch16u::@3 +(label) bsearch16u::@6 +(label) bsearch16u::@7 +(label) bsearch16u::@8 +(label) bsearch16u::@9 +(label) bsearch16u::@return +(word*) bsearch16u::items +(word*) bsearch16u::items#0 +(word*) bsearch16u::items#1 +(word*) bsearch16u::items#2 +(word*) bsearch16u::items#3 +(word*) bsearch16u::items#4 +(word*) bsearch16u::items#5 +(word*) bsearch16u::items#6 +(word*) bsearch16u::items#7 +(word*) bsearch16u::items#8 +(word*) bsearch16u::items#9 +(word) bsearch16u::key +(word) bsearch16u::key#0 +(word) bsearch16u::key#1 +(word) bsearch16u::key#2 +(word) bsearch16u::key#3 +(word) bsearch16u::key#4 +(word) bsearch16u::key#5 +(word) bsearch16u::key#6 +(word) bsearch16u::key#7 +(byte) bsearch16u::num +(byte) bsearch16u::num#0 +(byte) bsearch16u::num#1 +(byte) bsearch16u::num#2 +(byte) bsearch16u::num#3 +(byte) bsearch16u::num#4 +(byte) bsearch16u::num#5 +(byte) bsearch16u::num#6 +(byte) bsearch16u::num#7 +(byte) bsearch16u::num#8 +(word*) bsearch16u::pivot +(word*) bsearch16u::pivot#0 +(word*) bsearch16u::pivot#1 +(word*) bsearch16u::pivot#2 +(word*) bsearch16u::pivot#3 +(signed word) bsearch16u::result +(signed word) bsearch16u::result#0 +(signed word) bsearch16u::result#1 +(word*) bsearch16u::return +(word*) bsearch16u::return#0 +(word*) bsearch16u::return#1 +(word*) bsearch16u::return#2 +(word*) bsearch16u::return#3 +(word*) bsearch16u::return#4 +(word*) bsearch16u::return#5 +(byte*) heap_head +(byte*) heap_head#0 +(byte*) heap_head#1 +(byte*) heap_head#10 +(byte*) heap_head#11 +(byte*) heap_head#12 +(byte*) heap_head#13 +(byte*) heap_head#14 +(byte*) heap_head#15 +(byte*) heap_head#16 +(byte*) heap_head#17 +(byte*) heap_head#18 +(byte*) heap_head#19 +(byte*) heap_head#2 +(byte*) heap_head#20 +(byte*) heap_head#21 +(byte*) heap_head#22 +(byte*) heap_head#23 +(byte*) heap_head#24 +(byte*) heap_head#25 +(byte*) heap_head#26 +(byte*) heap_head#27 +(byte*) heap_head#28 +(byte*) heap_head#29 +(byte*) heap_head#3 +(byte*) heap_head#30 +(byte*) heap_head#31 +(byte*) heap_head#32 +(byte*) heap_head#33 +(byte*) heap_head#34 +(byte*) heap_head#35 +(byte*) heap_head#36 +(byte*) heap_head#37 +(byte*) heap_head#4 +(byte*) heap_head#5 +(byte*) heap_head#6 +(byte*) heap_head#7 +(byte*) heap_head#8 +(byte*) heap_head#9 +(void()) init_font_hex((byte*) init_font_hex::charset) +(byte~) init_font_hex::$0 +(byte~) init_font_hex::$1 +(byte~) init_font_hex::$2 +(bool~) init_font_hex::$3 +(bool~) init_font_hex::$4 +(bool~) init_font_hex::$5 +(label) init_font_hex::@1 +(label) init_font_hex::@2 +(label) init_font_hex::@3 +(label) init_font_hex::@4 +(label) init_font_hex::@5 +(label) init_font_hex::@return +(byte) init_font_hex::c +(byte) init_font_hex::c#0 +(byte) init_font_hex::c#1 +(byte) init_font_hex::c#2 +(byte) init_font_hex::c#3 +(byte) init_font_hex::c#4 +(byte) init_font_hex::c#5 +(byte) init_font_hex::c#6 +(byte) init_font_hex::c1 +(byte) init_font_hex::c1#0 +(byte) init_font_hex::c1#1 +(byte) init_font_hex::c1#2 +(byte) init_font_hex::c1#3 +(byte) init_font_hex::c1#4 +(byte*) init_font_hex::charset +(byte*) init_font_hex::charset#0 +(byte*) init_font_hex::charset#1 +(byte*) init_font_hex::charset#2 +(byte*) init_font_hex::charset#3 +(byte*) init_font_hex::charset#4 +(byte*) init_font_hex::charset#5 +(byte*) init_font_hex::charset#6 +(byte*) init_font_hex::charset#7 +(byte) init_font_hex::i +(byte) init_font_hex::i#0 +(byte) init_font_hex::i#1 +(byte) init_font_hex::i#2 +(byte) init_font_hex::idx +(byte) init_font_hex::idx#0 +(byte) init_font_hex::idx#1 +(byte) init_font_hex::idx#2 +(byte) init_font_hex::idx#3 +(byte) init_font_hex::idx#4 +(byte) init_font_hex::idx#5 +(byte) init_font_hex::idx#6 +(byte*) init_font_hex::proto_hi +(byte*) init_font_hex::proto_hi#0 +(byte*) init_font_hex::proto_hi#1 +(byte*) init_font_hex::proto_hi#2 +(byte*) init_font_hex::proto_hi#3 +(byte*) init_font_hex::proto_hi#4 +(byte*) init_font_hex::proto_hi#5 +(byte*) init_font_hex::proto_hi#6 +(byte*) init_font_hex::proto_lo +(byte*) init_font_hex::proto_lo#0 +(byte*) init_font_hex::proto_lo#1 +(byte*) init_font_hex::proto_lo#2 +(byte*) init_font_hex::proto_lo#3 +(byte*) init_font_hex::proto_lo#4 +(void()) init_squares() +(byte~) init_squares::$0 +(byte*~) init_squares::$1 +(number~) init_squares::$2 +(number~) init_squares::$3 +(number~) init_squares::$4 +(bool~) init_squares::$5 +(label) init_squares::@1 +(label) init_squares::@3 +(label) init_squares::@return +(byte) init_squares::i +(byte) init_squares::i#0 +(byte) init_squares::i#1 +(byte) init_squares::i#2 +(word) init_squares::sqr +(word) init_squares::sqr#0 +(word) init_squares::sqr#1 +(word) init_squares::sqr#2 +(word*) init_squares::squares +(word*) init_squares::squares#0 +(word*) init_squares::squares#1 +(word*) init_squares::squares#2 +(void()) main() +(byte~) main::$1 +(word~) main::$10 +(number~) main::$11 +(bool~) main::$12 +(number~) main::$13 +(number~) main::$14 +(number~) main::$15 +(number~) main::$16 +(number~) main::$17 +(word~) main::$18 +(word~) main::$19 +(byte~) main::$20 +(bool~) main::$21 +(bool~) main::$22 +(number~) main::$3 +(bool~) main::$4 +(number~) main::$5 +(number~) main::$6 +(number~) main::$7 +(number~) main::$8 +(number~) main::$9 +(label) main::@1 +(label) main::@11 +(label) main::@15 +(label) main::@16 +(label) main::@17 +(label) main::@18 +(label) main::@19 +(label) main::@2 +(label) main::@20 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@8 +(label) main::@return +(byte) main::d +(byte) main::d#0 +(word) main::ds +(word) main::ds#0 +(byte*) main::screen +(byte*) main::screen#0 +(byte*) main::screen#1 +(byte*) main::screen#10 +(byte*) main::screen#11 +(byte*) main::screen#12 +(byte*) main::screen#13 +(byte*) main::screen#2 +(byte*) main::screen#3 +(byte*) main::screen#4 +(byte*) main::screen#5 +(byte*) main::screen#6 +(byte*) main::screen#7 +(byte*) main::screen#8 +(byte*) main::screen#9 +(label) main::toD0181 +(word~) main::toD0181_$0 +(word~) main::toD0181_$0#0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$1#0 +(number~) main::toD0181_$2 +(number~) main::toD0181_$2#0 +(number~) main::toD0181_$3 +(number~) main::toD0181_$3#0 +(word~) main::toD0181_$4 +(word~) main::toD0181_$4#0 +(byte~) main::toD0181_$5 +(byte~) main::toD0181_$5#0 +(number~) main::toD0181_$6 +(number~) main::toD0181_$6#0 +(number~) main::toD0181_$7 +(number~) main::toD0181_$7#0 +(number~) main::toD0181_$8 +(number~) main::toD0181_$8#0 +(label) main::toD0181_@return +(byte*) main::toD0181_gfx +(byte*) main::toD0181_gfx#0 +(byte*) main::toD0181_gfx#1 +(byte) main::toD0181_return +(byte) main::toD0181_return#0 +(byte) main::toD0181_return#1 +(byte) main::toD0181_return#2 +(byte) main::toD0181_return#3 +(byte*) main::toD0181_screen +(byte*) main::toD0181_screen#0 +(byte*) main::toD0181_screen#1 +(byte) main::x +(byte) main::x#0 +(byte) main::x#1 +(byte) main::x#2 +(byte) main::x#3 +(byte) main::x#4 +(byte) main::x#5 +(byte) main::x#6 +(byte) main::x#7 +(byte) main::x2 +(byte) main::x2#0 +(byte) main::x2#1 +(byte) main::x2#2 +(byte) main::xd +(byte) main::xd#0 +(word) main::xds +(word) main::xds#0 +(byte) main::y +(byte) main::y#0 +(byte) main::y#1 +(byte) main::y#10 +(byte) main::y#11 +(byte) main::y#12 +(byte) main::y#13 +(byte) main::y#2 +(byte) main::y#3 +(byte) main::y#4 +(byte) main::y#5 +(byte) main::y#6 +(byte) main::y#7 +(byte) main::y#8 +(byte) main::y#9 +(byte) main::y2 +(byte) main::y2#0 +(byte) main::y2#1 +(byte) main::y2#2 +(byte) main::yd +(byte) main::yd#0 +(word) main::yds +(word) main::yds#0 +(word) main::yds#1 +(word) main::yds#2 +(word) main::yds#3 +(word) main::yds#4 +(word) main::yds#5 +(word) main::yds#6 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::mem#0 +(byte*) malloc::return +(byte*) malloc::return#0 +(byte*) malloc::return#1 +(byte*) malloc::return#2 +(byte*) malloc::return#3 +(byte*) malloc::return#4 +(word) malloc::size +(word) malloc::size#0 +(word) malloc::size#1 +(word()) sqr((byte) sqr::val) +(byte~) sqr::$0 +(label) sqr::@return +(word) sqr::return +(word) sqr::return#0 +(word) sqr::return#1 +(word) sqr::return#2 +(word) sqr::return#3 +(word) sqr::return#4 +(word) sqr::return#5 +(word) sqr::return#6 +(byte) sqr::val +(byte) sqr::val#0 +(byte) sqr::val#1 +(byte) sqr::val#2 +(byte()) sqrt((word) sqrt::val) +(word*~) sqrt::$0 +(byte*~) sqrt::$1 +(byte*~) sqrt::$2 +(word~) sqrt::$3 +(byte~) sqrt::$4 +(number~) sqrt::$5 +(label) sqrt::@2 +(label) sqrt::@return +(word*) sqrt::found +(word*) sqrt::found#0 +(byte) sqrt::return +(byte) sqrt::return#0 +(byte) sqrt::return#1 +(byte) sqrt::return#2 +(byte) sqrt::return#3 +(byte) sqrt::return#4 +(byte) sqrt::sqr1 +(byte) sqrt::sqr1#0 +(word) sqrt::val +(word) sqrt::val#0 +(word) sqrt::val#1 + +Adding number conversion cast (unumber) 0 in (byte) init_font_hex::idx#0 ← (number) 0 +Adding number conversion cast (unumber) 0 in *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#0) ← (number) 0 +Adding number conversion cast (unumber) 4 in (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#2 + (byte) init_font_hex::i#2) << (number) 4 +Adding number conversion cast (unumber) 1 in (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#2 + (byte) init_font_hex::i#2) << (number) 1 +Adding number conversion cast (unumber) 0 in *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#6) ← (number) 0 +Adding number conversion cast (unumber) 0 in *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#3) ← (number) 0 +Adding number conversion cast (unumber) 5 in (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#3 + (number) 5 +Adding number conversion cast (unumber) 8 in (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#4 + (number) 8 +Adding number conversion cast (unumber) 5 in (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#3 + (number) 5 +Adding number conversion cast (unumber) $3fff in (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (number) $3fff +Adding number conversion cast (unumber) main::toD0181_$1#0 in (number~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (unumber)(number) $3fff +Adding number conversion cast (unumber) 4 in (number~) main::toD0181_$2#0 ← (unumber~) main::toD0181_$1#0 * (number) 4 +Adding number conversion cast (unumber) main::toD0181_$2#0 in (number~) main::toD0181_$2#0 ← (unumber~) main::toD0181_$1#0 * (unumber)(number) 4 +Adding number conversion cast (unumber) main::toD0181_$3#0 in (number~) main::toD0181_$3#0 ← > (unumber~) main::toD0181_$2#0 +Adding number conversion cast (unumber) 4 in (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (number) 4 +Adding number conversion cast (unumber) main::toD0181_$6#0 in (number~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (unumber)(number) 4 +Adding number conversion cast (unumber) $f in (number~) main::toD0181_$7#0 ← (unumber~) main::toD0181_$6#0 & (number) $f +Adding number conversion cast (unumber) main::toD0181_$7#0 in (number~) main::toD0181_$7#0 ← (unumber~) main::toD0181_$6#0 & (unumber)(number) $f +Adding number conversion cast (unumber) main::toD0181_$8#0 in (number~) main::toD0181_$8#0 ← (unumber~) main::toD0181_$3#0 | (unumber~) main::toD0181_$7#0 +Adding number conversion cast (unumber) $30 in (byte) NUM_SQUARES#0 ← (number) $30 +Adding number conversion cast (unumber) 2 in (number~) main::$3 ← (byte) main::y#2 * (number) 2 +Adding number conversion cast (unumber) main::$3 in (number~) main::$3 ← (byte) main::y#2 * (unumber)(number) 2 +Adding number conversion cast (unumber) $18 in (bool~) main::$4 ← (byte) main::y2#0 >= (number) $18 +Adding number conversion cast (unumber) $18 in (number~) main::$7 ← (byte) main::y2#1 - (number) $18 +Adding number conversion cast (unumber) main::$7 in (number~) main::$7 ← (byte) main::y2#1 - (unumber)(number) $18 +Adding number conversion cast (unumber) main::$8 in (number~) main::$8 ← (unumber~) main::$7 +Adding number conversion cast (unumber) $18 in (number~) main::$5 ← (number) $18 - (byte) main::y2#2 +Adding number conversion cast (unumber) main::$5 in (number~) main::$5 ← (unumber)(number) $18 - (byte) main::y2#2 +Adding number conversion cast (unumber) main::$6 in (number~) main::$6 ← (unumber~) main::$5 +Adding number conversion cast (unumber) main::$9 in (byte*) heap_head#34 ← phi( main::@2/(byte*) heap_head#35 main::@3/(byte*) heap_head#36 ) + (byte) main::y#11 ← phi( main::@2/(byte) main::y#12 main::@3/(byte) main::y#13 ) + (byte) NUM_SQUARES#18 ← phi( main::@2/(byte) NUM_SQUARES#19 main::@3/(byte) NUM_SQUARES#20 ) + (byte*) main::screen#9 ← phi( main::@2/(byte*) main::screen#10 main::@3/(byte*) main::screen#11 ) + (word*) SQUARES#16 ← phi( main::@2/(word*) SQUARES#21 main::@3/(word*) SQUARES#22 ) + (number~) main::$9 ← phi( main::@2/(unumber~) main::$8 main::@3/(unumber~) main::$6 ) +Adding number conversion cast (unumber) 2 in (number~) main::$11 ← (byte) main::x#2 * (number) 2 +Adding number conversion cast (unumber) main::$11 in (number~) main::$11 ← (byte) main::x#2 * (unumber)(number) 2 +Adding number conversion cast (unumber) $27 in (bool~) main::$12 ← (byte) main::x2#0 >= (number) $27 +Adding number conversion cast (unumber) $27 in (number~) main::$15 ← (byte) main::x2#1 - (number) $27 +Adding number conversion cast (unumber) main::$15 in (number~) main::$15 ← (byte) main::x2#1 - (unumber)(number) $27 +Adding number conversion cast (unumber) main::$16 in (number~) main::$16 ← (unumber~) main::$15 +Adding number conversion cast (unumber) $27 in (number~) main::$13 ← (number) $27 - (byte) main::x2#2 +Adding number conversion cast (unumber) main::$13 in (number~) main::$13 ← (unumber)(number) $27 - (byte) main::x2#2 +Adding number conversion cast (unumber) main::$14 in (number~) main::$14 ← (unumber~) main::$13 +Adding number conversion cast (unumber) main::$17 in (byte*) heap_head#28 ← phi( main::@6/(byte*) heap_head#30 main::@7/(byte*) heap_head#31 ) + (byte) main::y#6 ← phi( main::@6/(byte) main::y#7 main::@7/(byte) main::y#8 ) + (byte) NUM_SQUARES#12 ← phi( main::@6/(byte) NUM_SQUARES#14 main::@7/(byte) NUM_SQUARES#15 ) + (byte) main::x#5 ← phi( main::@6/(byte) main::x#6 main::@7/(byte) main::x#7 ) + (byte*) main::screen#4 ← phi( main::@6/(byte*) main::screen#5 main::@7/(byte*) main::screen#6 ) + (word*) SQUARES#17 ← phi( main::@6/(word*) SQUARES#23 main::@7/(word*) SQUARES#24 ) + (word) main::yds#2 ← phi( main::@6/(word) main::yds#3 main::@7/(word) main::yds#4 ) + (number~) main::$17 ← phi( main::@6/(unumber~) main::$16 main::@7/(unumber~) main::$14 ) +Adding number conversion cast (unumber) $ff in (byte) NUM_SQUARES#2 ← (number) $ff +Adding number conversion cast (unumber) 0 in (word) init_squares::sqr#0 ← (number) 0 +Adding number conversion cast (unumber) 1 in (number~) init_squares::$2 ← (byte) NUM_SQUARES#6 - (number) 1 +Adding number conversion cast (unumber) init_squares::$2 in (number~) init_squares::$2 ← (byte) NUM_SQUARES#6 - (unumber)(number) 1 +Adding number conversion cast (unumber) 2 in (number~) init_squares::$3 ← (byte) init_squares::i#2 * (number) 2 +Adding number conversion cast (unumber) init_squares::$3 in (number~) init_squares::$3 ← (byte) init_squares::i#2 * (unumber)(number) 2 +Adding number conversion cast (unumber) 1 in (number~) init_squares::$4 ← (unumber~) init_squares::$3 + (number) 1 +Adding number conversion cast (unumber) init_squares::$4 in (number~) init_squares::$4 ← (unumber~) init_squares::$3 + (unumber)(number) 1 +Adding number conversion cast (unumber) 2 in (number~) sqrt::$5 ← (byte~) sqrt::$4 / (number) 2 +Adding number conversion cast (unumber) sqrt::$5 in (number~) sqrt::$5 ← (byte~) sqrt::$4 / (unumber)(number) 2 +Adding number conversion cast (unumber) 0 in (bool~) bsearch16u::$5 ← (byte) bsearch16u::num#3 > (number) 0 +Adding number conversion cast (unumber) 1 in (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#4 >> (number) 1 +Adding number conversion cast (snumber) 0 in (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (number) 0 +Adding number conversion cast (unumber) 1 in (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (number) 1 +Adding number conversion cast (unumber) 1 in (number~) bsearch16u::$17 ← (number) 1 * (const byte) SIZEOF_WORD +Adding number conversion cast (unumber) bsearch16u::$17 in (number~) bsearch16u::$17 ← (unumber)(number) 1 * (const byte) SIZEOF_WORD +Adding number conversion cast (unumber) 1 in (number~) bsearch16u::$18 ← (number) 1 * (const byte) SIZEOF_WORD +Adding number conversion cast (unumber) bsearch16u::$18 in (number~) bsearch16u::$18 ← (unumber)(number) 1 * (const byte) SIZEOF_WORD +Successful SSA optimization PassNAddNumberTypeConversions +Adding number conversion cast (byte) to elements in (byte[]) FONT_HEX_PROTO#0 ← { (byte)(number) 2, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 2, (byte)(number) 6, (byte)(number) 2, (byte)(number) 2, (byte)(number) 2, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 4, (byte)(number) 7, (byte)(number) 6, (byte)(number) 1, (byte)(number) 2, (byte)(number) 1, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 1, (byte)(number) 6, (byte)(number) 3, (byte)(number) 4, (byte)(number) 6, (byte)(number) 5, (byte)(number) 2, (byte)(number) 7, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 5, (byte)(number) 2, (byte)(number) 2, (byte)(number) 5, (byte)(number) 3, (byte)(number) 1, (byte)(number) 1, (byte)(number) 2, (byte)(number) 5, (byte)(number) 7, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 5, (byte)(number) 6, (byte)(number) 2, (byte)(number) 5, (byte)(number) 4, (byte)(number) 5, (byte)(number) 2, (byte)(number) 6, (byte)(number) 5, (byte)(number) 5, (byte)(number) 5, (byte)(number) 6, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 4, (byte)(number) 7, (byte)(number) 7, (byte)(number) 4, (byte)(number) 6, (byte)(number) 4, (byte)(number) 4 } +Successful SSA optimization PassNAddArrayNumberTypeConversions +Inlining cast (byte*) HEAP_START#0 ← (byte*)(number) $c000 +Inlining cast (byte*) D018#0 ← (byte*)(number) $d018 +Inlining cast (byte) init_font_hex::idx#0 ← (unumber)(number) 0 +Inlining cast *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#0) ← (unumber)(number) 0 +Inlining cast *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#6) ← (unumber)(number) 0 +Inlining cast *((byte*) init_font_hex::charset#4 + (byte) init_font_hex::idx#3) ← (unumber)(number) 0 +Inlining cast (byte*) CHARSET#0 ← (byte*)(number) $2000 +Inlining cast (byte*) SCREEN#0 ← (byte*)(number) $2800 +Inlining cast (word~) main::toD0181_$0#0 ← (word)(byte*) main::toD0181_screen#1 +Inlining cast (word~) main::toD0181_$4#0 ← (word)(byte*) main::toD0181_gfx#1 +Inlining cast (byte) NUM_SQUARES#0 ← (unumber)(number) $30 +Inlining cast (byte) NUM_SQUARES#2 ← (unumber)(number) $ff +Inlining cast (word) init_squares::sqr#0 ← (unumber)(number) 0 +Inlining cast (byte*~) sqrt::$1 ← (byte*)(word*) sqrt::found#0 +Inlining cast (byte*~) sqrt::$2 ← (byte*)(word*) SQUARES#11 +Inlining cast (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 +Inlining cast (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#1 +Inlining cast (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0) +Successful SSA optimization Pass2InlineCast +Simplifying constant pointer cast (byte*) 49152 +Simplifying constant pointer cast (byte*) 53272 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 4 +Simplifying constant integer cast 1 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 5 +Simplifying constant integer cast 8 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 6 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 7 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 1 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 7 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 1 +Simplifying constant integer cast 6 +Simplifying constant integer cast 3 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 7 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 3 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 7 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 2 +Simplifying constant integer cast 5 +Simplifying constant integer cast 4 +Simplifying constant integer cast 5 +Simplifying constant integer cast 2 +Simplifying constant integer cast 6 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 5 +Simplifying constant integer cast 6 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 4 +Simplifying constant integer cast 7 +Simplifying constant integer cast 7 +Simplifying constant integer cast 4 +Simplifying constant integer cast 6 +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Simplifying constant pointer cast (byte*) 8192 +Simplifying constant pointer cast (byte*) 10240 +Simplifying constant integer cast $3fff +Simplifying constant integer cast 4 +Simplifying constant integer cast 4 +Simplifying constant integer cast $f +Simplifying constant integer cast $30 +Simplifying constant integer cast 2 +Simplifying constant integer cast $18 +Simplifying constant integer cast $18 +Simplifying constant integer cast $18 +Simplifying constant integer cast 2 +Simplifying constant integer cast $27 +Simplifying constant integer cast $27 +Simplifying constant integer cast $27 +Simplifying constant integer cast $ff +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 1 +Simplifying constant integer cast 2 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 0 +Simplifying constant integer cast 0 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Simplifying constant integer cast 1 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) 8 +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (word) $3fff +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) 4 +Finalized unsigned number type (byte) $f +Finalized unsigned number type (byte) $30 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) $18 +Finalized unsigned number type (byte) $18 +Finalized unsigned number type (byte) $18 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) $27 +Finalized unsigned number type (byte) $27 +Finalized unsigned number type (byte) $27 +Finalized unsigned number type (byte) $ff +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 2 +Finalized unsigned number type (byte) 0 +Finalized unsigned number type (byte) 1 +Finalized signed number type (signed byte) 0 +Finalized signed number type (signed byte) 0 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 1 +Finalized unsigned number type (byte) 1 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Inferred type updated to word in (unumber~) main::toD0181_$1#0 ← (word~) main::toD0181_$0#0 & (word) $3fff +Inferred type updated to word in (unumber~) main::toD0181_$2#0 ← (word~) main::toD0181_$1#0 * (byte) 4 +Inferred type updated to byte in (unumber~) main::toD0181_$3#0 ← > (word~) main::toD0181_$2#0 +Inferred type updated to byte in (unumber~) main::toD0181_$6#0 ← (byte~) main::toD0181_$5#0 / (byte) 4 +Inferred type updated to byte in (unumber~) main::toD0181_$7#0 ← (byte~) main::toD0181_$6#0 & (byte) $f +Inferred type updated to byte in (unumber~) main::toD0181_$8#0 ← (byte~) main::toD0181_$3#0 | (byte~) main::toD0181_$7#0 +Inferred type updated to byte in (unumber~) main::$3 ← (byte) main::y#2 * (byte) 2 +Inferred type updated to byte in (unumber~) main::$7 ← (byte) main::y2#1 - (byte) $18 +Inferred type updated to byte in (unumber~) main::$8 ← (byte~) main::$7 +Inferred type updated to byte in (unumber~) main::$5 ← (byte) $18 - (byte) main::y2#2 +Inferred type updated to byte in (unumber~) main::$6 ← (byte~) main::$5 +Inferred type updated to byte for (unumber~) main::$9 +Inferred type updated to byte in (unumber~) main::$11 ← (byte) main::x#2 * (byte) 2 +Inferred type updated to byte in (unumber~) main::$15 ← (byte) main::x2#1 - (byte) $27 +Inferred type updated to byte in (unumber~) main::$16 ← (byte~) main::$15 +Inferred type updated to byte in (unumber~) main::$13 ← (byte) $27 - (byte) main::x2#2 +Inferred type updated to byte in (unumber~) main::$14 ← (byte~) main::$13 +Inferred type updated to byte for (unumber~) main::$17 +Inferred type updated to byte in (unumber~) init_squares::$2 ← (byte) NUM_SQUARES#6 - (byte) 1 +Inferred type updated to byte in (unumber~) init_squares::$3 ← (byte) init_squares::i#2 * (byte) 2 +Inferred type updated to byte in (unumber~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 +Inferred type updated to byte in (unumber~) sqrt::$5 ← (byte~) sqrt::$4 / (byte) 2 +Inferred type updated to byte in (unumber~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD +Inferred type updated to byte in (unumber~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD +Inversing boolean not [210] (bool~) bsearch16u::$12 ← (signed word) bsearch16u::result#0 != (signed byte) 0 from [209] (bool~) bsearch16u::$11 ← (signed word) bsearch16u::result#0 == (signed byte) 0 +Inversing boolean not [217] (bool~) bsearch16u::$14 ← (signed word) bsearch16u::result#1 <= (signed byte) 0 from [216] (bool~) bsearch16u::$13 ← (signed word) bsearch16u::result#1 > (signed byte) 0 +Successful SSA optimization Pass2UnaryNotSimplification +Alias (byte*) HEAP_START#0 = (byte*) heap_head#0 (byte*) heap_head#26 (byte*) heap_head#25 (byte*) heap_head#22 (byte*) heap_head#19 +Alias (byte*) malloc::return#0 = (byte*) malloc::mem#0 (byte*) malloc::return#3 (byte*) malloc::return#1 +Alias (byte*) heap_head#1 = (byte*) heap_head#9 (byte*) heap_head#2 +Alias (byte*) init_font_hex::charset#3 = (byte*) init_font_hex::charset#4 +Alias (byte) init_font_hex::idx#2 = (byte) init_font_hex::idx#6 +Alias (byte*) init_font_hex::proto_lo#2 = (byte*) init_font_hex::proto_lo#3 +Alias (byte) init_font_hex::c1#2 = (byte) init_font_hex::c1#3 +Alias (byte*) init_font_hex::proto_hi#2 = (byte*) init_font_hex::proto_hi#5 (byte*) init_font_hex::proto_hi#3 +Alias (byte) init_font_hex::c#2 = (byte) init_font_hex::c#3 (byte) init_font_hex::c#4 +Alias (byte*) init_font_hex::charset#0 = (byte*) init_font_hex::charset#7 +Alias (byte*) heap_head#16 = (byte*) heap_head#27 (byte*) heap_head#29 (byte*) heap_head#23 (byte*) heap_head#20 +Alias (word*) SQUARES#13 = (word*) SQUARES#29 (word*) SQUARES#31 (word*) SQUARES#26 (word*) SQUARES#20 +Alias (byte*) main::toD0181_screen#0 = (byte*) main::toD0181_screen#1 +Alias (byte*) main::toD0181_gfx#0 = (byte*) main::toD0181_gfx#1 +Alias (byte) main::toD0181_return#0 = (byte~) main::toD0181_$8#0 (byte) main::toD0181_return#2 (byte) main::toD0181_return#1 (byte) main::toD0181_return#3 (byte~) main::$1 +Alias (byte) NUM_SQUARES#0 = (byte) NUM_SQUARES#22 +Alias (byte*) heap_head#10 = (byte*) heap_head#3 +Alias (word*) SQUARES#0 = (word*) SQUARES#6 +Alias (byte) main::y2#0 = (byte~) main::$3 (byte) main::y2#1 (byte) main::y2#2 +Alias (word*) SQUARES#21 = (word*) SQUARES#27 (word*) SQUARES#22 +Alias (byte*) main::screen#10 = (byte*) main::screen#12 (byte*) main::screen#11 +Alias (byte) NUM_SQUARES#19 = (byte) NUM_SQUARES#21 (byte) NUM_SQUARES#20 +Alias (byte) main::y#12 = (byte) main::y#2 (byte) main::y#13 +Alias (byte*) heap_head#35 = (byte*) heap_head#37 (byte*) heap_head#36 +Alias (byte~) main::$8 = (byte~) main::$7 +Alias (byte~) main::$6 = (byte~) main::$5 +Alias (byte) main::yd#0 = (byte~) main::$9 +Alias (word) sqr::return#0 = (word) sqr::return#4 +Alias (word*) SQUARES#16 = (word*) SQUARES#30 +Alias (byte*) main::screen#8 = (byte*) main::screen#9 +Alias (byte) NUM_SQUARES#17 = (byte) NUM_SQUARES#18 +Alias (byte) main::y#10 = (byte) main::y#11 +Alias (byte*) heap_head#33 = (byte*) heap_head#34 +Alias (word) main::yds#0 = (word~) main::$10 +Alias (byte) main::x2#0 = (byte~) main::$11 (byte) main::x2#1 (byte) main::x2#2 +Alias (word) main::yds#3 = (word) main::yds#5 (word) main::yds#4 +Alias (word*) SQUARES#23 = (word*) SQUARES#28 (word*) SQUARES#24 +Alias (byte*) main::screen#5 = (byte*) main::screen#7 (byte*) main::screen#6 +Alias (byte) main::x#2 = (byte) main::x#6 (byte) main::x#7 +Alias (byte) NUM_SQUARES#14 = (byte) NUM_SQUARES#16 (byte) NUM_SQUARES#15 +Alias (byte) main::y#7 = (byte) main::y#9 (byte) main::y#8 +Alias (byte*) heap_head#30 = (byte*) heap_head#32 (byte*) heap_head#31 +Alias (byte~) main::$16 = (byte~) main::$15 +Alias (byte~) main::$14 = (byte~) main::$13 +Alias (byte) main::xd#0 = (byte~) main::$17 +Alias (word) sqr::return#1 = (word) sqr::return#5 +Alias (word) main::yds#1 = (word) main::yds#2 (word) main::yds#6 +Alias (byte*) main::screen#2 = (byte*) main::screen#3 (byte*) main::screen#4 +Alias (byte) main::x#3 = (byte) main::x#4 (byte) main::x#5 +Alias (word*) SQUARES#1 = (word*) SQUARES#18 (word*) SQUARES#17 (word*) SQUARES#25 (word*) SQUARES#14 (word*) SQUARES#7 +Alias (byte) NUM_SQUARES#1 = (byte) NUM_SQUARES#10 (byte) NUM_SQUARES#12 (byte) NUM_SQUARES#13 (byte) NUM_SQUARES#9 (byte) NUM_SQUARES#4 +Alias (byte) main::y#3 = (byte) main::y#5 (byte) main::y#6 (byte) main::y#4 +Alias (byte*) heap_head#11 = (byte*) heap_head#24 (byte*) heap_head#28 (byte*) heap_head#21 (byte*) heap_head#17 (byte*) heap_head#4 +Alias (word) main::xds#0 = (word~) main::$18 +Alias (word) main::ds#0 = (word~) main::$19 +Alias (byte) sqrt::return#0 = (byte) sqrt::return#3 +Alias (byte) main::d#0 = (byte~) main::$20 +Alias (byte*) main::screen#1 = (byte*) main::screen#13 +Alias (word) malloc::size#0 = (byte~) init_squares::$0 +Alias (byte*) malloc::return#2 = (byte*) malloc::return#4 +Alias (byte) NUM_SQUARES#5 = (byte) NUM_SQUARES#6 +Alias (byte*) heap_head#12 = (byte*) heap_head#5 +Alias (word*) SQUARES#3 = (byte*~) init_squares::$1 +Alias (byte*) heap_head#13 = (byte*) heap_head#18 (byte*) heap_head#6 +Alias (word*) SQUARES#15 = (word*) SQUARES#8 (word*) SQUARES#4 +Alias (word) sqr::return#2 = (word) sqr::return#6 (word) sqr::return#3 +Alias (word*) bsearch16u::return#0 = (word*) bsearch16u::return#4 +Alias (word*) SQUARES#10 = (word*) SQUARES#11 +Alias (word*) sqrt::found#0 = (word*~) sqrt::$0 +Alias (byte) sqrt::return#1 = (byte) sqrt::sqr1#0 (byte~) sqrt::$5 (byte) sqrt::return#4 (byte) sqrt::return#2 +Alias (byte) bsearch16u::num#3 = (byte) bsearch16u::num#4 (byte) bsearch16u::num#8 (byte) bsearch16u::num#6 +Alias (word*) bsearch16u::items#2 = (word*) bsearch16u::items#6 (word*) bsearch16u::items#3 (word*) bsearch16u::items#9 (word*) bsearch16u::items#4 (word*~) bsearch16u::$3 (word*) bsearch16u::items#5 +Alias (word) bsearch16u::key#1 = (word) bsearch16u::key#3 (word) bsearch16u::key#2 (word) bsearch16u::key#7 (word) bsearch16u::key#6 +Alias (word*) bsearch16u::pivot#0 = (word*~) bsearch16u::$7 (word*) bsearch16u::pivot#3 (word*) bsearch16u::pivot#1 (word*) bsearch16u::return#1 (word*) bsearch16u::pivot#2 +Alias (signed word) bsearch16u::result#0 = (signed word~) bsearch16u::$10 (signed word) bsearch16u::result#1 +Alias (word*) bsearch16u::return#2 = (word*) bsearch16u::return#5 +Alias (word*) bsearch16u::items#1 = (word*~) bsearch16u::$15 +Alias (word*~) bsearch16u::$2 = (word*~) bsearch16u::$1 +Alias (word*) bsearch16u::return#3 = (word*~) bsearch16u::$4 +Alias (byte) NUM_SQUARES#11 = (byte) NUM_SQUARES#2 +Alias (word*) SQUARES#19 = (word*) SQUARES#2 +Alias (byte) NUM_SQUARES#3 = (byte) NUM_SQUARES#8 +Alias (byte*) heap_head#14 = (byte*) heap_head#7 +Alias (word*) SQUARES#12 = (word*) SQUARES#5 +Successful SSA optimization Pass2AliasElimination +Alias (word*) SQUARES#16 = (word*) SQUARES#21 +Alias (byte*) main::screen#10 = (byte*) main::screen#8 +Alias (byte) NUM_SQUARES#17 = (byte) NUM_SQUARES#19 +Alias (byte) main::y#10 = (byte) main::y#12 +Alias (byte*) heap_head#33 = (byte*) heap_head#35 +Alias (word) main::yds#1 = (word) main::yds#3 +Alias (word*) SQUARES#1 = (word*) SQUARES#23 +Alias (byte*) main::screen#2 = (byte*) main::screen#5 +Alias (byte) main::x#2 = (byte) main::x#3 +Alias (byte) NUM_SQUARES#1 = (byte) NUM_SQUARES#14 +Alias (byte) main::y#3 = (byte) main::y#7 +Alias (byte*) heap_head#11 = (byte*) heap_head#30 +Alias (word) bsearch16u::key#1 = (word) bsearch16u::key#5 +Successful SSA optimization Pass2AliasElimination +Self Phi Eliminated (byte*) init_font_hex::proto_hi#2 +Self Phi Eliminated (byte*) init_font_hex::proto_lo#2 +Self Phi Eliminated (byte*) init_font_hex::charset#3 +Self Phi Eliminated (byte) init_font_hex::c1#2 +Self Phi Eliminated (byte) init_font_hex::c#2 +Self Phi Eliminated (word) main::yds#1 +Self Phi Eliminated (word*) SQUARES#1 +Self Phi Eliminated (byte) NUM_SQUARES#1 +Self Phi Eliminated (byte) main::y#3 +Self Phi Eliminated (byte*) heap_head#11 +Self Phi Eliminated (byte*) heap_head#13 +Self Phi Eliminated (word*) SQUARES#15 +Self Phi Eliminated (word) bsearch16u::key#1 +Successful SSA optimization Pass2SelfPhiElimination +Identical Phi Values (byte*) heap_head#8 (byte*) heap_head#15 +Identical Phi Values (word) malloc::size#1 (word) malloc::size#0 +Identical Phi Values (byte*) init_font_hex::charset#6 (byte*) init_font_hex::charset#1 +Identical Phi Values (byte*) init_font_hex::proto_hi#2 (byte*) init_font_hex::proto_hi#4 +Identical Phi Values (byte*) init_font_hex::proto_lo#2 (byte*) init_font_hex::proto_lo#4 +Identical Phi Values (byte*) init_font_hex::charset#3 (byte*) init_font_hex::charset#2 +Identical Phi Values (byte) init_font_hex::c1#2 (byte) init_font_hex::c1#4 +Identical Phi Values (byte) init_font_hex::c#2 (byte) init_font_hex::c#5 +Identical Phi Values (byte*) heap_head#16 (byte*) HEAP_START#0 +Identical Phi Values (word*) SQUARES#13 (word*) SQUARES#19 +Identical Phi Values (byte*) heap_head#10 (byte*) heap_head#13 +Identical Phi Values (word*) SQUARES#0 (word*) SQUARES#15 +Identical Phi Values (word) main::yds#1 (word) main::yds#0 +Identical Phi Values (word*) SQUARES#1 (word*) SQUARES#16 +Identical Phi Values (byte) NUM_SQUARES#1 (byte) NUM_SQUARES#17 +Identical Phi Values (byte) main::y#3 (byte) main::y#10 +Identical Phi Values (byte*) heap_head#11 (byte*) heap_head#33 +Identical Phi Values (byte) NUM_SQUARES#5 (byte) NUM_SQUARES#0 +Identical Phi Values (byte*) heap_head#15 (byte*) heap_head#16 +Identical Phi Values (byte*) heap_head#12 (byte*) heap_head#1 +Identical Phi Values (byte*) heap_head#13 (byte*) heap_head#12 +Identical Phi Values (word*) SQUARES#15 (word*) SQUARES#3 +Identical Phi Values (word) sqrt::val#1 (word) sqrt::val#0 +Identical Phi Values (word*) SQUARES#10 (word*) SQUARES#1 +Identical Phi Values (byte) NUM_SQUARES#7 (byte) NUM_SQUARES#1 +Identical Phi Values (byte) bsearch16u::num#7 (byte) bsearch16u::num#0 +Identical Phi Values (word*) bsearch16u::items#7 (word*) bsearch16u::items#0 +Identical Phi Values (word) bsearch16u::key#4 (word) bsearch16u::key#0 +Identical Phi Values (word) bsearch16u::key#1 (word) bsearch16u::key#4 +Identical Phi Values (byte) NUM_SQUARES#3 (byte) NUM_SQUARES#1 +Identical Phi Values (byte*) heap_head#14 (byte*) heap_head#11 +Identical Phi Values (word*) SQUARES#12 (word*) SQUARES#1 +Successful SSA optimization Pass2IdenticalPhiElimination +Identical Phi Values (word*) SQUARES#9 (word*) SQUARES#16 +Successful SSA optimization Pass2IdenticalPhiElimination +Simple Condition (bool~) init_font_hex::$3 [31] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 +Simple Condition (bool~) init_font_hex::$4 [41] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 +Simple Condition (bool~) init_font_hex::$5 [46] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 +Simple Condition (bool~) main::$4 [85] if((byte) main::y2#0>=(byte) $18) goto main::@2 +Simple Condition (bool~) main::$12 [105] if((byte) main::x2#0>=(byte) $27) goto main::@6 +Simple Condition (bool~) main::$21 [132] if((byte) main::x#1!=rangelast(0,$27)) goto main::@5 +Simple Condition (bool~) main::$22 [136] if((byte) main::y#1!=rangelast(0,$18)) goto main::@1 +Simple Condition (bool~) init_squares::$5 [166] if((byte) init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1 +Simple Condition (bool~) bsearch16u::$5 [199] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@7 +Simple Condition (bool~) bsearch16u::$12 [211] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@9 +Simple Condition (bool~) bsearch16u::$0 [214] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@1 +Simple Condition (bool~) bsearch16u::$14 [218] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@10 +Successful SSA optimization Pass2ConditionalJumpSimplification +Constant right-side identified [49] (byte[]) FONT_HEX_PROTO#0 ← { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 } +Constant right-side identified [227] (byte~) bsearch16u::$17 ← (byte) 1 * (const byte) SIZEOF_WORD +Constant right-side identified [234] (byte~) bsearch16u::$18 ← (byte) 1 * (const byte) SIZEOF_WORD +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte*) HEAP_START#0 = (byte*) 49152 +Constant (const byte*) D018#0 = (byte*) 53272 +Constant (const byte) init_font_hex::c#0 = 0 +Constant (const byte) init_font_hex::c1#0 = 0 +Constant (const byte) init_font_hex::idx#0 = 0 +Constant (const byte) init_font_hex::i#0 = 0 +Constant (const byte[]) FONT_HEX_PROTO#0 = { 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4 } +Constant (const byte*) CHARSET#0 = (byte*) 8192 +Constant (const byte*) SCREEN#0 = (byte*) 10240 +Constant (const byte) NUM_SQUARES#0 = $30 +Constant (const byte) main::y#0 = 0 +Constant (const byte) main::x#0 = 0 +Constant (const byte) NUM_SQUARES#11 = $ff +Constant (const word*) SQUARES#19 = (word*) 0 +Constant (const word) init_squares::sqr#0 = 0 +Constant (const byte) init_squares::i#0 = 0 +Constant (const byte) bsearch16u::$17 = 1*SIZEOF_WORD +Constant (const byte) bsearch16u::$18 = 1*SIZEOF_WORD +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#0 = HEAP_START#0 +Constant (const byte*) init_font_hex::proto_hi#0 = FONT_HEX_PROTO#0 +Constant (const byte*) init_font_hex::proto_lo#0 = FONT_HEX_PROTO#0 +Constant (const byte*) init_font_hex::charset#1 = CHARSET#0 +Constant (const byte*) main::toD0181_screen#0 = SCREEN#0 +Constant (const byte*) main::toD0181_gfx#0 = CHARSET#0 +Constant (const byte*) main::screen#0 = SCREEN#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const byte*) malloc::return#2 = malloc::return#0 +Successful SSA optimization Pass2ConstantIdentification +Constant (const word*) SQUARES#3 = malloc::return#2 +Successful SSA optimization Pass2ConstantIdentification +Constant (const word*) init_squares::squares#0 = SQUARES#3 +Successful SSA optimization Pass2ConstantIdentification +Constant value identified (word)main::toD0181_screen#0 in [59] (word~) main::toD0181_$0#0 ← (word)(const byte*) main::toD0181_screen#0 +Constant value identified (word)main::toD0181_gfx#0 in [63] (word~) main::toD0181_$4#0 ← (word)(const byte*) main::toD0181_gfx#0 +Successful SSA optimization Pass2ConstantValues +Resolved ranged next value [29] init_font_hex::i#1 ← ++ init_font_hex::i#2 to ++ +Resolved ranged comparison value [31] if(init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 to (number) 5 +Resolved ranged next value [39] init_font_hex::c1#1 ← ++ init_font_hex::c1#4 to ++ +Resolved ranged comparison value [41] if(init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 to (number) $10 +Resolved ranged next value [44] init_font_hex::c#1 ← ++ init_font_hex::c#5 to ++ +Resolved ranged comparison value [46] if(init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 to (number) $10 +Resolved ranged next value [130] main::x#1 ← ++ main::x#2 to ++ +Resolved ranged comparison value [132] if(main::x#1!=rangelast(0,$27)) goto main::@5 to (number) $28 +Resolved ranged next value [134] main::y#1 ← ++ main::y#10 to ++ +Resolved ranged comparison value [136] if(main::y#1!=rangelast(0,$18)) goto main::@1 to (number) $19 +Simplifying expression containing zero init_font_hex::charset#2 in [20] *((byte*) init_font_hex::charset#2 + (const byte) init_font_hex::idx#0) ← (byte) 0 +Successful SSA optimization PassNSimplifyExpressionWithZero +Eliminating unused variable (byte) init_font_hex::idx#4 and assignment [17] (byte) init_font_hex::idx#4 ← ++ (byte) init_font_hex::idx#3 +Eliminating unused variable - keeping the phi block (byte*) heap_head#33 +Eliminating unused constant (const byte) NUM_SQUARES#11 +Eliminating unused constant (const word*) SQUARES#19 +Successful SSA optimization PassNEliminateUnusedVars +Eliminating unused variable (byte*) heap_head#1 and assignment [0] (byte*) heap_head#1 ← (const byte*) HEAP_START#0 + (word) malloc::size#0 +Successful SSA optimization PassNEliminateUnusedVars +Eliminating unused variable (word) malloc::size#0 and assignment [68] (word) malloc::size#0 ← (const byte) NUM_SQUARES#0 * (const byte) SIZEOF_WORD +Successful SSA optimization PassNEliminateUnusedVars +Adding number conversion cast (unumber) 5 in if((byte) init_font_hex::i#1!=(number) 5) goto init_font_hex::@3 +Adding number conversion cast (unumber) $10 in if((byte) init_font_hex::c1#1!=(number) $10) goto init_font_hex::@2 +Adding number conversion cast (unumber) $10 in if((byte) init_font_hex::c#1!=(number) $10) goto init_font_hex::@1 +Adding number conversion cast (unumber) $28 in if((byte) main::x#1!=(number) $28) goto main::@5 +Adding number conversion cast (unumber) $19 in if((byte) main::y#1!=(number) $19) goto main::@1 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast 5 +Simplifying constant integer cast $10 +Simplifying constant integer cast $10 +Simplifying constant integer cast $28 +Simplifying constant integer cast $19 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 5 +Finalized unsigned number type (byte) $10 +Finalized unsigned number type (byte) $10 +Finalized unsigned number type (byte) $28 +Finalized unsigned number type (byte) $19 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Self Phi Eliminated (byte*) init_font_hex::proto_hi#4 +Self Phi Eliminated (byte) init_font_hex::c#5 +Self Phi Eliminated (word*) SQUARES#16 +Self Phi Eliminated (byte) NUM_SQUARES#17 +Successful SSA optimization Pass2SelfPhiElimination +Identical Phi Values (byte*) init_font_hex::proto_hi#4 (byte*) init_font_hex::proto_hi#6 +Identical Phi Values (byte) init_font_hex::c#5 (byte) init_font_hex::c#6 +Identical Phi Values (word*) SQUARES#16 (const word*) SQUARES#3 +Identical Phi Values (byte) NUM_SQUARES#17 (const byte) NUM_SQUARES#0 +Successful SSA optimization Pass2IdenticalPhiElimination +Constant right-side identified [4] (byte) init_font_hex::idx#1 ← ++ (const byte) init_font_hex::idx#0 +Constant right-side identified [69] (byte~) init_squares::$2 ← (const byte) NUM_SQUARES#0 - (byte) 1 +Constant right-side identified [90] (byte*~) sqrt::$2 ← (byte*)(const word*) SQUARES#3 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) init_font_hex::idx#1 = ++init_font_hex::idx#0 +Constant (const word) main::toD0181_$0#0 = (word)main::toD0181_screen#0 +Constant (const word) main::toD0181_$4#0 = (word)main::toD0181_gfx#0 +Constant (const byte) init_squares::$2 = NUM_SQUARES#0-1 +Constant (const word*) bsearch16u::items#0 = SQUARES#3 +Constant (const byte) bsearch16u::num#0 = NUM_SQUARES#0 +Constant (const byte*) sqrt::$2 = (byte*)SQUARES#3 +Successful SSA optimization Pass2ConstantIdentification +Resolved ranged next value [76] init_squares::i#1 ← ++ init_squares::i#2 to ++ +Resolved ranged comparison value [77] if(init_squares::i#1!=rangelast(0,init_squares::$2)) goto init_squares::@1 to (const byte) init_squares::$2+(number) 1 +Adding number conversion cast (unumber) init_squares::$2+1 in if((byte) init_squares::i#1!=(const byte) init_squares::$2+(number) 1) goto init_squares::@1 +Adding number conversion cast (unumber) 1 in if((byte) init_squares::i#1!=(unumber)(const byte) init_squares::$2+(number) 1) goto init_squares::@1 +Successful SSA optimization PassNAddNumberTypeConversions +Simplifying constant integer cast (const byte) init_squares::$2+(unumber)(number) 1 +Simplifying constant integer cast 1 +Successful SSA optimization PassNCastSimplification +Finalized unsigned number type (byte) 1 +Successful SSA optimization PassNFinalizeNumberTypeConversions +Constant right-side identified [24] (word~) main::toD0181_$1#0 ← (const word) main::toD0181_$0#0 & (word) $3fff +Constant right-side identified [27] (byte~) main::toD0181_$5#0 ← > (const word) main::toD0181_$4#0 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const word) main::toD0181_$1#0 = main::toD0181_$0#0&$3fff +Constant (const byte) main::toD0181_$5#0 = >main::toD0181_$4#0 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [24] (word~) main::toD0181_$2#0 ← (const word) main::toD0181_$1#0 * (byte) 4 +Constant right-side identified [26] (byte~) main::toD0181_$6#0 ← (const byte) main::toD0181_$5#0 / (byte) 4 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const word) main::toD0181_$2#0 = main::toD0181_$1#0*4 +Constant (const byte) main::toD0181_$6#0 = main::toD0181_$5#0/4 +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [24] (byte~) main::toD0181_$3#0 ← > (const word) main::toD0181_$2#0 +Constant right-side identified [25] (byte~) main::toD0181_$7#0 ← (const byte) main::toD0181_$6#0 & (byte) $f +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::toD0181_$3#0 = >main::toD0181_$2#0 +Constant (const byte) main::toD0181_$7#0 = main::toD0181_$6#0&$f +Successful SSA optimization Pass2ConstantIdentification +Constant right-side identified [24] (byte) main::toD0181_return#0 ← (const byte) main::toD0181_$3#0 | (const byte) main::toD0181_$7#0 +Successful SSA optimization Pass2ConstantRValueConsolidation +Constant (const byte) main::toD0181_return#0 = main::toD0181_$3#0|main::toD0181_$7#0 +Successful SSA optimization Pass2ConstantIdentification +Inlining Noop Cast [76] (byte*~) sqrt::$1 ← (byte*)(word*) sqrt::found#0 keeping sqrt::found#0 +Inlining Noop Cast [86] (signed word~) bsearch16u::$8 ← (signed word)(word) bsearch16u::key#0 keeping bsearch16u::key#0 +Inlining Noop Cast [87] (signed word~) bsearch16u::$9 ← (signed word)*((word*) bsearch16u::pivot#0) keeping *(bsearch16u::pivot#0) +Successful SSA optimization Pass2NopCastInlining +Rewriting multiplication to use shift [27] (byte) main::y2#0 ← (byte) main::y#10 * (byte) 2 +Rewriting multiplication to use shift [37] (byte) main::x2#0 ← (byte) main::x#2 * (byte) 2 +Rewriting multiplication to use shift [62] (byte~) init_squares::$3 ← (byte) init_squares::i#2 * (byte) 2 +Rewriting multiplication to use shift [69] (byte~) sqr::$0 ← (byte) sqr::val#2 * (const byte) SIZEOF_WORD +Rewriting division to use shift [79] (byte) sqrt::return#1 ← (byte~) sqrt::$4 / (byte) 2 +Rewriting multiplication to use shift [84] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 * (const byte) SIZEOF_WORD +Successful SSA optimization Pass2MultiplyToShiftRewriting +Inlining constant with var siblings (const byte) init_font_hex::c#0 +Inlining constant with var siblings (const byte) init_font_hex::c1#0 +Inlining constant with var siblings (const byte) init_font_hex::idx#0 +Inlining constant with var siblings (const byte) init_font_hex::i#0 +Inlining constant with var siblings (const byte*) init_font_hex::proto_hi#0 +Inlining constant with var siblings (const byte*) init_font_hex::proto_lo#0 +Inlining constant with var siblings (const byte*) init_font_hex::charset#1 +Inlining constant with var siblings (const byte) init_font_hex::idx#1 +Inlining constant with var siblings (const byte) main::y#0 +Inlining constant with var siblings (const byte) main::x#0 +Inlining constant with var siblings (const byte*) main::screen#0 +Inlining constant with var siblings (const word) init_squares::sqr#0 +Inlining constant with var siblings (const byte) init_squares::i#0 +Inlining constant with var siblings (const word*) init_squares::squares#0 +Inlining constant with var siblings (const word*) bsearch16u::items#0 +Inlining constant with var siblings (const byte) bsearch16u::num#0 +Constant inlined main::screen#0 = (const byte*) SCREEN#0 +Constant inlined main::toD0181_screen#0 = (const byte*) SCREEN#0 +Constant inlined main::toD0181_gfx#0 = (const byte*) CHARSET#0 +Constant inlined init_squares::sqr#0 = (byte) 0 +Constant inlined init_squares::squares#0 = (const byte*) HEAP_START#0 +Constant inlined init_font_hex::proto_hi#0 = (const byte[]) FONT_HEX_PROTO#0 +Constant inlined init_font_hex::charset#1 = (const byte*) CHARSET#0 +Constant inlined init_font_hex::c1#0 = (byte) 0 +Constant inlined malloc::return#2 = (const byte*) HEAP_START#0 +Constant inlined malloc::return#0 = (const byte*) HEAP_START#0 +Constant inlined sqrt::$2 = (byte*)(const byte*) HEAP_START#0 +Constant inlined bsearch16u::num#0 = (const byte) NUM_SQUARES#0 +Constant inlined SQUARES#3 = (const byte*) HEAP_START#0 +Constant inlined main::toD0181_$0#0 = (word)(const byte*) SCREEN#0 +Constant inlined main::x#0 = (byte) 0 +Constant inlined main::toD0181_$1#0 = (word)(const byte*) SCREEN#0&(word) $3fff +Constant inlined main::y#0 = (byte) 0 +Constant inlined init_font_hex::i#0 = (byte) 0 +Constant inlined bsearch16u::$17 = (byte) 1*(const byte) SIZEOF_WORD +Constant inlined bsearch16u::$18 = (byte) 1*(const byte) SIZEOF_WORD +Constant inlined bsearch16u::items#0 = (const byte*) HEAP_START#0 +Constant inlined main::toD0181_$6#0 = >(word)(const byte*) CHARSET#0/(byte) 4 +Constant inlined main::toD0181_$7#0 = >(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +Constant inlined init_font_hex::idx#1 = ++(byte) 0 +Constant inlined init_font_hex::idx#0 = (byte) 0 +Constant inlined main::toD0181_$2#0 = (word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4 +Constant inlined init_squares::i#0 = (byte) 0 +Constant inlined main::toD0181_$3#0 = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4 +Constant inlined main::toD0181_$4#0 = (word)(const byte*) CHARSET#0 +Constant inlined main::toD0181_$5#0 = >(word)(const byte*) CHARSET#0 +Constant inlined init_font_hex::proto_lo#0 = (const byte[]) FONT_HEX_PROTO#0 +Constant inlined init_font_hex::c#0 = (byte) 0 +Constant inlined init_squares::$2 = (const byte) NUM_SQUARES#0-(byte) 1 +Successful SSA optimization Pass2ConstantInlining +Simplifying constant integer increment ++0 +Successful SSA optimization Pass2ConstantSimplification +Simplifying constant integer cast (const byte*) HEAP_START#0 +Successful SSA optimization PassNCastSimplification +Added new block during phi lifting init_font_hex::@7(between init_font_hex::@5 and init_font_hex::@1) +Added new block during phi lifting init_font_hex::@8(between init_font_hex::@4 and init_font_hex::@2) +Added new block during phi lifting init_font_hex::@9(between init_font_hex::@3 and init_font_hex::@3) +Added new block during phi lifting main::@21(between main::@11 and main::@1) +Added new block during phi lifting main::@22(between main::@20 and main::@5) +Added new block during phi lifting init_squares::@4(between init_squares::@1 and init_squares::@1) +Added new block during phi lifting bsearch16u::@18(between bsearch16u::@9 and bsearch16u::@10) +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @2 +Adding NOP phi() at start of @7 +Adding NOP phi() at start of @8 +Adding NOP phi() at start of @12 +Adding NOP phi() at start of @13 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::@16 +Adding NOP phi() at start of main::toD0181 +Adding NOP phi() at start of main::toD0181_@return +Adding NOP phi() at start of main::@17 +Adding NOP phi() at start of bsearch16u +Adding NOP phi() at start of init_squares +Adding NOP phi() at start of init_squares::@3 +Adding NOP phi() at start of malloc +Adding NOP phi() at start of init_font_hex +CALL GRAPH +Calls in [] to main:5 +Calls in [main] to init_font_hex:9 init_squares:14 sqr:24 sqr:36 sqrt:41 +Calls in [sqrt] to bsearch16u:60 +Calls in [init_squares] to malloc:100 + +Created 24 initial phi equivalence classes +Coalesced [20] main::yd#2 ← main::$6 +Coalesced [23] sqr::val#3 ← sqr::val#0 +Coalesced [27] main::screen#15 ← main::screen#10 +Coalesced [32] main::xd#2 ← main::$14 +Coalesced [35] sqr::val#4 ← sqr::val#1 +Coalesced [51] main::y#14 ← main::y#1 +Coalesced [52] main::screen#14 ← main::screen#1 +Coalesced [53] main::x#8 ← main::x#1 +Coalesced (already) [54] main::screen#16 ← main::screen#1 +Coalesced [56] main::xd#1 ← main::$16 +Coalesced [58] main::yd#1 ← main::$8 +Coalesced [72] bsearch16u::return#9 ← bsearch16u::$2 +Coalesced [74] bsearch16u::return#7 ← bsearch16u::return#3 +Coalesced [77] bsearch16u::return#8 ← bsearch16u::items#2 +Not coalescing [83] bsearch16u::return#6 ← bsearch16u::pivot#0 +Coalesced [87] bsearch16u::num#10 ← bsearch16u::num#2 +Coalesced [88] bsearch16u::items#11 ← bsearch16u::items#1 +Coalesced [91] bsearch16u::num#9 ← bsearch16u::num#1 +Coalesced [92] bsearch16u::items#10 ← bsearch16u::items#8 +Coalesced [93] bsearch16u::num#11 ← bsearch16u::num#3 +Coalesced (already) [94] bsearch16u::items#12 ← bsearch16u::items#2 +Coalesced [111] init_squares::sqr#3 ← init_squares::sqr#1 +Coalesced [112] init_squares::squares#3 ← init_squares::squares#1 +Coalesced [113] init_squares::i#3 ← init_squares::i#1 +Coalesced [118] init_font_hex::charset#9 ← init_font_hex::charset#5 +Coalesced [140] init_font_hex::charset#8 ← init_font_hex::charset#0 +Coalesced [141] init_font_hex::proto_hi#7 ← init_font_hex::proto_hi#1 +Coalesced [142] init_font_hex::c#7 ← init_font_hex::c#1 +Coalesced (already) [143] init_font_hex::charset#10 ← init_font_hex::charset#0 +Coalesced [144] init_font_hex::proto_lo#5 ← init_font_hex::proto_lo#1 +Coalesced [145] init_font_hex::c1#5 ← init_font_hex::c1#1 +Coalesced [146] init_font_hex::i#3 ← init_font_hex::i#1 +Coalesced [147] init_font_hex::idx#7 ← init_font_hex::idx#2 +Coalesced down to 19 phi equivalence classes +Culled Empty Block (label) @2 +Culled Empty Block (label) @7 +Culled Empty Block (label) @8 +Culled Empty Block (label) @13 +Culled Empty Block (label) main::@16 +Culled Empty Block (label) main::toD0181_@return +Culled Empty Block (label) main::@17 +Culled Empty Block (label) main::@21 +Culled Empty Block (label) main::@22 +Culled Empty Block (label) bsearch16u::@1 +Culled Empty Block (label) bsearch16u::@18 +Culled Empty Block (label) init_squares::@3 +Culled Empty Block (label) init_squares::@4 +Culled Empty Block (label) init_font_hex::@7 +Culled Empty Block (label) init_font_hex::@8 +Culled Empty Block (label) init_font_hex::@9 +Renumbering block @12 to @1 +Renumbering block main::@11 to main::@9 +Renumbering block main::@15 to main::@10 +Renumbering block main::@18 to main::@11 +Renumbering block main::@19 to main::@12 +Renumbering block main::@20 to main::@13 +Renumbering block sqrt::@2 to sqrt::@1 +Renumbering block bsearch16u::@2 to bsearch16u::@1 +Renumbering block bsearch16u::@3 to bsearch16u::@2 +Renumbering block bsearch16u::@6 to bsearch16u::@3 +Renumbering block bsearch16u::@7 to bsearch16u::@4 +Renumbering block bsearch16u::@8 to bsearch16u::@5 +Renumbering block bsearch16u::@9 to bsearch16u::@6 +Renumbering block bsearch16u::@10 to bsearch16u::@7 +Renumbering block bsearch16u::@13 to bsearch16u::@8 +Renumbering block bsearch16u::@15 to bsearch16u::@9 +Adding NOP phi() at start of @begin +Adding NOP phi() at start of @1 +Adding NOP phi() at start of @end +Adding NOP phi() at start of main +Adding NOP phi() at start of main::toD0181 +Adding NOP phi() at start of bsearch16u +Adding NOP phi() at start of init_squares +Adding NOP phi() at start of malloc +Adding NOP phi() at start of init_font_hex + +FINAL CONTROL FLOW GRAPH +@begin: scope:[] from + [0] phi() + to:@1 +@1: scope:[] from @begin + [1] phi() + [2] call main + to:@end +@end: scope:[] from @1 + [3] phi() +main: scope:[main] from @1 + [4] phi() + [5] call init_font_hex + to:main::toD0181 +main::toD0181: scope:[main] from main + [6] phi() + to:main::@10 +main::@10: scope:[main] from main::toD0181 + [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 + [8] call init_squares + to:main::@1 +main::@1: scope:[main] from main::@10 main::@9 + [9] (byte*) main::screen#10 ← phi( main::@9/(byte*) main::screen#1 main::@10/(const byte*) SCREEN#0 ) + [9] (byte) main::y#10 ← phi( main::@9/(byte) main::y#1 main::@10/(byte) 0 ) + [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 + [11] if((byte) main::y2#0>=(byte) $18) goto main::@2 + to:main::@3 +main::@3: scope:[main] from main::@1 + [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 + to:main::@4 +main::@4: scope:[main] from main::@2 main::@3 + [13] (byte) main::yd#0 ← phi( main::@2/(byte~) main::$8 main::@3/(byte~) main::$6 ) + [14] (byte) sqr::val#0 ← (byte) main::yd#0 + [15] call sqr + [16] (word) sqr::return#0 ← (word) sqr::return#2 + to:main::@11 +main::@11: scope:[main] from main::@4 + [17] (word) main::yds#0 ← (word) sqr::return#0 + to:main::@5 +main::@5: scope:[main] from main::@11 main::@13 + [18] (byte*) main::screen#2 ← phi( main::@11/(byte*) main::screen#10 main::@13/(byte*) main::screen#1 ) + [18] (byte) main::x#2 ← phi( main::@11/(byte) 0 main::@13/(byte) main::x#1 ) + [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 + [20] if((byte) main::x2#0>=(byte) $27) goto main::@6 + to:main::@7 +main::@7: scope:[main] from main::@5 + [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 + to:main::@8 +main::@8: scope:[main] from main::@6 main::@7 + [22] (byte) main::xd#0 ← phi( main::@6/(byte~) main::$16 main::@7/(byte~) main::$14 ) + [23] (byte) sqr::val#1 ← (byte) main::xd#0 + [24] call sqr + [25] (word) sqr::return#1 ← (word) sqr::return#2 + to:main::@12 +main::@12: scope:[main] from main::@8 + [26] (word) main::xds#0 ← (word) sqr::return#1 + [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 + [28] (word) sqrt::val#0 ← (word) main::ds#0 + [29] call sqrt + [30] (byte) sqrt::return#0 ← (byte) sqrt::return#1 + to:main::@13 +main::@13: scope:[main] from main::@12 + [31] (byte) main::d#0 ← (byte) sqrt::return#0 + [32] *((byte*) main::screen#2) ← (byte) main::d#0 + [33] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 + [34] (byte) main::x#1 ← ++ (byte) main::x#2 + [35] if((byte) main::x#1!=(byte) $28) goto main::@5 + to:main::@9 +main::@9: scope:[main] from main::@13 + [36] (byte) main::y#1 ← ++ (byte) main::y#10 + [37] if((byte) main::y#1!=(byte) $19) goto main::@1 + to:main::@return +main::@return: scope:[main] from main::@9 + [38] return + to:@return +main::@6: scope:[main] from main::@5 + [39] (byte~) main::$16 ← (byte) main::x2#0 - (byte) $27 + to:main::@8 +main::@2: scope:[main] from main::@1 + [40] (byte~) main::$8 ← (byte) main::y2#0 - (byte) $18 + to:main::@4 +sqrt: scope:[sqrt] from main::@12 + [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 + [42] call bsearch16u + [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 + to:sqrt::@1 +sqrt::@1: scope:[sqrt] from sqrt + [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 + [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 + [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 + [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 + to:sqrt::@return +sqrt::@return: scope:[sqrt] from sqrt::@1 + [48] return + to:@return +bsearch16u: scope:[bsearch16u] from sqrt + [49] phi() + to:bsearch16u::@3 +bsearch16u::@3: scope:[bsearch16u] from bsearch16u bsearch16u::@7 + [50] (word*) bsearch16u::items#2 ← phi( bsearch16u/(const byte*) HEAP_START#0 bsearch16u::@7/(word*) bsearch16u::items#8 ) + [50] (byte) bsearch16u::num#3 ← phi( bsearch16u/(const byte) NUM_SQUARES#0 bsearch16u::@7/(byte) bsearch16u::num#1 ) + [51] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4 + to:bsearch16u::@5 +bsearch16u::@5: scope:[bsearch16u] from bsearch16u::@3 + [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 + to:bsearch16u::@1 +bsearch16u::@1: scope:[bsearch16u] from bsearch16u::@5 + [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD + to:bsearch16u::@2 +bsearch16u::@2: scope:[bsearch16u] from bsearch16u::@1 bsearch16u::@5 + [54] (word*) bsearch16u::return#3 ← phi( bsearch16u::@5/(word*) bsearch16u::items#2 bsearch16u::@1/(word*~) bsearch16u::$2 ) + to:bsearch16u::@return +bsearch16u::@return: scope:[bsearch16u] from bsearch16u::@2 bsearch16u::@8 + [55] (word*) bsearch16u::return#2 ← phi( bsearch16u::@8/(word*~) bsearch16u::return#6 bsearch16u::@2/(word*) bsearch16u::return#3 ) + [56] return + to:@return +bsearch16u::@4: scope:[bsearch16u] from bsearch16u::@3 + [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 + [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 + [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 + [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) + [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 + to:bsearch16u::@8 +bsearch16u::@8: scope:[bsearch16u] from bsearch16u::@4 + [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 + to:bsearch16u::@return +bsearch16u::@6: scope:[bsearch16u] from bsearch16u::@4 + [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 + to:bsearch16u::@9 +bsearch16u::@9: scope:[bsearch16u] from bsearch16u::@6 + [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD + [65] (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#3 + to:bsearch16u::@7 +bsearch16u::@7: scope:[bsearch16u] from bsearch16u::@6 bsearch16u::@9 + [66] (word*) bsearch16u::items#8 ← phi( bsearch16u::@9/(word*) bsearch16u::items#1 bsearch16u::@6/(word*) bsearch16u::items#2 ) + [66] (byte) bsearch16u::num#5 ← phi( bsearch16u::@9/(byte) bsearch16u::num#2 bsearch16u::@6/(byte) bsearch16u::num#3 ) + [67] (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (byte) 1 + to:bsearch16u::@3 +sqr: scope:[sqr] from main::@4 main::@8 + [68] (byte) sqr::val#2 ← phi( main::@4/(byte) sqr::val#0 main::@8/(byte) sqr::val#1 ) + [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 + [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) + to:sqr::@return +sqr::@return: scope:[sqr] from sqr + [71] return + to:@return +init_squares: scope:[init_squares] from main::@10 + [72] phi() + [73] call malloc + to:init_squares::@1 +init_squares::@1: scope:[init_squares] from init_squares init_squares::@1 + [74] (byte) init_squares::i#2 ← phi( init_squares::@1/(byte) init_squares::i#1 init_squares/(byte) 0 ) + [74] (word*) init_squares::squares#2 ← phi( init_squares::@1/(word*) init_squares::squares#1 init_squares/(const byte*) HEAP_START#0 ) + [74] (word) init_squares::sqr#2 ← phi( init_squares::@1/(word) init_squares::sqr#1 init_squares/(byte) 0 ) + [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 + [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD + [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 + [78] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 + [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 + [80] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2 + [81] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#0-(byte) 1+(byte) 1) goto init_squares::@1 + to:init_squares::@return +init_squares::@return: scope:[init_squares] from init_squares::@1 + [82] return + to:@return +malloc: scope:[malloc] from init_squares + [83] phi() + to:malloc::@return +malloc::@return: scope:[malloc] from malloc + [84] return + to:@return +init_font_hex: scope:[init_font_hex] from main + [85] phi() + to:init_font_hex::@1 +init_font_hex::@1: scope:[init_font_hex] from init_font_hex init_font_hex::@5 + [86] (byte) init_font_hex::c#6 ← phi( init_font_hex/(byte) 0 init_font_hex::@5/(byte) init_font_hex::c#1 ) + [86] (byte*) init_font_hex::proto_hi#6 ← phi( init_font_hex/(const byte[]) FONT_HEX_PROTO#0 init_font_hex::@5/(byte*) init_font_hex::proto_hi#1 ) + [86] (byte*) init_font_hex::charset#5 ← phi( init_font_hex/(const byte*) CHARSET#0 init_font_hex::@5/(byte*) init_font_hex::charset#0 ) + to:init_font_hex::@2 +init_font_hex::@2: scope:[init_font_hex] from init_font_hex::@1 init_font_hex::@4 + [87] (byte) init_font_hex::c1#4 ← phi( init_font_hex::@1/(byte) 0 init_font_hex::@4/(byte) init_font_hex::c1#1 ) + [87] (byte*) init_font_hex::proto_lo#4 ← phi( init_font_hex::@1/(const byte[]) FONT_HEX_PROTO#0 init_font_hex::@4/(byte*) init_font_hex::proto_lo#1 ) + [87] (byte*) init_font_hex::charset#2 ← phi( init_font_hex::@1/(byte*) init_font_hex::charset#5 init_font_hex::@4/(byte*) init_font_hex::charset#0 ) + [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 + to:init_font_hex::@3 +init_font_hex::@3: scope:[init_font_hex] from init_font_hex::@2 init_font_hex::@3 + [89] (byte) init_font_hex::idx#5 ← phi( init_font_hex::@2/(byte) 1 init_font_hex::@3/(byte) init_font_hex::idx#2 ) + [89] (byte) init_font_hex::i#2 ← phi( init_font_hex::@2/(byte) 0 init_font_hex::@3/(byte) init_font_hex::i#1 ) + [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 + [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 + [92] (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 + [93] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 + [94] (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 + [95] (byte) init_font_hex::i#1 ← ++ (byte) init_font_hex::i#2 + [96] if((byte) init_font_hex::i#1!=(byte) 5) goto init_font_hex::@3 + to:init_font_hex::@4 +init_font_hex::@4: scope:[init_font_hex] from init_font_hex::@3 + [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 + [98] (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#2 + [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 + [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 + [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 + [102] (byte) init_font_hex::c1#1 ← ++ (byte) init_font_hex::c1#4 + [103] if((byte) init_font_hex::c1#1!=(byte) $10) goto init_font_hex::@2 + to:init_font_hex::@5 +init_font_hex::@5: scope:[init_font_hex] from init_font_hex::@4 + [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 + [105] (byte) init_font_hex::c#1 ← ++ (byte) init_font_hex::c#6 + [106] if((byte) init_font_hex::c#1!=(byte) $10) goto init_font_hex::@1 + to:init_font_hex::@return +init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 + [107] return + to:@return + + +VARIABLE REGISTER WEIGHTS +(byte*) CHARSET +(byte*) D018 +(byte[]) FONT_HEX_PROTO +(byte*) HEAP_START +(byte) NUM_SQUARES +(byte*) SCREEN +(word*) SQUARES +(word*()) bsearch16u((word) bsearch16u::key , (word*) bsearch16u::items , (byte) bsearch16u::num) +(byte~) bsearch16u::$16 2002.0 +(word*~) bsearch16u::$2 4.0 +(byte~) bsearch16u::$6 2002.0 +(word*) bsearch16u::items +(word*) bsearch16u::items#1 1001.0 +(word*) bsearch16u::items#2 334.33333333333337 +(word*) bsearch16u::items#8 1501.5 +(word) bsearch16u::key +(word) bsearch16u::key#0 0.2857142857142857 +(byte) bsearch16u::num +(byte) bsearch16u::num#1 2002.0 +(byte) bsearch16u::num#2 2002.0 +(byte) bsearch16u::num#3 556.1111111111111 +(byte) bsearch16u::num#5 3003.0 +(word*) bsearch16u::pivot +(word*) bsearch16u::pivot#0 501.0 +(signed word) bsearch16u::result +(signed word) bsearch16u::result#0 1501.5 +(word*) bsearch16u::return +(word*) bsearch16u::return#0 4.0 +(word*) bsearch16u::return#2 2.0 +(word*) bsearch16u::return#3 6.0 +(word*~) bsearch16u::return#6 4.0 +(byte*) heap_head +(void()) init_font_hex((byte*) init_font_hex::charset) +(byte~) init_font_hex::$0 1001.0 +(byte~) init_font_hex::$1 2002.0 +(byte~) init_font_hex::$2 2002.0 +(byte) init_font_hex::c +(byte) init_font_hex::c#1 16.5 +(byte) init_font_hex::c#6 1.1578947368421053 +(byte) init_font_hex::c1 +(byte) init_font_hex::c1#1 151.5 +(byte) init_font_hex::c1#4 13.466666666666667 +(byte*) init_font_hex::charset +(byte*) init_font_hex::charset#0 35.5 +(byte*) init_font_hex::charset#2 108.35714285714285 +(byte*) init_font_hex::charset#5 22.0 +(byte) init_font_hex::i +(byte) init_font_hex::i#1 1501.5 +(byte) init_font_hex::i#2 667.3333333333334 +(byte) init_font_hex::idx +(byte) init_font_hex::idx#2 551.0 +(byte) init_font_hex::idx#3 202.0 +(byte) init_font_hex::idx#5 600.5999999999999 +(byte*) init_font_hex::proto_hi +(byte*) init_font_hex::proto_hi#1 7.333333333333333 +(byte*) init_font_hex::proto_hi#6 56.83333333333334 +(byte*) init_font_hex::proto_lo +(byte*) init_font_hex::proto_lo#1 50.5 +(byte*) init_font_hex::proto_lo#4 92.53846153846155 +(void()) init_squares() +(byte~) init_squares::$3 22.0 +(byte~) init_squares::$4 22.0 +(byte) init_squares::i +(byte) init_squares::i#1 16.5 +(byte) init_squares::i#2 5.5 +(word) init_squares::sqr +(word) init_squares::sqr#1 7.333333333333333 +(word) init_squares::sqr#2 6.6000000000000005 +(word*) init_squares::squares +(word*) init_squares::squares#1 3.6666666666666665 +(word*) init_squares::squares#2 16.5 +(void()) main() +(byte~) main::$14 202.0 +(byte~) main::$16 202.0 +(byte~) main::$6 22.0 +(byte~) main::$8 22.0 +(byte) main::d +(byte) main::d#0 202.0 +(word) main::ds +(word) main::ds#0 202.0 +(byte*) main::screen +(byte*) main::screen#1 42.599999999999994 +(byte*) main::screen#10 2.2 +(byte*) main::screen#2 19.625 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(byte*) main::toD0181_screen +(byte) main::x +(byte) main::x#1 151.5 +(byte) main::x#2 17.823529411764707 +(byte) main::x2 +(byte) main::x2#0 202.0 +(byte) main::xd +(byte) main::xd#0 303.0 +(word) main::xds +(word) main::xds#0 202.0 +(byte) main::y +(byte) main::y#1 16.5 +(byte) main::y#10 1.1379310344827585 +(byte) main::y2 +(byte) main::y2#0 22.0 +(byte) main::yd +(byte) main::yd#0 33.0 +(word) main::yds +(word) main::yds#0 5.6 +(byte*()) malloc((word) malloc::size) +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size +(word()) sqr((byte) sqr::val) +(byte~) sqr::$0 4.0 +(word) sqr::return +(word) sqr::return#0 22.0 +(word) sqr::return#1 202.0 +(word) sqr::return#2 28.5 +(byte) sqr::val +(byte) sqr::val#0 22.0 +(byte) sqr::val#1 202.0 +(byte) sqr::val#2 114.0 +(byte()) sqrt((word) sqrt::val) +(word~) sqrt::$3 2.0 +(byte~) sqrt::$4 4.0 +(word*) sqrt::found +(word*) sqrt::found#0 2.0 +(byte) sqrt::return +(byte) sqrt::return#0 202.0 +(byte) sqrt::return#1 34.33333333333333 +(byte) sqrt::sqr1 +(word) sqrt::val +(word) sqrt::val#0 103.0 + +Initial phi equivalence classes +[ main::y#10 main::y#1 ] +[ main::yd#0 main::$8 main::$6 ] +[ main::x#2 main::x#1 ] +[ main::screen#2 main::screen#10 main::screen#1 ] +[ main::xd#0 main::$16 main::$14 ] +[ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] +[ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +[ sqr::val#2 sqr::val#0 sqr::val#1 ] +[ init_squares::sqr#2 init_squares::sqr#1 ] +[ init_squares::squares#2 init_squares::squares#1 ] +[ init_squares::i#2 init_squares::i#1 ] +[ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +[ init_font_hex::c#6 init_font_hex::c#1 ] +[ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +[ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +[ init_font_hex::c1#4 init_font_hex::c1#1 ] +[ init_font_hex::i#2 init_font_hex::i#1 ] +[ init_font_hex::idx#5 init_font_hex::idx#2 ] +Added variable main::y2#0 to zero page equivalence class [ main::y2#0 ] +Added variable sqr::return#0 to zero page equivalence class [ sqr::return#0 ] +Added variable main::yds#0 to zero page equivalence class [ main::yds#0 ] +Added variable main::x2#0 to zero page equivalence class [ main::x2#0 ] +Added variable sqr::return#1 to zero page equivalence class [ sqr::return#1 ] +Added variable main::xds#0 to zero page equivalence class [ main::xds#0 ] +Added variable main::ds#0 to zero page equivalence class [ main::ds#0 ] +Added variable sqrt::val#0 to zero page equivalence class [ sqrt::val#0 ] +Added variable sqrt::return#0 to zero page equivalence class [ sqrt::return#0 ] +Added variable main::d#0 to zero page equivalence class [ main::d#0 ] +Added variable bsearch16u::key#0 to zero page equivalence class [ bsearch16u::key#0 ] +Added variable bsearch16u::return#0 to zero page equivalence class [ bsearch16u::return#0 ] +Added variable sqrt::found#0 to zero page equivalence class [ sqrt::found#0 ] +Added variable sqrt::$3 to zero page equivalence class [ sqrt::$3 ] +Added variable sqrt::$4 to zero page equivalence class [ sqrt::$4 ] +Added variable sqrt::return#1 to zero page equivalence class [ sqrt::return#1 ] +Added variable bsearch16u::$6 to zero page equivalence class [ bsearch16u::$6 ] +Added variable bsearch16u::$16 to zero page equivalence class [ bsearch16u::$16 ] +Added variable bsearch16u::pivot#0 to zero page equivalence class [ bsearch16u::pivot#0 ] +Added variable bsearch16u::result#0 to zero page equivalence class [ bsearch16u::result#0 ] +Added variable sqr::$0 to zero page equivalence class [ sqr::$0 ] +Added variable sqr::return#2 to zero page equivalence class [ sqr::return#2 ] +Added variable init_squares::$3 to zero page equivalence class [ init_squares::$3 ] +Added variable init_squares::$4 to zero page equivalence class [ init_squares::$4 ] +Added variable init_font_hex::$0 to zero page equivalence class [ init_font_hex::$0 ] +Added variable init_font_hex::$1 to zero page equivalence class [ init_font_hex::$1 ] +Added variable init_font_hex::$2 to zero page equivalence class [ init_font_hex::$2 ] +Added variable init_font_hex::idx#3 to zero page equivalence class [ init_font_hex::idx#3 ] +Complete equivalence classes +[ main::y#10 main::y#1 ] +[ main::yd#0 main::$8 main::$6 ] +[ main::x#2 main::x#1 ] +[ main::screen#2 main::screen#10 main::screen#1 ] +[ main::xd#0 main::$16 main::$14 ] +[ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] +[ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +[ sqr::val#2 sqr::val#0 sqr::val#1 ] +[ init_squares::sqr#2 init_squares::sqr#1 ] +[ init_squares::squares#2 init_squares::squares#1 ] +[ init_squares::i#2 init_squares::i#1 ] +[ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +[ init_font_hex::c#6 init_font_hex::c#1 ] +[ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +[ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +[ init_font_hex::c1#4 init_font_hex::c1#1 ] +[ init_font_hex::i#2 init_font_hex::i#1 ] +[ init_font_hex::idx#5 init_font_hex::idx#2 ] +[ main::y2#0 ] +[ sqr::return#0 ] +[ main::yds#0 ] +[ main::x2#0 ] +[ sqr::return#1 ] +[ main::xds#0 ] +[ main::ds#0 ] +[ sqrt::val#0 ] +[ sqrt::return#0 ] +[ main::d#0 ] +[ bsearch16u::key#0 ] +[ bsearch16u::return#0 ] +[ sqrt::found#0 ] +[ sqrt::$3 ] +[ sqrt::$4 ] +[ sqrt::return#1 ] +[ bsearch16u::$6 ] +[ bsearch16u::$16 ] +[ bsearch16u::pivot#0 ] +[ bsearch16u::result#0 ] +[ sqr::$0 ] +[ sqr::return#2 ] +[ init_squares::$3 ] +[ init_squares::$4 ] +[ init_font_hex::$0 ] +[ init_font_hex::$1 ] +[ init_font_hex::$2 ] +[ init_font_hex::idx#3 ] +Allocated zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +Allocated zp ZP_BYTE:3 [ main::yd#0 main::$8 main::$6 ] +Allocated zp ZP_BYTE:4 [ main::x#2 main::x#1 ] +Allocated zp ZP_WORD:5 [ main::screen#2 main::screen#10 main::screen#1 ] +Allocated zp ZP_BYTE:7 [ main::xd#0 main::$16 main::$14 ] +Allocated zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] +Allocated zp ZP_BYTE:11 [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +Allocated zp ZP_BYTE:12 [ sqr::val#2 sqr::val#0 sqr::val#1 ] +Allocated zp ZP_WORD:13 [ init_squares::sqr#2 init_squares::sqr#1 ] +Allocated zp ZP_WORD:15 [ init_squares::squares#2 init_squares::squares#1 ] +Allocated zp ZP_BYTE:17 [ init_squares::i#2 init_squares::i#1 ] +Allocated zp ZP_WORD:18 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +Allocated zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Allocated zp ZP_WORD:21 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +Allocated zp ZP_WORD:23 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +Allocated zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Allocated zp ZP_BYTE:26 [ init_font_hex::i#2 init_font_hex::i#1 ] +Allocated zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Allocated zp ZP_BYTE:28 [ main::y2#0 ] +Allocated zp ZP_WORD:29 [ sqr::return#0 ] +Allocated zp ZP_WORD:31 [ main::yds#0 ] +Allocated zp ZP_BYTE:33 [ main::x2#0 ] +Allocated zp ZP_WORD:34 [ sqr::return#1 ] +Allocated zp ZP_WORD:36 [ main::xds#0 ] +Allocated zp ZP_WORD:38 [ main::ds#0 ] +Allocated zp ZP_WORD:40 [ sqrt::val#0 ] +Allocated zp ZP_BYTE:42 [ sqrt::return#0 ] +Allocated zp ZP_BYTE:43 [ main::d#0 ] +Allocated zp ZP_WORD:44 [ bsearch16u::key#0 ] +Allocated zp ZP_WORD:46 [ bsearch16u::return#0 ] +Allocated zp ZP_WORD:48 [ sqrt::found#0 ] +Allocated zp ZP_WORD:50 [ sqrt::$3 ] +Allocated zp ZP_BYTE:52 [ sqrt::$4 ] +Allocated zp ZP_BYTE:53 [ sqrt::return#1 ] +Allocated zp ZP_BYTE:54 [ bsearch16u::$6 ] +Allocated zp ZP_BYTE:55 [ bsearch16u::$16 ] +Allocated zp ZP_WORD:56 [ bsearch16u::pivot#0 ] +Allocated zp ZP_WORD:58 [ bsearch16u::result#0 ] +Allocated zp ZP_BYTE:60 [ sqr::$0 ] +Allocated zp ZP_WORD:61 [ sqr::return#2 ] +Allocated zp ZP_BYTE:63 [ init_squares::$3 ] +Allocated zp ZP_BYTE:64 [ init_squares::$4 ] +Allocated zp ZP_BYTE:65 [ init_font_hex::$0 ] +Allocated zp ZP_BYTE:66 [ init_font_hex::$1 ] +Allocated zp ZP_BYTE:67 [ init_font_hex::$2 ] +Allocated zp ZP_BYTE:68 [ init_font_hex::idx#3 ] + +INITIAL ASM +//SEG0 File Comments +// Calculate the distance to the center of the screen - and show it using font-hex +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 + .label D018 = $d018 + .label CHARSET = $2000 + .label SCREEN = $2800 + .const NUM_SQUARES = $30 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG9 @end +bend: +//SEG10 main +main: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label _6 = 3 + .label _8 = 3 + .label _14 = 7 + .label _16 = 7 + .label y2 = $1c + .label yd = 3 + .label yds = $1f + .label x2 = $21 + .label xd = 7 + .label xds = $24 + .label ds = $26 + .label d = $2b + .label screen = 5 + .label x = 4 + .label y = 2 + //SEG11 [5] call init_font_hex + //SEG12 [85] phi from main to init_font_hex [phi:main->init_font_hex] + init_font_hex_from_main: + jsr init_font_hex + //SEG13 [6] phi from main to main::toD0181 [phi:main->main::toD0181] + toD0181_from_main: + jmp toD0181 + //SEG14 main::toD0181 + toD0181: + jmp b10 + //SEG15 main::@10 + b10: + //SEG16 [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG17 [8] call init_squares + //SEG18 [72] phi from main::@10 to init_squares [phi:main::@10->init_squares] + init_squares_from_b10: + jsr init_squares + //SEG19 [9] phi from main::@10 to main::@1 [phi:main::@10->main::@1] + b1_from_b10: + //SEG20 [9] phi (byte*) main::screen#10 = (const byte*) SCREEN#0 [phi:main::@10->main::@1#0] -- pbuz1=pbuc1 + lda #SCREEN + sta screen+1 + //SEG21 [9] phi (byte) main::y#10 = (byte) 0 [phi:main::@10->main::@1#1] -- vbuz1=vbuc1 + lda #0 + sta y + jmp b1 + //SEG22 [9] phi from main::@9 to main::@1 [phi:main::@9->main::@1] + b1_from_b9: + //SEG23 [9] phi (byte*) main::screen#10 = (byte*) main::screen#1 [phi:main::@9->main::@1#0] -- register_copy + //SEG24 [9] phi (byte) main::y#10 = (byte) main::y#1 [phi:main::@9->main::@1#1] -- register_copy + jmp b1 + //SEG25 main::@1 + b1: + //SEG26 [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda y + asl + sta y2 + //SEG27 [11] if((byte) main::y2#0>=(byte) $18) goto main::@2 -- vbuz1_ge_vbuc1_then_la1 + lda y2 + cmp #$18 + bcs b2 + jmp b3 + //SEG28 main::@3 + b3: + //SEG29 [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 -- vbuz1=vbuc1_minus_vbuz2 + lda #$18 + sec + sbc y2 + sta _6 + //SEG30 [13] phi from main::@2 main::@3 to main::@4 [phi:main::@2/main::@3->main::@4] + b4_from_b2: + b4_from_b3: + //SEG31 [13] phi (byte) main::yd#0 = (byte~) main::$8 [phi:main::@2/main::@3->main::@4#0] -- register_copy + jmp b4 + //SEG32 main::@4 + b4: + //SEG33 [14] (byte) sqr::val#0 ← (byte) main::yd#0 -- vbuz1=vbuz2 + lda yd + sta sqr.val + //SEG34 [15] call sqr + //SEG35 [68] phi from main::@4 to sqr [phi:main::@4->sqr] + sqr_from_b4: + //SEG36 [68] phi (byte) sqr::val#2 = (byte) sqr::val#0 [phi:main::@4->sqr#0] -- register_copy + jsr sqr + //SEG37 [16] (word) sqr::return#0 ← (word) sqr::return#2 -- vwuz1=vwuz2 + lda sqr.return_2 + sta sqr.return + lda sqr.return_2+1 + sta sqr.return+1 + jmp b11 + //SEG38 main::@11 + b11: + //SEG39 [17] (word) main::yds#0 ← (word) sqr::return#0 -- vwuz1=vwuz2 + lda sqr.return + sta yds + lda sqr.return+1 + sta yds+1 + //SEG40 [18] phi from main::@11 to main::@5 [phi:main::@11->main::@5] + b5_from_b11: + //SEG41 [18] phi (byte*) main::screen#2 = (byte*) main::screen#10 [phi:main::@11->main::@5#0] -- register_copy + //SEG42 [18] phi (byte) main::x#2 = (byte) 0 [phi:main::@11->main::@5#1] -- vbuz1=vbuc1 + lda #0 + sta x + jmp b5 + //SEG43 [18] phi from main::@13 to main::@5 [phi:main::@13->main::@5] + b5_from_b13: + //SEG44 [18] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@13->main::@5#0] -- register_copy + //SEG45 [18] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@13->main::@5#1] -- register_copy + jmp b5 + //SEG46 main::@5 + b5: + //SEG47 [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda x + asl + sta x2 + //SEG48 [20] if((byte) main::x2#0>=(byte) $27) goto main::@6 -- vbuz1_ge_vbuc1_then_la1 + lda x2 + cmp #$27 + bcs b6 + jmp b7 + //SEG49 main::@7 + b7: + //SEG50 [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 -- vbuz1=vbuc1_minus_vbuz2 + lda #$27 + sec + sbc x2 + sta _14 + //SEG51 [22] phi from main::@6 main::@7 to main::@8 [phi:main::@6/main::@7->main::@8] + b8_from_b6: + b8_from_b7: + //SEG52 [22] phi (byte) main::xd#0 = (byte~) main::$16 [phi:main::@6/main::@7->main::@8#0] -- register_copy + jmp b8 + //SEG53 main::@8 + b8: + //SEG54 [23] (byte) sqr::val#1 ← (byte) main::xd#0 -- vbuz1=vbuz2 + lda xd + sta sqr.val + //SEG55 [24] call sqr + //SEG56 [68] phi from main::@8 to sqr [phi:main::@8->sqr] + sqr_from_b8: + //SEG57 [68] phi (byte) sqr::val#2 = (byte) sqr::val#1 [phi:main::@8->sqr#0] -- register_copy + jsr sqr + //SEG58 [25] (word) sqr::return#1 ← (word) sqr::return#2 -- vwuz1=vwuz2 + lda sqr.return_2 + sta sqr.return_1 + lda sqr.return_2+1 + sta sqr.return_1+1 + jmp b12 + //SEG59 main::@12 + b12: + //SEG60 [26] (word) main::xds#0 ← (word) sqr::return#1 -- vwuz1=vwuz2 + lda sqr.return_1 + sta xds + lda sqr.return_1+1 + sta xds+1 + //SEG61 [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 -- vwuz1=vwuz2_plus_vwuz3 + lda xds + clc + adc yds + sta ds + lda xds+1 + adc yds+1 + sta ds+1 + //SEG62 [28] (word) sqrt::val#0 ← (word) main::ds#0 -- vwuz1=vwuz2 + lda ds + sta sqrt.val + lda ds+1 + sta sqrt.val+1 + //SEG63 [29] call sqrt + jsr sqrt + //SEG64 [30] (byte) sqrt::return#0 ← (byte) sqrt::return#1 -- vbuz1=vbuz2 + lda sqrt.return_1 + sta sqrt.return + jmp b13 + //SEG65 main::@13 + b13: + //SEG66 [31] (byte) main::d#0 ← (byte) sqrt::return#0 -- vbuz1=vbuz2 + lda sqrt.return + sta d + //SEG67 [32] *((byte*) main::screen#2) ← (byte) main::d#0 -- _deref_pbuz1=vbuz2 + lda d + ldy #0 + sta (screen),y + //SEG68 [33] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1 + inc screen + bne !+ + inc screen+1 + !: + //SEG69 [34] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 + inc x + //SEG70 [35] if((byte) main::x#1!=(byte) $28) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 + lda #$28 + cmp x + bne b5_from_b13 + jmp b9 + //SEG71 main::@9 + b9: + //SEG72 [36] (byte) main::y#1 ← ++ (byte) main::y#10 -- vbuz1=_inc_vbuz1 + inc y + //SEG73 [37] if((byte) main::y#1!=(byte) $19) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$19 + cmp y + bne b1_from_b9 + jmp breturn + //SEG74 main::@return + breturn: + //SEG75 [38] return + rts + //SEG76 main::@6 + b6: + //SEG77 [39] (byte~) main::$16 ← (byte) main::x2#0 - (byte) $27 -- vbuz1=vbuz2_minus_vbuc1 + lax x2 + axs #$27 + stx _16 + jmp b8_from_b6 + //SEG78 main::@2 + b2: + //SEG79 [40] (byte~) main::$8 ← (byte) main::y2#0 - (byte) $18 -- vbuz1=vbuz2_minus_vbuc1 + lax y2 + axs #$18 + stx _8 + jmp b4_from_b2 +} +//SEG80 sqrt +// Find the (integer) square root of a word value +// If the square is not an integer then it returns the largest integer N where N*N <= val +// Uses a table of squares that must be initialized by calling init_squares() +// sqrt(word zeropage($28) val) +sqrt: { + .label _3 = $32 + .label _4 = $34 + .label val = $28 + .label return = $2a + .label found = $30 + .label return_1 = $35 + //SEG81 [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 -- vwuz1=vwuz2 + lda val + sta bsearch16u.key + lda val+1 + sta bsearch16u.key+1 + //SEG82 [42] call bsearch16u + //SEG83 [49] phi from sqrt to bsearch16u [phi:sqrt->bsearch16u] + bsearch16u_from_sqrt: + jsr bsearch16u + //SEG84 [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 -- pwuz1=pwuz2 + lda bsearch16u.return_2 + sta bsearch16u.return + lda bsearch16u.return_2+1 + sta bsearch16u.return+1 + jmp b1 + //SEG85 sqrt::@1 + b1: + //SEG86 [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 -- pwuz1=pwuz2 + lda bsearch16u.return + sta found + lda bsearch16u.return+1 + sta found+1 + //SEG87 [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 -- vwuz1=pbuz2_minus_pbuc1 + lda found + sec + sbc #HEAP_START + sta _3+1 + //SEG88 [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 -- vbuz1=_byte_vwuz2 + lda _3 + sta _4 + //SEG89 [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 -- vbuz1=vbuz2_ror_1 + lda _4 + lsr + sta return_1 + jmp breturn + //SEG90 sqrt::@return + breturn: + //SEG91 [48] return + rts +} +//SEG92 bsearch16u +// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key. +// - key - The value to look for +// - items - Pointer to the start of the array to search in +// - num - The number of items in the array +// Returns pointer to an entry in the array that matches the search key +// bsearch16u(word zeropage($2c) key, word* zeropage(9) items, byte zeropage($b) num) +bsearch16u: { + .label _2 = 9 + .label _6 = $36 + .label _16 = $37 + .label key = $2c + .label return = $2e + .label pivot = $38 + .label result = $3a + .label return_2 = 9 + .label num = $b + .label items = 9 + .label return_3 = 9 + .label return_6 = 9 + //SEG93 [50] phi from bsearch16u to bsearch16u::@3 [phi:bsearch16u->bsearch16u::@3] + b3_from_bsearch16u: + //SEG94 [50] phi (word*) bsearch16u::items#2 = (const byte*) HEAP_START#0 [phi:bsearch16u->bsearch16u::@3#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta items+1 + //SEG95 [50] phi (byte) bsearch16u::num#3 = (const byte) NUM_SQUARES#0 [phi:bsearch16u->bsearch16u::@3#1] -- vbuz1=vbuc1 + lda #NUM_SQUARES + sta num + jmp b3 + //SEG96 bsearch16u::@3 + b3: + //SEG97 [51] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4 -- vbuz1_gt_0_then_la1 + lda num + bne b4 + jmp b5 + //SEG98 bsearch16u::@5 + b5: + //SEG99 [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 -- _deref_pwuz1_le_vwuz2_then_la1 + ldy #1 + lda (items),y + cmp key+1 + bne !+ + dey + lda (items),y + cmp key + beq b2_from_b5 + !: + bcc b2_from_b5 + jmp b1 + //SEG100 bsearch16u::@1 + b1: + //SEG101 [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz1_minus_vwuc1 + lda _2 + sec + sbc #<1*SIZEOF_WORD + sta _2 + lda _2+1 + sbc #>1*SIZEOF_WORD + sta _2+1 + //SEG102 [54] phi from bsearch16u::@1 bsearch16u::@5 to bsearch16u::@2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2] + b2_from_b1: + b2_from_b5: + //SEG103 [54] phi (word*) bsearch16u::return#3 = (word*~) bsearch16u::$2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2#0] -- register_copy + jmp b2 + //SEG104 bsearch16u::@2 + b2: + //SEG105 [55] phi from bsearch16u::@2 bsearch16u::@8 to bsearch16u::@return [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return] + breturn_from_b2: + breturn_from_b8: + //SEG106 [55] phi (word*) bsearch16u::return#2 = (word*) bsearch16u::return#3 [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return#0] -- register_copy + jmp breturn + //SEG107 bsearch16u::@return + breturn: + //SEG108 [56] return + rts + //SEG109 bsearch16u::@4 + b4: + //SEG110 [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 -- vbuz1=vbuz2_ror_1 + lda num + lsr + sta _6 + //SEG111 [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda _6 + asl + sta _16 + //SEG112 [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 -- pwuz1=pwuz2_plus_vbuz3 + lda _16 + clc + adc items + sta pivot + lda #0 + adc items+1 + sta pivot+1 + //SEG113 [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) -- vwsz1=vwsz2_minus__deref_pwsz3 + sec + lda key + ldy #0 + sbc (pivot),y + sta result + lda key+1 + iny + sbc (pivot),y + sta result+1 + //SEG114 [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 -- vwsz1_neq_0_then_la1 + lda result+1 + bne b6 + lda result + bne b6 + jmp b8 + //SEG115 bsearch16u::@8 + b8: + //SEG116 [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 -- pwuz1=pwuz2 + lda pivot + sta return_6 + lda pivot+1 + sta return_6+1 + jmp breturn_from_b8 + //SEG117 bsearch16u::@6 + b6: + //SEG118 [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 -- vwsz1_le_0_then_la1 + lda result+1 + bmi b7_from_b6 + bne !+ + lda result + beq b7_from_b6 + !: + jmp b9 + //SEG119 bsearch16u::@9 + b9: + //SEG120 [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz2_plus_vbuc1 + lda #1*SIZEOF_WORD + clc + adc pivot + sta items + lda #0 + adc pivot+1 + sta items+1 + //SEG121 [65] (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#3 -- vbuz1=_dec_vbuz1 + dec num + //SEG122 [66] phi from bsearch16u::@6 bsearch16u::@9 to bsearch16u::@7 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7] + b7_from_b6: + b7_from_b9: + //SEG123 [66] phi (word*) bsearch16u::items#8 = (word*) bsearch16u::items#2 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#0] -- register_copy + //SEG124 [66] phi (byte) bsearch16u::num#5 = (byte) bsearch16u::num#3 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#1] -- register_copy + jmp b7 + //SEG125 bsearch16u::@7 + b7: + //SEG126 [67] (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (byte) 1 -- vbuz1=vbuz1_ror_1 + lsr num + //SEG127 [50] phi from bsearch16u::@7 to bsearch16u::@3 [phi:bsearch16u::@7->bsearch16u::@3] + b3_from_b7: + //SEG128 [50] phi (word*) bsearch16u::items#2 = (word*) bsearch16u::items#8 [phi:bsearch16u::@7->bsearch16u::@3#0] -- register_copy + //SEG129 [50] phi (byte) bsearch16u::num#3 = (byte) bsearch16u::num#1 [phi:bsearch16u::@7->bsearch16u::@3#1] -- register_copy + jmp b3 +} +//SEG130 sqr +// Find the square of a byte value +// Uses a table of squares that must be initialized by calling init_squares() +// sqr(byte zeropage($c) val) +sqr: { + .label _0 = $3c + .label val = $c + .label return = $1d + .label return_1 = $22 + .label return_2 = $3d + //SEG131 [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda val + asl + sta _0 + //SEG132 [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) -- vwuz1=pbuc1_derefidx_vbuz2 + ldy _0 + lda HEAP_START,y + sta return_2 + lda #0 + sta return_2+1 + jmp breturn + //SEG133 sqr::@return + breturn: + //SEG134 [71] return + rts +} +//SEG135 init_squares +// Initialize squares table +// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 +init_squares: { + .label _3 = $3f + .label _4 = $40 + .label squares = $f + .label sqr = $d + .label i = $11 + //SEG136 [73] call malloc + //SEG137 [83] phi from init_squares to malloc [phi:init_squares->malloc] + malloc_from_init_squares: + jsr malloc + //SEG138 [74] phi from init_squares to init_squares::@1 [phi:init_squares->init_squares::@1] + b1_from_init_squares: + //SEG139 [74] phi (byte) init_squares::i#2 = (byte) 0 [phi:init_squares->init_squares::@1#0] -- vbuz1=vbuc1 + lda #0 + sta i + //SEG140 [74] phi (word*) init_squares::squares#2 = (const byte*) HEAP_START#0 [phi:init_squares->init_squares::@1#1] -- pwuz1=pbuc1 + lda #HEAP_START + sta squares+1 + //SEG141 [74] phi (word) init_squares::sqr#2 = (byte) 0 [phi:init_squares->init_squares::@1#2] -- vwuz1=vbuc1 + lda #0 + sta sqr + lda #0 + sta sqr+1 + jmp b1 + //SEG142 [74] phi from init_squares::@1 to init_squares::@1 [phi:init_squares::@1->init_squares::@1] + b1_from_b1: + //SEG143 [74] phi (byte) init_squares::i#2 = (byte) init_squares::i#1 [phi:init_squares::@1->init_squares::@1#0] -- register_copy + //SEG144 [74] phi (word*) init_squares::squares#2 = (word*) init_squares::squares#1 [phi:init_squares::@1->init_squares::@1#1] -- register_copy + //SEG145 [74] phi (word) init_squares::sqr#2 = (word) init_squares::sqr#1 [phi:init_squares::@1->init_squares::@1#2] -- register_copy + jmp b1 + //SEG146 init_squares::@1 + b1: + //SEG147 [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 -- _deref_pwuz1=vwuz2 + ldy #0 + lda sqr + sta (squares),y + iny + lda sqr+1 + sta (squares),y + //SEG148 [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc squares + sta squares + bcc !+ + inc squares+1 + !: + //SEG149 [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1 + lda i + asl + sta _3 + //SEG150 [78] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 -- vbuz1=vbuz2_plus_1 + ldy _3 + iny + sty _4 + //SEG151 [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 -- vwuz1=vwuz1_plus_vbuz2 + lda _4 + clc + adc sqr + sta sqr + bcc !+ + inc sqr+1 + !: + //SEG152 [80] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2 -- vbuz1=_inc_vbuz1 + inc i + //SEG153 [81] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#0-(byte) 1+(byte) 1) goto init_squares::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #NUM_SQUARES-1+1 + cmp i + bne b1_from_b1 + jmp breturn + //SEG154 init_squares::@return + breturn: + //SEG155 [82] return + rts +} +//SEG156 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG157 malloc::@return + breturn: + //SEG158 [84] return + rts +} +//SEG159 init_font_hex +// Make charset from proto chars +// init_font_hex(byte* zeropage($15) charset) +init_font_hex: { + .label _0 = $41 + .label _1 = $42 + .label _2 = $43 + .label idx = $1b + .label i = $1a + .label idx_3 = $44 + .label proto_lo = $17 + .label charset = $15 + .label c1 = $19 + .label proto_hi = $12 + .label c = $14 + //SEG160 [86] phi from init_font_hex to init_font_hex::@1 [phi:init_font_hex->init_font_hex::@1] + b1_from_init_font_hex: + //SEG161 [86] phi (byte) init_font_hex::c#6 = (byte) 0 [phi:init_font_hex->init_font_hex::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG162 [86] phi (byte*) init_font_hex::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex->init_font_hex::@1#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + //SEG163 [86] phi (byte*) init_font_hex::charset#5 = (const byte*) CHARSET#0 [phi:init_font_hex->init_font_hex::@1#2] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + jmp b1 + //SEG164 [86] phi from init_font_hex::@5 to init_font_hex::@1 [phi:init_font_hex::@5->init_font_hex::@1] + b1_from_b5: + //SEG165 [86] phi (byte) init_font_hex::c#6 = (byte) init_font_hex::c#1 [phi:init_font_hex::@5->init_font_hex::@1#0] -- register_copy + //SEG166 [86] phi (byte*) init_font_hex::proto_hi#6 = (byte*) init_font_hex::proto_hi#1 [phi:init_font_hex::@5->init_font_hex::@1#1] -- register_copy + //SEG167 [86] phi (byte*) init_font_hex::charset#5 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@5->init_font_hex::@1#2] -- register_copy + jmp b1 + //SEG168 init_font_hex::@1 + b1: + //SEG169 [87] phi from init_font_hex::@1 to init_font_hex::@2 [phi:init_font_hex::@1->init_font_hex::@2] + b2_from_b1: + //SEG170 [87] phi (byte) init_font_hex::c1#4 = (byte) 0 [phi:init_font_hex::@1->init_font_hex::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c1 + //SEG171 [87] phi (byte*) init_font_hex::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex::@1->init_font_hex::@2#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + //SEG172 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#5 [phi:init_font_hex::@1->init_font_hex::@2#2] -- register_copy + jmp b2 + //SEG173 [87] phi from init_font_hex::@4 to init_font_hex::@2 [phi:init_font_hex::@4->init_font_hex::@2] + b2_from_b4: + //SEG174 [87] phi (byte) init_font_hex::c1#4 = (byte) init_font_hex::c1#1 [phi:init_font_hex::@4->init_font_hex::@2#0] -- register_copy + //SEG175 [87] phi (byte*) init_font_hex::proto_lo#4 = (byte*) init_font_hex::proto_lo#1 [phi:init_font_hex::@4->init_font_hex::@2#1] -- register_copy + //SEG176 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@4->init_font_hex::@2#2] -- register_copy + jmp b2 + //SEG177 init_font_hex::@2 + b2: + //SEG178 [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 -- _deref_pbuz1=vbuc1 + lda #0 + ldy #0 + sta (charset),y + //SEG179 [89] phi from init_font_hex::@2 to init_font_hex::@3 [phi:init_font_hex::@2->init_font_hex::@3] + b3_from_b2: + //SEG180 [89] phi (byte) init_font_hex::idx#5 = (byte) 1 [phi:init_font_hex::@2->init_font_hex::@3#0] -- vbuz1=vbuc1 + lda #1 + sta idx + //SEG181 [89] phi (byte) init_font_hex::i#2 = (byte) 0 [phi:init_font_hex::@2->init_font_hex::@3#1] -- vbuz1=vbuc1 + lda #0 + sta i + jmp b3 + //SEG182 [89] phi from init_font_hex::@3 to init_font_hex::@3 [phi:init_font_hex::@3->init_font_hex::@3] + b3_from_b3: + //SEG183 [89] phi (byte) init_font_hex::idx#5 = (byte) init_font_hex::idx#2 [phi:init_font_hex::@3->init_font_hex::@3#0] -- register_copy + //SEG184 [89] phi (byte) init_font_hex::i#2 = (byte) init_font_hex::i#1 [phi:init_font_hex::@3->init_font_hex::@3#1] -- register_copy + jmp b3 + //SEG185 init_font_hex::@3 + b3: + //SEG186 [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 -- vbuz1=pbuz2_derefidx_vbuz3_rol_4 + ldy i + lda (proto_hi),y + asl + asl + asl + asl + sta _0 + //SEG187 [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 -- vbuz1=pbuz2_derefidx_vbuz3_rol_1 + ldy i + lda (proto_lo),y + asl + sta _1 + //SEG188 [92] (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 -- vbuz1=vbuz2_bor_vbuz3 + lda _0 + ora _1 + sta _2 + //SEG189 [93] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 -- pbuz1_derefidx_vbuz2=vbuz3 + lda _2 + ldy idx + sta (charset),y + //SEG190 [94] (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 -- vbuz1=_inc_vbuz1 + inc idx + //SEG191 [95] (byte) init_font_hex::i#1 ← ++ (byte) init_font_hex::i#2 -- vbuz1=_inc_vbuz1 + inc i + //SEG192 [96] if((byte) init_font_hex::i#1!=(byte) 5) goto init_font_hex::@3 -- vbuz1_neq_vbuc1_then_la1 + lda #5 + cmp i + bne b3_from_b3 + jmp b4 + //SEG193 init_font_hex::@4 + b4: + //SEG194 [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 -- pbuz1_derefidx_vbuz2=vbuc1 + lda #0 + ldy idx + sta (charset),y + //SEG195 [98] (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#2 -- vbuz1=_inc_vbuz2 + ldy idx + iny + sty idx_3 + //SEG196 [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 -- pbuz1_derefidx_vbuz2=vbuc1 + lda #0 + ldy idx_3 + sta (charset),y + //SEG197 [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG198 [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG199 [102] (byte) init_font_hex::c1#1 ← ++ (byte) init_font_hex::c1#4 -- vbuz1=_inc_vbuz1 + inc c1 + //SEG200 [103] if((byte) init_font_hex::c1#1!=(byte) $10) goto init_font_hex::@2 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c1 + bne b2_from_b4 + jmp b5 + //SEG201 init_font_hex::@5 + b5: + //SEG202 [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG203 [105] (byte) init_font_hex::c#1 ← ++ (byte) init_font_hex::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG204 [106] if((byte) init_font_hex::c#1!=(byte) $10) goto init_font_hex::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1_from_b5 + jmp breturn + //SEG205 init_font_hex::@return + breturn: + //SEG206 [107] return + rts +} +//SEG207 File Data + // Bit patterns for symbols 0-f (3x5 pixels) used in font hex + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4 + +REGISTER UPLIFT POTENTIAL REGISTERS +Statement [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 [ main::y#10 main::screen#10 main::y2#0 ] ( main:2 [ main::y#10 main::screen#10 main::y2#0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +Statement [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 [ main::y#10 main::screen#10 main::$6 ] ( main:2 [ main::y#10 main::screen#10 main::$6 ] ) always clobbers reg byte a +Statement [16] (word) sqr::return#0 ← (word) sqr::return#2 [ main::y#10 main::screen#10 sqr::return#0 ] ( main:2 [ main::y#10 main::screen#10 sqr::return#0 ] ) always clobbers reg byte a +Statement [17] (word) main::yds#0 ← (word) sqr::return#0 [ main::y#10 main::screen#10 main::yds#0 ] ( main:2 [ main::y#10 main::screen#10 main::yds#0 ] ) always clobbers reg byte a +Statement [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::x2#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::x2#0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ] +Statement [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::$14 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::$14 ] ) always clobbers reg byte a +Statement [25] (word) sqr::return#1 ← (word) sqr::return#2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#1 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#1 ] ) always clobbers reg byte a +Statement [26] (word) main::xds#0 ← (word) sqr::return#1 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::xds#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::xds#0 ] ) always clobbers reg byte a +Statement [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::ds#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::ds#0 ] ) always clobbers reg byte a +Statement [28] (word) sqrt::val#0 ← (word) main::ds#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::val#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::val#0 ] ) always clobbers reg byte a +Statement [32] *((byte*) main::screen#2) ← (byte) main::d#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 ] ) always clobbers reg byte y +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:4 [ main::x#2 main::x#1 ] +Statement [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 [ bsearch16u::key#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 ] ) always clobbers reg byte a +Statement [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 [ bsearch16u::return#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::return#0 ] ) always clobbers reg byte a +Statement [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 [ sqrt::found#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::found#0 ] ) always clobbers reg byte a +Statement [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 [ sqrt::$3 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::$3 ] ) always clobbers reg byte a +Statement [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 [ sqrt::$4 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::$4 ] ) always clobbers reg byte a +Statement [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 [ sqrt::return#1 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::return#1 ] ) always clobbers reg byte a +Statement [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 [ bsearch16u::items#2 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::items#2 ] ) always clobbers reg byte a reg byte y +Statement [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD [ bsearch16u::$2 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::$2 ] ) always clobbers reg byte a +Statement [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$6 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$6 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:11 [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +Statement [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$16 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$16 ] ) always clobbers reg byte a +Statement [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ) always clobbers reg byte a +Statement [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:11 [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +Statement [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ) always clobbers reg byte a +Statement [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 [ bsearch16u::return#6 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::return#6 ] ) always clobbers reg byte a +Statement [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ) always clobbers reg byte a +Statement [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#1 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#1 ] ) always clobbers reg byte a +Statement [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 [ sqr::$0 ] ( main:2::sqr:15 [ main::y#10 main::screen#10 sqr::$0 ] main:2::sqr:24 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::$0 ] ) always clobbers reg byte a +Statement [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) [ sqr::return#2 ] ( main:2::sqr:15 [ main::y#10 main::screen#10 sqr::return#2 ] main:2::sqr:24 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#2 ] ) always clobbers reg byte a +Statement [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 [ init_squares::sqr#2 init_squares::squares#2 init_squares::i#2 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::squares#2 init_squares::i#2 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:17 [ init_squares::i#2 init_squares::i#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:17 [ init_squares::i#2 init_squares::i#1 ] +Statement [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a +Statement [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a +Statement [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:2::init_squares:8 [ init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a +Statement [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ) always clobbers reg byte a reg byte y +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Removing always clobbered register reg byte y as potential for zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Statement [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:26 [ init_font_hex::i#2 init_font_hex::i#1 ] +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Statement [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 init_font_hex::$1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 init_font_hex::$1 ] ) always clobbers reg byte a +Removing always clobbered register reg byte a as potential for zp ZP_BYTE:65 [ init_font_hex::$0 ] +Statement [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::idx#2 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::idx#2 ] ) always clobbers reg byte a +Statement [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ) always clobbers reg byte a +Statement [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ) always clobbers reg byte a +Statement [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ) always clobbers reg byte a +Statement [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 [ init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::proto_hi#1 ] ( main:2::init_font_hex:5 [ init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::proto_hi#1 ] ) always clobbers reg byte a +Statement [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 [ ] ( main:2 [ ] ) always clobbers reg byte a +Statement [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 [ main::y#10 main::screen#10 main::y2#0 ] ( main:2 [ main::y#10 main::screen#10 main::y2#0 ] ) always clobbers reg byte a +Statement [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 [ main::y#10 main::screen#10 main::$6 ] ( main:2 [ main::y#10 main::screen#10 main::$6 ] ) always clobbers reg byte a +Statement [16] (word) sqr::return#0 ← (word) sqr::return#2 [ main::y#10 main::screen#10 sqr::return#0 ] ( main:2 [ main::y#10 main::screen#10 sqr::return#0 ] ) always clobbers reg byte a +Statement [17] (word) main::yds#0 ← (word) sqr::return#0 [ main::y#10 main::screen#10 main::yds#0 ] ( main:2 [ main::y#10 main::screen#10 main::yds#0 ] ) always clobbers reg byte a +Statement [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::x2#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::x2#0 ] ) always clobbers reg byte a +Statement [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::$14 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::$14 ] ) always clobbers reg byte a +Statement [25] (word) sqr::return#1 ← (word) sqr::return#2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#1 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#1 ] ) always clobbers reg byte a +Statement [26] (word) main::xds#0 ← (word) sqr::return#1 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::xds#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::xds#0 ] ) always clobbers reg byte a +Statement [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::ds#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 main::ds#0 ] ) always clobbers reg byte a +Statement [28] (word) sqrt::val#0 ← (word) main::ds#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::val#0 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::val#0 ] ) always clobbers reg byte a +Statement [32] *((byte*) main::screen#2) ← (byte) main::d#0 [ main::y#10 main::yds#0 main::x#2 main::screen#2 ] ( main:2 [ main::y#10 main::yds#0 main::x#2 main::screen#2 ] ) always clobbers reg byte y +Statement [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 [ bsearch16u::key#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 ] ) always clobbers reg byte a +Statement [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 [ bsearch16u::return#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::return#0 ] ) always clobbers reg byte a +Statement [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 [ sqrt::found#0 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::found#0 ] ) always clobbers reg byte a +Statement [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 [ sqrt::$3 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::$3 ] ) always clobbers reg byte a +Statement [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 [ sqrt::$4 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::$4 ] ) always clobbers reg byte a +Statement [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 [ sqrt::return#1 ] ( main:2::sqrt:29 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqrt::return#1 ] ) always clobbers reg byte a +Statement [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 [ bsearch16u::items#2 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::items#2 ] ) always clobbers reg byte a reg byte y +Statement [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD [ bsearch16u::$2 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::$2 ] ) always clobbers reg byte a +Statement [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$6 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$6 ] ) always clobbers reg byte a +Statement [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$16 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::$16 ] ) always clobbers reg byte a +Statement [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ) always clobbers reg byte a +Statement [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ) always clobbers reg byte a reg byte y +Statement [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 bsearch16u::result#0 ] ) always clobbers reg byte a +Statement [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 [ bsearch16u::return#6 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::return#6 ] ) always clobbers reg byte a +Statement [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#2 bsearch16u::pivot#0 ] ) always clobbers reg byte a +Statement [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD [ bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#1 ] ( main:2::sqrt:29::bsearch16u:42 [ main::y#10 main::yds#0 main::x#2 main::screen#2 bsearch16u::key#0 bsearch16u::num#3 bsearch16u::items#1 ] ) always clobbers reg byte a +Statement [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 [ sqr::$0 ] ( main:2::sqr:15 [ main::y#10 main::screen#10 sqr::$0 ] main:2::sqr:24 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::$0 ] ) always clobbers reg byte a +Statement [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) [ sqr::return#2 ] ( main:2::sqr:15 [ main::y#10 main::screen#10 sqr::return#2 ] main:2::sqr:24 [ main::y#10 main::yds#0 main::x#2 main::screen#2 sqr::return#2 ] ) always clobbers reg byte a +Statement [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 [ init_squares::sqr#2 init_squares::squares#2 init_squares::i#2 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::squares#2 init_squares::i#2 ] ) always clobbers reg byte a reg byte y +Statement [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 ] ) always clobbers reg byte a +Statement [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ( main:2::init_squares:8 [ init_squares::sqr#2 init_squares::i#2 init_squares::squares#1 init_squares::$3 ] ) always clobbers reg byte a +Statement [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 [ init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ( main:2::init_squares:8 [ init_squares::i#2 init_squares::sqr#1 init_squares::squares#1 ] ) always clobbers reg byte a +Statement [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ) always clobbers reg byte a reg byte y +Statement [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 ] ) always clobbers reg byte a +Statement [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 init_font_hex::$1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::i#2 init_font_hex::idx#5 init_font_hex::$0 init_font_hex::$1 ] ) always clobbers reg byte a +Statement [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::idx#2 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 init_font_hex::idx#2 ] ) always clobbers reg byte a +Statement [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::proto_lo#4 init_font_hex::c1#4 ] ) always clobbers reg byte a +Statement [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#2 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ) always clobbers reg byte a +Statement [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ( main:2::init_font_hex:5 [ init_font_hex::proto_hi#6 init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::c1#4 init_font_hex::proto_lo#1 ] ) always clobbers reg byte a +Statement [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 [ init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::proto_hi#1 ] ( main:2::init_font_hex:5 [ init_font_hex::c#6 init_font_hex::charset#0 init_font_hex::proto_hi#1 ] ) always clobbers reg byte a +Potential registers zp ZP_BYTE:2 [ main::y#10 main::y#1 ] : zp ZP_BYTE:2 , reg byte x , +Potential registers zp ZP_BYTE:3 [ main::yd#0 main::$8 main::$6 ] : zp ZP_BYTE:3 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:4 [ main::x#2 main::x#1 ] : zp ZP_BYTE:4 , reg byte x , +Potential registers zp ZP_WORD:5 [ main::screen#2 main::screen#10 main::screen#1 ] : zp ZP_WORD:5 , +Potential registers zp ZP_BYTE:7 [ main::xd#0 main::$16 main::$14 ] : zp ZP_BYTE:7 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] : zp ZP_WORD:9 , +Potential registers zp ZP_BYTE:11 [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] : zp ZP_BYTE:11 , reg byte x , +Potential registers zp ZP_BYTE:12 [ sqr::val#2 sqr::val#0 sqr::val#1 ] : zp ZP_BYTE:12 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:13 [ init_squares::sqr#2 init_squares::sqr#1 ] : zp ZP_WORD:13 , +Potential registers zp ZP_WORD:15 [ init_squares::squares#2 init_squares::squares#1 ] : zp ZP_WORD:15 , +Potential registers zp ZP_BYTE:17 [ init_squares::i#2 init_squares::i#1 ] : zp ZP_BYTE:17 , reg byte x , +Potential registers zp ZP_WORD:18 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] : zp ZP_WORD:18 , +Potential registers zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] : zp ZP_BYTE:20 , reg byte x , +Potential registers zp ZP_WORD:21 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] : zp ZP_WORD:21 , +Potential registers zp ZP_WORD:23 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] : zp ZP_WORD:23 , +Potential registers zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] : zp ZP_BYTE:25 , reg byte x , +Potential registers zp ZP_BYTE:26 [ init_font_hex::i#2 init_font_hex::i#1 ] : zp ZP_BYTE:26 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] : zp ZP_BYTE:27 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:28 [ main::y2#0 ] : zp ZP_BYTE:28 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:29 [ sqr::return#0 ] : zp ZP_WORD:29 , +Potential registers zp ZP_WORD:31 [ main::yds#0 ] : zp ZP_WORD:31 , +Potential registers zp ZP_BYTE:33 [ main::x2#0 ] : zp ZP_BYTE:33 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:34 [ sqr::return#1 ] : zp ZP_WORD:34 , +Potential registers zp ZP_WORD:36 [ main::xds#0 ] : zp ZP_WORD:36 , +Potential registers zp ZP_WORD:38 [ main::ds#0 ] : zp ZP_WORD:38 , +Potential registers zp ZP_WORD:40 [ sqrt::val#0 ] : zp ZP_WORD:40 , +Potential registers zp ZP_BYTE:42 [ sqrt::return#0 ] : zp ZP_BYTE:42 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:43 [ main::d#0 ] : zp ZP_BYTE:43 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:44 [ bsearch16u::key#0 ] : zp ZP_WORD:44 , +Potential registers zp ZP_WORD:46 [ bsearch16u::return#0 ] : zp ZP_WORD:46 , +Potential registers zp ZP_WORD:48 [ sqrt::found#0 ] : zp ZP_WORD:48 , +Potential registers zp ZP_WORD:50 [ sqrt::$3 ] : zp ZP_WORD:50 , +Potential registers zp ZP_BYTE:52 [ sqrt::$4 ] : zp ZP_BYTE:52 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:53 [ sqrt::return#1 ] : zp ZP_BYTE:53 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:54 [ bsearch16u::$6 ] : zp ZP_BYTE:54 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:55 [ bsearch16u::$16 ] : zp ZP_BYTE:55 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:56 [ bsearch16u::pivot#0 ] : zp ZP_WORD:56 , +Potential registers zp ZP_WORD:58 [ bsearch16u::result#0 ] : zp ZP_WORD:58 , +Potential registers zp ZP_BYTE:60 [ sqr::$0 ] : zp ZP_BYTE:60 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_WORD:61 [ sqr::return#2 ] : zp ZP_WORD:61 , +Potential registers zp ZP_BYTE:63 [ init_squares::$3 ] : zp ZP_BYTE:63 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:64 [ init_squares::$4 ] : zp ZP_BYTE:64 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:65 [ init_font_hex::$0 ] : zp ZP_BYTE:65 , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:66 [ init_font_hex::$1 ] : zp ZP_BYTE:66 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:67 [ init_font_hex::$2 ] : zp ZP_BYTE:67 , reg byte a , reg byte x , reg byte y , +Potential registers zp ZP_BYTE:68 [ init_font_hex::idx#3 ] : zp ZP_BYTE:68 , reg byte a , reg byte x , reg byte y , + +REGISTER UPLIFT SCOPES +Uplift Scope [bsearch16u] 7,563.11: zp ZP_BYTE:11 [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] 2,852.83: zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] 2,002: zp ZP_BYTE:54 [ bsearch16u::$6 ] 2,002: zp ZP_BYTE:55 [ bsearch16u::$16 ] 1,501.5: zp ZP_WORD:58 [ bsearch16u::result#0 ] 501: zp ZP_WORD:56 [ bsearch16u::pivot#0 ] 4: zp ZP_WORD:46 [ bsearch16u::return#0 ] 0.29: zp ZP_WORD:44 [ bsearch16u::key#0 ] +Uplift Scope [init_font_hex] 2,168.83: zp ZP_BYTE:26 [ init_font_hex::i#2 init_font_hex::i#1 ] 2,002: zp ZP_BYTE:66 [ init_font_hex::$1 ] 2,002: zp ZP_BYTE:67 [ init_font_hex::$2 ] 1,151.6: zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] 1,001: zp ZP_BYTE:65 [ init_font_hex::$0 ] 202: zp ZP_BYTE:68 [ init_font_hex::idx#3 ] 165.86: zp ZP_WORD:21 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] 164.97: zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] 143.04: zp ZP_WORD:23 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] 64.17: zp ZP_WORD:18 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] 17.66: zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplift Scope [main] 707: zp ZP_BYTE:7 [ main::xd#0 main::$16 main::$14 ] 202: zp ZP_BYTE:33 [ main::x2#0 ] 202: zp ZP_WORD:36 [ main::xds#0 ] 202: zp ZP_WORD:38 [ main::ds#0 ] 202: zp ZP_BYTE:43 [ main::d#0 ] 169.32: zp ZP_BYTE:4 [ main::x#2 main::x#1 ] 77: zp ZP_BYTE:3 [ main::yd#0 main::$8 main::$6 ] 64.42: zp ZP_WORD:5 [ main::screen#2 main::screen#10 main::screen#1 ] 22: zp ZP_BYTE:28 [ main::y2#0 ] 17.64: zp ZP_BYTE:2 [ main::y#10 main::y#1 ] 5.6: zp ZP_WORD:31 [ main::yds#0 ] +Uplift Scope [sqr] 338: zp ZP_BYTE:12 [ sqr::val#2 sqr::val#0 sqr::val#1 ] 202: zp ZP_WORD:34 [ sqr::return#1 ] 28.5: zp ZP_WORD:61 [ sqr::return#2 ] 22: zp ZP_WORD:29 [ sqr::return#0 ] 4: zp ZP_BYTE:60 [ sqr::$0 ] +Uplift Scope [sqrt] 202: zp ZP_BYTE:42 [ sqrt::return#0 ] 103: zp ZP_WORD:40 [ sqrt::val#0 ] 34.33: zp ZP_BYTE:53 [ sqrt::return#1 ] 4: zp ZP_BYTE:52 [ sqrt::$4 ] 2: zp ZP_WORD:48 [ sqrt::found#0 ] 2: zp ZP_WORD:50 [ sqrt::$3 ] +Uplift Scope [init_squares] 22: zp ZP_BYTE:17 [ init_squares::i#2 init_squares::i#1 ] 22: zp ZP_BYTE:63 [ init_squares::$3 ] 22: zp ZP_BYTE:64 [ init_squares::$4 ] 20.17: zp ZP_WORD:15 [ init_squares::squares#2 init_squares::squares#1 ] 13.93: zp ZP_WORD:13 [ init_squares::sqr#2 init_squares::sqr#1 ] +Uplift Scope [malloc] +Uplift Scope [] + +Uplifting [bsearch16u] best 258794 combination reg byte x [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] reg byte a [ bsearch16u::$6 ] reg byte a [ bsearch16u::$16 ] zp ZP_WORD:58 [ bsearch16u::result#0 ] zp ZP_WORD:56 [ bsearch16u::pivot#0 ] zp ZP_WORD:46 [ bsearch16u::return#0 ] zp ZP_WORD:44 [ bsearch16u::key#0 ] +Uplifting [init_font_hex] best 239794 combination reg byte x [ init_font_hex::i#2 init_font_hex::i#1 ] reg byte a [ init_font_hex::$1 ] reg byte a [ init_font_hex::$2 ] zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:65 [ init_font_hex::$0 ] zp ZP_BYTE:68 [ init_font_hex::idx#3 ] zp ZP_WORD:21 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:23 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:18 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Limited combination testing to 100 combinations of 6912 possible. +Uplifting [main] best 237494 combination reg byte a [ main::xd#0 main::$16 main::$14 ] reg byte a [ main::x2#0 ] zp ZP_WORD:36 [ main::xds#0 ] zp ZP_WORD:38 [ main::ds#0 ] reg byte a [ main::d#0 ] zp ZP_BYTE:4 [ main::x#2 main::x#1 ] zp ZP_BYTE:3 [ main::yd#0 main::$8 main::$6 ] zp ZP_WORD:5 [ main::screen#2 main::screen#10 main::screen#1 ] zp ZP_BYTE:28 [ main::y2#0 ] zp ZP_BYTE:2 [ main::y#10 main::y#1 ] zp ZP_WORD:31 [ main::yds#0 ] +Limited combination testing to 100 combinations of 4096 possible. +Uplifting [sqr] best 237157 combination reg byte a [ sqr::val#2 sqr::val#0 sqr::val#1 ] zp ZP_WORD:34 [ sqr::return#1 ] zp ZP_WORD:61 [ sqr::return#2 ] zp ZP_WORD:29 [ sqr::return#0 ] reg byte a [ sqr::$0 ] +Uplifting [sqrt] best 236248 combination reg byte a [ sqrt::return#0 ] zp ZP_WORD:40 [ sqrt::val#0 ] reg byte a [ sqrt::return#1 ] reg byte a [ sqrt::$4 ] zp ZP_WORD:48 [ sqrt::found#0 ] zp ZP_WORD:50 [ sqrt::$3 ] +Uplifting [init_squares] best 236048 combination reg byte x [ init_squares::i#2 init_squares::i#1 ] reg byte a [ init_squares::$3 ] reg byte a [ init_squares::$4 ] zp ZP_WORD:15 [ init_squares::squares#2 init_squares::squares#1 ] zp ZP_WORD:13 [ init_squares::sqr#2 init_squares::sqr#1 ] +Uplifting [malloc] best 236048 combination +Uplifting [] best 236048 combination +Attempting to uplift remaining variables inzp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Uplifting [init_font_hex] best 236048 combination zp ZP_BYTE:27 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Attempting to uplift remaining variables inzp ZP_BYTE:65 [ init_font_hex::$0 ] +Uplifting [init_font_hex] best 236048 combination zp ZP_BYTE:65 [ init_font_hex::$0 ] +Attempting to uplift remaining variables inzp ZP_BYTE:68 [ init_font_hex::idx#3 ] +Uplifting [init_font_hex] best 235448 combination reg byte y [ init_font_hex::idx#3 ] +Attempting to uplift remaining variables inzp ZP_BYTE:4 [ main::x#2 main::x#1 ] +Uplifting [main] best 235448 combination zp ZP_BYTE:4 [ main::x#2 main::x#1 ] +Attempting to uplift remaining variables inzp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Uplifting [init_font_hex] best 235448 combination zp ZP_BYTE:25 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Attempting to uplift remaining variables inzp ZP_BYTE:3 [ main::yd#0 main::$8 main::$6 ] +Uplifting [main] best 235378 combination reg byte a [ main::yd#0 main::$8 main::$6 ] +Attempting to uplift remaining variables inzp ZP_BYTE:28 [ main::y2#0 ] +Uplifting [main] best 235278 combination reg byte a [ main::y2#0 ] +Attempting to uplift remaining variables inzp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [init_font_hex] best 235278 combination zp ZP_BYTE:20 [ init_font_hex::c#6 init_font_hex::c#1 ] +Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::y#10 main::y#1 ] +Uplifting [main] best 235278 combination zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +Coalescing zero page register with common assignment [ zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 ] ] with [ zp ZP_WORD:46 [ bsearch16u::return#0 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:29 [ sqr::return#0 ] ] with [ zp ZP_WORD:31 [ main::yds#0 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:34 [ sqr::return#1 ] ] with [ zp ZP_WORD:36 [ main::xds#0 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:34 [ sqr::return#1 main::xds#0 ] ] with [ zp ZP_WORD:61 [ sqr::return#2 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:38 [ main::ds#0 ] ] with [ zp ZP_WORD:40 [ sqrt::val#0 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:48 [ sqrt::found#0 ] ] with [ zp ZP_WORD:50 [ sqrt::$3 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:9 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 bsearch16u::return#0 ] ] with [ zp ZP_WORD:48 [ sqrt::found#0 sqrt::$3 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:34 [ sqr::return#1 main::xds#0 sqr::return#2 ] ] with [ zp ZP_WORD:38 [ main::ds#0 sqrt::val#0 ] ] - score: 1 +Coalescing zero page register with common assignment [ zp ZP_WORD:34 [ sqr::return#1 main::xds#0 sqr::return#2 main::ds#0 sqrt::val#0 ] ] with [ zp ZP_WORD:44 [ bsearch16u::key#0 ] ] - score: 1 +Allocated (was zp ZP_BYTE:4) zp ZP_BYTE:3 [ main::x#2 main::x#1 ] +Allocated (was zp ZP_WORD:5) zp ZP_WORD:4 [ main::screen#2 main::screen#10 main::screen#1 ] +Allocated (was zp ZP_WORD:9) zp ZP_WORD:6 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 bsearch16u::return#0 sqrt::found#0 sqrt::$3 ] +Allocated (was zp ZP_WORD:13) zp ZP_WORD:9 [ init_squares::sqr#2 init_squares::sqr#1 ] +Allocated (was zp ZP_WORD:15) zp ZP_WORD:11 [ init_squares::squares#2 init_squares::squares#1 ] +Allocated (was zp ZP_WORD:18) zp ZP_WORD:13 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +Allocated (was zp ZP_BYTE:20) zp ZP_BYTE:15 [ init_font_hex::c#6 init_font_hex::c#1 ] +Allocated (was zp ZP_WORD:21) zp ZP_WORD:16 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +Allocated (was zp ZP_WORD:23) zp ZP_WORD:18 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +Allocated (was zp ZP_BYTE:25) zp ZP_BYTE:20 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Allocated (was zp ZP_BYTE:27) zp ZP_BYTE:21 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Allocated (was zp ZP_WORD:29) zp ZP_WORD:22 [ sqr::return#0 main::yds#0 ] +Allocated (was zp ZP_WORD:34) zp ZP_WORD:24 [ sqr::return#1 main::xds#0 sqr::return#2 main::ds#0 sqrt::val#0 bsearch16u::key#0 ] +Allocated (was zp ZP_WORD:56) zp ZP_WORD:26 [ bsearch16u::pivot#0 ] +Allocated (was zp ZP_WORD:58) zp ZP_WORD:28 [ bsearch16u::result#0 ] +Allocated (was zp ZP_BYTE:65) zp ZP_BYTE:30 [ init_font_hex::$0 ] + +ASSEMBLER BEFORE OPTIMIZATION +//SEG0 File Comments +// Calculate the distance to the center of the screen - and show it using font-hex +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(bbegin) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 + .label D018 = $d018 + .label CHARSET = $2000 + .label SCREEN = $2800 + .const NUM_SQUARES = $30 +//SEG3 @begin +bbegin: +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +b1_from_bbegin: + jmp b1 +//SEG5 @1 +b1: +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +main_from_b1: + jsr main +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +bend_from_b1: + jmp bend +//SEG9 @end +bend: +//SEG10 main +main: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label yds = $16 + .label xds = $18 + .label ds = $18 + .label screen = 4 + .label x = 3 + .label y = 2 + //SEG11 [5] call init_font_hex + //SEG12 [85] phi from main to init_font_hex [phi:main->init_font_hex] + init_font_hex_from_main: + jsr init_font_hex + //SEG13 [6] phi from main to main::toD0181 [phi:main->main::toD0181] + toD0181_from_main: + jmp toD0181 + //SEG14 main::toD0181 + toD0181: + jmp b10 + //SEG15 main::@10 + b10: + //SEG16 [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG17 [8] call init_squares + //SEG18 [72] phi from main::@10 to init_squares [phi:main::@10->init_squares] + init_squares_from_b10: + jsr init_squares + //SEG19 [9] phi from main::@10 to main::@1 [phi:main::@10->main::@1] + b1_from_b10: + //SEG20 [9] phi (byte*) main::screen#10 = (const byte*) SCREEN#0 [phi:main::@10->main::@1#0] -- pbuz1=pbuc1 + lda #SCREEN + sta screen+1 + //SEG21 [9] phi (byte) main::y#10 = (byte) 0 [phi:main::@10->main::@1#1] -- vbuz1=vbuc1 + lda #0 + sta y + jmp b1 + //SEG22 [9] phi from main::@9 to main::@1 [phi:main::@9->main::@1] + b1_from_b9: + //SEG23 [9] phi (byte*) main::screen#10 = (byte*) main::screen#1 [phi:main::@9->main::@1#0] -- register_copy + //SEG24 [9] phi (byte) main::y#10 = (byte) main::y#1 [phi:main::@9->main::@1#1] -- register_copy + jmp b1 + //SEG25 main::@1 + b1: + //SEG26 [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda y + asl + //SEG27 [11] if((byte) main::y2#0>=(byte) $18) goto main::@2 -- vbuaa_ge_vbuc1_then_la1 + cmp #$18 + bcs b2 + jmp b3 + //SEG28 main::@3 + b3: + //SEG29 [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 -- vbuaa=vbuc1_minus_vbuaa + eor #$ff + clc + adc #$18+1 + //SEG30 [13] phi from main::@2 main::@3 to main::@4 [phi:main::@2/main::@3->main::@4] + b4_from_b2: + b4_from_b3: + //SEG31 [13] phi (byte) main::yd#0 = (byte~) main::$8 [phi:main::@2/main::@3->main::@4#0] -- register_copy + jmp b4 + //SEG32 main::@4 + b4: + //SEG33 [14] (byte) sqr::val#0 ← (byte) main::yd#0 + //SEG34 [15] call sqr + //SEG35 [68] phi from main::@4 to sqr [phi:main::@4->sqr] + sqr_from_b4: + //SEG36 [68] phi (byte) sqr::val#2 = (byte) sqr::val#0 [phi:main::@4->sqr#0] -- register_copy + jsr sqr + //SEG37 [16] (word) sqr::return#0 ← (word) sqr::return#2 -- vwuz1=vwuz2 + lda sqr.return_2 + sta sqr.return + lda sqr.return_2+1 + sta sqr.return+1 + jmp b11 + //SEG38 main::@11 + b11: + //SEG39 [17] (word) main::yds#0 ← (word) sqr::return#0 + //SEG40 [18] phi from main::@11 to main::@5 [phi:main::@11->main::@5] + b5_from_b11: + //SEG41 [18] phi (byte*) main::screen#2 = (byte*) main::screen#10 [phi:main::@11->main::@5#0] -- register_copy + //SEG42 [18] phi (byte) main::x#2 = (byte) 0 [phi:main::@11->main::@5#1] -- vbuz1=vbuc1 + lda #0 + sta x + jmp b5 + //SEG43 [18] phi from main::@13 to main::@5 [phi:main::@13->main::@5] + b5_from_b13: + //SEG44 [18] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@13->main::@5#0] -- register_copy + //SEG45 [18] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@13->main::@5#1] -- register_copy + jmp b5 + //SEG46 main::@5 + b5: + //SEG47 [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda x + asl + //SEG48 [20] if((byte) main::x2#0>=(byte) $27) goto main::@6 -- vbuaa_ge_vbuc1_then_la1 + cmp #$27 + bcs b6 + jmp b7 + //SEG49 main::@7 + b7: + //SEG50 [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 -- vbuaa=vbuc1_minus_vbuaa + eor #$ff + clc + adc #$27+1 + //SEG51 [22] phi from main::@6 main::@7 to main::@8 [phi:main::@6/main::@7->main::@8] + b8_from_b6: + b8_from_b7: + //SEG52 [22] phi (byte) main::xd#0 = (byte~) main::$16 [phi:main::@6/main::@7->main::@8#0] -- register_copy + jmp b8 + //SEG53 main::@8 + b8: + //SEG54 [23] (byte) sqr::val#1 ← (byte) main::xd#0 + //SEG55 [24] call sqr + //SEG56 [68] phi from main::@8 to sqr [phi:main::@8->sqr] + sqr_from_b8: + //SEG57 [68] phi (byte) sqr::val#2 = (byte) sqr::val#1 [phi:main::@8->sqr#0] -- register_copy + jsr sqr + //SEG58 [25] (word) sqr::return#1 ← (word) sqr::return#2 + jmp b12 + //SEG59 main::@12 + b12: + //SEG60 [26] (word) main::xds#0 ← (word) sqr::return#1 + //SEG61 [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 -- vwuz1=vwuz1_plus_vwuz2 + lda ds + clc + adc yds + sta ds + lda ds+1 + adc yds+1 + sta ds+1 + //SEG62 [28] (word) sqrt::val#0 ← (word) main::ds#0 + //SEG63 [29] call sqrt + jsr sqrt + //SEG64 [30] (byte) sqrt::return#0 ← (byte) sqrt::return#1 + jmp b13 + //SEG65 main::@13 + b13: + //SEG66 [31] (byte) main::d#0 ← (byte) sqrt::return#0 + //SEG67 [32] *((byte*) main::screen#2) ← (byte) main::d#0 -- _deref_pbuz1=vbuaa + ldy #0 + sta (screen),y + //SEG68 [33] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1 + inc screen + bne !+ + inc screen+1 + !: + //SEG69 [34] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 + inc x + //SEG70 [35] if((byte) main::x#1!=(byte) $28) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 + lda #$28 + cmp x + bne b5_from_b13 + jmp b9 + //SEG71 main::@9 + b9: + //SEG72 [36] (byte) main::y#1 ← ++ (byte) main::y#10 -- vbuz1=_inc_vbuz1 + inc y + //SEG73 [37] if((byte) main::y#1!=(byte) $19) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$19 + cmp y + bne b1_from_b9 + jmp breturn + //SEG74 main::@return + breturn: + //SEG75 [38] return + rts + //SEG76 main::@6 + b6: + //SEG77 [39] (byte~) main::$16 ← (byte) main::x2#0 - (byte) $27 -- vbuaa=vbuaa_minus_vbuc1 + sec + sbc #$27 + jmp b8_from_b6 + //SEG78 main::@2 + b2: + //SEG79 [40] (byte~) main::$8 ← (byte) main::y2#0 - (byte) $18 -- vbuaa=vbuaa_minus_vbuc1 + sec + sbc #$18 + jmp b4_from_b2 +} +//SEG80 sqrt +// Find the (integer) square root of a word value +// If the square is not an integer then it returns the largest integer N where N*N <= val +// Uses a table of squares that must be initialized by calling init_squares() +// sqrt(word zeropage($18) val) +sqrt: { + .label _3 = 6 + .label val = $18 + .label found = 6 + //SEG81 [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 + //SEG82 [42] call bsearch16u + //SEG83 [49] phi from sqrt to bsearch16u [phi:sqrt->bsearch16u] + bsearch16u_from_sqrt: + jsr bsearch16u + //SEG84 [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 + jmp b1 + //SEG85 sqrt::@1 + b1: + //SEG86 [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 + //SEG87 [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 -- vwuz1=pbuz1_minus_pbuc1 + lda _3 + sec + sbc #HEAP_START + sta _3+1 + //SEG88 [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 -- vbuaa=_byte_vwuz1 + lda _3 + //SEG89 [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 -- vbuaa=vbuaa_ror_1 + lsr + jmp breturn + //SEG90 sqrt::@return + breturn: + //SEG91 [48] return + rts +} +//SEG92 bsearch16u +// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key. +// - key - The value to look for +// - items - Pointer to the start of the array to search in +// - num - The number of items in the array +// Returns pointer to an entry in the array that matches the search key +// bsearch16u(word zeropage($18) key, word* zeropage(6) items, byte register(X) num) +bsearch16u: { + .label _2 = 6 + .label key = $18 + .label return = 6 + .label pivot = $1a + .label result = $1c + .label items = 6 + //SEG93 [50] phi from bsearch16u to bsearch16u::@3 [phi:bsearch16u->bsearch16u::@3] + b3_from_bsearch16u: + //SEG94 [50] phi (word*) bsearch16u::items#2 = (const byte*) HEAP_START#0 [phi:bsearch16u->bsearch16u::@3#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta items+1 + //SEG95 [50] phi (byte) bsearch16u::num#3 = (const byte) NUM_SQUARES#0 [phi:bsearch16u->bsearch16u::@3#1] -- vbuxx=vbuc1 + ldx #NUM_SQUARES + jmp b3 + //SEG96 bsearch16u::@3 + b3: + //SEG97 [51] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4 -- vbuxx_gt_0_then_la1 + cpx #0 + bne b4 + jmp b5 + //SEG98 bsearch16u::@5 + b5: + //SEG99 [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 -- _deref_pwuz1_le_vwuz2_then_la1 + ldy #1 + lda (items),y + cmp key+1 + bne !+ + dey + lda (items),y + cmp key + beq b2_from_b5 + !: + bcc b2_from_b5 + jmp b1 + //SEG100 bsearch16u::@1 + b1: + //SEG101 [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz1_minus_vwuc1 + lda _2 + sec + sbc #<1*SIZEOF_WORD + sta _2 + lda _2+1 + sbc #>1*SIZEOF_WORD + sta _2+1 + //SEG102 [54] phi from bsearch16u::@1 bsearch16u::@5 to bsearch16u::@2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2] + b2_from_b1: + b2_from_b5: + //SEG103 [54] phi (word*) bsearch16u::return#3 = (word*~) bsearch16u::$2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2#0] -- register_copy + jmp b2 + //SEG104 bsearch16u::@2 + b2: + //SEG105 [55] phi from bsearch16u::@2 bsearch16u::@8 to bsearch16u::@return [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return] + breturn_from_b2: + breturn_from_b8: + //SEG106 [55] phi (word*) bsearch16u::return#2 = (word*) bsearch16u::return#3 [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return#0] -- register_copy + jmp breturn + //SEG107 bsearch16u::@return + breturn: + //SEG108 [56] return + rts + //SEG109 bsearch16u::@4 + b4: + //SEG110 [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 -- vbuaa=vbuxx_ror_1 + txa + lsr + //SEG111 [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 -- vbuaa=vbuaa_rol_1 + asl + //SEG112 [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 -- pwuz1=pwuz2_plus_vbuaa + clc + adc items + sta pivot + lda #0 + adc items+1 + sta pivot+1 + //SEG113 [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) -- vwsz1=vwsz2_minus__deref_pwsz3 + sec + lda key + ldy #0 + sbc (pivot),y + sta result + lda key+1 + iny + sbc (pivot),y + sta result+1 + //SEG114 [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 -- vwsz1_neq_0_then_la1 + lda result+1 + bne b6 + lda result + bne b6 + jmp b8 + //SEG115 bsearch16u::@8 + b8: + //SEG116 [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 -- pwuz1=pwuz2 + lda pivot + sta return + lda pivot+1 + sta return+1 + jmp breturn_from_b8 + //SEG117 bsearch16u::@6 + b6: + //SEG118 [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 -- vwsz1_le_0_then_la1 + lda result+1 + bmi b7_from_b6 + bne !+ + lda result + beq b7_from_b6 + !: + jmp b9 + //SEG119 bsearch16u::@9 + b9: + //SEG120 [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz2_plus_vbuc1 + lda #1*SIZEOF_WORD + clc + adc pivot + sta items + lda #0 + adc pivot+1 + sta items+1 + //SEG121 [65] (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#3 -- vbuxx=_dec_vbuxx + dex + //SEG122 [66] phi from bsearch16u::@6 bsearch16u::@9 to bsearch16u::@7 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7] + b7_from_b6: + b7_from_b9: + //SEG123 [66] phi (word*) bsearch16u::items#8 = (word*) bsearch16u::items#2 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#0] -- register_copy + //SEG124 [66] phi (byte) bsearch16u::num#5 = (byte) bsearch16u::num#3 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#1] -- register_copy + jmp b7 + //SEG125 bsearch16u::@7 + b7: + //SEG126 [67] (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (byte) 1 -- vbuxx=vbuxx_ror_1 + txa + lsr + tax + //SEG127 [50] phi from bsearch16u::@7 to bsearch16u::@3 [phi:bsearch16u::@7->bsearch16u::@3] + b3_from_b7: + //SEG128 [50] phi (word*) bsearch16u::items#2 = (word*) bsearch16u::items#8 [phi:bsearch16u::@7->bsearch16u::@3#0] -- register_copy + //SEG129 [50] phi (byte) bsearch16u::num#3 = (byte) bsearch16u::num#1 [phi:bsearch16u::@7->bsearch16u::@3#1] -- register_copy + jmp b3 +} +//SEG130 sqr +// Find the square of a byte value +// Uses a table of squares that must be initialized by calling init_squares() +// sqr(byte register(A) val) +sqr: { + .label return = $16 + .label return_1 = $18 + .label return_2 = $18 + //SEG131 [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 -- vbuaa=vbuaa_rol_1 + asl + //SEG132 [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) -- vwuz1=pbuc1_derefidx_vbuaa + tay + lda HEAP_START,y + sta return_2 + lda #0 + sta return_2+1 + jmp breturn + //SEG133 sqr::@return + breturn: + //SEG134 [71] return + rts +} +//SEG135 init_squares +// Initialize squares table +// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 +init_squares: { + .label squares = $b + .label sqr = 9 + //SEG136 [73] call malloc + //SEG137 [83] phi from init_squares to malloc [phi:init_squares->malloc] + malloc_from_init_squares: + jsr malloc + //SEG138 [74] phi from init_squares to init_squares::@1 [phi:init_squares->init_squares::@1] + b1_from_init_squares: + //SEG139 [74] phi (byte) init_squares::i#2 = (byte) 0 [phi:init_squares->init_squares::@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG140 [74] phi (word*) init_squares::squares#2 = (const byte*) HEAP_START#0 [phi:init_squares->init_squares::@1#1] -- pwuz1=pbuc1 + lda #HEAP_START + sta squares+1 + //SEG141 [74] phi (word) init_squares::sqr#2 = (byte) 0 [phi:init_squares->init_squares::@1#2] -- vwuz1=vbuc1 + lda #0 + sta sqr + lda #0 + sta sqr+1 + jmp b1 + //SEG142 [74] phi from init_squares::@1 to init_squares::@1 [phi:init_squares::@1->init_squares::@1] + b1_from_b1: + //SEG143 [74] phi (byte) init_squares::i#2 = (byte) init_squares::i#1 [phi:init_squares::@1->init_squares::@1#0] -- register_copy + //SEG144 [74] phi (word*) init_squares::squares#2 = (word*) init_squares::squares#1 [phi:init_squares::@1->init_squares::@1#1] -- register_copy + //SEG145 [74] phi (word) init_squares::sqr#2 = (word) init_squares::sqr#1 [phi:init_squares::@1->init_squares::@1#2] -- register_copy + jmp b1 + //SEG146 init_squares::@1 + b1: + //SEG147 [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 -- _deref_pwuz1=vwuz2 + ldy #0 + lda sqr + sta (squares),y + iny + lda sqr+1 + sta (squares),y + //SEG148 [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc squares + sta squares + bcc !+ + inc squares+1 + !: + //SEG149 [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 -- vbuaa=vbuxx_rol_1 + txa + asl + //SEG150 [78] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 -- vbuaa=vbuaa_plus_1 + clc + adc #1 + //SEG151 [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 -- vwuz1=vwuz1_plus_vbuaa + clc + adc sqr + sta sqr + bcc !+ + inc sqr+1 + !: + //SEG152 [80] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG153 [81] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#0-(byte) 1+(byte) 1) goto init_squares::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #NUM_SQUARES-1+1 + bne b1_from_b1 + jmp breturn + //SEG154 init_squares::@return + breturn: + //SEG155 [82] return + rts +} +//SEG156 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + jmp breturn + //SEG157 malloc::@return + breturn: + //SEG158 [84] return + rts +} +//SEG159 init_font_hex +// Make charset from proto chars +// init_font_hex(byte* zeropage($10) charset) +init_font_hex: { + .label _0 = $1e + .label idx = $15 + .label proto_lo = $12 + .label charset = $10 + .label c1 = $14 + .label proto_hi = $d + .label c = $f + //SEG160 [86] phi from init_font_hex to init_font_hex::@1 [phi:init_font_hex->init_font_hex::@1] + b1_from_init_font_hex: + //SEG161 [86] phi (byte) init_font_hex::c#6 = (byte) 0 [phi:init_font_hex->init_font_hex::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG162 [86] phi (byte*) init_font_hex::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex->init_font_hex::@1#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + //SEG163 [86] phi (byte*) init_font_hex::charset#5 = (const byte*) CHARSET#0 [phi:init_font_hex->init_font_hex::@1#2] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + jmp b1 + //SEG164 [86] phi from init_font_hex::@5 to init_font_hex::@1 [phi:init_font_hex::@5->init_font_hex::@1] + b1_from_b5: + //SEG165 [86] phi (byte) init_font_hex::c#6 = (byte) init_font_hex::c#1 [phi:init_font_hex::@5->init_font_hex::@1#0] -- register_copy + //SEG166 [86] phi (byte*) init_font_hex::proto_hi#6 = (byte*) init_font_hex::proto_hi#1 [phi:init_font_hex::@5->init_font_hex::@1#1] -- register_copy + //SEG167 [86] phi (byte*) init_font_hex::charset#5 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@5->init_font_hex::@1#2] -- register_copy + jmp b1 + //SEG168 init_font_hex::@1 + b1: + //SEG169 [87] phi from init_font_hex::@1 to init_font_hex::@2 [phi:init_font_hex::@1->init_font_hex::@2] + b2_from_b1: + //SEG170 [87] phi (byte) init_font_hex::c1#4 = (byte) 0 [phi:init_font_hex::@1->init_font_hex::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c1 + //SEG171 [87] phi (byte*) init_font_hex::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex::@1->init_font_hex::@2#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + //SEG172 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#5 [phi:init_font_hex::@1->init_font_hex::@2#2] -- register_copy + jmp b2 + //SEG173 [87] phi from init_font_hex::@4 to init_font_hex::@2 [phi:init_font_hex::@4->init_font_hex::@2] + b2_from_b4: + //SEG174 [87] phi (byte) init_font_hex::c1#4 = (byte) init_font_hex::c1#1 [phi:init_font_hex::@4->init_font_hex::@2#0] -- register_copy + //SEG175 [87] phi (byte*) init_font_hex::proto_lo#4 = (byte*) init_font_hex::proto_lo#1 [phi:init_font_hex::@4->init_font_hex::@2#1] -- register_copy + //SEG176 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@4->init_font_hex::@2#2] -- register_copy + jmp b2 + //SEG177 init_font_hex::@2 + b2: + //SEG178 [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 -- _deref_pbuz1=vbuc1 + lda #0 + ldy #0 + sta (charset),y + //SEG179 [89] phi from init_font_hex::@2 to init_font_hex::@3 [phi:init_font_hex::@2->init_font_hex::@3] + b3_from_b2: + //SEG180 [89] phi (byte) init_font_hex::idx#5 = (byte) 1 [phi:init_font_hex::@2->init_font_hex::@3#0] -- vbuz1=vbuc1 + lda #1 + sta idx + //SEG181 [89] phi (byte) init_font_hex::i#2 = (byte) 0 [phi:init_font_hex::@2->init_font_hex::@3#1] -- vbuxx=vbuc1 + ldx #0 + jmp b3 + //SEG182 [89] phi from init_font_hex::@3 to init_font_hex::@3 [phi:init_font_hex::@3->init_font_hex::@3] + b3_from_b3: + //SEG183 [89] phi (byte) init_font_hex::idx#5 = (byte) init_font_hex::idx#2 [phi:init_font_hex::@3->init_font_hex::@3#0] -- register_copy + //SEG184 [89] phi (byte) init_font_hex::i#2 = (byte) init_font_hex::i#1 [phi:init_font_hex::@3->init_font_hex::@3#1] -- register_copy + jmp b3 + //SEG185 init_font_hex::@3 + b3: + //SEG186 [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 -- vbuz1=pbuz2_derefidx_vbuxx_rol_4 + txa + tay + lda (proto_hi),y + asl + asl + asl + asl + sta _0 + //SEG187 [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 -- vbuaa=pbuz1_derefidx_vbuxx_rol_1 + txa + tay + lda (proto_lo),y + asl + //SEG188 [92] (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 -- vbuaa=vbuz1_bor_vbuaa + ora _0 + //SEG189 [93] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 -- pbuz1_derefidx_vbuz2=vbuaa + ldy idx + sta (charset),y + //SEG190 [94] (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 -- vbuz1=_inc_vbuz1 + inc idx + //SEG191 [95] (byte) init_font_hex::i#1 ← ++ (byte) init_font_hex::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG192 [96] if((byte) init_font_hex::i#1!=(byte) 5) goto init_font_hex::@3 -- vbuxx_neq_vbuc1_then_la1 + cpx #5 + bne b3_from_b3 + jmp b4 + //SEG193 init_font_hex::@4 + b4: + //SEG194 [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 -- pbuz1_derefidx_vbuz2=vbuc1 + lda #0 + ldy idx + sta (charset),y + //SEG195 [98] (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#2 -- vbuyy=_inc_vbuz1 + ldy idx + iny + //SEG196 [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 -- pbuz1_derefidx_vbuyy=vbuc1 + lda #0 + sta (charset),y + //SEG197 [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG198 [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG199 [102] (byte) init_font_hex::c1#1 ← ++ (byte) init_font_hex::c1#4 -- vbuz1=_inc_vbuz1 + inc c1 + //SEG200 [103] if((byte) init_font_hex::c1#1!=(byte) $10) goto init_font_hex::@2 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c1 + bne b2_from_b4 + jmp b5 + //SEG201 init_font_hex::@5 + b5: + //SEG202 [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG203 [105] (byte) init_font_hex::c#1 ← ++ (byte) init_font_hex::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG204 [106] if((byte) init_font_hex::c#1!=(byte) $10) goto init_font_hex::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1_from_b5 + jmp breturn + //SEG205 init_font_hex::@return + breturn: + //SEG206 [107] return + rts +} +//SEG207 File Data + // Bit patterns for symbols 0-f (3x5 pixels) used in font hex + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4 + +ASSEMBLER OPTIMIZATIONS +Removing instruction jmp b1 +Removing instruction jmp bend +Removing instruction jmp toD0181 +Removing instruction jmp b10 +Removing instruction jmp b1 +Removing instruction jmp b3 +Removing instruction jmp b4 +Removing instruction jmp b11 +Removing instruction jmp b5 +Removing instruction jmp b7 +Removing instruction jmp b8 +Removing instruction jmp b12 +Removing instruction jmp b13 +Removing instruction jmp b9 +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp breturn +Removing instruction jmp b3 +Removing instruction jmp b5 +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp breturn +Removing instruction jmp b8 +Removing instruction jmp b9 +Removing instruction jmp b7 +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp breturn +Removing instruction jmp breturn +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Removing instruction jmp b4 +Removing instruction jmp b5 +Removing instruction jmp breturn +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction lda result+1 +Replacing instruction lda #0 with TXA +Removing instruction lda #0 +Replacing instruction ldy #0 with TAY +Removing instruction ldy idx +Removing instruction lda #0 +Succesful ASM optimization Pass5UnnecesaryLoadElimination +Replacing label b5_from_b13 with b5 +Replacing label b1_from_b9 with b1 +Replacing label b8_from_b6 with b8 +Replacing label b4_from_b2 with b4 +Replacing label b2_from_b5 with b2 +Replacing label b2_from_b5 with b2 +Replacing label breturn_from_b8 with b2 +Replacing label b7_from_b6 with b7 +Replacing label b7_from_b6 with b7 +Replacing label b1_from_b1 with b1 +Replacing label b3_from_b3 with b3 +Replacing label b2_from_b4 with b2 +Replacing label b1_from_b5 with b1 +Removing instruction b1_from_bbegin: +Removing instruction b1: +Removing instruction main_from_b1: +Removing instruction bend_from_b1: +Removing instruction toD0181_from_main: +Removing instruction toD0181: +Removing instruction b1_from_b9: +Removing instruction b4_from_b2: +Removing instruction b4_from_b3: +Removing instruction sqr_from_b4: +Removing instruction b5_from_b11: +Removing instruction b5_from_b13: +Removing instruction b8_from_b6: +Removing instruction b8_from_b7: +Removing instruction sqr_from_b8: +Removing instruction b2_from_b1: +Removing instruction b2_from_b5: +Removing instruction breturn_from_b2: +Removing instruction breturn_from_b8: +Removing instruction breturn: +Removing instruction b7_from_b6: +Removing instruction b7_from_b9: +Removing instruction b1_from_b1: +Removing instruction b1_from_b5: +Removing instruction b2_from_b1: +Removing instruction b2_from_b4: +Removing instruction b3_from_b3: +Succesful ASM optimization Pass5RedundantLabelElimination +Removing instruction bend: +Removing instruction init_font_hex_from_main: +Removing instruction b10: +Removing instruction init_squares_from_b10: +Removing instruction b1_from_b10: +Removing instruction b3: +Removing instruction b11: +Removing instruction b7: +Removing instruction b12: +Removing instruction b13: +Removing instruction b9: +Removing instruction breturn: +Removing instruction bsearch16u_from_sqrt: +Removing instruction b1: +Removing instruction breturn: +Removing instruction b3_from_bsearch16u: +Removing instruction b5: +Removing instruction b1: +Removing instruction b8: +Removing instruction b9: +Removing instruction b3_from_b7: +Removing instruction breturn: +Removing instruction malloc_from_init_squares: +Removing instruction b1_from_init_squares: +Removing instruction breturn: +Removing instruction breturn: +Removing instruction b1_from_init_font_hex: +Removing instruction b3_from_b2: +Removing instruction b4: +Removing instruction b5: +Removing instruction breturn: +Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Replacing jump to rts with rts in jmp b2 +Succesful ASM optimization Pass5DoubleJumpElimination +Removing instruction jmp b1 +Removing instruction jmp b5 +Removing instruction jmp b1 +Removing instruction jmp b1 +Removing instruction jmp b2 +Removing instruction jmp b3 +Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination + +FINAL SYMBOL TABLE +(label) @1 +(label) @begin +(label) @end +(byte*) CHARSET +(const byte*) CHARSET#0 CHARSET = (byte*) 8192 +(byte*) D018 +(const byte*) D018#0 D018 = (byte*) 53272 +(byte[]) FONT_HEX_PROTO +(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 } +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(byte) NUM_SQUARES +(const byte) NUM_SQUARES#0 NUM_SQUARES = (byte) $30 +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 10240 +(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 +(word*) SQUARES +(word*()) bsearch16u((word) bsearch16u::key , (word*) bsearch16u::items , (byte) bsearch16u::num) +(byte~) bsearch16u::$16 reg byte a 2002.0 +(word*~) bsearch16u::$2 $2 zp ZP_WORD:6 4.0 +(byte~) bsearch16u::$6 reg byte a 2002.0 +(label) bsearch16u::@1 +(label) bsearch16u::@2 +(label) bsearch16u::@3 +(label) bsearch16u::@4 +(label) bsearch16u::@5 +(label) bsearch16u::@6 +(label) bsearch16u::@7 +(label) bsearch16u::@8 +(label) bsearch16u::@9 +(label) bsearch16u::@return +(word*) bsearch16u::items +(word*) bsearch16u::items#1 items zp ZP_WORD:6 1001.0 +(word*) bsearch16u::items#2 items zp ZP_WORD:6 334.33333333333337 +(word*) bsearch16u::items#8 items zp ZP_WORD:6 1501.5 +(word) bsearch16u::key +(word) bsearch16u::key#0 key zp ZP_WORD:24 0.2857142857142857 +(byte) bsearch16u::num +(byte) bsearch16u::num#1 reg byte x 2002.0 +(byte) bsearch16u::num#2 reg byte x 2002.0 +(byte) bsearch16u::num#3 reg byte x 556.1111111111111 +(byte) bsearch16u::num#5 reg byte x 3003.0 +(word*) bsearch16u::pivot +(word*) bsearch16u::pivot#0 pivot zp ZP_WORD:26 501.0 +(signed word) bsearch16u::result +(signed word) bsearch16u::result#0 result zp ZP_WORD:28 1501.5 +(word*) bsearch16u::return +(word*) bsearch16u::return#0 return zp ZP_WORD:6 4.0 +(word*) bsearch16u::return#2 return zp ZP_WORD:6 2.0 +(word*) bsearch16u::return#3 return zp ZP_WORD:6 6.0 +(word*~) bsearch16u::return#6 return zp ZP_WORD:6 4.0 +(byte*) heap_head +(void()) init_font_hex((byte*) init_font_hex::charset) +(byte~) init_font_hex::$0 $0 zp ZP_BYTE:30 1001.0 +(byte~) init_font_hex::$1 reg byte a 2002.0 +(byte~) init_font_hex::$2 reg byte a 2002.0 +(label) init_font_hex::@1 +(label) init_font_hex::@2 +(label) init_font_hex::@3 +(label) init_font_hex::@4 +(label) init_font_hex::@5 +(label) init_font_hex::@return +(byte) init_font_hex::c +(byte) init_font_hex::c#1 c zp ZP_BYTE:15 16.5 +(byte) init_font_hex::c#6 c zp ZP_BYTE:15 1.1578947368421053 +(byte) init_font_hex::c1 +(byte) init_font_hex::c1#1 c1 zp ZP_BYTE:20 151.5 +(byte) init_font_hex::c1#4 c1 zp ZP_BYTE:20 13.466666666666667 +(byte*) init_font_hex::charset +(byte*) init_font_hex::charset#0 charset zp ZP_WORD:16 35.5 +(byte*) init_font_hex::charset#2 charset zp ZP_WORD:16 108.35714285714285 +(byte*) init_font_hex::charset#5 charset zp ZP_WORD:16 22.0 +(byte) init_font_hex::i +(byte) init_font_hex::i#1 reg byte x 1501.5 +(byte) init_font_hex::i#2 reg byte x 667.3333333333334 +(byte) init_font_hex::idx +(byte) init_font_hex::idx#2 idx zp ZP_BYTE:21 551.0 +(byte) init_font_hex::idx#3 reg byte y 202.0 +(byte) init_font_hex::idx#5 idx zp ZP_BYTE:21 600.5999999999999 +(byte*) init_font_hex::proto_hi +(byte*) init_font_hex::proto_hi#1 proto_hi zp ZP_WORD:13 7.333333333333333 +(byte*) init_font_hex::proto_hi#6 proto_hi zp ZP_WORD:13 56.83333333333334 +(byte*) init_font_hex::proto_lo +(byte*) init_font_hex::proto_lo#1 proto_lo zp ZP_WORD:18 50.5 +(byte*) init_font_hex::proto_lo#4 proto_lo zp ZP_WORD:18 92.53846153846155 +(void()) init_squares() +(byte~) init_squares::$3 reg byte a 22.0 +(byte~) init_squares::$4 reg byte a 22.0 +(label) init_squares::@1 +(label) init_squares::@return +(byte) init_squares::i +(byte) init_squares::i#1 reg byte x 16.5 +(byte) init_squares::i#2 reg byte x 5.5 +(word) init_squares::sqr +(word) init_squares::sqr#1 sqr zp ZP_WORD:9 7.333333333333333 +(word) init_squares::sqr#2 sqr zp ZP_WORD:9 6.6000000000000005 +(word*) init_squares::squares +(word*) init_squares::squares#1 squares zp ZP_WORD:11 3.6666666666666665 +(word*) init_squares::squares#2 squares zp ZP_WORD:11 16.5 +(void()) main() +(byte~) main::$14 reg byte a 202.0 +(byte~) main::$16 reg byte a 202.0 +(byte~) main::$6 reg byte a 22.0 +(byte~) main::$8 reg byte a 22.0 +(label) main::@1 +(label) main::@10 +(label) main::@11 +(label) main::@12 +(label) main::@13 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@8 +(label) main::@9 +(label) main::@return +(byte) main::d +(byte) main::d#0 reg byte a 202.0 +(word) main::ds +(word) main::ds#0 ds zp ZP_WORD:24 202.0 +(byte*) main::screen +(byte*) main::screen#1 screen zp ZP_WORD:4 42.599999999999994 +(byte*) main::screen#10 screen zp ZP_WORD:4 2.2 +(byte*) main::screen#2 screen zp ZP_WORD:4 19.625 +(label) main::toD0181 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(const byte) main::toD0181_return#0 toD0181_return = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4|>(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +(byte*) main::toD0181_screen +(byte) main::x +(byte) main::x#1 x zp ZP_BYTE:3 151.5 +(byte) main::x#2 x zp ZP_BYTE:3 17.823529411764707 +(byte) main::x2 +(byte) main::x2#0 reg byte a 202.0 +(byte) main::xd +(byte) main::xd#0 reg byte a 303.0 +(word) main::xds +(word) main::xds#0 xds zp ZP_WORD:24 202.0 +(byte) main::y +(byte) main::y#1 y zp ZP_BYTE:2 16.5 +(byte) main::y#10 y zp ZP_BYTE:2 1.1379310344827585 +(byte) main::y2 +(byte) main::y2#0 reg byte a 22.0 +(byte) main::yd +(byte) main::yd#0 reg byte a 33.0 +(word) main::yds +(word) main::yds#0 yds zp ZP_WORD:22 5.6 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size +(word()) sqr((byte) sqr::val) +(byte~) sqr::$0 reg byte a 4.0 +(label) sqr::@return +(word) sqr::return +(word) sqr::return#0 return zp ZP_WORD:22 22.0 +(word) sqr::return#1 return#1 zp ZP_WORD:24 202.0 +(word) sqr::return#2 return#2 zp ZP_WORD:24 28.5 +(byte) sqr::val +(byte) sqr::val#0 reg byte a 22.0 +(byte) sqr::val#1 reg byte a 202.0 +(byte) sqr::val#2 reg byte a 114.0 +(byte()) sqrt((word) sqrt::val) +(word~) sqrt::$3 $3 zp ZP_WORD:6 2.0 +(byte~) sqrt::$4 reg byte a 4.0 +(label) sqrt::@1 +(label) sqrt::@return +(word*) sqrt::found +(word*) sqrt::found#0 found zp ZP_WORD:6 2.0 +(byte) sqrt::return +(byte) sqrt::return#0 reg byte a 202.0 +(byte) sqrt::return#1 reg byte a 34.33333333333333 +(byte) sqrt::sqr1 +(word) sqrt::val +(word) sqrt::val#0 val zp ZP_WORD:24 103.0 + +zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +reg byte a [ main::yd#0 main::$8 main::$6 ] +zp ZP_BYTE:3 [ main::x#2 main::x#1 ] +zp ZP_WORD:4 [ main::screen#2 main::screen#10 main::screen#1 ] +reg byte a [ main::xd#0 main::$16 main::$14 ] +zp ZP_WORD:6 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 bsearch16u::return#0 sqrt::found#0 sqrt::$3 ] +reg byte x [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +reg byte a [ sqr::val#2 sqr::val#0 sqr::val#1 ] +zp ZP_WORD:9 [ init_squares::sqr#2 init_squares::sqr#1 ] +zp ZP_WORD:11 [ init_squares::squares#2 init_squares::squares#1 ] +reg byte x [ init_squares::i#2 init_squares::i#1 ] +zp ZP_WORD:13 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +zp ZP_BYTE:15 [ init_font_hex::c#6 init_font_hex::c#1 ] +zp ZP_WORD:16 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +zp ZP_WORD:18 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +zp ZP_BYTE:20 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +reg byte x [ init_font_hex::i#2 init_font_hex::i#1 ] +zp ZP_BYTE:21 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +reg byte a [ main::y2#0 ] +zp ZP_WORD:22 [ sqr::return#0 main::yds#0 ] +reg byte a [ main::x2#0 ] +zp ZP_WORD:24 [ sqr::return#1 main::xds#0 sqr::return#2 main::ds#0 sqrt::val#0 bsearch16u::key#0 ] +reg byte a [ sqrt::return#0 ] +reg byte a [ main::d#0 ] +reg byte a [ sqrt::$4 ] +reg byte a [ sqrt::return#1 ] +reg byte a [ bsearch16u::$6 ] +reg byte a [ bsearch16u::$16 ] +zp ZP_WORD:26 [ bsearch16u::pivot#0 ] +zp ZP_WORD:28 [ bsearch16u::result#0 ] +reg byte a [ sqr::$0 ] +reg byte a [ init_squares::$3 ] +reg byte a [ init_squares::$4 ] +zp ZP_BYTE:30 [ init_font_hex::$0 ] +reg byte a [ init_font_hex::$1 ] +reg byte a [ init_font_hex::$2 ] +reg byte y [ init_font_hex::idx#3 ] + + +FINAL ASSEMBLER +Score: 200552 + +//SEG0 File Comments +// Calculate the distance to the center of the screen - and show it using font-hex +//SEG1 Basic Upstart +.pc = $801 "Basic" +:BasicUpstart(main) +.pc = $80d "Program" +//SEG2 Global Constants & labels + .const SIZEOF_WORD = 2 + // Start of the heap used by malloc() + .label HEAP_START = $c000 + .label D018 = $d018 + .label CHARSET = $2000 + .label SCREEN = $2800 + .const NUM_SQUARES = $30 +//SEG3 @begin +//SEG4 [1] phi from @begin to @1 [phi:@begin->@1] +//SEG5 @1 +//SEG6 [2] call main +//SEG7 [4] phi from @1 to main [phi:@1->main] +//SEG8 [3] phi from @1 to @end [phi:@1->@end] +//SEG9 @end +//SEG10 main +main: { + .const toD0181_return = (>(SCREEN&$3fff)*4)|(>CHARSET)/4&$f + .label yds = $16 + .label xds = $18 + .label ds = $18 + .label screen = 4 + .label x = 3 + .label y = 2 + //SEG11 [5] call init_font_hex + //SEG12 [85] phi from main to init_font_hex [phi:main->init_font_hex] + jsr init_font_hex + //SEG13 [6] phi from main to main::toD0181 [phi:main->main::toD0181] + //SEG14 main::toD0181 + //SEG15 main::@10 + //SEG16 [7] *((const byte*) D018#0) ← (const byte) main::toD0181_return#0 -- _deref_pbuc1=vbuc2 + lda #toD0181_return + sta D018 + //SEG17 [8] call init_squares + //SEG18 [72] phi from main::@10 to init_squares [phi:main::@10->init_squares] + jsr init_squares + //SEG19 [9] phi from main::@10 to main::@1 [phi:main::@10->main::@1] + //SEG20 [9] phi (byte*) main::screen#10 = (const byte*) SCREEN#0 [phi:main::@10->main::@1#0] -- pbuz1=pbuc1 + lda #SCREEN + sta screen+1 + //SEG21 [9] phi (byte) main::y#10 = (byte) 0 [phi:main::@10->main::@1#1] -- vbuz1=vbuc1 + lda #0 + sta y + //SEG22 [9] phi from main::@9 to main::@1 [phi:main::@9->main::@1] + //SEG23 [9] phi (byte*) main::screen#10 = (byte*) main::screen#1 [phi:main::@9->main::@1#0] -- register_copy + //SEG24 [9] phi (byte) main::y#10 = (byte) main::y#1 [phi:main::@9->main::@1#1] -- register_copy + //SEG25 main::@1 + b1: + //SEG26 [10] (byte) main::y2#0 ← (byte) main::y#10 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda y + asl + //SEG27 [11] if((byte) main::y2#0>=(byte) $18) goto main::@2 -- vbuaa_ge_vbuc1_then_la1 + cmp #$18 + bcs b2 + //SEG28 main::@3 + //SEG29 [12] (byte~) main::$6 ← (byte) $18 - (byte) main::y2#0 -- vbuaa=vbuc1_minus_vbuaa + eor #$ff + clc + adc #$18+1 + //SEG30 [13] phi from main::@2 main::@3 to main::@4 [phi:main::@2/main::@3->main::@4] + //SEG31 [13] phi (byte) main::yd#0 = (byte~) main::$8 [phi:main::@2/main::@3->main::@4#0] -- register_copy + //SEG32 main::@4 + b4: + //SEG33 [14] (byte) sqr::val#0 ← (byte) main::yd#0 + //SEG34 [15] call sqr + //SEG35 [68] phi from main::@4 to sqr [phi:main::@4->sqr] + //SEG36 [68] phi (byte) sqr::val#2 = (byte) sqr::val#0 [phi:main::@4->sqr#0] -- register_copy + jsr sqr + //SEG37 [16] (word) sqr::return#0 ← (word) sqr::return#2 -- vwuz1=vwuz2 + lda sqr.return_2 + sta sqr.return + lda sqr.return_2+1 + sta sqr.return+1 + //SEG38 main::@11 + //SEG39 [17] (word) main::yds#0 ← (word) sqr::return#0 + //SEG40 [18] phi from main::@11 to main::@5 [phi:main::@11->main::@5] + //SEG41 [18] phi (byte*) main::screen#2 = (byte*) main::screen#10 [phi:main::@11->main::@5#0] -- register_copy + //SEG42 [18] phi (byte) main::x#2 = (byte) 0 [phi:main::@11->main::@5#1] -- vbuz1=vbuc1 + lda #0 + sta x + //SEG43 [18] phi from main::@13 to main::@5 [phi:main::@13->main::@5] + //SEG44 [18] phi (byte*) main::screen#2 = (byte*) main::screen#1 [phi:main::@13->main::@5#0] -- register_copy + //SEG45 [18] phi (byte) main::x#2 = (byte) main::x#1 [phi:main::@13->main::@5#1] -- register_copy + //SEG46 main::@5 + b5: + //SEG47 [19] (byte) main::x2#0 ← (byte) main::x#2 << (byte) 1 -- vbuaa=vbuz1_rol_1 + lda x + asl + //SEG48 [20] if((byte) main::x2#0>=(byte) $27) goto main::@6 -- vbuaa_ge_vbuc1_then_la1 + cmp #$27 + bcs b6 + //SEG49 main::@7 + //SEG50 [21] (byte~) main::$14 ← (byte) $27 - (byte) main::x2#0 -- vbuaa=vbuc1_minus_vbuaa + eor #$ff + clc + adc #$27+1 + //SEG51 [22] phi from main::@6 main::@7 to main::@8 [phi:main::@6/main::@7->main::@8] + //SEG52 [22] phi (byte) main::xd#0 = (byte~) main::$16 [phi:main::@6/main::@7->main::@8#0] -- register_copy + //SEG53 main::@8 + b8: + //SEG54 [23] (byte) sqr::val#1 ← (byte) main::xd#0 + //SEG55 [24] call sqr + //SEG56 [68] phi from main::@8 to sqr [phi:main::@8->sqr] + //SEG57 [68] phi (byte) sqr::val#2 = (byte) sqr::val#1 [phi:main::@8->sqr#0] -- register_copy + jsr sqr + //SEG58 [25] (word) sqr::return#1 ← (word) sqr::return#2 + //SEG59 main::@12 + //SEG60 [26] (word) main::xds#0 ← (word) sqr::return#1 + //SEG61 [27] (word) main::ds#0 ← (word) main::xds#0 + (word) main::yds#0 -- vwuz1=vwuz1_plus_vwuz2 + lda ds + clc + adc yds + sta ds + lda ds+1 + adc yds+1 + sta ds+1 + //SEG62 [28] (word) sqrt::val#0 ← (word) main::ds#0 + //SEG63 [29] call sqrt + jsr sqrt + //SEG64 [30] (byte) sqrt::return#0 ← (byte) sqrt::return#1 + //SEG65 main::@13 + //SEG66 [31] (byte) main::d#0 ← (byte) sqrt::return#0 + //SEG67 [32] *((byte*) main::screen#2) ← (byte) main::d#0 -- _deref_pbuz1=vbuaa + ldy #0 + sta (screen),y + //SEG68 [33] (byte*) main::screen#1 ← ++ (byte*) main::screen#2 -- pbuz1=_inc_pbuz1 + inc screen + bne !+ + inc screen+1 + !: + //SEG69 [34] (byte) main::x#1 ← ++ (byte) main::x#2 -- vbuz1=_inc_vbuz1 + inc x + //SEG70 [35] if((byte) main::x#1!=(byte) $28) goto main::@5 -- vbuz1_neq_vbuc1_then_la1 + lda #$28 + cmp x + bne b5 + //SEG71 main::@9 + //SEG72 [36] (byte) main::y#1 ← ++ (byte) main::y#10 -- vbuz1=_inc_vbuz1 + inc y + //SEG73 [37] if((byte) main::y#1!=(byte) $19) goto main::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$19 + cmp y + bne b1 + //SEG74 main::@return + //SEG75 [38] return + rts + //SEG76 main::@6 + b6: + //SEG77 [39] (byte~) main::$16 ← (byte) main::x2#0 - (byte) $27 -- vbuaa=vbuaa_minus_vbuc1 + sec + sbc #$27 + jmp b8 + //SEG78 main::@2 + b2: + //SEG79 [40] (byte~) main::$8 ← (byte) main::y2#0 - (byte) $18 -- vbuaa=vbuaa_minus_vbuc1 + sec + sbc #$18 + jmp b4 +} +//SEG80 sqrt +// Find the (integer) square root of a word value +// If the square is not an integer then it returns the largest integer N where N*N <= val +// Uses a table of squares that must be initialized by calling init_squares() +// sqrt(word zeropage($18) val) +sqrt: { + .label _3 = 6 + .label val = $18 + .label found = 6 + //SEG81 [41] (word) bsearch16u::key#0 ← (word) sqrt::val#0 + //SEG82 [42] call bsearch16u + //SEG83 [49] phi from sqrt to bsearch16u [phi:sqrt->bsearch16u] + jsr bsearch16u + //SEG84 [43] (word*) bsearch16u::return#0 ← (word*) bsearch16u::return#2 + //SEG85 sqrt::@1 + //SEG86 [44] (word*) sqrt::found#0 ← (word*) bsearch16u::return#0 + //SEG87 [45] (word~) sqrt::$3 ← (byte*)(word*) sqrt::found#0 - (const byte*) HEAP_START#0 -- vwuz1=pbuz1_minus_pbuc1 + lda _3 + sec + sbc #HEAP_START + sta _3+1 + //SEG88 [46] (byte~) sqrt::$4 ← (byte)(word~) sqrt::$3 -- vbuaa=_byte_vwuz1 + lda _3 + //SEG89 [47] (byte) sqrt::return#1 ← (byte~) sqrt::$4 >> (byte) 1 -- vbuaa=vbuaa_ror_1 + lsr + //SEG90 sqrt::@return + //SEG91 [48] return + rts +} +//SEG92 bsearch16u +// Searches an array of nitems unsigned words, the initial member of which is pointed to by base, for a member that matches the value key. +// - key - The value to look for +// - items - Pointer to the start of the array to search in +// - num - The number of items in the array +// Returns pointer to an entry in the array that matches the search key +// bsearch16u(word zeropage($18) key, word* zeropage(6) items, byte register(X) num) +bsearch16u: { + .label _2 = 6 + .label key = $18 + .label return = 6 + .label pivot = $1a + .label result = $1c + .label items = 6 + //SEG93 [50] phi from bsearch16u to bsearch16u::@3 [phi:bsearch16u->bsearch16u::@3] + //SEG94 [50] phi (word*) bsearch16u::items#2 = (const byte*) HEAP_START#0 [phi:bsearch16u->bsearch16u::@3#0] -- pwuz1=pbuc1 + lda #HEAP_START + sta items+1 + //SEG95 [50] phi (byte) bsearch16u::num#3 = (const byte) NUM_SQUARES#0 [phi:bsearch16u->bsearch16u::@3#1] -- vbuxx=vbuc1 + ldx #NUM_SQUARES + //SEG96 bsearch16u::@3 + b3: + //SEG97 [51] if((byte) bsearch16u::num#3>(byte) 0) goto bsearch16u::@4 -- vbuxx_gt_0_then_la1 + cpx #0 + bne b4 + //SEG98 bsearch16u::@5 + //SEG99 [52] if(*((word*) bsearch16u::items#2)<=(word) bsearch16u::key#0) goto bsearch16u::@2 -- _deref_pwuz1_le_vwuz2_then_la1 + ldy #1 + lda (items),y + cmp key+1 + bne !+ + dey + lda (items),y + cmp key + beq b2 + !: + bcc b2 + //SEG100 bsearch16u::@1 + //SEG101 [53] (word*~) bsearch16u::$2 ← (word*) bsearch16u::items#2 - (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz1_minus_vwuc1 + lda _2 + sec + sbc #<1*SIZEOF_WORD + sta _2 + lda _2+1 + sbc #>1*SIZEOF_WORD + sta _2+1 + //SEG102 [54] phi from bsearch16u::@1 bsearch16u::@5 to bsearch16u::@2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2] + //SEG103 [54] phi (word*) bsearch16u::return#3 = (word*~) bsearch16u::$2 [phi:bsearch16u::@1/bsearch16u::@5->bsearch16u::@2#0] -- register_copy + //SEG104 bsearch16u::@2 + b2: + //SEG105 [55] phi from bsearch16u::@2 bsearch16u::@8 to bsearch16u::@return [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return] + //SEG106 [55] phi (word*) bsearch16u::return#2 = (word*) bsearch16u::return#3 [phi:bsearch16u::@2/bsearch16u::@8->bsearch16u::@return#0] -- register_copy + //SEG107 bsearch16u::@return + //SEG108 [56] return + rts + //SEG109 bsearch16u::@4 + b4: + //SEG110 [57] (byte~) bsearch16u::$6 ← (byte) bsearch16u::num#3 >> (byte) 1 -- vbuaa=vbuxx_ror_1 + txa + lsr + //SEG111 [58] (byte~) bsearch16u::$16 ← (byte~) bsearch16u::$6 << (byte) 1 -- vbuaa=vbuaa_rol_1 + asl + //SEG112 [59] (word*) bsearch16u::pivot#0 ← (word*) bsearch16u::items#2 + (byte~) bsearch16u::$16 -- pwuz1=pwuz2_plus_vbuaa + clc + adc items + sta pivot + lda #0 + adc items+1 + sta pivot+1 + //SEG113 [60] (signed word) bsearch16u::result#0 ← (signed word)(word) bsearch16u::key#0 - (signed word)*((word*) bsearch16u::pivot#0) -- vwsz1=vwsz2_minus__deref_pwsz3 + sec + lda key + ldy #0 + sbc (pivot),y + sta result + lda key+1 + iny + sbc (pivot),y + sta result+1 + //SEG114 [61] if((signed word) bsearch16u::result#0!=(signed byte) 0) goto bsearch16u::@6 -- vwsz1_neq_0_then_la1 + bne b6 + lda result + bne b6 + //SEG115 bsearch16u::@8 + //SEG116 [62] (word*~) bsearch16u::return#6 ← (word*) bsearch16u::pivot#0 -- pwuz1=pwuz2 + lda pivot + sta return + lda pivot+1 + sta return+1 + rts + //SEG117 bsearch16u::@6 + b6: + //SEG118 [63] if((signed word) bsearch16u::result#0<=(signed byte) 0) goto bsearch16u::@7 -- vwsz1_le_0_then_la1 + lda result+1 + bmi b7 + bne !+ + lda result + beq b7 + !: + //SEG119 bsearch16u::@9 + //SEG120 [64] (word*) bsearch16u::items#1 ← (word*) bsearch16u::pivot#0 + (byte) 1*(const byte) SIZEOF_WORD -- pwuz1=pwuz2_plus_vbuc1 + lda #1*SIZEOF_WORD + clc + adc pivot + sta items + lda #0 + adc pivot+1 + sta items+1 + //SEG121 [65] (byte) bsearch16u::num#2 ← -- (byte) bsearch16u::num#3 -- vbuxx=_dec_vbuxx + dex + //SEG122 [66] phi from bsearch16u::@6 bsearch16u::@9 to bsearch16u::@7 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7] + //SEG123 [66] phi (word*) bsearch16u::items#8 = (word*) bsearch16u::items#2 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#0] -- register_copy + //SEG124 [66] phi (byte) bsearch16u::num#5 = (byte) bsearch16u::num#3 [phi:bsearch16u::@6/bsearch16u::@9->bsearch16u::@7#1] -- register_copy + //SEG125 bsearch16u::@7 + b7: + //SEG126 [67] (byte) bsearch16u::num#1 ← (byte) bsearch16u::num#5 >> (byte) 1 -- vbuxx=vbuxx_ror_1 + txa + lsr + tax + //SEG127 [50] phi from bsearch16u::@7 to bsearch16u::@3 [phi:bsearch16u::@7->bsearch16u::@3] + //SEG128 [50] phi (word*) bsearch16u::items#2 = (word*) bsearch16u::items#8 [phi:bsearch16u::@7->bsearch16u::@3#0] -- register_copy + //SEG129 [50] phi (byte) bsearch16u::num#3 = (byte) bsearch16u::num#1 [phi:bsearch16u::@7->bsearch16u::@3#1] -- register_copy + jmp b3 +} +//SEG130 sqr +// Find the square of a byte value +// Uses a table of squares that must be initialized by calling init_squares() +// sqr(byte register(A) val) +sqr: { + .label return = $16 + .label return_1 = $18 + .label return_2 = $18 + //SEG131 [69] (byte~) sqr::$0 ← (byte) sqr::val#2 << (byte) 1 -- vbuaa=vbuaa_rol_1 + asl + //SEG132 [70] (word) sqr::return#2 ← *((const byte*) HEAP_START#0 + (byte~) sqr::$0) -- vwuz1=pbuc1_derefidx_vbuaa + tay + lda HEAP_START,y + sta return_2 + lda #0 + sta return_2+1 + //SEG133 sqr::@return + //SEG134 [71] return + rts +} +//SEG135 init_squares +// Initialize squares table +// Uses iterative formula (x+1)^2 = x^2 + 2*x + 1 +init_squares: { + .label squares = $b + .label sqr = 9 + //SEG136 [73] call malloc + //SEG137 [83] phi from init_squares to malloc [phi:init_squares->malloc] + jsr malloc + //SEG138 [74] phi from init_squares to init_squares::@1 [phi:init_squares->init_squares::@1] + //SEG139 [74] phi (byte) init_squares::i#2 = (byte) 0 [phi:init_squares->init_squares::@1#0] -- vbuxx=vbuc1 + ldx #0 + //SEG140 [74] phi (word*) init_squares::squares#2 = (const byte*) HEAP_START#0 [phi:init_squares->init_squares::@1#1] -- pwuz1=pbuc1 + lda #HEAP_START + sta squares+1 + //SEG141 [74] phi (word) init_squares::sqr#2 = (byte) 0 [phi:init_squares->init_squares::@1#2] -- vwuz1=vbuc1 + txa + sta sqr + sta sqr+1 + //SEG142 [74] phi from init_squares::@1 to init_squares::@1 [phi:init_squares::@1->init_squares::@1] + //SEG143 [74] phi (byte) init_squares::i#2 = (byte) init_squares::i#1 [phi:init_squares::@1->init_squares::@1#0] -- register_copy + //SEG144 [74] phi (word*) init_squares::squares#2 = (word*) init_squares::squares#1 [phi:init_squares::@1->init_squares::@1#1] -- register_copy + //SEG145 [74] phi (word) init_squares::sqr#2 = (word) init_squares::sqr#1 [phi:init_squares::@1->init_squares::@1#2] -- register_copy + //SEG146 init_squares::@1 + b1: + //SEG147 [75] *((word*) init_squares::squares#2) ← (word) init_squares::sqr#2 -- _deref_pwuz1=vwuz2 + ldy #0 + lda sqr + sta (squares),y + iny + lda sqr+1 + sta (squares),y + //SEG148 [76] (word*) init_squares::squares#1 ← (word*) init_squares::squares#2 + (const byte) SIZEOF_WORD -- pwuz1=pwuz1_plus_vbuc1 + lda #SIZEOF_WORD + clc + adc squares + sta squares + bcc !+ + inc squares+1 + !: + //SEG149 [77] (byte~) init_squares::$3 ← (byte) init_squares::i#2 << (byte) 1 -- vbuaa=vbuxx_rol_1 + txa + asl + //SEG150 [78] (byte~) init_squares::$4 ← (byte~) init_squares::$3 + (byte) 1 -- vbuaa=vbuaa_plus_1 + clc + adc #1 + //SEG151 [79] (word) init_squares::sqr#1 ← (word) init_squares::sqr#2 + (byte~) init_squares::$4 -- vwuz1=vwuz1_plus_vbuaa + clc + adc sqr + sta sqr + bcc !+ + inc sqr+1 + !: + //SEG152 [80] (byte) init_squares::i#1 ← ++ (byte) init_squares::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG153 [81] if((byte) init_squares::i#1!=(const byte) NUM_SQUARES#0-(byte) 1+(byte) 1) goto init_squares::@1 -- vbuxx_neq_vbuc1_then_la1 + cpx #NUM_SQUARES-1+1 + bne b1 + //SEG154 init_squares::@return + //SEG155 [82] return + rts +} +//SEG156 malloc +// Allocates a block of size bytes of memory, returning a pointer to the beginning of the block. +// The content of the newly allocated block of memory is not initialized, remaining with indeterminate values. +malloc: { + //SEG157 malloc::@return + //SEG158 [84] return + rts +} +//SEG159 init_font_hex +// Make charset from proto chars +// init_font_hex(byte* zeropage($10) charset) +init_font_hex: { + .label _0 = $1e + .label idx = $15 + .label proto_lo = $12 + .label charset = $10 + .label c1 = $14 + .label proto_hi = $d + .label c = $f + //SEG160 [86] phi from init_font_hex to init_font_hex::@1 [phi:init_font_hex->init_font_hex::@1] + //SEG161 [86] phi (byte) init_font_hex::c#6 = (byte) 0 [phi:init_font_hex->init_font_hex::@1#0] -- vbuz1=vbuc1 + lda #0 + sta c + //SEG162 [86] phi (byte*) init_font_hex::proto_hi#6 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex->init_font_hex::@1#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_hi+1 + //SEG163 [86] phi (byte*) init_font_hex::charset#5 = (const byte*) CHARSET#0 [phi:init_font_hex->init_font_hex::@1#2] -- pbuz1=pbuc1 + lda #CHARSET + sta charset+1 + //SEG164 [86] phi from init_font_hex::@5 to init_font_hex::@1 [phi:init_font_hex::@5->init_font_hex::@1] + //SEG165 [86] phi (byte) init_font_hex::c#6 = (byte) init_font_hex::c#1 [phi:init_font_hex::@5->init_font_hex::@1#0] -- register_copy + //SEG166 [86] phi (byte*) init_font_hex::proto_hi#6 = (byte*) init_font_hex::proto_hi#1 [phi:init_font_hex::@5->init_font_hex::@1#1] -- register_copy + //SEG167 [86] phi (byte*) init_font_hex::charset#5 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@5->init_font_hex::@1#2] -- register_copy + //SEG168 init_font_hex::@1 + b1: + //SEG169 [87] phi from init_font_hex::@1 to init_font_hex::@2 [phi:init_font_hex::@1->init_font_hex::@2] + //SEG170 [87] phi (byte) init_font_hex::c1#4 = (byte) 0 [phi:init_font_hex::@1->init_font_hex::@2#0] -- vbuz1=vbuc1 + lda #0 + sta c1 + //SEG171 [87] phi (byte*) init_font_hex::proto_lo#4 = (const byte[]) FONT_HEX_PROTO#0 [phi:init_font_hex::@1->init_font_hex::@2#1] -- pbuz1=pbuc1 + lda #FONT_HEX_PROTO + sta proto_lo+1 + //SEG172 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#5 [phi:init_font_hex::@1->init_font_hex::@2#2] -- register_copy + //SEG173 [87] phi from init_font_hex::@4 to init_font_hex::@2 [phi:init_font_hex::@4->init_font_hex::@2] + //SEG174 [87] phi (byte) init_font_hex::c1#4 = (byte) init_font_hex::c1#1 [phi:init_font_hex::@4->init_font_hex::@2#0] -- register_copy + //SEG175 [87] phi (byte*) init_font_hex::proto_lo#4 = (byte*) init_font_hex::proto_lo#1 [phi:init_font_hex::@4->init_font_hex::@2#1] -- register_copy + //SEG176 [87] phi (byte*) init_font_hex::charset#2 = (byte*) init_font_hex::charset#0 [phi:init_font_hex::@4->init_font_hex::@2#2] -- register_copy + //SEG177 init_font_hex::@2 + b2: + //SEG178 [88] *((byte*) init_font_hex::charset#2) ← (byte) 0 -- _deref_pbuz1=vbuc1 + lda #0 + tay + sta (charset),y + //SEG179 [89] phi from init_font_hex::@2 to init_font_hex::@3 [phi:init_font_hex::@2->init_font_hex::@3] + //SEG180 [89] phi (byte) init_font_hex::idx#5 = (byte) 1 [phi:init_font_hex::@2->init_font_hex::@3#0] -- vbuz1=vbuc1 + lda #1 + sta idx + //SEG181 [89] phi (byte) init_font_hex::i#2 = (byte) 0 [phi:init_font_hex::@2->init_font_hex::@3#1] -- vbuxx=vbuc1 + ldx #0 + //SEG182 [89] phi from init_font_hex::@3 to init_font_hex::@3 [phi:init_font_hex::@3->init_font_hex::@3] + //SEG183 [89] phi (byte) init_font_hex::idx#5 = (byte) init_font_hex::idx#2 [phi:init_font_hex::@3->init_font_hex::@3#0] -- register_copy + //SEG184 [89] phi (byte) init_font_hex::i#2 = (byte) init_font_hex::i#1 [phi:init_font_hex::@3->init_font_hex::@3#1] -- register_copy + //SEG185 init_font_hex::@3 + b3: + //SEG186 [90] (byte~) init_font_hex::$0 ← *((byte*) init_font_hex::proto_hi#6 + (byte) init_font_hex::i#2) << (byte) 4 -- vbuz1=pbuz2_derefidx_vbuxx_rol_4 + txa + tay + lda (proto_hi),y + asl + asl + asl + asl + sta _0 + //SEG187 [91] (byte~) init_font_hex::$1 ← *((byte*) init_font_hex::proto_lo#4 + (byte) init_font_hex::i#2) << (byte) 1 -- vbuaa=pbuz1_derefidx_vbuxx_rol_1 + txa + tay + lda (proto_lo),y + asl + //SEG188 [92] (byte~) init_font_hex::$2 ← (byte~) init_font_hex::$0 | (byte~) init_font_hex::$1 -- vbuaa=vbuz1_bor_vbuaa + ora _0 + //SEG189 [93] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#5) ← (byte~) init_font_hex::$2 -- pbuz1_derefidx_vbuz2=vbuaa + ldy idx + sta (charset),y + //SEG190 [94] (byte) init_font_hex::idx#2 ← ++ (byte) init_font_hex::idx#5 -- vbuz1=_inc_vbuz1 + inc idx + //SEG191 [95] (byte) init_font_hex::i#1 ← ++ (byte) init_font_hex::i#2 -- vbuxx=_inc_vbuxx + inx + //SEG192 [96] if((byte) init_font_hex::i#1!=(byte) 5) goto init_font_hex::@3 -- vbuxx_neq_vbuc1_then_la1 + cpx #5 + bne b3 + //SEG193 init_font_hex::@4 + //SEG194 [97] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#2) ← (byte) 0 -- pbuz1_derefidx_vbuz2=vbuc1 + lda #0 + ldy idx + sta (charset),y + //SEG195 [98] (byte) init_font_hex::idx#3 ← ++ (byte) init_font_hex::idx#2 -- vbuyy=_inc_vbuz1 + iny + //SEG196 [99] *((byte*) init_font_hex::charset#2 + (byte) init_font_hex::idx#3) ← (byte) 0 -- pbuz1_derefidx_vbuyy=vbuc1 + sta (charset),y + //SEG197 [100] (byte*) init_font_hex::proto_lo#1 ← (byte*) init_font_hex::proto_lo#4 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_lo + sta proto_lo + bcc !+ + inc proto_lo+1 + !: + //SEG198 [101] (byte*) init_font_hex::charset#0 ← (byte*) init_font_hex::charset#2 + (byte) 8 -- pbuz1=pbuz1_plus_vbuc1 + lda #8 + clc + adc charset + sta charset + bcc !+ + inc charset+1 + !: + //SEG199 [102] (byte) init_font_hex::c1#1 ← ++ (byte) init_font_hex::c1#4 -- vbuz1=_inc_vbuz1 + inc c1 + //SEG200 [103] if((byte) init_font_hex::c1#1!=(byte) $10) goto init_font_hex::@2 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c1 + bne b2 + //SEG201 init_font_hex::@5 + //SEG202 [104] (byte*) init_font_hex::proto_hi#1 ← (byte*) init_font_hex::proto_hi#6 + (byte) 5 -- pbuz1=pbuz1_plus_vbuc1 + lda #5 + clc + adc proto_hi + sta proto_hi + bcc !+ + inc proto_hi+1 + !: + //SEG203 [105] (byte) init_font_hex::c#1 ← ++ (byte) init_font_hex::c#6 -- vbuz1=_inc_vbuz1 + inc c + //SEG204 [106] if((byte) init_font_hex::c#1!=(byte) $10) goto init_font_hex::@1 -- vbuz1_neq_vbuc1_then_la1 + lda #$10 + cmp c + bne b1 + //SEG205 init_font_hex::@return + //SEG206 [107] return + rts +} +//SEG207 File Data + // Bit patterns for symbols 0-f (3x5 pixels) used in font hex + FONT_HEX_PROTO: .byte 2, 5, 5, 5, 2, 6, 2, 2, 2, 7, 6, 1, 2, 4, 7, 6, 1, 2, 1, 6, 5, 5, 7, 1, 1, 7, 4, 6, 1, 6, 3, 4, 6, 5, 2, 7, 1, 1, 1, 1, 2, 5, 2, 5, 2, 2, 5, 3, 1, 1, 2, 5, 7, 5, 5, 6, 5, 6, 5, 6, 2, 5, 4, 5, 2, 6, 5, 5, 5, 6, 7, 4, 6, 4, 7, 7, 4, 6, 4, 4 + diff --git a/src/test/ref/screen-center-distance.sym b/src/test/ref/screen-center-distance.sym new file mode 100644 index 000000000..b20bd13d8 --- /dev/null +++ b/src/test/ref/screen-center-distance.sym @@ -0,0 +1,225 @@ +(label) @1 +(label) @begin +(label) @end +(byte*) CHARSET +(const byte*) CHARSET#0 CHARSET = (byte*) 8192 +(byte*) D018 +(const byte*) D018#0 D018 = (byte*) 53272 +(byte[]) FONT_HEX_PROTO +(const byte[]) FONT_HEX_PROTO#0 FONT_HEX_PROTO = { (byte) 2, (byte) 5, (byte) 5, (byte) 5, (byte) 2, (byte) 6, (byte) 2, (byte) 2, (byte) 2, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 4, (byte) 7, (byte) 6, (byte) 1, (byte) 2, (byte) 1, (byte) 6, (byte) 5, (byte) 5, (byte) 7, (byte) 1, (byte) 1, (byte) 7, (byte) 4, (byte) 6, (byte) 1, (byte) 6, (byte) 3, (byte) 4, (byte) 6, (byte) 5, (byte) 2, (byte) 7, (byte) 1, (byte) 1, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 2, (byte) 5, (byte) 2, (byte) 2, (byte) 5, (byte) 3, (byte) 1, (byte) 1, (byte) 2, (byte) 5, (byte) 7, (byte) 5, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 5, (byte) 6, (byte) 2, (byte) 5, (byte) 4, (byte) 5, (byte) 2, (byte) 6, (byte) 5, (byte) 5, (byte) 5, (byte) 6, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 7, (byte) 7, (byte) 4, (byte) 6, (byte) 4, (byte) 4 } +(byte*) HEAP_START +(const byte*) HEAP_START#0 HEAP_START = (byte*) 49152 +(byte) NUM_SQUARES +(const byte) NUM_SQUARES#0 NUM_SQUARES = (byte) $30 +(byte*) SCREEN +(const byte*) SCREEN#0 SCREEN = (byte*) 10240 +(const byte) SIZEOF_WORD SIZEOF_WORD = (byte) 2 +(word*) SQUARES +(word*()) bsearch16u((word) bsearch16u::key , (word*) bsearch16u::items , (byte) bsearch16u::num) +(byte~) bsearch16u::$16 reg byte a 2002.0 +(word*~) bsearch16u::$2 $2 zp ZP_WORD:6 4.0 +(byte~) bsearch16u::$6 reg byte a 2002.0 +(label) bsearch16u::@1 +(label) bsearch16u::@2 +(label) bsearch16u::@3 +(label) bsearch16u::@4 +(label) bsearch16u::@5 +(label) bsearch16u::@6 +(label) bsearch16u::@7 +(label) bsearch16u::@8 +(label) bsearch16u::@9 +(label) bsearch16u::@return +(word*) bsearch16u::items +(word*) bsearch16u::items#1 items zp ZP_WORD:6 1001.0 +(word*) bsearch16u::items#2 items zp ZP_WORD:6 334.33333333333337 +(word*) bsearch16u::items#8 items zp ZP_WORD:6 1501.5 +(word) bsearch16u::key +(word) bsearch16u::key#0 key zp ZP_WORD:24 0.2857142857142857 +(byte) bsearch16u::num +(byte) bsearch16u::num#1 reg byte x 2002.0 +(byte) bsearch16u::num#2 reg byte x 2002.0 +(byte) bsearch16u::num#3 reg byte x 556.1111111111111 +(byte) bsearch16u::num#5 reg byte x 3003.0 +(word*) bsearch16u::pivot +(word*) bsearch16u::pivot#0 pivot zp ZP_WORD:26 501.0 +(signed word) bsearch16u::result +(signed word) bsearch16u::result#0 result zp ZP_WORD:28 1501.5 +(word*) bsearch16u::return +(word*) bsearch16u::return#0 return zp ZP_WORD:6 4.0 +(word*) bsearch16u::return#2 return zp ZP_WORD:6 2.0 +(word*) bsearch16u::return#3 return zp ZP_WORD:6 6.0 +(word*~) bsearch16u::return#6 return zp ZP_WORD:6 4.0 +(byte*) heap_head +(void()) init_font_hex((byte*) init_font_hex::charset) +(byte~) init_font_hex::$0 $0 zp ZP_BYTE:30 1001.0 +(byte~) init_font_hex::$1 reg byte a 2002.0 +(byte~) init_font_hex::$2 reg byte a 2002.0 +(label) init_font_hex::@1 +(label) init_font_hex::@2 +(label) init_font_hex::@3 +(label) init_font_hex::@4 +(label) init_font_hex::@5 +(label) init_font_hex::@return +(byte) init_font_hex::c +(byte) init_font_hex::c#1 c zp ZP_BYTE:15 16.5 +(byte) init_font_hex::c#6 c zp ZP_BYTE:15 1.1578947368421053 +(byte) init_font_hex::c1 +(byte) init_font_hex::c1#1 c1 zp ZP_BYTE:20 151.5 +(byte) init_font_hex::c1#4 c1 zp ZP_BYTE:20 13.466666666666667 +(byte*) init_font_hex::charset +(byte*) init_font_hex::charset#0 charset zp ZP_WORD:16 35.5 +(byte*) init_font_hex::charset#2 charset zp ZP_WORD:16 108.35714285714285 +(byte*) init_font_hex::charset#5 charset zp ZP_WORD:16 22.0 +(byte) init_font_hex::i +(byte) init_font_hex::i#1 reg byte x 1501.5 +(byte) init_font_hex::i#2 reg byte x 667.3333333333334 +(byte) init_font_hex::idx +(byte) init_font_hex::idx#2 idx zp ZP_BYTE:21 551.0 +(byte) init_font_hex::idx#3 reg byte y 202.0 +(byte) init_font_hex::idx#5 idx zp ZP_BYTE:21 600.5999999999999 +(byte*) init_font_hex::proto_hi +(byte*) init_font_hex::proto_hi#1 proto_hi zp ZP_WORD:13 7.333333333333333 +(byte*) init_font_hex::proto_hi#6 proto_hi zp ZP_WORD:13 56.83333333333334 +(byte*) init_font_hex::proto_lo +(byte*) init_font_hex::proto_lo#1 proto_lo zp ZP_WORD:18 50.5 +(byte*) init_font_hex::proto_lo#4 proto_lo zp ZP_WORD:18 92.53846153846155 +(void()) init_squares() +(byte~) init_squares::$3 reg byte a 22.0 +(byte~) init_squares::$4 reg byte a 22.0 +(label) init_squares::@1 +(label) init_squares::@return +(byte) init_squares::i +(byte) init_squares::i#1 reg byte x 16.5 +(byte) init_squares::i#2 reg byte x 5.5 +(word) init_squares::sqr +(word) init_squares::sqr#1 sqr zp ZP_WORD:9 7.333333333333333 +(word) init_squares::sqr#2 sqr zp ZP_WORD:9 6.6000000000000005 +(word*) init_squares::squares +(word*) init_squares::squares#1 squares zp ZP_WORD:11 3.6666666666666665 +(word*) init_squares::squares#2 squares zp ZP_WORD:11 16.5 +(void()) main() +(byte~) main::$14 reg byte a 202.0 +(byte~) main::$16 reg byte a 202.0 +(byte~) main::$6 reg byte a 22.0 +(byte~) main::$8 reg byte a 22.0 +(label) main::@1 +(label) main::@10 +(label) main::@11 +(label) main::@12 +(label) main::@13 +(label) main::@2 +(label) main::@3 +(label) main::@4 +(label) main::@5 +(label) main::@6 +(label) main::@7 +(label) main::@8 +(label) main::@9 +(label) main::@return +(byte) main::d +(byte) main::d#0 reg byte a 202.0 +(word) main::ds +(word) main::ds#0 ds zp ZP_WORD:24 202.0 +(byte*) main::screen +(byte*) main::screen#1 screen zp ZP_WORD:4 42.599999999999994 +(byte*) main::screen#10 screen zp ZP_WORD:4 2.2 +(byte*) main::screen#2 screen zp ZP_WORD:4 19.625 +(label) main::toD0181 +(word~) main::toD0181_$0 +(number~) main::toD0181_$1 +(number~) main::toD0181_$2 +(number~) main::toD0181_$3 +(word~) main::toD0181_$4 +(byte~) main::toD0181_$5 +(number~) main::toD0181_$6 +(number~) main::toD0181_$7 +(number~) main::toD0181_$8 +(byte*) main::toD0181_gfx +(byte) main::toD0181_return +(const byte) main::toD0181_return#0 toD0181_return = >(word)(const byte*) SCREEN#0&(word) $3fff*(byte) 4|>(word)(const byte*) CHARSET#0/(byte) 4&(byte) $f +(byte*) main::toD0181_screen +(byte) main::x +(byte) main::x#1 x zp ZP_BYTE:3 151.5 +(byte) main::x#2 x zp ZP_BYTE:3 17.823529411764707 +(byte) main::x2 +(byte) main::x2#0 reg byte a 202.0 +(byte) main::xd +(byte) main::xd#0 reg byte a 303.0 +(word) main::xds +(word) main::xds#0 xds zp ZP_WORD:24 202.0 +(byte) main::y +(byte) main::y#1 y zp ZP_BYTE:2 16.5 +(byte) main::y#10 y zp ZP_BYTE:2 1.1379310344827585 +(byte) main::y2 +(byte) main::y2#0 reg byte a 22.0 +(byte) main::yd +(byte) main::yd#0 reg byte a 33.0 +(word) main::yds +(word) main::yds#0 yds zp ZP_WORD:22 5.6 +(byte*()) malloc((word) malloc::size) +(label) malloc::@return +(byte*) malloc::mem +(byte*) malloc::return +(word) malloc::size +(word()) sqr((byte) sqr::val) +(byte~) sqr::$0 reg byte a 4.0 +(label) sqr::@return +(word) sqr::return +(word) sqr::return#0 return zp ZP_WORD:22 22.0 +(word) sqr::return#1 return#1 zp ZP_WORD:24 202.0 +(word) sqr::return#2 return#2 zp ZP_WORD:24 28.5 +(byte) sqr::val +(byte) sqr::val#0 reg byte a 22.0 +(byte) sqr::val#1 reg byte a 202.0 +(byte) sqr::val#2 reg byte a 114.0 +(byte()) sqrt((word) sqrt::val) +(word~) sqrt::$3 $3 zp ZP_WORD:6 2.0 +(byte~) sqrt::$4 reg byte a 4.0 +(label) sqrt::@1 +(label) sqrt::@return +(word*) sqrt::found +(word*) sqrt::found#0 found zp ZP_WORD:6 2.0 +(byte) sqrt::return +(byte) sqrt::return#0 reg byte a 202.0 +(byte) sqrt::return#1 reg byte a 34.33333333333333 +(byte) sqrt::sqr1 +(word) sqrt::val +(word) sqrt::val#0 val zp ZP_WORD:24 103.0 + +zp ZP_BYTE:2 [ main::y#10 main::y#1 ] +reg byte a [ main::yd#0 main::$8 main::$6 ] +zp ZP_BYTE:3 [ main::x#2 main::x#1 ] +zp ZP_WORD:4 [ main::screen#2 main::screen#10 main::screen#1 ] +reg byte a [ main::xd#0 main::$16 main::$14 ] +zp ZP_WORD:6 [ bsearch16u::return#2 bsearch16u::return#6 bsearch16u::return#3 bsearch16u::items#2 bsearch16u::items#8 bsearch16u::$2 bsearch16u::items#1 bsearch16u::return#0 sqrt::found#0 sqrt::$3 ] +reg byte x [ bsearch16u::num#5 bsearch16u::num#2 bsearch16u::num#3 bsearch16u::num#1 ] +reg byte a [ sqr::val#2 sqr::val#0 sqr::val#1 ] +zp ZP_WORD:9 [ init_squares::sqr#2 init_squares::sqr#1 ] +zp ZP_WORD:11 [ init_squares::squares#2 init_squares::squares#1 ] +reg byte x [ init_squares::i#2 init_squares::i#1 ] +zp ZP_WORD:13 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] +zp ZP_BYTE:15 [ init_font_hex::c#6 init_font_hex::c#1 ] +zp ZP_WORD:16 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] +zp ZP_WORD:18 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] +zp ZP_BYTE:20 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +reg byte x [ init_font_hex::i#2 init_font_hex::i#1 ] +zp ZP_BYTE:21 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +reg byte a [ main::y2#0 ] +zp ZP_WORD:22 [ sqr::return#0 main::yds#0 ] +reg byte a [ main::x2#0 ] +zp ZP_WORD:24 [ sqr::return#1 main::xds#0 sqr::return#2 main::ds#0 sqrt::val#0 bsearch16u::key#0 ] +reg byte a [ sqrt::return#0 ] +reg byte a [ main::d#0 ] +reg byte a [ sqrt::$4 ] +reg byte a [ sqrt::return#1 ] +reg byte a [ bsearch16u::$6 ] +reg byte a [ bsearch16u::$16 ] +zp ZP_WORD:26 [ bsearch16u::pivot#0 ] +zp ZP_WORD:28 [ bsearch16u::result#0 ] +reg byte a [ sqr::$0 ] +reg byte a [ init_squares::$3 ] +reg byte a [ init_squares::$4 ] +zp ZP_BYTE:30 [ init_font_hex::$0 ] +reg byte a [ init_font_hex::$1 ] +reg byte a [ init_font_hex::$2 ] +reg byte y [ init_font_hex::idx#3 ] diff --git a/src/test/ref/semi-struct-2.log b/src/test/ref/semi-struct-2.log index 82606c51d..5d4c57d1a 100644 --- a/src/test/ref/semi-struct-2.log +++ b/src/test/ref/semi-struct-2.log @@ -5843,7 +5843,7 @@ printEntry: { jmp b1 //SEG200 printEntry::@1 b1: - //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pptz2 + //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pwuz2 ldy #0 lda (entry),y sta print_word.w @@ -5895,7 +5895,7 @@ printEntry: { jmp b2 //SEG219 printEntry::@2 b2: - //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #2 lda (entry),y sta print_word.w @@ -5999,7 +5999,7 @@ printEntry: { jmp b4 //SEG257 printEntry::@4 b4: - //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #6 lda (entry),y sta print_word.w @@ -7918,7 +7918,7 @@ printEntry: { jmp b1 //SEG200 printEntry::@1 b1: - //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pptz2 + //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pwuz2 ldy #0 lda (entry),y sta print_word.w @@ -7970,7 +7970,7 @@ printEntry: { jmp b2 //SEG219 printEntry::@2 b2: - //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #2 lda (entry),y sta print_word.w @@ -8074,7 +8074,7 @@ printEntry: { jmp b4 //SEG257 printEntry::@4 b4: - //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #6 lda (entry),y sta print_word.w @@ -10389,7 +10389,7 @@ printEntry: { //SEG198 [96] phi from printEntry to printEntry::entryBufDisk1 [phi:printEntry->printEntry::entryBufDisk1] //SEG199 printEntry::entryBufDisk1 //SEG200 printEntry::@1 - //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pptz2 + //SEG201 [97] (word~) print_word::w#7 ← (word)*((byte**)(byte*) printEntry::entry#10) -- vwuz1=_deref_pwuz2 ldy #0 lda (entry),y sta print_word.w @@ -10429,7 +10429,7 @@ printEntry: { //SEG217 [103] phi from printEntry::@15 to printEntry::entryBufEdit1 [phi:printEntry::@15->printEntry::entryBufEdit1] //SEG218 printEntry::entryBufEdit1 //SEG219 printEntry::@2 - //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG220 [104] (word~) print_word::w#8 ← (word)*((byte**)(byte*) printEntry::entry#10 + (byte) 2) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #2 lda (entry),y sta print_word.w @@ -10509,7 +10509,7 @@ printEntry: { //SEG255 [117] phi from printEntry::@19 to printEntry::entryTsOrder1 [phi:printEntry::@19->printEntry::entryTsOrder1] //SEG256 printEntry::entryTsOrder1 //SEG257 printEntry::@4 - //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pptz2_derefidx_vbuc1 + //SEG258 [118] (word~) print_word::w#10 ← (word)*((word**)(byte*) printEntry::entry#10 + (byte) 6) -- vwuz1=pwuz2_derefidx_vbuc1 ldy #6 lda (entry),y sta print_word.w diff --git a/src/test/ref/typeinference-problem.asm b/src/test/ref/typeinference-problem.asm index f86496071..240b58683 100644 --- a/src/test/ref/typeinference-problem.asm +++ b/src/test/ref/typeinference-problem.asm @@ -9,7 +9,7 @@ main: { tya eor #$ff tax - axs #$ff+1 + axs #-$ff-1 lda #0 sta table,x iny diff --git a/src/test/ref/typeinference-problem.log b/src/test/ref/typeinference-problem.log index ddcb384d9..bb7553def 100644 --- a/src/test/ref/typeinference-problem.log +++ b/src/test/ref/typeinference-problem.log @@ -257,7 +257,7 @@ main: { tya eor #$ff tax - axs #$ff+1 + axs #-$ff-1 //SEG17 [7] *((const byte[$100]) table#0 + (byte~) main::$0) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 lda #0 sta table,x @@ -349,7 +349,7 @@ main: { tya eor #$ff tax - axs #$ff+1 + axs #-$ff-1 //SEG17 [7] *((const byte[$100]) table#0 + (byte~) main::$0) ← (byte) 0 -- pbuc1_derefidx_vbuxx=vbuc2 lda #0 sta table,x