diff --git a/src/main/fragment/vwsz1=vwsz1_ror_vbuxx.asm b/src/main/fragment/vwsz1=vwsz1_ror_vbuxx.asm new file mode 100644 index 000000000..ba1265181 --- /dev/null +++ b/src/main/fragment/vwsz1=vwsz1_ror_vbuxx.asm @@ -0,0 +1,10 @@ +cpx #0 +beq !e+ +!: +lda {z1}+1 +cmp #$80 +ror {z1}+1 +ror {z1} +dex +bne !- +!e: \ No newline at end of file diff --git a/src/main/fragment/vwsz1=vwsz1_ror_vbuyy.asm b/src/main/fragment/vwsz1=vwsz1_ror_vbuyy.asm new file mode 100644 index 000000000..69d5c876c --- /dev/null +++ b/src/main/fragment/vwsz1=vwsz1_ror_vbuyy.asm @@ -0,0 +1,10 @@ +cpy #0 +beq !e+ +!: +lda {z1}+1 +cmp #$80 +ror {z1}+1 +ror {z1} +dey +bne !- +!e: \ No newline at end of file diff --git a/src/main/fragment/vwuz1=vbuaa_word__lo_vwsz2.asm b/src/main/fragment/vwuz1=vbuaa_word__lo_vwsz2.asm new file mode 100644 index 000000000..cc2d30e9f --- /dev/null +++ b/src/main/fragment/vwuz1=vbuaa_word__lo_vwsz2.asm @@ -0,0 +1,3 @@ +sta {z1}+1 +lda {z2} +sta {z1} \ No newline at end of file diff --git a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java index 7331fea05..e54dc2593 100644 --- a/src/test/java/dk/camelot64/kickc/test/TestPrograms.java +++ b/src/test/java/dk/camelot64/kickc/test/TestPrograms.java @@ -37,7 +37,7 @@ public class TestPrograms { @Test public void testArraysInitKasm0() throws IOException, URISyntaxException { - compileAndCompare("arrays-init-kasm-0", log()); + compileAndCompare("arrays-init-kasm-0"); } @Test @@ -92,7 +92,7 @@ public class TestPrograms { @Test public void testBitmapPlot2() throws IOException, URISyntaxException { - compileAndCompare("bitmap-plot-2", log()); + compileAndCompare("bitmap-plot-2"); } @Test diff --git a/src/test/ref/cordic-atan2-16-ref.asm b/src/test/ref/cordic-atan2-16-ref.asm index bea8f4af3..c4e944b73 100644 --- a/src/test/ref/cordic-atan2-16-ref.asm +++ b/src/test/ref/cordic-atan2-16-ref.asm @@ -174,15 +174,9 @@ atan2_16: { .label x = $1b .label y = $1d lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: sec lda #0 sbc y @@ -192,15 +186,9 @@ atan2_16: { sta _2+1 b3: lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: sec lda #0 sbc x @@ -274,13 +262,7 @@ atan2_16: { bne !- !e: lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: lda xi sec sbc yd diff --git a/src/test/ref/cordic-atan2-16-ref.cfg b/src/test/ref/cordic-atan2-16-ref.cfg index ce6b02e18..68c8cece6 100644 --- a/src/test/ref/cordic-atan2-16-ref.cfg +++ b/src/test/ref/cordic-atan2-16-ref.cfg @@ -116,14 +116,14 @@ diff::@1: scope:[diff] from diff [57] (byte~) diff::$4 ← (byte) diff::bb2#0 - (byte) diff::bb1#0 to:diff::@3 atan2_16: scope:[atan2_16] from main::@2 - [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [59] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [60] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [62] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -162,7 +162,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [75] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [76] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [78] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 diff --git a/src/test/ref/cordic-atan2-16-ref.log b/src/test/ref/cordic-atan2-16-ref.log index 1de7a3c5e..3ee488e9f 100644 --- a/src/test/ref/cordic-atan2-16-ref.log +++ b/src/test/ref/cordic-atan2-16-ref.log @@ -174,7 +174,7 @@ init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 atan2_16: scope:[atan2_16] from main::@2 (signed word) atan2_16::x#9 ← phi( main::@2/(signed word) atan2_16::x#0 ) (signed word) atan2_16::y#1 ← phi( main::@2/(signed word) atan2_16::y#0 ) - (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 + (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 if((bool~) atan2_16::$0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@1: scope:[atan2_16] from atan2_16 @@ -193,7 +193,7 @@ atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 (signed word) atan2_16::x#1 ← phi( atan2_16::@1/(signed word) atan2_16::x#5 atan2_16::@2/(signed word) atan2_16::x#6 ) (signed word~) atan2_16::$4 ← phi( atan2_16::@1/(signed word~) atan2_16::$3 atan2_16::@2/(signed word~) atan2_16::$2 ) (signed word) atan2_16::yi#0 ← (signed word~) atan2_16::$4 - (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 + (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 if((bool~) atan2_16::$5) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@4: scope:[atan2_16] from atan2_16::@3 @@ -241,7 +241,7 @@ atan2_16::@16: scope:[atan2_16] from atan2_16::@15 (signed word) atan2_16::xd#0 ← (signed word~) atan2_16::$19 (signed word~) atan2_16::$20 ← (signed word) atan2_16::yi#4 >> (byte) atan2_16::i#2 (signed word) atan2_16::yd#0 ← (signed word~) atan2_16::$20 - (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 + (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 if((bool~) atan2_16::$21) goto atan2_16::@18 to:atan2_16::@22 atan2_16::@17: scope:[atan2_16] from atan2_16::@15 atan2_16::@19 @@ -1033,13 +1033,13 @@ Adding number conversion cast (unumber) 5 in (byte*) init_font_hex::proto_lo#1 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) $f in (byte) CORDIC_ITERATIONS_16#0 ← (number) $f -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 Adding number conversion cast (unumber) 0 in (word) atan2_16::angle#0 ← (number) 0 Adding number conversion cast (unumber) 1 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (number) 1 Adding number conversion cast (unumber) atan2_16::$16 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (unumber)(number) 1 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 Adding number conversion cast (unumber) 2 in (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 / (number) 2 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (number) 0 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (number) 0 @@ -1373,10 +1373,10 @@ Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) init_font_hex::$3 [19] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 Simple Condition (bool~) init_font_hex::$4 [29] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 Simple Condition (bool~) init_font_hex::$5 [34] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 -Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 +Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 +Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 Simple Condition (bool~) atan2_16::$18 [64] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16 -Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@18 +Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@18 Simple Condition (bool~) atan2_16::$11 [76] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@7 Simple Condition (bool~) atan2_16::$22 [90] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15 Simple Condition (bool~) atan2_16::$14 [94] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@8 @@ -1825,14 +1825,14 @@ diff::@1: scope:[diff] from diff [57] (byte~) diff::$4 ← (byte) diff::bb2#0 - (byte) diff::bb1#0 to:diff::@3 atan2_16: scope:[atan2_16] from main::@2 - [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [59] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [60] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [62] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -1871,7 +1871,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [75] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [76] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [78] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 @@ -2645,15 +2645,9 @@ atan2_16: { .label angle_6 = $14 .label angle_12 = $14 .label angle_13 = $14 - //SEG117 [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG117 [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG118 atan2_16::@2 b2: @@ -2672,15 +2666,9 @@ atan2_16: { jmp b3 //SEG122 atan2_16::@3 b3: - //SEG123 [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG123 [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG124 atan2_16::@5 b5: @@ -2814,15 +2802,9 @@ atan2_16: { dey bne !- !e: - //SEG157 [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG157 [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG158 atan2_16::@15 b15: @@ -3142,9 +3124,9 @@ Statement [50] *((byte*) print_char_cursor#18) ← (byte) print_char::ch#2 [ pri Removing always clobbered register reg byte y as potential for zp ZP_BYTE:10 [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] Statement [54] (byte~) diff::$2 ← (byte) diff::bb1#0 - (byte) diff::bb2#0 [ diff::$2 ] ( main:2::diff:21 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 main::ang_w#0 diff::$2 ] ) always clobbers reg byte a Statement [57] (byte~) diff::$4 ← (byte) diff::bb2#0 - (byte) diff::bb1#0 [ diff::$4 ] ( main:2::diff:21 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 main::ang_w#0 diff::$4 ] ) always clobbers reg byte a -Statement [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [59] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [62] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [65] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] @@ -3155,7 +3137,7 @@ Statement [71] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [72] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [75] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [76] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [78] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [79] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [80] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -3203,9 +3185,9 @@ Statement [45] (byte~) print_byte::$2 ← (byte) print_byte::b#2 & (byte) $f [ p Statement [50] *((byte*) print_char_cursor#18) ← (byte) print_char::ch#2 [ print_char_cursor#18 ] ( main:2::print_word:34::print_byte:37::print_char:44 [ print_word::w#0 print_byte::b#2 print_char_cursor#18 ] main:2::print_word:34::print_byte:39::print_char:44 [ print_byte::b#2 print_char_cursor#18 ] main:2::print_word:34::print_byte:37::print_char:47 [ print_word::w#0 print_char_cursor#18 ] main:2::print_word:34::print_byte:39::print_char:47 [ print_char_cursor#18 ] ) always clobbers reg byte y Statement [54] (byte~) diff::$2 ← (byte) diff::bb1#0 - (byte) diff::bb2#0 [ diff::$2 ] ( main:2::diff:21 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 main::ang_w#0 diff::$2 ] ) always clobbers reg byte a Statement [57] (byte~) diff::$4 ← (byte) diff::bb2#0 - (byte) diff::bb1#0 [ diff::$4 ] ( main:2::diff:21 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 main::ang_w#0 diff::$4 ] ) always clobbers reg byte a -Statement [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [59] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [62] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [65] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Statement [67] (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 >> (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ) always clobbers reg byte a @@ -3215,7 +3197,7 @@ Statement [71] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [72] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [75] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [76] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [78] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [79] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [80] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen_ref#2 main::diff_sum#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -3290,35 +3272,35 @@ Uplift Scope [print_char] 14: zp ZP_BYTE:11 [ print_char::ch#2 print_char::ch#0 Uplift Scope [] 6: zp ZP_WORD:12 [ print_char_cursor#18 print_char_cursor#24 print_char_cursor#19 ] Uplift Scope [print_word] 2: zp ZP_WORD:54 [ print_word::w#0 ] -Uplifting [atan2_16] best 414229 combination zp ZP_WORD:20 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:15 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:17 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:60 [ atan2_16::yd#0 ] zp ZP_WORD:58 [ atan2_16::xd#0 ] zp ZP_WORD:42 [ atan2_16::return#2 ] zp ZP_WORD:22 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:38 [ atan2_16::x#0 ] zp ZP_WORD:40 [ atan2_16::y#0 ] -Uplifting [init_font_hex] best 395229 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:33 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:64 [ init_font_hex::$0 ] zp ZP_BYTE:67 [ init_font_hex::idx#3 ] zp ZP_WORD:27 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:31 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:29 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:24 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:26 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [atan2_16] best 404209 combination zp ZP_WORD:20 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:15 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:17 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:60 [ atan2_16::yd#0 ] zp ZP_WORD:58 [ atan2_16::xd#0 ] zp ZP_WORD:42 [ atan2_16::return#2 ] zp ZP_WORD:22 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:38 [ atan2_16::x#0 ] zp ZP_WORD:40 [ atan2_16::y#0 ] +Uplifting [init_font_hex] best 385209 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:33 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:64 [ init_font_hex::$0 ] zp ZP_BYTE:67 [ init_font_hex::idx#3 ] zp ZP_WORD:27 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:31 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:29 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:24 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:26 [ init_font_hex::c#6 init_font_hex::c#1 ] Limited combination testing to 100 combinations of 6912 possible. -Uplifting [main] best 393029 combination zp ZP_WORD:44 [ main::angle_w#0 ] zp ZP_WORD:46 [ main::$12 ] reg byte a [ main::$14 ] reg byte a [ main::$15 ] reg byte x [ main::x#2 main::x#1 ] zp ZP_WORD:4 [ main::screen_ref#2 main::screen_ref#5 main::screen_ref#1 ] zp ZP_WORD:8 [ main::screen#2 main::screen#5 main::screen#1 ] zp ZP_WORD:6 [ main::diff_sum#2 main::diff_sum#7 main::diff_sum#1 ] zp ZP_WORD:34 [ main::xw#0 ] zp ZP_WORD:36 [ main::yw#0 ] zp ZP_BYTE:48 [ main::ang_w#0 ] zp ZP_BYTE:2 [ main::y#4 main::y#1 ] +Uplifting [main] best 383009 combination zp ZP_WORD:44 [ main::angle_w#0 ] zp ZP_WORD:46 [ main::$12 ] reg byte a [ main::$14 ] reg byte a [ main::$15 ] reg byte x [ main::x#2 main::x#1 ] zp ZP_WORD:4 [ main::screen_ref#2 main::screen_ref#5 main::screen_ref#1 ] zp ZP_WORD:8 [ main::screen#2 main::screen#5 main::screen#1 ] zp ZP_WORD:6 [ main::diff_sum#2 main::diff_sum#7 main::diff_sum#1 ] zp ZP_WORD:34 [ main::xw#0 ] zp ZP_WORD:36 [ main::yw#0 ] zp ZP_BYTE:48 [ main::ang_w#0 ] zp ZP_BYTE:2 [ main::y#4 main::y#1 ] Limited combination testing to 100 combinations of 128 possible. -Uplifting [diff] best 391819 combination reg byte a [ diff::return#0 ] reg byte a [ diff::bb2#0 ] reg byte a [ diff::return#1 diff::$4 diff::$2 ] zp ZP_BYTE:49 [ diff::bb1#0 ] +Uplifting [diff] best 381799 combination reg byte a [ diff::return#0 ] reg byte a [ diff::bb2#0 ] reg byte a [ diff::return#1 diff::$4 diff::$2 ] zp ZP_BYTE:49 [ diff::bb1#0 ] Limited combination testing to 100 combinations of 128 possible. -Uplifting [print_byte] best 391805 combination reg byte x [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] reg byte a [ print_byte::$0 ] reg byte x [ print_byte::$2 ] -Uplifting [print_char] best 391796 combination reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ] -Uplifting [] best 391796 combination zp ZP_WORD:12 [ print_char_cursor#18 print_char_cursor#24 print_char_cursor#19 ] -Uplifting [print_word] best 391796 combination zp ZP_WORD:54 [ print_word::w#0 ] +Uplifting [print_byte] best 381785 combination reg byte x [ print_byte::b#2 print_byte::b#0 print_byte::b#1 ] reg byte a [ print_byte::$0 ] reg byte x [ print_byte::$2 ] +Uplifting [print_char] best 381776 combination reg byte a [ print_char::ch#2 print_char::ch#0 print_char::ch#1 ] +Uplifting [] best 381776 combination zp ZP_WORD:12 [ print_char_cursor#18 print_char_cursor#24 print_char_cursor#19 ] +Uplifting [print_word] best 381776 combination zp ZP_WORD:54 [ print_word::w#0 ] Attempting to uplift remaining variables inzp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] -Uplifting [atan2_16] best 391796 combination zp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] +Uplifting [atan2_16] best 381776 combination zp ZP_BYTE:19 [ atan2_16::i#2 atan2_16::i#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:33 [ init_font_hex::idx#5 init_font_hex::idx#2 ] -Uplifting [init_font_hex] best 391796 combination zp ZP_BYTE:33 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Uplifting [init_font_hex] best 381776 combination zp ZP_BYTE:33 [ init_font_hex::idx#5 init_font_hex::idx#2 ] Attempting to uplift remaining variables inzp ZP_BYTE:64 [ init_font_hex::$0 ] -Uplifting [init_font_hex] best 391796 combination zp ZP_BYTE:64 [ init_font_hex::$0 ] +Uplifting [init_font_hex] best 381776 combination zp ZP_BYTE:64 [ init_font_hex::$0 ] Attempting to uplift remaining variables inzp ZP_BYTE:67 [ init_font_hex::idx#3 ] -Uplifting [init_font_hex] best 391196 combination reg byte y [ init_font_hex::idx#3 ] +Uplifting [init_font_hex] best 381176 combination reg byte y [ init_font_hex::idx#3 ] Attempting to uplift remaining variables inzp ZP_BYTE:31 [ init_font_hex::c1#4 init_font_hex::c1#1 ] -Uplifting [init_font_hex] best 391196 combination zp ZP_BYTE:31 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Uplifting [init_font_hex] best 381176 combination zp ZP_BYTE:31 [ init_font_hex::c1#4 init_font_hex::c1#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:48 [ main::ang_w#0 ] -Uplifting [main] best 391196 combination zp ZP_BYTE:48 [ main::ang_w#0 ] +Uplifting [main] best 381176 combination zp ZP_BYTE:48 [ main::ang_w#0 ] Attempting to uplift remaining variables inzp ZP_BYTE:49 [ diff::bb1#0 ] -Uplifting [diff] best 391196 combination zp ZP_BYTE:49 [ diff::bb1#0 ] +Uplifting [diff] best 381176 combination zp ZP_BYTE:49 [ diff::bb1#0 ] Attempting to uplift remaining variables inzp ZP_BYTE:26 [ init_font_hex::c#6 init_font_hex::c#1 ] -Uplifting [init_font_hex] best 391196 combination zp ZP_BYTE:26 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [init_font_hex] best 381176 combination zp ZP_BYTE:26 [ init_font_hex::c#6 init_font_hex::c#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::y#4 main::y#1 ] -Uplifting [main] best 391196 combination zp ZP_BYTE:2 [ main::y#4 main::y#1 ] +Uplifting [main] best 381176 combination zp ZP_BYTE:2 [ main::y#4 main::y#1 ] Coalescing zero page register with common assignment [ zp ZP_WORD:6 [ main::diff_sum#2 main::diff_sum#7 main::diff_sum#1 ] ] with [ zp ZP_WORD:54 [ print_word::w#0 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:20 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:22 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:34 [ main::xw#0 ] ] with [ zp ZP_WORD:38 [ atan2_16::x#0 ] ] - score: 1 @@ -3698,15 +3680,9 @@ atan2_16: { .label return = $10 .label x = $1b .label y = $1d - //SEG117 [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG117 [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG118 atan2_16::@2 b2: @@ -3725,15 +3701,9 @@ atan2_16: { jmp b3 //SEG122 atan2_16::@3 b3: - //SEG123 [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG123 [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG124 atan2_16::@5 b5: @@ -3863,15 +3833,9 @@ atan2_16: { dey bne !- !e: - //SEG157 [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG157 [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG158 atan2_16::@15 b15: @@ -4282,9 +4246,9 @@ Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Removing instruction b3: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [307] beq b12 to bne -Fixing long branch [181] bpl b1 to bmi -Fixing long branch [199] bpl b4 to bmi +Fixing long branch [289] beq b12 to bne +Fixing long branch [176] bpl b1 to bmi +Fixing long branch [188] bpl b4 to bmi FINAL SYMBOL TABLE (label) @1 @@ -4540,7 +4504,7 @@ reg byte y [ init_font_hex::idx#3 ] FINAL ASSEMBLER -Score: 363081 +Score: 353061 //SEG0 File Comments // Find atan2(x, y) using the CORDIC method @@ -4834,17 +4798,11 @@ atan2_16: { .label return = $10 .label x = $1b .label y = $1d - //SEG117 [58] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG117 [58] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: //SEG118 atan2_16::@2 //SEG119 [59] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 -- vwsz1=_neg_vwsz2 sec @@ -4858,17 +4816,11 @@ atan2_16: { //SEG121 [60] phi (signed word) atan2_16::yi#0 = (signed word~) atan2_16::yi#11 [phi:atan2_16::@1/atan2_16::@2->atan2_16::@3#0] -- register_copy //SEG122 atan2_16::@3 b3: - //SEG123 [61] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG123 [61] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: //SEG124 atan2_16::@5 //SEG125 [62] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 -- vwsz1=_neg_vwsz2 sec @@ -4974,15 +4926,9 @@ atan2_16: { dey bne !- !e: - //SEG157 [77] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG157 [77] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: //SEG158 atan2_16::@15 //SEG159 [78] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 -- vwsz1=vwsz1_minus_vwsz2 lda xi diff --git a/src/test/ref/cordic-atan2-16.asm b/src/test/ref/cordic-atan2-16.asm index 4323d98f6..7aa86730d 100644 --- a/src/test/ref/cordic-atan2-16.asm +++ b/src/test/ref/cordic-atan2-16.asm @@ -83,15 +83,9 @@ atan2_16: { .label x = $15 .label y = $17 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: sec lda #0 sbc y @@ -101,15 +95,9 @@ atan2_16: { sta _2+1 b3: lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: sec lda #0 sbc x @@ -183,13 +171,7 @@ atan2_16: { bne !- !e: lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: lda xi sec sbc yd diff --git a/src/test/ref/cordic-atan2-16.cfg b/src/test/ref/cordic-atan2-16.cfg index e886c2ac8..24df97c35 100644 --- a/src/test/ref/cordic-atan2-16.cfg +++ b/src/test/ref/cordic-atan2-16.cfg @@ -48,14 +48,14 @@ main::@4: scope:[main] from main::@3 main::@4 [25] *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) ← ++ *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) to:main::@4 atan2_16: scope:[atan2_16] from main::@2 - [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [27] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [28] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [30] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -94,7 +94,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [43] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [44] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [46] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 diff --git a/src/test/ref/cordic-atan2-16.log b/src/test/ref/cordic-atan2-16.log index e1cc859ae..75e81ed1a 100644 --- a/src/test/ref/cordic-atan2-16.log +++ b/src/test/ref/cordic-atan2-16.log @@ -152,7 +152,7 @@ init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 atan2_16: scope:[atan2_16] from main::@2 (signed word) atan2_16::x#9 ← phi( main::@2/(signed word) atan2_16::x#0 ) (signed word) atan2_16::y#1 ← phi( main::@2/(signed word) atan2_16::y#0 ) - (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 + (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 if((bool~) atan2_16::$0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@1: scope:[atan2_16] from atan2_16 @@ -171,7 +171,7 @@ atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 (signed word) atan2_16::x#1 ← phi( atan2_16::@1/(signed word) atan2_16::x#5 atan2_16::@2/(signed word) atan2_16::x#6 ) (signed word~) atan2_16::$4 ← phi( atan2_16::@1/(signed word~) atan2_16::$3 atan2_16::@2/(signed word~) atan2_16::$2 ) (signed word) atan2_16::yi#0 ← (signed word~) atan2_16::$4 - (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 + (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 if((bool~) atan2_16::$5) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@4: scope:[atan2_16] from atan2_16::@3 @@ -219,7 +219,7 @@ atan2_16::@16: scope:[atan2_16] from atan2_16::@15 (signed word) atan2_16::xd#0 ← (signed word~) atan2_16::$19 (signed word~) atan2_16::$20 ← (signed word) atan2_16::yi#4 >> (byte) atan2_16::i#2 (signed word) atan2_16::yd#0 ← (signed word~) atan2_16::$20 - (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 + (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 if((bool~) atan2_16::$21) goto atan2_16::@18 to:atan2_16::@22 atan2_16::@17: scope:[atan2_16] from atan2_16::@15 atan2_16::@19 @@ -727,13 +727,13 @@ Adding number conversion cast (unumber) 5 in (byte*) init_font_hex::proto_lo#1 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) $f in (byte) CORDIC_ITERATIONS_16#0 ← (number) $f -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 Adding number conversion cast (unumber) 0 in (word) atan2_16::angle#0 ← (number) 0 Adding number conversion cast (unumber) 1 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (number) 1 Adding number conversion cast (unumber) atan2_16::$16 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (unumber)(number) 1 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 Adding number conversion cast (unumber) 2 in (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 / (number) 2 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (number) 0 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (number) 0 @@ -1013,10 +1013,10 @@ Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) init_font_hex::$3 [19] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 Simple Condition (bool~) init_font_hex::$4 [29] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 Simple Condition (bool~) init_font_hex::$5 [34] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 -Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 +Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 +Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 Simple Condition (bool~) atan2_16::$18 [64] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16 -Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@18 +Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@18 Simple Condition (bool~) atan2_16::$11 [76] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@7 Simple Condition (bool~) atan2_16::$22 [90] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15 Simple Condition (bool~) atan2_16::$14 [94] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@8 @@ -1353,14 +1353,14 @@ main::@4: scope:[main] from main::@3 main::@4 [25] *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) ← ++ *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) to:main::@4 atan2_16: scope:[atan2_16] from main::@2 - [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [27] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [28] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [30] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -1399,7 +1399,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [43] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [44] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [46] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 @@ -1873,15 +1873,9 @@ atan2_16: { .label angle_6 = $b .label angle_12 = $b .label angle_13 = $b - //SEG51 [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG51 [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG52 atan2_16::@2 b2: @@ -1900,15 +1894,9 @@ atan2_16: { jmp b3 //SEG56 atan2_16::@3 b3: - //SEG57 [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG57 [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG58 atan2_16::@5 b5: @@ -2042,15 +2030,9 @@ atan2_16: { dey bne !- !e: - //SEG91 [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG91 [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG92 atan2_16::@15 b15: @@ -2347,9 +2329,9 @@ Statement [17] (word~) main::$11 ← (word) main::angle_w#0 + (byte) $80 [ main: Statement [18] (byte) main::ang_w#0 ← > (word~) main::$11 [ main::y#4 main::x#2 main::screen#2 main::ang_w#0 ] ( main:2 [ main::y#4 main::x#2 main::screen#2 main::ang_w#0 ] ) always clobbers reg byte a Statement [19] *((byte*) main::screen#2) ← (byte) main::ang_w#0 [ main::y#4 main::x#2 main::screen#2 ] ( main:2 [ main::y#4 main::x#2 main::screen#2 ] ) always clobbers reg byte y Statement [25] *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) ← ++ *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [27] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [30] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [33] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] @@ -2360,7 +2342,7 @@ Statement [39] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [40] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [43] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [44] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [46] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [47] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [48] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2397,9 +2379,9 @@ Statement [17] (word~) main::$11 ← (word) main::angle_w#0 + (byte) $80 [ main: Statement [18] (byte) main::ang_w#0 ← > (word~) main::$11 [ main::y#4 main::x#2 main::screen#2 main::ang_w#0 ] ( main:2 [ main::y#4 main::x#2 main::screen#2 main::ang_w#0 ] ) always clobbers reg byte a Statement [19] *((byte*) main::screen#2) ← (byte) main::ang_w#0 [ main::y#4 main::x#2 main::screen#2 ] ( main:2 [ main::y#4 main::x#2 main::screen#2 ] ) always clobbers reg byte y Statement [25] *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) ← ++ *((const byte*) COLS#0+(word)(number) $c*(number) $28+(byte) $13) [ ] ( main:2 [ ] ) always clobbers reg byte a -Statement [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [27] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [30] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [33] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Statement [35] (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 >> (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ) always clobbers reg byte a @@ -2409,7 +2391,7 @@ Statement [39] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [40] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [43] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [44] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [46] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [47] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [48] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::atan2_16:14 [ main::y#4 main::x#2 main::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2466,25 +2448,25 @@ Uplift Scope [init_font_hex] 2,168.83: zp ZP_BYTE:23 [ init_font_hex::i#2 init_f Uplift Scope [main] 202: zp ZP_WORD:35 [ main::angle_w#0 ] 202: zp ZP_WORD:37 [ main::$11 ] 202: zp ZP_BYTE:39 [ main::ang_w#0 ] 168.33: zp ZP_BYTE:3 [ main::x#2 main::x#1 ] 93.15: zp ZP_WORD:4 [ main::screen#2 main::screen#4 main::screen#1 ] 50.5: zp ZP_WORD:25 [ main::xw#0 ] 50.5: zp ZP_WORD:27 [ main::yw#0 ] 17.97: zp ZP_BYTE:2 [ main::y#4 main::y#1 ] Uplift Scope [] -Uplifting [atan2_16] best 405389 combination zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:6 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:8 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:42 [ atan2_16::yd#0 ] zp ZP_WORD:40 [ atan2_16::xd#0 ] zp ZP_WORD:33 [ atan2_16::return#2 ] zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:29 [ atan2_16::x#0 ] zp ZP_WORD:31 [ atan2_16::y#0 ] -Uplifting [init_font_hex] best 386389 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:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:46 [ init_font_hex::$0 ] zp ZP_BYTE:49 [ init_font_hex::idx#3 ] zp ZP_WORD:18 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:20 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:15 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [atan2_16] best 395369 combination zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:6 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:8 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:42 [ atan2_16::yd#0 ] zp ZP_WORD:40 [ atan2_16::xd#0 ] zp ZP_WORD:33 [ atan2_16::return#2 ] zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:29 [ atan2_16::x#0 ] zp ZP_WORD:31 [ atan2_16::y#0 ] +Uplifting [init_font_hex] best 376369 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:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:46 [ init_font_hex::$0 ] zp ZP_BYTE:49 [ init_font_hex::idx#3 ] zp ZP_WORD:18 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:20 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:15 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] Limited combination testing to 100 combinations of 6912 possible. -Uplifting [main] best 384789 combination zp ZP_WORD:35 [ main::angle_w#0 ] zp ZP_WORD:37 [ main::$11 ] reg byte a [ main::ang_w#0 ] reg byte x [ main::x#2 main::x#1 ] zp ZP_WORD:4 [ main::screen#2 main::screen#4 main::screen#1 ] zp ZP_WORD:25 [ main::xw#0 ] zp ZP_WORD:27 [ main::yw#0 ] zp ZP_BYTE:2 [ main::y#4 main::y#1 ] -Uplifting [] best 384789 combination +Uplifting [main] best 374769 combination zp ZP_WORD:35 [ main::angle_w#0 ] zp ZP_WORD:37 [ main::$11 ] reg byte a [ main::ang_w#0 ] reg byte x [ main::x#2 main::x#1 ] zp ZP_WORD:4 [ main::screen#2 main::screen#4 main::screen#1 ] zp ZP_WORD:25 [ main::xw#0 ] zp ZP_WORD:27 [ main::yw#0 ] zp ZP_BYTE:2 [ main::y#4 main::y#1 ] +Uplifting [] best 374769 combination Attempting to uplift remaining variables inzp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] -Uplifting [atan2_16] best 384789 combination zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] +Uplifting [atan2_16] best 374769 combination zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] -Uplifting [init_font_hex] best 384789 combination zp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Uplifting [init_font_hex] best 374769 combination zp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] Attempting to uplift remaining variables inzp ZP_BYTE:46 [ init_font_hex::$0 ] -Uplifting [init_font_hex] best 384789 combination zp ZP_BYTE:46 [ init_font_hex::$0 ] +Uplifting [init_font_hex] best 374769 combination zp ZP_BYTE:46 [ init_font_hex::$0 ] Attempting to uplift remaining variables inzp ZP_BYTE:49 [ init_font_hex::idx#3 ] -Uplifting [init_font_hex] best 384189 combination reg byte y [ init_font_hex::idx#3 ] +Uplifting [init_font_hex] best 374169 combination reg byte y [ init_font_hex::idx#3 ] Attempting to uplift remaining variables inzp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] -Uplifting [init_font_hex] best 384189 combination zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Uplifting [init_font_hex] best 374169 combination zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:2 [ main::y#4 main::y#1 ] -Uplifting [main] best 384189 combination zp ZP_BYTE:2 [ main::y#4 main::y#1 ] +Uplifting [main] best 374169 combination zp ZP_BYTE:2 [ main::y#4 main::y#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] -Uplifting [init_font_hex] best 384189 combination zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [init_font_hex] best 374169 combination zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] Coalescing zero page register with common assignment [ zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:25 [ main::xw#0 ] ] with [ zp ZP_WORD:29 [ atan2_16::x#0 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:27 [ main::yw#0 ] ] with [ zp ZP_WORD:31 [ atan2_16::y#0 ] ] - score: 1 @@ -2673,15 +2655,9 @@ atan2_16: { .label return = $a .label x = $15 .label y = $17 - //SEG51 [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG51 [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG52 atan2_16::@2 b2: @@ -2700,15 +2676,9 @@ atan2_16: { jmp b3 //SEG56 atan2_16::@3 b3: - //SEG57 [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG57 [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG58 atan2_16::@5 b5: @@ -2838,15 +2808,9 @@ atan2_16: { dey bne !- !e: - //SEG91 [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG91 [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG92 atan2_16::@15 b15: @@ -3220,9 +3184,9 @@ Removing instruction jmp b3 Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [216] beq b12 to bne -Fixing long branch [90] bpl b1 to bmi -Fixing long branch [108] bpl b4 to bmi +Fixing long branch [198] beq b12 to bne +Fixing long branch [85] bpl b1 to bmi +Fixing long branch [97] bpl b4 to bmi FINAL SYMBOL TABLE (label) @1 @@ -3407,7 +3371,7 @@ reg byte y [ init_font_hex::idx#3 ] FINAL ASSEMBLER -Score: 357257 +Score: 347237 //SEG0 File Comments // Find atan2(x, y) using the CORDIC method @@ -3544,17 +3508,11 @@ atan2_16: { .label return = $a .label x = $15 .label y = $17 - //SEG51 [26] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG51 [26] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: //SEG52 atan2_16::@2 //SEG53 [27] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 -- vwsz1=_neg_vwsz2 sec @@ -3568,17 +3526,11 @@ atan2_16: { //SEG55 [28] phi (signed word) atan2_16::yi#0 = (signed word~) atan2_16::yi#11 [phi:atan2_16::@1/atan2_16::@2->atan2_16::@3#0] -- register_copy //SEG56 atan2_16::@3 b3: - //SEG57 [29] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG57 [29] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: //SEG58 atan2_16::@5 //SEG59 [30] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 -- vwsz1=_neg_vwsz2 sec @@ -3684,15 +3636,9 @@ atan2_16: { dey bne !- !e: - //SEG91 [45] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG91 [45] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: //SEG92 atan2_16::@15 //SEG93 [46] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 -- vwsz1=vwsz1_minus_vwsz2 lda xi diff --git a/src/test/ref/cordic-atan2-clear.asm b/src/test/ref/cordic-atan2-clear.asm index 84db5e206..179add02f 100644 --- a/src/test/ref/cordic-atan2-clear.asm +++ b/src/test/ref/cordic-atan2-clear.asm @@ -105,15 +105,9 @@ atan2_16: { .label x = $17 .label y = $19 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: sec lda #0 sbc y @@ -123,15 +117,9 @@ atan2_16: { sta _2+1 b3: lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: sec lda #0 sbc x @@ -205,13 +193,7 @@ atan2_16: { bne !- !e: lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: lda xi sec sbc yd diff --git a/src/test/ref/cordic-atan2-clear.cfg b/src/test/ref/cordic-atan2-clear.cfg index bfb551d00..e5624f989 100644 --- a/src/test/ref/cordic-atan2-clear.cfg +++ b/src/test/ref/cordic-atan2-clear.cfg @@ -65,14 +65,14 @@ init_screen::@return: scope:[init_screen] from init_screen::@3 [32] return to:@return atan2_16: scope:[atan2_16] from init_screen::@2 - [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [34] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [35] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [37] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -111,7 +111,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [50] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [51] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [53] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 diff --git a/src/test/ref/cordic-atan2-clear.log b/src/test/ref/cordic-atan2-clear.log index 6b307f2d5..966debf45 100644 --- a/src/test/ref/cordic-atan2-clear.log +++ b/src/test/ref/cordic-atan2-clear.log @@ -156,7 +156,7 @@ init_font_hex::@return: scope:[init_font_hex] from init_font_hex::@5 atan2_16: scope:[atan2_16] from init_screen::@2 (signed word) atan2_16::x#9 ← phi( init_screen::@2/(signed word) atan2_16::x#0 ) (signed word) atan2_16::y#1 ← phi( init_screen::@2/(signed word) atan2_16::y#0 ) - (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 + (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 if((bool~) atan2_16::$0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@1: scope:[atan2_16] from atan2_16 @@ -175,7 +175,7 @@ atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 (signed word) atan2_16::x#1 ← phi( atan2_16::@1/(signed word) atan2_16::x#5 atan2_16::@2/(signed word) atan2_16::x#6 ) (signed word~) atan2_16::$4 ← phi( atan2_16::@1/(signed word~) atan2_16::$3 atan2_16::@2/(signed word~) atan2_16::$2 ) (signed word) atan2_16::yi#0 ← (signed word~) atan2_16::$4 - (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 + (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 if((bool~) atan2_16::$5) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@4: scope:[atan2_16] from atan2_16::@3 @@ -223,7 +223,7 @@ atan2_16::@16: scope:[atan2_16] from atan2_16::@15 (signed word) atan2_16::xd#0 ← (signed word~) atan2_16::$19 (signed word~) atan2_16::$20 ← (signed word) atan2_16::yi#4 >> (byte) atan2_16::i#2 (signed word) atan2_16::yd#0 ← (signed word~) atan2_16::$20 - (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 + (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 if((bool~) atan2_16::$21) goto atan2_16::@18 to:atan2_16::@22 atan2_16::@17: scope:[atan2_16] from atan2_16::@15 atan2_16::@19 @@ -757,13 +757,13 @@ Adding number conversion cast (unumber) 5 in (byte*) init_font_hex::proto_lo#1 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) $f in (byte) CORDIC_ITERATIONS_16#0 ← (number) $f -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 > (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$0 ← (signed word) atan2_16::y#1 >= (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$5 ← (signed word) atan2_16::x#1 >= (number) 0 Adding number conversion cast (unumber) 0 in (word) atan2_16::angle#0 ← (number) 0 Adding number conversion cast (unumber) 1 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (number) 1 Adding number conversion cast (unumber) atan2_16::$16 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (unumber)(number) 1 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 Adding number conversion cast (unumber) 2 in (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 / (number) 2 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (number) 0 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (number) 0 @@ -1049,10 +1049,10 @@ Successful SSA optimization Pass2IdenticalPhiElimination Simple Condition (bool~) init_font_hex::$3 [19] if((byte) init_font_hex::i#1!=rangelast(0,4)) goto init_font_hex::@3 Simple Condition (bool~) init_font_hex::$4 [29] if((byte) init_font_hex::c1#1!=rangelast(0,$f)) goto init_font_hex::@2 Simple Condition (bool~) init_font_hex::$5 [34] if((byte) init_font_hex::c#1!=rangelast(0,$f)) goto init_font_hex::@1 -Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 +Simple Condition (bool~) atan2_16::$0 [41] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 +Simple Condition (bool~) atan2_16::$5 [50] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 Simple Condition (bool~) atan2_16::$18 [64] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16 -Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@18 +Simple Condition (bool~) atan2_16::$21 [71] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@18 Simple Condition (bool~) atan2_16::$11 [76] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@7 Simple Condition (bool~) atan2_16::$22 [90] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15 Simple Condition (bool~) atan2_16::$14 [94] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@8 @@ -1409,14 +1409,14 @@ init_screen::@return: scope:[init_screen] from init_screen::@3 [32] return to:@return atan2_16: scope:[atan2_16] from init_screen::@2 - [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 + [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 to:atan2_16::@2 atan2_16::@2: scope:[atan2_16] from atan2_16 [34] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 to:atan2_16::@3 atan2_16::@3: scope:[atan2_16] from atan2_16::@1 atan2_16::@2 [35] (signed word) atan2_16::yi#0 ← phi( atan2_16::@1/(signed word~) atan2_16::yi#11 atan2_16::@2/(signed word~) atan2_16::$2 ) - [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 + [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 to:atan2_16::@5 atan2_16::@5: scope:[atan2_16] from atan2_16::@3 [37] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 @@ -1455,7 +1455,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [50] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [51] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [53] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 @@ -1986,15 +1986,9 @@ atan2_16: { .label angle_6 = $d .label angle_12 = $d .label angle_13 = $d - //SEG67 [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG67 [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG68 atan2_16::@2 b2: @@ -2013,15 +2007,9 @@ atan2_16: { jmp b3 //SEG72 atan2_16::@3 b3: - //SEG73 [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG73 [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG74 atan2_16::@5 b5: @@ -2155,15 +2143,9 @@ atan2_16: { dey bne !- !e: - //SEG107 [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG107 [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG108 atan2_16::@15 b15: @@ -2462,9 +2444,9 @@ Statement [23] (word) init_screen::angle_w#0 ← (word) atan2_16::return#2 [ ini Statement [24] (word~) init_screen::$7 ← (word) init_screen::angle_w#0 + (byte) $80 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::$7 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::$7 ] ) always clobbers reg byte a Statement [25] (byte) init_screen::ang_w#0 ← > (word~) init_screen::$7 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::ang_w#0 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::ang_w#0 ] ) always clobbers reg byte a Statement [26] *((byte*) init_screen::screen#2) ← (byte) init_screen::ang_w#0 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 ] ) always clobbers reg byte y -Statement [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [34] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [37] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [40] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Removing always clobbered register reg byte a as potential for zp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] @@ -2475,7 +2457,7 @@ Statement [46] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [47] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [50] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [51] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [53] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [54] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [55] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2514,9 +2496,9 @@ Statement [23] (word) init_screen::angle_w#0 ← (word) atan2_16::return#2 [ ini Statement [24] (word~) init_screen::$7 ← (word) init_screen::angle_w#0 + (byte) $80 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::$7 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::$7 ] ) always clobbers reg byte a Statement [25] (byte) init_screen::ang_w#0 ← > (word~) init_screen::$7 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::ang_w#0 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 init_screen::ang_w#0 ] ) always clobbers reg byte a Statement [26] *((byte*) init_screen::screen#2) ← (byte) init_screen::ang_w#0 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 ] ( main:2::init_screen:8 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 ] ) always clobbers reg byte y -Statement [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a +Statement [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 [ atan2_16::x#0 atan2_16::y#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 ] ) always clobbers reg byte a Statement [34] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::$2 ] ) always clobbers reg byte a -Statement [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a +Statement [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 ] ) always clobbers reg byte a Statement [37] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#0 atan2_16::$7 ] ) always clobbers reg byte a Statement [40] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@11 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 ] ) always clobbers reg byte a Statement [42] (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 >> (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::angle#1 ] ) always clobbers reg byte a @@ -2526,7 +2508,7 @@ Statement [46] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [47] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [50] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [51] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [53] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [54] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [55] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::init_screen:8::atan2_16:21 [ init_screen::y#4 init_screen::x#2 init_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2585,26 +2567,26 @@ Uplift Scope [init_screen] 202: zp ZP_WORD:37 [ init_screen::angle_w#0 ] 202: zp Uplift Scope [main] 55.5: zp ZP_WORD:2 [ main::clear_char#5 main::clear_char#1 ] Uplift Scope [] -Uplifting [atan2_16] best 420956 combination zp ZP_WORD:13 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:8 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:10 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:44 [ atan2_16::yd#0 ] zp ZP_WORD:42 [ atan2_16::xd#0 ] zp ZP_WORD:35 [ atan2_16::return#2 ] zp ZP_WORD:15 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:31 [ atan2_16::x#0 ] zp ZP_WORD:33 [ atan2_16::y#0 ] -Uplifting [init_font_hex] best 401956 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:26 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:48 [ init_font_hex::$0 ] zp ZP_BYTE:51 [ init_font_hex::idx#3 ] zp ZP_WORD:20 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:24 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:22 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:17 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:19 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [atan2_16] best 410936 combination zp ZP_WORD:13 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:8 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:10 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:44 [ atan2_16::yd#0 ] zp ZP_WORD:42 [ atan2_16::xd#0 ] zp ZP_WORD:35 [ atan2_16::return#2 ] zp ZP_WORD:15 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:31 [ atan2_16::x#0 ] zp ZP_WORD:33 [ atan2_16::y#0 ] +Uplifting [init_font_hex] best 391936 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:26 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:48 [ init_font_hex::$0 ] zp ZP_BYTE:51 [ init_font_hex::idx#3 ] zp ZP_WORD:20 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:24 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:22 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:17 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:19 [ init_font_hex::c#6 init_font_hex::c#1 ] Limited combination testing to 100 combinations of 6912 possible. -Uplifting [init_screen] best 400356 combination zp ZP_WORD:37 [ init_screen::angle_w#0 ] zp ZP_WORD:39 [ init_screen::$7 ] reg byte a [ init_screen::ang_w#0 ] reg byte x [ init_screen::x#2 init_screen::x#1 ] zp ZP_WORD:6 [ init_screen::screen#2 init_screen::screen#4 init_screen::screen#1 ] zp ZP_WORD:27 [ init_screen::xw#0 ] zp ZP_WORD:29 [ init_screen::yw#0 ] zp ZP_BYTE:4 [ init_screen::y#4 init_screen::y#1 ] -Uplifting [main] best 400356 combination zp ZP_WORD:2 [ main::clear_char#5 main::clear_char#1 ] -Uplifting [] best 400356 combination +Uplifting [init_screen] best 390336 combination zp ZP_WORD:37 [ init_screen::angle_w#0 ] zp ZP_WORD:39 [ init_screen::$7 ] reg byte a [ init_screen::ang_w#0 ] reg byte x [ init_screen::x#2 init_screen::x#1 ] zp ZP_WORD:6 [ init_screen::screen#2 init_screen::screen#4 init_screen::screen#1 ] zp ZP_WORD:27 [ init_screen::xw#0 ] zp ZP_WORD:29 [ init_screen::yw#0 ] zp ZP_BYTE:4 [ init_screen::y#4 init_screen::y#1 ] +Uplifting [main] best 390336 combination zp ZP_WORD:2 [ main::clear_char#5 main::clear_char#1 ] +Uplifting [] best 390336 combination Attempting to uplift remaining variables inzp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] -Uplifting [atan2_16] best 400356 combination zp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] +Uplifting [atan2_16] best 390336 combination zp ZP_BYTE:12 [ atan2_16::i#2 atan2_16::i#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:26 [ init_font_hex::idx#5 init_font_hex::idx#2 ] -Uplifting [init_font_hex] best 400356 combination zp ZP_BYTE:26 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Uplifting [init_font_hex] best 390336 combination zp ZP_BYTE:26 [ init_font_hex::idx#5 init_font_hex::idx#2 ] Attempting to uplift remaining variables inzp ZP_BYTE:48 [ init_font_hex::$0 ] -Uplifting [init_font_hex] best 400356 combination zp ZP_BYTE:48 [ init_font_hex::$0 ] +Uplifting [init_font_hex] best 390336 combination zp ZP_BYTE:48 [ init_font_hex::$0 ] Attempting to uplift remaining variables inzp ZP_BYTE:51 [ init_font_hex::idx#3 ] -Uplifting [init_font_hex] best 399756 combination reg byte y [ init_font_hex::idx#3 ] +Uplifting [init_font_hex] best 389736 combination reg byte y [ init_font_hex::idx#3 ] Attempting to uplift remaining variables inzp ZP_BYTE:24 [ init_font_hex::c1#4 init_font_hex::c1#1 ] -Uplifting [init_font_hex] best 399756 combination zp ZP_BYTE:24 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Uplifting [init_font_hex] best 389736 combination zp ZP_BYTE:24 [ init_font_hex::c1#4 init_font_hex::c1#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:4 [ init_screen::y#4 init_screen::y#1 ] -Uplifting [init_screen] best 399756 combination zp ZP_BYTE:4 [ init_screen::y#4 init_screen::y#1 ] +Uplifting [init_screen] best 389736 combination zp ZP_BYTE:4 [ init_screen::y#4 init_screen::y#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:19 [ init_font_hex::c#6 init_font_hex::c#1 ] -Uplifting [init_font_hex] best 399756 combination zp ZP_BYTE:19 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [init_font_hex] best 389736 combination zp ZP_BYTE:19 [ init_font_hex::c#6 init_font_hex::c#1 ] Coalescing zero page register with common assignment [ zp ZP_WORD:13 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:15 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:27 [ init_screen::xw#0 ] ] with [ zp ZP_WORD:31 [ atan2_16::x#0 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:29 [ init_screen::yw#0 ] ] with [ zp ZP_WORD:33 [ atan2_16::y#0 ] ] - score: 1 @@ -2844,15 +2826,9 @@ atan2_16: { .label return = $c .label x = $17 .label y = $19 - //SEG67 [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG67 [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bpl b1 - !e: jmp b2 //SEG68 atan2_16::@2 b2: @@ -2871,15 +2847,9 @@ atan2_16: { jmp b3 //SEG72 atan2_16::@3 b3: - //SEG73 [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG73 [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bpl b4 - !e: jmp b5 //SEG74 atan2_16::@5 b5: @@ -3009,15 +2979,9 @@ atan2_16: { dey bne !- !e: - //SEG107 [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG107 [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG108 atan2_16::@15 b15: @@ -3409,9 +3373,9 @@ Removing instruction jmp b3 Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [238] beq b12 to bne -Fixing long branch [112] bpl b1 to bmi -Fixing long branch [130] bpl b4 to bmi +Fixing long branch [220] beq b12 to bne +Fixing long branch [107] bpl b1 to bmi +Fixing long branch [119] bpl b4 to bmi FINAL SYMBOL TABLE (label) @1 @@ -3604,7 +3568,7 @@ reg byte y [ init_font_hex::idx#3 ] FINAL ASSEMBLER -Score: 368894 +Score: 358874 //SEG0 File Comments // Find atan2(x, y) using the CORDIC method @@ -3779,17 +3743,11 @@ atan2_16: { .label return = $c .label x = $17 .label y = $19 - //SEG67 [33] if((signed word) atan2_16::y#0>(signed byte) 0) goto atan2_16::@1 -- vwsz1_gt_0_then_la1 + //SEG67 [33] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 -- vwsz1_ge_0_then_la1 lda y+1 - bne !+ - lda y - beq !e+ - lsr - !: bmi !b1+ jmp b1 !b1: - !e: //SEG68 atan2_16::@2 //SEG69 [34] (signed word~) atan2_16::$2 ← - (signed word) atan2_16::y#0 -- vwsz1=_neg_vwsz2 sec @@ -3803,17 +3761,11 @@ atan2_16: { //SEG71 [35] phi (signed word) atan2_16::yi#0 = (signed word~) atan2_16::yi#11 [phi:atan2_16::@1/atan2_16::@2->atan2_16::@3#0] -- register_copy //SEG72 atan2_16::@3 b3: - //SEG73 [36] if((signed word) atan2_16::x#0>(signed byte) 0) goto atan2_16::@4 -- vwsz1_gt_0_then_la1 + //SEG73 [36] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 -- vwsz1_ge_0_then_la1 lda x+1 - bne !+ - lda x - beq !e+ - lsr - !: bmi !b4+ jmp b4 !b4: - !e: //SEG74 atan2_16::@5 //SEG75 [37] (signed word~) atan2_16::$7 ← - (signed word) atan2_16::x#0 -- vwsz1=_neg_vwsz2 sec @@ -3919,15 +3871,9 @@ atan2_16: { dey bne !- !e: - //SEG107 [52] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG107 [52] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: //SEG108 atan2_16::@15 //SEG109 [53] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 -- vwsz1=vwsz1_minus_vwsz2 lda xi diff --git a/src/test/ref/screen-center-angle.asm b/src/test/ref/screen-center-angle.asm index 2a382aa8a..e06750f22 100644 --- a/src/test/ref/screen-center-angle.asm +++ b/src/test/ref/screen-center-angle.asm @@ -171,13 +171,7 @@ atan2_16: { bne !- !e: lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: lda xi sec sbc yd diff --git a/src/test/ref/screen-center-angle.cfg b/src/test/ref/screen-center-angle.cfg index 249a75067..0c1b0ac28 100644 --- a/src/test/ref/screen-center-angle.cfg +++ b/src/test/ref/screen-center-angle.cfg @@ -101,7 +101,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [46] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [47] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [49] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 diff --git a/src/test/ref/screen-center-angle.log b/src/test/ref/screen-center-angle.log index e38deea4b..bd116ff11 100644 --- a/src/test/ref/screen-center-angle.log +++ b/src/test/ref/screen-center-angle.log @@ -229,7 +229,7 @@ atan2_16::@16: scope:[atan2_16] from atan2_16::@15 (signed word) atan2_16::xd#0 ← (signed word~) atan2_16::$19 (signed word~) atan2_16::$20 ← (signed word) atan2_16::yi#4 >> (byte) atan2_16::i#2 (signed word) atan2_16::yd#0 ← (signed word~) atan2_16::$20 - (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 + (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 if((bool~) atan2_16::$21) goto atan2_16::@18 to:atan2_16::@22 atan2_16::@17: scope:[atan2_16] from atan2_16::@15 atan2_16::@19 @@ -728,7 +728,7 @@ Adding number conversion cast (unumber) 0 in (word) atan2_16::angle#0 ← (numbe Adding number conversion cast (unumber) 1 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (number) 1 Adding number conversion cast (unumber) atan2_16::$16 in (number~) atan2_16::$16 ← (byte) CORDIC_ITERATIONS_16#0 - (unumber)(number) 1 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$17 ← (signed word) atan2_16::yi#3 == (number) 0 -Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 > (number) 0 +Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$21 ← (signed word) atan2_16::yi#4 >= (number) 0 Adding number conversion cast (unumber) 2 in (word) atan2_16::angle#1 ← (word) atan2_16::angle#6 / (number) 2 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$10 ← (signed word) atan2_16::x#4 < (number) 0 Adding number conversion cast (snumber) 0 in (bool~) atan2_16::$13 ← (signed word) atan2_16::y#4 < (number) 0 @@ -1002,7 +1002,7 @@ Simple Condition (bool~) init_font_hex::$5 [35] if((byte) init_font_hex::c#1!=ra Simple Condition (bool~) atan2_16::$0 [42] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@1 Simple Condition (bool~) atan2_16::$5 [51] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@4 Simple Condition (bool~) atan2_16::$18 [65] if((signed word) atan2_16::yi#3!=(signed byte) 0) goto atan2_16::@16 -Simple Condition (bool~) atan2_16::$21 [72] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@18 +Simple Condition (bool~) atan2_16::$21 [72] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@18 Simple Condition (bool~) atan2_16::$11 [77] if((signed word) atan2_16::x#0>=(signed byte) 0) goto atan2_16::@7 Simple Condition (bool~) atan2_16::$22 [91] if((byte) atan2_16::i#1!=rangelast(0,atan2_16::$16)) goto atan2_16::@15 Simple Condition (bool~) atan2_16::$14 [95] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@8 @@ -1376,7 +1376,7 @@ atan2_16::@return: scope:[atan2_16] from atan2_16::@8 atan2_16::@11: scope:[atan2_16] from atan2_16::@10 [46] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [47] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 - [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 + [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 to:atan2_16::@15 atan2_16::@15: scope:[atan2_16] from atan2_16::@11 [49] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 @@ -2015,15 +2015,9 @@ atan2_16: { dey bne !- !e: - //SEG96 [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG96 [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG97 atan2_16::@15 b15: @@ -2332,7 +2326,7 @@ Statement [42] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [43] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [46] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [47] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [49] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [50] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [51] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2380,7 +2374,7 @@ Statement [42] if((signed word) atan2_16::y#0>=(signed byte) 0) goto atan2_16::@ Statement [43] (word) atan2_16::angle#5 ← - (word) atan2_16::angle#11 [ atan2_16::angle#5 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::angle#5 ] ) always clobbers reg byte a Statement [46] (signed word) atan2_16::xd#0 ← (signed word) atan2_16::xi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 ] ) always clobbers reg byte a Statement [47] (signed word) atan2_16::yd#0 ← (signed word) atan2_16::yi#3 >> (byte) atan2_16::i#2 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a -Statement [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a +Statement [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::xi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::yd#0 ] ) always clobbers reg byte a Statement [49] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::yi#3 atan2_16::i#2 atan2_16::angle#12 atan2_16::xd#0 atan2_16::xi#2 ] ) always clobbers reg byte a Statement [50] (signed word) atan2_16::yi#2 ← (signed word) atan2_16::yi#3 + (signed word) atan2_16::xd#0 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 ] ) always clobbers reg byte a Statement [51] (byte~) atan2_16::$24 ← (byte) atan2_16::i#2 << (byte) 1 [ atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ( main:2::init_angle_screen:8::atan2_16:17 [ init_angle_screen::y#4 init_angle_screen::x#2 init_angle_screen::screen#2 atan2_16::x#0 atan2_16::y#0 atan2_16::i#2 atan2_16::angle#12 atan2_16::xi#2 atan2_16::yi#2 atan2_16::$24 ] ) always clobbers reg byte a @@ -2438,26 +2432,26 @@ Uplift Scope [init_angle_screen] 202: zp ZP_WORD:35 [ init_angle_screen::angle_w Uplift Scope [main] Uplift Scope [] -Uplifting [atan2_16] best 405240 combination zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:6 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:8 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:42 [ atan2_16::yd#0 ] zp ZP_WORD:40 [ atan2_16::xd#0 ] zp ZP_WORD:33 [ atan2_16::return#2 ] zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:29 [ atan2_16::x#0 ] zp ZP_WORD:31 [ atan2_16::y#0 ] -Uplifting [init_font_hex] best 386240 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:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:46 [ init_font_hex::$0 ] zp ZP_BYTE:49 [ init_font_hex::idx#3 ] zp ZP_WORD:18 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:20 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:15 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [atan2_16] best 395240 combination zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] zp ZP_WORD:6 [ atan2_16::yi#3 atan2_16::yi#7 atan2_16::yi#0 atan2_16::yi#11 atan2_16::$2 atan2_16::yi#1 atan2_16::yi#2 ] zp ZP_WORD:8 [ atan2_16::xi#3 atan2_16::xi#7 atan2_16::xi#0 atan2_16::xi#8 atan2_16::$7 atan2_16::xi#1 atan2_16::xi#2 ] reg byte a [ atan2_16::$24 ] reg byte a [ atan2_16::$23 ] zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] zp ZP_WORD:42 [ atan2_16::yd#0 ] zp ZP_WORD:40 [ atan2_16::xd#0 ] zp ZP_WORD:33 [ atan2_16::return#2 ] zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] zp ZP_WORD:29 [ atan2_16::x#0 ] zp ZP_WORD:31 [ atan2_16::y#0 ] +Uplifting [init_font_hex] best 376240 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:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] zp ZP_BYTE:46 [ init_font_hex::$0 ] zp ZP_BYTE:49 [ init_font_hex::idx#3 ] zp ZP_WORD:18 [ init_font_hex::charset#2 init_font_hex::charset#5 init_font_hex::charset#0 ] zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] zp ZP_WORD:20 [ init_font_hex::proto_lo#4 init_font_hex::proto_lo#1 ] zp ZP_WORD:15 [ init_font_hex::proto_hi#6 init_font_hex::proto_hi#1 ] zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] Limited combination testing to 100 combinations of 6912 possible. -Uplifting [init_angle_screen] best 384640 combination zp ZP_WORD:35 [ init_angle_screen::angle_w#0 ] zp ZP_WORD:37 [ init_angle_screen::$7 ] reg byte a [ init_angle_screen::ang_w#0 ] reg byte x [ init_angle_screen::x#2 init_angle_screen::x#1 ] zp ZP_WORD:4 [ init_angle_screen::screen#2 init_angle_screen::screen#4 init_angle_screen::screen#1 ] zp ZP_WORD:25 [ init_angle_screen::xw#0 ] zp ZP_WORD:27 [ init_angle_screen::yw#0 ] zp ZP_BYTE:2 [ init_angle_screen::y#4 init_angle_screen::y#1 ] -Uplifting [main] best 384640 combination -Uplifting [] best 384640 combination +Uplifting [init_angle_screen] best 374640 combination zp ZP_WORD:35 [ init_angle_screen::angle_w#0 ] zp ZP_WORD:37 [ init_angle_screen::$7 ] reg byte a [ init_angle_screen::ang_w#0 ] reg byte x [ init_angle_screen::x#2 init_angle_screen::x#1 ] zp ZP_WORD:4 [ init_angle_screen::screen#2 init_angle_screen::screen#4 init_angle_screen::screen#1 ] zp ZP_WORD:25 [ init_angle_screen::xw#0 ] zp ZP_WORD:27 [ init_angle_screen::yw#0 ] zp ZP_BYTE:2 [ init_angle_screen::y#4 init_angle_screen::y#1 ] +Uplifting [main] best 374640 combination +Uplifting [] best 374640 combination Attempting to uplift remaining variables inzp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] -Uplifting [atan2_16] best 384640 combination zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] +Uplifting [atan2_16] best 374640 combination zp ZP_BYTE:10 [ atan2_16::i#2 atan2_16::i#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] -Uplifting [init_font_hex] best 384640 combination zp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] +Uplifting [init_font_hex] best 374640 combination zp ZP_BYTE:24 [ init_font_hex::idx#5 init_font_hex::idx#2 ] Attempting to uplift remaining variables inzp ZP_BYTE:46 [ init_font_hex::$0 ] -Uplifting [init_font_hex] best 384640 combination zp ZP_BYTE:46 [ init_font_hex::$0 ] +Uplifting [init_font_hex] best 374640 combination zp ZP_BYTE:46 [ init_font_hex::$0 ] Attempting to uplift remaining variables inzp ZP_BYTE:49 [ init_font_hex::idx#3 ] -Uplifting [init_font_hex] best 384040 combination reg byte y [ init_font_hex::idx#3 ] +Uplifting [init_font_hex] best 374040 combination reg byte y [ init_font_hex::idx#3 ] Attempting to uplift remaining variables inzp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] -Uplifting [init_font_hex] best 384040 combination zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] +Uplifting [init_font_hex] best 374040 combination zp ZP_BYTE:22 [ init_font_hex::c1#4 init_font_hex::c1#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:2 [ init_angle_screen::y#4 init_angle_screen::y#1 ] -Uplifting [init_angle_screen] best 384040 combination zp ZP_BYTE:2 [ init_angle_screen::y#4 init_angle_screen::y#1 ] +Uplifting [init_angle_screen] best 374040 combination zp ZP_BYTE:2 [ init_angle_screen::y#4 init_angle_screen::y#1 ] Attempting to uplift remaining variables inzp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] -Uplifting [init_font_hex] best 384040 combination zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] +Uplifting [init_font_hex] best 374040 combination zp ZP_BYTE:17 [ init_font_hex::c#6 init_font_hex::c#1 ] Coalescing zero page register with common assignment [ zp ZP_WORD:11 [ atan2_16::angle#6 atan2_16::angle#12 atan2_16::angle#13 atan2_16::angle#2 atan2_16::angle#3 ] ] with [ zp ZP_WORD:13 [ atan2_16::return#0 atan2_16::angle#5 atan2_16::angle#11 atan2_16::angle#1 atan2_16::angle#4 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:25 [ init_angle_screen::xw#0 ] ] with [ zp ZP_WORD:29 [ atan2_16::x#0 ] ] - score: 1 Coalescing zero page register with common assignment [ zp ZP_WORD:27 [ init_angle_screen::yw#0 ] ] with [ zp ZP_WORD:31 [ atan2_16::y#0 ] ] - score: 1 @@ -2808,15 +2802,9 @@ atan2_16: { dey bne !- !e: - //SEG96 [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG96 [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: jmp b15 //SEG97 atan2_16::@15 b15: @@ -3194,7 +3182,7 @@ Removing instruction jmp b3 Succesful ASM optimization Pass5NextJumpElimination Removing instruction bbegin: Succesful ASM optimization Pass5UnusedLabelElimination -Fixing long branch [204] beq b12 to bne +Fixing long branch [198] beq b12 to bne Fixing long branch [85] bpl b1 to bmi Fixing long branch [97] bpl b4 to bmi @@ -3380,7 +3368,7 @@ reg byte y [ init_font_hex::idx#3 ] FINAL ASSEMBLER -Score: 357105 +Score: 347105 //SEG0 File Comments // Calculate the angle to the center of the screen - and show it using font-hex @@ -3650,15 +3638,9 @@ atan2_16: { dey bne !- !e: - //SEG96 [48] if((signed word) atan2_16::yi#3>(signed byte) 0) goto atan2_16::@13 -- vwsz1_gt_0_then_la1 + //SEG96 [48] if((signed word) atan2_16::yi#3>=(signed byte) 0) goto atan2_16::@13 -- vwsz1_ge_0_then_la1 lda yi+1 - bne !+ - lda yi - beq !e+ - lsr - !: bpl b13 - !e: //SEG97 atan2_16::@15 //SEG98 [49] (signed word) atan2_16::xi#2 ← (signed word) atan2_16::xi#3 - (signed word) atan2_16::yd#0 -- vwsz1=vwsz1_minus_vwsz2 lda xi