1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-01-15 16:30:02 +00:00

Added another test for #525 demonstrating problem with reuse of index*sizeof(). Added more fragments and optimizing others.

This commit is contained in:
jespergravgaard 2020-09-29 01:35:08 +02:00
parent 8abaa95008
commit d9ced92fd7
28 changed files with 1998 additions and 1338 deletions

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 132c9fe4d5 132c9ffe57
//KICKC FRAGMENT CACHE 12beec37ea 12beec5182
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 132c9fe4d5 132c9ffe57
//KICKC FRAGMENT CACHE 12beec37ea 12beec5182
//FRAGMENT _deref_pbuc1=vbuc2
lda #{c2}
sta {c1}

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 132c9fe4d5 132c9ffe57
//KICKC FRAGMENT CACHE 12beec37ea 12beec5182
//FRAGMENT vbuz1=vbuc1
lda #{c1}
sta {z1}

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
//KICKC FRAGMENT CACHE 132c9fe4d5 132c9ffe57
//KICKC FRAGMENT CACHE 12beec37ea 12beec5182
//FRAGMENT vbuz1=_deref_pbuc1
lda {c1}
sta {z1}

View File

@ -0,0 +1,4 @@
inc {c1},x
bne !+
inc {c1}+1,x
!:

View File

@ -0,0 +1,6 @@
lda {c1}+1,x
bne !+
lda {c1},x
cmp #{c2}
bcc {la1}
!:

View File

@ -0,0 +1,9 @@
clc
lda {c1},y
adc #1
sta {c1},y
bne !+
lda {c1}+1,y
adc #0
sta {c1}+1,y
!:

View File

@ -0,0 +1,6 @@
lda {c1}+1,y
bne !+
lda {c1},y
cmp #{c2}
bcc {la1}
!:

View File

@ -1,8 +1,6 @@
lda {m1}+1
cmp #>{c1}
bcc {la1}
bne !+
lda {m1}
cmp #<{c1}
cmp #{c1}
bcc {la1}
!:

View File

@ -49,6 +49,11 @@ public class TestPrograms {
compileAndCompare("index-sizeof-reuse.c");
}
@Test
public void testIndexSizeofReuse2() throws IOException, URISyntaxException {
compileAndCompare("index-sizeof-reuse-2.c");
}
@Test
public void testPragmaNoParenthesis() throws IOException, URISyntaxException {
compileAndCompare("pragma-noparenthesis.c");

View File

@ -0,0 +1,39 @@
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
#define NUM_ENTITIES 25
unsigned int entities[NUM_ENTITIES];
char * const VIC_RASTER = 0xd012;
char * const VIC_BG_COLOR = 0xd020;
char * const SCREEN = 0x0400;
void main() {
asm { sei }
while(1) {
// Wait for raster refresh
while(*VIC_RASTER!=0xff) ;
*VIC_BG_COLOR = 0;
// Move the entities
char * line = SCREEN;
for(char i=0;i<NUM_ENTITIES;i++) {
// Delete old symbol
line[(char)entities[i]] = ' ';
// Move by velocity
entities[i] += 1;
// Reset if needed
if(entities[i]>39) {
entities[i] =0;
}
// Draw symbol
line[entities[i]] = '*';
// Next line
line +=40;
}
*VIC_BG_COLOR = 15;
}
}

View File

@ -208,11 +208,9 @@ main: {
!:
// if (c>=14)
lda.z c_2+1
cmp #>$e
bcc __b36
bne !+
lda.z c_2
cmp #<$e
cmp #$e
bcc __b36
!:
// if (0==stopIt && objects<maxDrawObjects)
@ -245,11 +243,9 @@ main: {
__b34:
// if (oCount>2 && objects>0)
lda.z oCount+1
cmp #>2+1
bcc __b35
bne !+
lda.z oCount
cmp #<2+1
cmp #2+1
bcc __b35
!:
lda.z objects

View File

@ -3483,11 +3483,9 @@ main: {
!:
// [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1
lda.z c_2+1
cmp #>$e
bcc __b33_from___b19
bne !+
lda.z c_2
cmp #<$e
cmp #$e
bcc __b33_from___b19
!:
jmp __b30
@ -3554,11 +3552,9 @@ main: {
__b34:
// [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1
lda.z oCount+1
cmp #>2+1
bcc __b35_from___b34
bne !+
lda.z oCount
cmp #<2+1
cmp #2+1
bcc __b35_from___b34
!:
jmp __b44
@ -4522,31 +4518,31 @@ Uplift Scope [$4]
Uplift Scope [$5]
Uplift Scope []
Uplifting [Print00] best 71507 combination reg byte x [ Print00::v#5 Print00::v#3 Print00::v0#0 Print00::v#1 Print00::v#2 ] reg byte y [ Print00::c#5 Print00::c#2 ] reg byte y [ Print00::c#10 Print00::c#4 ]
Uplifting [GetSprite] best 70211 combination reg byte x [ GetSprite::return#2 GetSprite::t0#3 GetSprite::t0#2 ] reg byte x [ GetSprite::return#4 ]
Uplifting [AddSprite] best 68968 combination reg byte y [ AddSprite::t0#3 AddSprite::t0#2 ] reg byte x [ AddSprite::sn#1 ]
Uplifting [main] best 68548 combination zp[1]:13 [ main::i#22 main::i#9 ] zp[2]:14 [ main::d#10 main::d#2 ] zp[2]:28 [ main::$27 ] zp[2]:30 [ main::$28 ] zp[2]:17 [ main::oCount#7 main::oCount#17 main::oCount#20 main::oCount#2 ] zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] reg byte x [ main::i#12 main::i#2 ] reg byte x [ main::i#14 main::i#4 ] zp[2]:6 [ main::c#11 main::c#4 ] zp[2]:4 [ main::c#10 main::c#2 ] reg byte x [ main::i#17 main::i#7 ] zp[1]:32 [ main::$132 ] reg byte a [ main::$52 ] zp[2]:38 [ main::$112 ] zp[2]:40 [ main::$109 ] zp[2]:42 [ main::$110 ] zp[2]:10 [ main::c#16 main::c#18 main::c#7 ] zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] zp[1]:26 [ main::i#11 ] zp[2]:36 [ main::$111 ] zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] zp[2]:34 [ main::d1#0 ]
Uplifting [Print00] best 71417 combination reg byte x [ Print00::v#5 Print00::v#3 Print00::v0#0 Print00::v#1 Print00::v#2 ] reg byte y [ Print00::c#5 Print00::c#2 ] reg byte y [ Print00::c#10 Print00::c#4 ]
Uplifting [GetSprite] best 70121 combination reg byte x [ GetSprite::return#2 GetSprite::t0#3 GetSprite::t0#2 ] reg byte x [ GetSprite::return#4 ]
Uplifting [AddSprite] best 68878 combination reg byte y [ AddSprite::t0#3 AddSprite::t0#2 ] reg byte x [ AddSprite::sn#1 ]
Uplifting [main] best 68458 combination zp[1]:13 [ main::i#22 main::i#9 ] zp[2]:14 [ main::d#10 main::d#2 ] zp[2]:28 [ main::$27 ] zp[2]:30 [ main::$28 ] zp[2]:17 [ main::oCount#7 main::oCount#17 main::oCount#20 main::oCount#2 ] zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ] reg byte x [ main::i#12 main::i#2 ] reg byte x [ main::i#14 main::i#4 ] zp[2]:6 [ main::c#11 main::c#4 ] zp[2]:4 [ main::c#10 main::c#2 ] reg byte x [ main::i#17 main::i#7 ] zp[1]:32 [ main::$132 ] reg byte a [ main::$52 ] zp[2]:38 [ main::$112 ] zp[2]:40 [ main::$109 ] zp[2]:42 [ main::$110 ] zp[2]:10 [ main::c#16 main::c#18 main::c#7 ] zp[1]:9 [ main::type#4 main::type#10 main::type#2 ] zp[1]:26 [ main::i#11 ] zp[2]:36 [ main::$111 ] zp[1]:12 [ main::stopIt#5 main::stopIt#15 ] zp[2]:34 [ main::d1#0 ]
Limited combination testing to 100 combinations of 1728 possible.
Uplifting [DelSprite] best 68512 combination reg byte x [ DelSprite::sn#0 ]
Uplifting [$0] best 68512 combination
Uplifting [$1] best 68512 combination
Uplifting [$2] best 68512 combination
Uplifting [$3] best 68512 combination
Uplifting [$4] best 68512 combination
Uplifting [$5] best 68512 combination
Uplifting [] best 68512 combination
Uplifting [DelSprite] best 68422 combination reg byte x [ DelSprite::sn#0 ]
Uplifting [$0] best 68422 combination
Uplifting [$1] best 68422 combination
Uplifting [$2] best 68422 combination
Uplifting [$3] best 68422 combination
Uplifting [$4] best 68422 combination
Uplifting [$5] best 68422 combination
Uplifting [] best 68422 combination
Attempting to uplift remaining variables inzp[1]:13 [ main::i#22 main::i#9 ]
Uplifting [main] best 68512 combination zp[1]:13 [ main::i#22 main::i#9 ]
Uplifting [main] best 68422 combination zp[1]:13 [ main::i#22 main::i#9 ]
Attempting to uplift remaining variables inzp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ]
Uplifting [main] best 68512 combination zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ]
Uplifting [main] best 68422 combination zp[1]:16 [ main::objects#12 main::objects#9 main::objects#17 main::objects#1 main::objects#15 ]
Attempting to uplift remaining variables inzp[1]:32 [ main::$132 ]
Uplifting [main] best 68492 combination reg byte a [ main::$132 ]
Uplifting [main] best 68402 combination reg byte a [ main::$132 ]
Attempting to uplift remaining variables inzp[1]:9 [ main::type#4 main::type#10 main::type#2 ]
Uplifting [main] best 68492 combination zp[1]:9 [ main::type#4 main::type#10 main::type#2 ]
Uplifting [main] best 68402 combination zp[1]:9 [ main::type#4 main::type#10 main::type#2 ]
Attempting to uplift remaining variables inzp[1]:26 [ main::i#11 ]
Uplifting [main] best 68282 combination reg byte x [ main::i#11 ]
Uplifting [main] best 68192 combination reg byte x [ main::i#11 ]
Attempting to uplift remaining variables inzp[1]:12 [ main::stopIt#5 main::stopIt#15 ]
Uplifting [main] best 68282 combination zp[1]:12 [ main::stopIt#5 main::stopIt#15 ]
Uplifting [main] best 68192 combination zp[1]:12 [ main::stopIt#5 main::stopIt#15 ]
Allocated (was zp[2]:4) zp[2]:2 [ main::c#10 main::c#2 ]
Allocated (was zp[2]:6) zp[2]:4 [ main::c#11 main::c#4 ]
Allocated (was zp[1]:9) zp[1]:6 [ main::type#4 main::type#10 main::type#2 ]
@ -4829,11 +4825,9 @@ main: {
!:
// [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1
lda.z c_2+1
cmp #>$e
bcc __b33_from___b19
bne !+
lda.z c_2
cmp #<$e
cmp #$e
bcc __b33_from___b19
!:
jmp __b30
@ -4900,11 +4894,9 @@ main: {
__b34:
// [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1
lda.z oCount+1
cmp #>2+1
bcc __b35_from___b34
bne !+
lda.z oCount
cmp #<2+1
cmp #2+1
bcc __b35_from___b34
!:
jmp __b44
@ -5648,7 +5640,6 @@ Replacing label __b33 with __b36
Replacing label __b33 with __b36
Replacing label __b34_from___b36 with __b34
Replacing label __b35_from___b34 with __b35
Replacing label __b35_from___b34 with __b35
Replacing label __b45_from___b13 with __b14
Removing instruction __b17_from___b16:
Removing instruction __b33_from___b42:
@ -5715,7 +5706,6 @@ Removing instruction __b5:
Removing instruction __b2_from___b4:
Succesful ASM optimization Pass5UnusedLabelElimination
Skipping double jump to __b36 in bcc __b33_from___b19
Skipping double jump to __b36 in bcc __b33_from___b19
Skipping double jump to __b36 in jmp __b33_from___b43
Replacing jump to rts with rts in jmp __breturn
Replacing jump to rts with rts in jmp __breturn
@ -5744,8 +5734,8 @@ Fixing long branch [101] bcc __b9 to bcs
Fixing long branch [107] bcc __b9 to bcs
Fixing long branch [145] bcc __b13 to bcs
Fixing long branch [166] bcc __b18 to bcs
Fixing long branch [267] bmi __b20 to bpl
Fixing long branch [292] bmi __b22 to bpl
Fixing long branch [263] bmi __b20 to bpl
Fixing long branch [288] bmi __b22 to bpl
FINAL SYMBOL TABLE
(signed byte) $5::ax
@ -5950,7 +5940,7 @@ zp[2]:28 [ main::$110 ]
FINAL ASSEMBLER
Score: 62702
Score: 62612
// File Comments
// bubbles64 - Q&D C64 port of the bubbles demo from vbcc6502's NES exmaples
@ -6232,11 +6222,9 @@ main: {
// if (c>=14)
// [41] if((word) main::c#7<(byte) $e) goto main::@33 -- vwuz1_lt_vbuc1_then_la1
lda.z c_2+1
cmp #>$e
bcc __b36
bne !+
lda.z c_2
cmp #<$e
cmp #$e
bcc __b36
!:
// main::@30
@ -6289,11 +6277,9 @@ main: {
// if (oCount>2 && objects>0)
// [48] if((word) main::oCount#7<(byte) 2+(byte) 1) goto main::@35 -- vwuz1_lt_vbuc1_then_la1
lda.z oCount+1
cmp #>2+1
bcc __b35
bne !+
lda.z oCount
cmp #<2+1
cmp #2+1
bcc __b35
!:
// main::@44

View File

@ -544,11 +544,9 @@ ppuDataTransfer: {
__b1:
// for(unsigned int i=0;i<size;i++)
lda.z i+1
cmp #>$20*SIZEOF_BYTE
bcc __b2
bne !+
lda.z i
cmp #<$20*SIZEOF_BYTE
cmp #$20*SIZEOF_BYTE
bcc __b2
!:
// }

View File

@ -3369,11 +3369,9 @@ ppuDataTransfer: {
__b1:
// [121] if((word) ppuDataTransfer::i#2<(byte) $20*(const byte) SIZEOF_BYTE) goto ppuDataTransfer::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$20*SIZEOF_BYTE
bcc __b2
bne !+
lda.z i
cmp #<$20*SIZEOF_BYTE
cmp #$20*SIZEOF_BYTE
bcc __b2
!:
jmp __breturn
@ -3825,72 +3823,72 @@ Uplift Scope [$0]
Uplift Scope [vblank]
Uplift Scope [__start]
Uplifting [ppuDataTransfer] best 56865 combination zp[2]:13 [ ppuDataTransfer::i#2 ppuDataTransfer::i#1 ] reg byte a [ ppuDataTransfer::ppuDataPut1_val#0 ] zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$0 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$1 ] zp[2]:9 [ ppuDataTransfer::ppuDataPrepare1_ppuData#0 ] zp[2]:11 [ ppuDataTransfer::cpuData#2 ]
Uplifting [rand] best 56865 combination zp[2]:73 [ rand::$0 ] zp[2]:77 [ rand::$1 ] zp[2]:81 [ rand::$2 ] zp[2]:83 [ rand::return#0 ] zp[2]:55 [ rand::return#2 ] zp[2]:62 [ rand::return#3 ]
Uplifting [] best 56865 combination zp[2]:75 [ rand_state#0 ] zp[2]:79 [ rand_state#1 ] zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] zp[1]:25 [ scroll_y ] zp[1]:26 [ vblank_hit ]
Uplifting [ppuDataFill] best 56853 combination zp[2]:21 [ ppuDataFill::i#2 ppuDataFill::i#1 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$0 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$1 ] zp[2]:19 [ ppuDataFill::size#3 ] zp[2]:17 [ ppuDataFill::ppuDataPrepare1_ppuData#0 ]
Uplifting [RICOH_2C02] best 56853 combination
Uplifting [RICOH_2A03] best 56853 combination
Uplifting [SpriteData] best 56853 combination
Uplifting [RADIX] best 56853 combination
Uplifting [printf_format_number] best 56853 combination
Uplifting [printf_buffer_number] best 56853 combination
Uplifting [printf_format_string] best 56853 combination
Uplifting [$0] best 56853 combination
Uplifting [vblank] best 56853 combination
Uplifting [__start] best 56853 combination
Uplifting [ppuDataTransfer] best 56820 combination zp[2]:13 [ ppuDataTransfer::i#2 ppuDataTransfer::i#1 ] reg byte a [ ppuDataTransfer::ppuDataPut1_val#0 ] zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$0 ] reg byte a [ ppuDataTransfer::ppuDataPrepare1_$1 ] zp[2]:9 [ ppuDataTransfer::ppuDataPrepare1_ppuData#0 ] zp[2]:11 [ ppuDataTransfer::cpuData#2 ]
Uplifting [rand] best 56820 combination zp[2]:73 [ rand::$0 ] zp[2]:77 [ rand::$1 ] zp[2]:81 [ rand::$2 ] zp[2]:83 [ rand::return#0 ] zp[2]:55 [ rand::return#2 ] zp[2]:62 [ rand::return#3 ]
Uplifting [] best 56820 combination zp[2]:75 [ rand_state#0 ] zp[2]:79 [ rand_state#1 ] zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] zp[1]:25 [ scroll_y ] zp[1]:26 [ vblank_hit ]
Uplifting [ppuDataFill] best 56808 combination zp[2]:21 [ ppuDataFill::i#2 ppuDataFill::i#1 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$0 ] reg byte a [ ppuDataFill::ppuDataPrepare1_$1 ] zp[2]:19 [ ppuDataFill::size#3 ] zp[2]:17 [ ppuDataFill::ppuDataPrepare1_ppuData#0 ]
Uplifting [RICOH_2C02] best 56808 combination
Uplifting [RICOH_2A03] best 56808 combination
Uplifting [SpriteData] best 56808 combination
Uplifting [RADIX] best 56808 combination
Uplifting [printf_format_number] best 56808 combination
Uplifting [printf_buffer_number] best 56808 combination
Uplifting [printf_format_string] best 56808 combination
Uplifting [$0] best 56808 combination
Uplifting [vblank] best 56808 combination
Uplifting [__start] best 56808 combination
Attempting to uplift remaining variables inzp[1]:36 [ main::$45 ]
Uplifting [main] best 56453 combination reg byte a [ main::$45 ]
Uplifting [main] best 56408 combination reg byte a [ main::$45 ]
Attempting to uplift remaining variables inzp[1]:33 [ main::$40 ]
Uplifting [main] best 55153 combination reg byte y [ main::$40 ]
Uplifting [main] best 55108 combination reg byte y [ main::$40 ]
Attempting to uplift remaining variables inzp[1]:7 [ main::i#10 main::i#4 ]
Uplifting [main] best 55153 combination zp[1]:7 [ main::i#10 main::i#4 ]
Uplifting [main] best 55108 combination zp[1]:7 [ main::i#10 main::i#4 ]
Attempting to uplift remaining variables inzp[1]:37 [ main::$44 ]
Uplifting [main] best 54453 combination reg byte y [ main::$44 ]
Uplifting [main] best 54408 combination reg byte y [ main::$44 ]
Attempting to uplift remaining variables inzp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ]
Uplifting [main] best 54453 combination zp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ]
Uplifting [main] best 54408 combination zp[1]:8 [ main::sprite_idx#3 main::sprite_idx#2 ]
Attempting to uplift remaining variables inzp[1]:42 [ main::$26 ]
Uplifting [main] best 54453 combination zp[1]:42 [ main::$26 ]
Uplifting [main] best 54408 combination zp[1]:42 [ main::$26 ]
Attempting to uplift remaining variables inzp[1]:44 [ main::$30 ]
Uplifting [main] best 53853 combination reg byte a [ main::$30 ]
Uplifting [main] best 53808 combination reg byte a [ main::$30 ]
Attempting to uplift remaining variables inzp[1]:52 [ main::$48 ]
Uplifting [main] best 52553 combination reg byte x [ main::$48 ]
Uplifting [main] best 52508 combination reg byte x [ main::$48 ]
Attempting to uplift remaining variables inzp[1]:43 [ main::$53 ]
Uplifting [main] best 51853 combination reg byte y [ main::$53 ]
Uplifting [main] best 51808 combination reg byte y [ main::$53 ]
Attempting to uplift remaining variables inzp[1]:49 [ main::$50 ]
Uplifting [main] best 51153 combination reg byte y [ main::$50 ]
Uplifting [main] best 51108 combination reg byte y [ main::$50 ]
Attempting to uplift remaining variables inzp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ]
Uplifting [main] best 51153 combination zp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ]
Uplifting [main] best 51108 combination zp[1]:6 [ main::timer#3 main::timer#15 main::timer#21 ]
Attempting to uplift remaining variables inzp[1]:2 [ main::initNES1_i#2 main::initNES1_i#1 ]
Uplifting [main] best 50823 combination reg byte x [ main::initNES1_i#2 main::initNES1_i#1 ]
Uplifting [main] best 50778 combination reg byte x [ main::initNES1_i#2 main::initNES1_i#1 ]
Attempting to uplift remaining variables inzp[1]:3 [ main::i#14 main::i#2 ]
Uplifting [main] best 50823 combination zp[1]:3 [ main::i#14 main::i#2 ]
Uplifting [main] best 50778 combination zp[1]:3 [ main::i#14 main::i#2 ]
Attempting to uplift remaining variables inzp[1]:4 [ main::timer_2#2 main::timer_2#1 ]
Uplifting [main] best 50823 combination zp[1]:4 [ main::timer_2#2 main::timer_2#1 ]
Uplifting [main] best 50778 combination zp[1]:4 [ main::timer_2#2 main::timer_2#1 ]
Attempting to uplift remaining variables inzp[1]:27 [ main::initNES1_waitForVBlank1_$0 ]
Uplifting [main] best 50763 combination reg byte a [ main::initNES1_waitForVBlank1_$0 ]
Uplifting [main] best 50718 combination reg byte a [ main::initNES1_waitForVBlank1_$0 ]
Attempting to uplift remaining variables inzp[1]:28 [ main::initNES1_waitForVBlank2_$0 ]
Uplifting [main] best 50703 combination reg byte a [ main::initNES1_waitForVBlank2_$0 ]
Uplifting [main] best 50658 combination reg byte a [ main::initNES1_waitForVBlank2_$0 ]
Attempting to uplift remaining variables inzp[1]:30 [ main::$14 ]
Uplifting [main] best 50643 combination reg byte a [ main::$14 ]
Uplifting [main] best 50598 combination reg byte a [ main::$14 ]
Attempting to uplift remaining variables inzp[1]:61 [ main::$35 ]
Uplifting [main] best 50603 combination reg byte a [ main::$35 ]
Uplifting [main] best 50558 combination reg byte a [ main::$35 ]
Attempting to uplift remaining variables inzp[1]:67 [ main::$36 ]
Uplifting [main] best 50543 combination reg byte a [ main::$36 ]
Uplifting [main] best 50498 combination reg byte a [ main::$36 ]
Attempting to uplift remaining variables inzp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ]
Uplifting [main] best 50543 combination zp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ]
Uplifting [main] best 50498 combination zp[1]:5 [ main::active_balls#2 main::active_balls#8 main::active_balls#1 ]
Attempting to uplift remaining variables inzp[1]:32 [ main::$38 ]
Uplifting [main] best 50533 combination reg byte x [ main::$38 ]
Uplifting [main] best 50488 combination reg byte x [ main::$38 ]
Attempting to uplift remaining variables inzp[1]:25 [ scroll_y ]
Uplifting [] best 50533 combination zp[1]:25 [ scroll_y ]
Uplifting [] best 50488 combination zp[1]:25 [ scroll_y ]
Attempting to uplift remaining variables inzp[1]:31 [ main::timer#1 ]
Uplifting [main] best 50473 combination reg byte x [ main::timer#1 ]
Uplifting [main] best 50428 combination reg byte x [ main::timer#1 ]
Attempting to uplift remaining variables inzp[1]:66 [ main::$12 ]
Uplifting [main] best 50433 combination reg byte x [ main::$12 ]
Uplifting [main] best 50388 combination reg byte x [ main::$12 ]
Attempting to uplift remaining variables inzp[1]:29 [ main::h_bar#1 ]
Uplifting [main] best 50433 combination zp[1]:29 [ main::h_bar#1 ]
Uplifting [main] best 50388 combination zp[1]:29 [ main::h_bar#1 ]
Attempting to uplift remaining variables inzp[1]:26 [ vblank_hit ]
Uplifting [] best 50433 combination zp[1]:26 [ vblank_hit ]
Uplifting [] best 50388 combination zp[1]:26 [ vblank_hit ]
Coalescing zero page register [ zp[2]:11 [ ppuDataTransfer::cpuData#2 ] ] with [ zp[2]:15 [ ppuDataTransfer::cpuSrc#2 ppuDataTransfer::cpuSrc#6 ppuDataTransfer::cpuSrc#1 ] ] - score: 1
Coalescing zero page register [ zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 ] ] with [ zp[2]:75 [ rand_state#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:23 [ rand_state#10 rand_state#17 rand_state#11 rand_state#0 ] ] with [ zp[2]:79 [ rand_state#1 ] ] - score: 1
@ -4727,11 +4725,9 @@ ppuDataTransfer: {
__b1:
// [121] if((word) ppuDataTransfer::i#2<(byte) $20*(const byte) SIZEOF_BYTE) goto ppuDataTransfer::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$20*SIZEOF_BYTE
bcc __b2
bne !+
lda.z i
cmp #<$20*SIZEOF_BYTE
cmp #$20*SIZEOF_BYTE
bcc __b2
!:
jmp __breturn
@ -5359,7 +5355,7 @@ zp[2]:32 [ rand::$2 ]
FINAL ASSEMBLER
Score: 45588
Score: 45543
// File Comments
//#pragma emulator("java -jar /Applications/Nintaco_bin_2020-05-01/Nintaco.jar")
@ -6123,11 +6119,9 @@ ppuDataTransfer: {
// for(unsigned int i=0;i<size;i++)
// [121] if((word) ppuDataTransfer::i#2<(byte) $20*(const byte) SIZEOF_BYTE) goto ppuDataTransfer::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$20*SIZEOF_BYTE
bcc __b2
bne !+
lda.z i
cmp #<$20*SIZEOF_BYTE
cmp #$20*SIZEOF_BYTE
bcc __b2
!:
// ppuDataTransfer::@return

View File

@ -0,0 +1,98 @@
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
main: {
// Move the entities
.label line = 3
.label i = 2
.label __11 = 5
// asm
sei
// Wait for raster refresh
__b1:
// while(*VIC_RASTER!=0xff)
lda #$ff
cmp VIC_RASTER
bne __b1
// *VIC_BG_COLOR = 0
lda #0
sta VIC_BG_COLOR
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
lda #0
sta.z i
__b3:
// for(char i=0;i<NUM_ENTITIES;i++)
lda.z i
cmp #$19
bcc __b4
// *VIC_BG_COLOR = 15
lda #$f
sta VIC_BG_COLOR
jmp __b1
__b4:
// line[(char)entities[i]] = ' '
lda.z i
asl
tax
lda entities,x
// Delete old symbol
tay
lda #' '
sta (line),y
// entities[i] += 1
// Move by velocity
inc entities,x
bne !+
inc entities+1,x
!:
// if(entities[i]>39)
lda entities+1,x
bne !+
lda entities,x
cmp #$27+1
bcc __b6
!:
// entities[i] =0
lda.z i
asl
ldx #0
tay
txa
sta entities,y
__b6:
// line[entities[i]] = '*'
lda.z i
asl
tay
clc
lda.z line
adc entities,y
sta.z __11
lda.z line+1
adc entities+1,y
sta.z __11+1
// Draw symbol
lda #'*'
ldy #0
sta (__11),y
// line +=40
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// for(char i=0;i<NUM_ENTITIES;i++)
inc.z i
jmp __b3
}
entities: .fill 2*$19, 0

View File

@ -0,0 +1,37 @@
(void()) main()
main: scope:[main] from
asm { sei }
to:main::@1
main::@1: scope:[main] from main main::@1 main::@5
[1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
[2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0
to:main::@3
main::@3: scope:[main] from main::@2 main::@6
[3] (byte*) main::line#2 ← phi( main::@2/(const nomodify byte*) SCREEN main::@6/(byte*) main::line#1 )
[3] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@6/(byte) main::i#1 )
[4] if((byte) main::i#2<(byte) $19) goto main::@4
to:main::@5
main::@5: scope:[main] from main::@3
[5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f
to:main::@1
main::@4: scope:[main] from main::@3
[6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1
[7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5)
[8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' '
[9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1
[10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6
to:main::@7
main::@7: scope:[main] from main::@4
[11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1
[12] *((const word*) entities + (byte~) main::$8) ← (byte) 0
to:main::@6
main::@6: scope:[main] from main::@4 main::@7
[13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1
[14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7)
[15] *((byte*~) main::$11) ← (byte) '*'
[16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28
[17] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@3

View File

@ -0,0 +1,812 @@
CONTROL FLOW GRAPH SSA
(void()) main()
main: scope:[main] from __start
asm { sei }
to:main::@1
main::@1: scope:[main] from main main::@6
(bool~) main::$10 ← (number) 0 != (number) 1
if((bool~) main::$10) goto main::@2
to:main::@return
main::@2: scope:[main] from main::@1 main::@2
(bool~) main::$0 ← *((const nomodify byte*) VIC_RASTER) != (number) $ff
if((bool~) main::$0) goto main::@2
to:main::@3
main::@3: scope:[main] from main::@2
*((const nomodify byte*) VIC_BG_COLOR) ← (number) 0
(byte*) main::line#0 ← (const nomodify byte*) SCREEN
(byte) main::i#0 ← (byte) 0
to:main::@4
main::@4: scope:[main] from main::@3 main::@7
(byte*) main::line#4 ← phi( main::@3/(byte*) main::line#0 main::@7/(byte*) main::line#1 )
(byte) main::i#2 ← phi( main::@3/(byte) main::i#0 main::@7/(byte) main::i#1 )
(bool~) main::$1 ← (byte) main::i#2 < (number) $19
if((bool~) main::$1) goto main::@5
to:main::@6
main::@5: scope:[main] from main::@4
(byte*) main::line#2 ← phi( main::@4/(byte*) main::line#4 )
(byte) main::i#3 ← phi( main::@4/(byte) main::i#2 )
(byte~) main::$4 ← (byte) main::i#3 * (const byte) SIZEOF_WORD
(byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$4)
*((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' '
(byte~) main::$5 ← (byte) main::i#3 * (const byte) SIZEOF_WORD
*((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (number) 1
(byte~) main::$6 ← (byte) main::i#3 * (const byte) SIZEOF_WORD
(bool~) main::$2 ← *((const word*) entities + (byte~) main::$6) > (number) $27
(bool~) main::$3 ← ! (bool~) main::$2
if((bool~) main::$3) goto main::@7
to:main::@8
main::@6: scope:[main] from main::@4
*((const nomodify byte*) VIC_BG_COLOR) ← (number) $f
to:main::@1
main::@7: scope:[main] from main::@5 main::@8
(byte*) main::line#3 ← phi( main::@5/(byte*) main::line#2 main::@8/(byte*) main::line#5 )
(byte) main::i#4 ← phi( main::@5/(byte) main::i#3 main::@8/(byte) main::i#5 )
(byte~) main::$7 ← (byte) main::i#4 * (const byte) SIZEOF_WORD
*((byte*) main::line#3 + *((const word*) entities + (byte~) main::$7)) ← (byte) '*'
(byte*) main::line#1 ← (byte*) main::line#3 + (number) $28
(byte) main::i#1 ← ++ (byte) main::i#4
to:main::@4
main::@8: scope:[main] from main::@5
(byte*) main::line#5 ← phi( main::@5/(byte*) main::line#2 )
(byte) main::i#5 ← phi( main::@5/(byte) main::i#3 )
(byte~) main::$8 ← (byte) main::i#5 * (const byte) SIZEOF_WORD
*((const word*) entities + (byte~) main::$8) ← (number) 0
to:main::@7
main::@return: scope:[main] from main::@1
return
to:@return
(void()) __start()
__start: scope:[__start] from
call main
to:__start::@1
__start::@1: scope:[__start] from __start
to:__start::@return
__start::@return: scope:[__start] from __start::@1
return
to:@return
SYMBOL TABLE SSA
(const nomodify byte*) SCREEN = (byte*)(number) $400
(const byte) SIZEOF_WORD = (byte) 2
(const nomodify byte*) VIC_BG_COLOR = (byte*)(number) $d020
(const nomodify byte*) VIC_RASTER = (byte*)(number) $d012
(void()) __start()
(label) __start::@1
(label) __start::@return
(const word*) entities[(number) $19] = { fill( $19, 0) }
(void()) main()
(bool~) main::$0
(bool~) main::$1
(bool~) main::$10
(bool~) main::$2
(bool~) main::$3
(byte~) main::$4
(byte~) main::$5
(byte~) main::$6
(byte~) main::$7
(byte~) main::$8
(byte~) main::$9
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(label) main::@8
(label) main::@return
(byte) main::i
(byte) main::i#0
(byte) main::i#1
(byte) main::i#2
(byte) main::i#3
(byte) main::i#4
(byte) main::i#5
(byte*) main::line
(byte*) main::line#0
(byte*) main::line#1
(byte*) main::line#2
(byte*) main::line#3
(byte*) main::line#4
(byte*) main::line#5
Adding number conversion cast (unumber) $ff in (bool~) main::$0 ← *((const nomodify byte*) VIC_RASTER) != (number) $ff
Adding number conversion cast (unumber) 0 in *((const nomodify byte*) VIC_BG_COLOR) ← (number) 0
Adding number conversion cast (unumber) $19 in (bool~) main::$1 ← (byte) main::i#2 < (number) $19
Adding number conversion cast (unumber) 1 in *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (number) 1
Adding number conversion cast (unumber) $27 in (bool~) main::$2 ← *((const word*) entities + (byte~) main::$6) > (number) $27
Adding number conversion cast (unumber) $f in *((const nomodify byte*) VIC_BG_COLOR) ← (number) $f
Adding number conversion cast (unumber) $28 in (byte*) main::line#1 ← (byte*) main::line#3 + (number) $28
Adding number conversion cast (unumber) 0 in *((const word*) entities + (byte~) main::$8) ← (number) 0
Successful SSA optimization PassNAddNumberTypeConversions
Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) 0
Inlining cast *((const nomodify byte*) VIC_BG_COLOR) ← (unumber)(number) $f
Inlining cast *((const word*) entities + (byte~) main::$8) ← (unumber)(number) 0
Successful SSA optimization Pass2InlineCast
Simplifying constant pointer cast (byte*) 53266
Simplifying constant pointer cast (byte*) 53280
Simplifying constant pointer cast (byte*) 1024
Simplifying constant integer cast $ff
Simplifying constant integer cast 0
Simplifying constant integer cast $19
Simplifying constant integer cast 1
Simplifying constant integer cast $27
Simplifying constant integer cast $f
Simplifying constant integer cast $28
Simplifying constant integer cast 0
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) $ff
Finalized unsigned number type (byte) 0
Finalized unsigned number type (byte) $19
Finalized unsigned number type (byte) 1
Finalized unsigned number type (byte) $27
Finalized unsigned number type (byte) $f
Finalized unsigned number type (byte) $28
Finalized unsigned number type (byte) 0
Successful SSA optimization PassNFinalizeNumberTypeConversions
Inversing boolean not [19] (bool~) main::$3 ← *((const word*) entities + (byte~) main::$6) <= (byte) $27 from [18] (bool~) main::$2 ← *((const word*) entities + (byte~) main::$6) > (byte) $27
Successful SSA optimization Pass2UnaryNotSimplification
Alias main::i#2 = main::i#3 main::i#5
Alias main::line#2 = main::line#4 main::line#5
Successful SSA optimization Pass2AliasElimination
Alias main::i#2 = main::i#4
Alias main::line#2 = main::line#3
Successful SSA optimization Pass2AliasElimination
Identified duplicate assignment right side [15] (byte~) main::$5 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Identified duplicate assignment right side [17] (byte~) main::$6 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2DuplicateRValueIdentification
Simple Condition (bool~) main::$10 [2] if((number) 0!=(number) 1) goto main::@2
Simple Condition (bool~) main::$0 [4] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@2
Simple Condition (bool~) main::$1 [10] if((byte) main::i#2<(byte) $19) goto main::@5
Simple Condition (bool~) main::$3 [18] if(*((const word*) entities + (byte~) main::$6)<=(byte) $27) goto main::@7
Successful SSA optimization Pass2ConditionalJumpSimplification
Constant (const byte*) main::line#0 = SCREEN
Constant (const byte) main::i#0 = 0
Successful SSA optimization Pass2ConstantIdentification
if() condition always true - replacing block destination [2] if((number) 0!=(number) 1) goto main::@2
Successful SSA optimization Pass2ConstantIfs
Rewriting conditional comparison [18] if(*((const word*) entities + (byte~) main::$6)<=(byte) $27) goto main::@7
De-inlining pointer[w] to *(pointer+w) [21] *((byte*) main::line#2 + *((const word*) entities + (byte~) main::$7)) ← (byte) '*'
Successful SSA optimization Pass2DeInlineWordDerefIdx
Removing unused block main::@return
Successful SSA optimization Pass2EliminateUnusedBlocks
Removing unused procedure __start
Removing unused procedure block __start
Removing unused procedure block __start::@1
Removing unused procedure block __start::@return
Successful SSA optimization PassNEliminateEmptyStart
Adding number conversion cast (unumber) $27+1 in [11] if(*((const word*) entities + (byte~) main::$6)<(byte) $27+(number) 1) goto main::@7
Adding number conversion cast (unumber) 1 in [11] if(*((const word*) entities + (byte~) main::$6)<(unumber)(byte) $27+(number) 1) goto main::@7
Successful SSA optimization PassNAddNumberTypeConversions
Simplifying constant integer cast (byte) $27+(unumber)(number) 1
Simplifying constant integer cast 1
Successful SSA optimization PassNCastSimplification
Finalized unsigned number type (byte) 1
Successful SSA optimization PassNFinalizeNumberTypeConversions
Alias main::$5 = main::$4 main::$6
Successful SSA optimization Pass2AliasElimination
Rewriting multiplication to use shift [5] (byte~) main::$5 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Rewriting multiplication to use shift [11] (byte~) main::$7 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Rewriting multiplication to use shift [16] (byte~) main::$8 ← (byte) main::i#2 * (const byte) SIZEOF_WORD
Successful SSA optimization Pass2MultiplyToShiftRewriting
Inlining constant with var siblings (const byte*) main::line#0
Inlining constant with var siblings (const byte) main::i#0
Constant inlined main::line#0 = (const nomodify byte*) SCREEN
Constant inlined main::i#0 = (byte) 0
Successful SSA optimization Pass2ConstantInlining
Eliminating unused constant (const byte) SIZEOF_WORD
Successful SSA optimization PassNEliminateUnusedVars
Adding NOP phi() at start of main::@1
CALL GRAPH
Created 2 initial phi equivalence classes
Coalesced [19] main::i#6 ← main::i#1
Coalesced [20] main::line#6 ← main::line#1
Coalesced down to 2 phi equivalence classes
Culled Empty Block (label) main::@1
Renumbering block main::@2 to main::@1
Renumbering block main::@3 to main::@2
Renumbering block main::@4 to main::@3
Renumbering block main::@5 to main::@4
Renumbering block main::@6 to main::@5
Renumbering block main::@7 to main::@6
Renumbering block main::@8 to main::@7
FINAL CONTROL FLOW GRAPH
(void()) main()
main: scope:[main] from
asm { sei }
to:main::@1
main::@1: scope:[main] from main main::@1 main::@5
[1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1
to:main::@2
main::@2: scope:[main] from main::@1
[2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0
to:main::@3
main::@3: scope:[main] from main::@2 main::@6
[3] (byte*) main::line#2 ← phi( main::@2/(const nomodify byte*) SCREEN main::@6/(byte*) main::line#1 )
[3] (byte) main::i#2 ← phi( main::@2/(byte) 0 main::@6/(byte) main::i#1 )
[4] if((byte) main::i#2<(byte) $19) goto main::@4
to:main::@5
main::@5: scope:[main] from main::@3
[5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f
to:main::@1
main::@4: scope:[main] from main::@3
[6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1
[7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5)
[8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' '
[9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1
[10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6
to:main::@7
main::@7: scope:[main] from main::@4
[11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1
[12] *((const word*) entities + (byte~) main::$8) ← (byte) 0
to:main::@6
main::@6: scope:[main] from main::@4 main::@7
[13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1
[14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7)
[15] *((byte*~) main::$11) ← (byte) '*'
[16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28
[17] (byte) main::i#1 ← ++ (byte) main::i#2
to:main::@3
VARIABLE REGISTER WEIGHTS
(void()) main()
(byte*~) main::$11 202.0
(byte~) main::$5 101.0
(byte~) main::$7 202.0
(byte~) main::$8 202.0
(byte~) main::$9 202.0
(byte) main::i
(byte) main::i#1 202.0
(byte) main::i#2 46.61538461538461
(byte*) main::line
(byte*) main::line#1 101.0
(byte*) main::line#2 33.666666666666664
Initial phi equivalence classes
[ main::i#2 main::i#1 ]
[ main::line#2 main::line#1 ]
Added variable main::$5 to live range equivalence class [ main::$5 ]
Added variable main::$9 to live range equivalence class [ main::$9 ]
Added variable main::$8 to live range equivalence class [ main::$8 ]
Added variable main::$7 to live range equivalence class [ main::$7 ]
Added variable main::$11 to live range equivalence class [ main::$11 ]
Complete equivalence classes
[ main::i#2 main::i#1 ]
[ main::line#2 main::line#1 ]
[ main::$5 ]
[ main::$9 ]
[ main::$8 ]
[ main::$7 ]
[ main::$11 ]
Allocated zp[1]:2 [ main::i#2 main::i#1 ]
Allocated zp[2]:3 [ main::line#2 main::line#1 ]
Allocated zp[1]:5 [ main::$5 ]
Allocated zp[1]:6 [ main::$9 ]
Allocated zp[1]:7 [ main::$8 ]
Allocated zp[1]:8 [ main::$7 ]
Allocated zp[2]:9 [ main::$11 ]
INITIAL ASM
Target platform is c64basic / MOS6502X
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
.label __5 = 5
.label __7 = 8
.label __8 = 7
.label __9 = 6
// Move the entities
.label line = 3
.label i = 2
.label __11 = 9
// asm { sei }
sei
jmp __b1
// Wait for raster refresh
// main::@1
__b1:
// [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b1
jmp __b2
// main::@2
__b2:
// [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
__b3_from___b2:
// [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1
lda #0
sta.z i
jmp __b3
// main::@3
__b3:
// [4] if((byte) main::i#2<(byte) $19) goto main::@4 -- vbuz1_lt_vbuc1_then_la1
lda.z i
cmp #$19
bcc __b4
jmp __b5
// main::@5
__b5:
// [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b1
// main::@4
__b4:
// [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i
asl
sta.z __5
// [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) -- vbuz1=_byte_pwuc1_derefidx_vbuz2
ldy.z __5
lda entities,y
sta.z __9
// [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' -- pbuz1_derefidx_vbuz2=vbuc1
// Delete old symbol
lda #' '
ldy.z __9
sta (line),y
// [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 -- pwuc1_derefidx_vbuz1=pwuc1_derefidx_vbuz1_plus_1
// Move by velocity
ldx.z __5
inc entities,x
bne !+
inc entities+1,x
!:
// [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuz1_lt_vbuc2_then_la1
ldy.z __5
lda entities+1,y
bne !+
lda entities,y
cmp #$27+1
bcc __b6
!:
jmp __b7
// main::@7
__b7:
// [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i
asl
sta.z __8
// [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuz1=vbuc2
lda.z __8
ldx #0
tay
txa
sta entities,y
jmp __b6
// main::@6
__b6:
// [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuz1=vbuz2_rol_1
lda.z i
asl
sta.z __7
// [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuz3
ldy.z __7
clc
lda.z line
adc entities,y
sta.z __11
lda.z line+1
adc entities+1,y
sta.z __11+1
// [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1
// Draw symbol
lda #'*'
ldy #0
sta (__11),y
// [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// [17] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [3] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
__b3_from___b6:
// [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy
// [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy
jmp __b3
}
// File Data
entities: .fill 2*$19, 0
REGISTER UPLIFT POTENTIAL REGISTERS
Statement [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a
Statement [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) [ main::i#2 main::line#2 main::$5 main::$9 ] ( [ main::i#2 main::line#2 main::$5 main::$9 ] { } ) always clobbers reg byte a
Removing always clobbered register reg byte a as potential for zp[1]:5 [ main::$5 ]
Statement [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a
Statement [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$8 ] ( [ main::i#2 main::line#2 main::$8 ] { } ) always clobbers reg byte a
Statement [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$7 ] ( [ main::i#2 main::line#2 main::$7 ] { } ) always clobbers reg byte a
Statement [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) [ main::i#2 main::line#2 main::$11 ] ( [ main::i#2 main::line#2 main::$11 ] { } ) always clobbers reg byte a
Statement [15] *((byte*~) main::$11) ← (byte) '*' [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y
Removing always clobbered register reg byte y as potential for zp[1]:2 [ main::i#2 main::i#1 ]
Statement [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i#2 main::line#1 ] ( [ main::i#2 main::line#1 ] { } ) always clobbers reg byte a
Statement [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 [ ] ( [ ] { } ) always clobbers reg byte a
Statement [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f [ ] ( [ ] { } ) always clobbers reg byte a
Statement [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a
Statement [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) [ main::i#2 main::line#2 main::$5 main::$9 ] ( [ main::i#2 main::line#2 main::$5 main::$9 ] { } ) always clobbers reg byte a
Statement [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' [ main::i#2 main::line#2 main::$5 ] ( [ main::i#2 main::line#2 main::$5 ] { } ) always clobbers reg byte a
Statement [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$8 ] ( [ main::i#2 main::line#2 main::$8 ] { } ) always clobbers reg byte a
Statement [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a
Statement [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 [ main::i#2 main::line#2 main::$7 ] ( [ main::i#2 main::line#2 main::$7 ] { } ) always clobbers reg byte a
Statement [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) [ main::i#2 main::line#2 main::$11 ] ( [ main::i#2 main::line#2 main::$11 ] { } ) always clobbers reg byte a
Statement [15] *((byte*~) main::$11) ← (byte) '*' [ main::i#2 main::line#2 ] ( [ main::i#2 main::line#2 ] { } ) always clobbers reg byte a reg byte y
Statement [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 [ main::i#2 main::line#1 ] ( [ main::i#2 main::line#1 ] { } ) always clobbers reg byte a
Potential registers zp[1]:2 [ main::i#2 main::i#1 ] : zp[1]:2 , reg byte x ,
Potential registers zp[2]:3 [ main::line#2 main::line#1 ] : zp[2]:3 ,
Potential registers zp[1]:5 [ main::$5 ] : zp[1]:5 , reg byte x , reg byte y ,
Potential registers zp[1]:6 [ main::$9 ] : zp[1]:6 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:7 [ main::$8 ] : zp[1]:7 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[1]:8 [ main::$7 ] : zp[1]:8 , reg byte a , reg byte x , reg byte y ,
Potential registers zp[2]:9 [ main::$11 ] : zp[2]:9 ,
REGISTER UPLIFT SCOPES
Uplift Scope [main] 248.62: zp[1]:2 [ main::i#2 main::i#1 ] 202: zp[1]:6 [ main::$9 ] 202: zp[1]:7 [ main::$8 ] 202: zp[1]:8 [ main::$7 ] 202: zp[2]:9 [ main::$11 ] 134.67: zp[2]:3 [ main::line#2 main::line#1 ] 101: zp[1]:5 [ main::$5 ]
Uplift Scope []
Uplifting [main] best 19305 combination zp[1]:2 [ main::i#2 main::i#1 ] reg byte a [ main::$9 ] reg byte a [ main::$8 ] reg byte a [ main::$7 ] zp[2]:9 [ main::$11 ] zp[2]:3 [ main::line#2 main::line#1 ] zp[1]:5 [ main::$5 ]
Limited combination testing to 100 combinations of 384 possible.
Uplifting [] best 19305 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::i#2 main::i#1 ]
Uplifting [main] best 19305 combination zp[1]:2 [ main::i#2 main::i#1 ]
Attempting to uplift remaining variables inzp[1]:5 [ main::$5 ]
Uplifting [main] best 18305 combination reg byte x [ main::$5 ]
Allocated (was zp[2]:9) zp[2]:5 [ main::$11 ]
ASSEMBLER BEFORE OPTIMIZATION
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
// Move the entities
.label line = 3
.label i = 2
.label __11 = 5
// asm { sei }
sei
jmp __b1
// Wait for raster refresh
// main::@1
__b1:
// [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b1
jmp __b2
// main::@2
__b2:
// [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
__b3_from___b2:
// [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1
lda #0
sta.z i
jmp __b3
// main::@3
__b3:
// [4] if((byte) main::i#2<(byte) $19) goto main::@4 -- vbuz1_lt_vbuc1_then_la1
lda.z i
cmp #$19
bcc __b4
jmp __b5
// main::@5
__b5:
// [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b1
// main::@4
__b4:
// [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuz1_rol_1
lda.z i
asl
tax
// [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) -- vbuaa=_byte_pwuc1_derefidx_vbuxx
lda entities,x
// [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' -- pbuz1_derefidx_vbuaa=vbuc1
// Delete old symbol
tay
lda #' '
sta (line),y
// [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 -- pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1
// Move by velocity
inc entities,x
bne !+
inc entities+1,x
!:
// [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1
lda entities+1,x
bne !+
lda entities,x
cmp #$27+1
bcc __b6
!:
jmp __b7
// main::@7
__b7:
// [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuaa=vbuc2
ldx #0
tay
txa
sta entities,y
jmp __b6
// main::@6
__b6:
// [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa
tay
clc
lda.z line
adc entities,y
sta.z __11
lda.z line+1
adc entities+1,y
sta.z __11+1
// [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1
// Draw symbol
lda #'*'
ldy #0
sta (__11),y
// [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// [17] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [3] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
__b3_from___b6:
// [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy
// [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy
jmp __b3
}
// File Data
entities: .fill 2*$19, 0
ASSEMBLER OPTIMIZATIONS
Removing instruction jmp __b1
Removing instruction jmp __b2
Removing instruction jmp __b3
Removing instruction jmp __b5
Removing instruction jmp __b7
Removing instruction jmp __b6
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction __b2:
Removing instruction __b3_from___b2:
Removing instruction __b5:
Removing instruction __b7:
Removing instruction __b3_from___b6:
Succesful ASM optimization Pass5UnusedLabelElimination
FINAL SYMBOL TABLE
(const nomodify byte*) SCREEN = (byte*) 1024
(const nomodify byte*) VIC_BG_COLOR = (byte*) 53280
(const nomodify byte*) VIC_RASTER = (byte*) 53266
(const word*) entities[(number) $19] = { fill( $19, 0) }
(void()) main()
(byte*~) main::$11 zp[2]:5 202.0
(byte~) main::$5 reg byte x 101.0
(byte~) main::$7 reg byte a 202.0
(byte~) main::$8 reg byte a 202.0
(byte~) main::$9 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(byte) main::i
(byte) main::i#1 i zp[1]:2 202.0
(byte) main::i#2 i zp[1]:2 46.61538461538461
(byte*) main::line
(byte*) main::line#1 line zp[2]:3 101.0
(byte*) main::line#2 line zp[2]:3 33.666666666666664
zp[1]:2 [ main::i#2 main::i#1 ]
zp[2]:3 [ main::line#2 main::line#1 ]
reg byte x [ main::$5 ]
reg byte a [ main::$9 ]
reg byte a [ main::$8 ]
reg byte a [ main::$7 ]
zp[2]:5 [ main::$11 ]
FINAL ASSEMBLER
Score: 16802
// File Comments
// Test that the multiplication of a idx*sizeof(element) is reused inside loops
// Upstart
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
// Global Constants & labels
.label VIC_RASTER = $d012
.label VIC_BG_COLOR = $d020
.label SCREEN = $400
// main
main: {
// Move the entities
.label line = 3
.label i = 2
.label __11 = 5
// asm
// asm { sei }
sei
// Wait for raster refresh
// main::@1
__b1:
// while(*VIC_RASTER!=0xff)
// [1] if(*((const nomodify byte*) VIC_RASTER)!=(byte) $ff) goto main::@1 -- _deref_pbuc1_neq_vbuc2_then_la1
lda #$ff
cmp VIC_RASTER
bne __b1
// main::@2
// *VIC_BG_COLOR = 0
// [2] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) 0 -- _deref_pbuc1=vbuc2
lda #0
sta VIC_BG_COLOR
// [3] phi from main::@2 to main::@3 [phi:main::@2->main::@3]
// [3] phi (byte*) main::line#2 = (const nomodify byte*) SCREEN [phi:main::@2->main::@3#0] -- pbuz1=pbuc1
lda #<SCREEN
sta.z line
lda #>SCREEN
sta.z line+1
// [3] phi (byte) main::i#2 = (byte) 0 [phi:main::@2->main::@3#1] -- vbuz1=vbuc1
lda #0
sta.z i
// main::@3
__b3:
// for(char i=0;i<NUM_ENTITIES;i++)
// [4] if((byte) main::i#2<(byte) $19) goto main::@4 -- vbuz1_lt_vbuc1_then_la1
lda.z i
cmp #$19
bcc __b4
// main::@5
// *VIC_BG_COLOR = 15
// [5] *((const nomodify byte*) VIC_BG_COLOR) ← (byte) $f -- _deref_pbuc1=vbuc2
lda #$f
sta VIC_BG_COLOR
jmp __b1
// main::@4
__b4:
// line[(char)entities[i]] = ' '
// [6] (byte~) main::$5 ← (byte) main::i#2 << (byte) 1 -- vbuxx=vbuz1_rol_1
lda.z i
asl
tax
// [7] (byte~) main::$9 ← (byte)*((const word*) entities + (byte~) main::$5) -- vbuaa=_byte_pwuc1_derefidx_vbuxx
lda entities,x
// [8] *((byte*) main::line#2 + (byte~) main::$9) ← (byte) ' ' -- pbuz1_derefidx_vbuaa=vbuc1
// Delete old symbol
tay
lda #' '
sta (line),y
// entities[i] += 1
// [9] *((const word*) entities + (byte~) main::$5) ← *((const word*) entities + (byte~) main::$5) + (byte) 1 -- pwuc1_derefidx_vbuxx=pwuc1_derefidx_vbuxx_plus_1
// Move by velocity
inc entities,x
bne !+
inc entities+1,x
!:
// if(entities[i]>39)
// [10] if(*((const word*) entities + (byte~) main::$5)<(byte) $27+(byte) 1) goto main::@6 -- pwuc1_derefidx_vbuxx_lt_vbuc2_then_la1
lda entities+1,x
bne !+
lda entities,x
cmp #$27+1
bcc __b6
!:
// main::@7
// entities[i] =0
// [11] (byte~) main::$8 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// [12] *((const word*) entities + (byte~) main::$8) ← (byte) 0 -- pwuc1_derefidx_vbuaa=vbuc2
ldx #0
tay
txa
sta entities,y
// main::@6
__b6:
// line[entities[i]] = '*'
// [13] (byte~) main::$7 ← (byte) main::i#2 << (byte) 1 -- vbuaa=vbuz1_rol_1
lda.z i
asl
// [14] (byte*~) main::$11 ← (byte*) main::line#2 + *((const word*) entities + (byte~) main::$7) -- pbuz1=pbuz2_plus_pwuc1_derefidx_vbuaa
tay
clc
lda.z line
adc entities,y
sta.z __11
lda.z line+1
adc entities+1,y
sta.z __11+1
// [15] *((byte*~) main::$11) ← (byte) '*' -- _deref_pbuz1=vbuc1
// Draw symbol
lda #'*'
ldy #0
sta (__11),y
// line +=40
// [16] (byte*) main::line#1 ← (byte*) main::line#2 + (byte) $28 -- pbuz1=pbuz1_plus_vbuc1
// Next line
lda #$28
clc
adc.z line
sta.z line
bcc !+
inc.z line+1
!:
// for(char i=0;i<NUM_ENTITIES;i++)
// [17] (byte) main::i#1 ← ++ (byte) main::i#2 -- vbuz1=_inc_vbuz1
inc.z i
// [3] phi from main::@6 to main::@3 [phi:main::@6->main::@3]
// [3] phi (byte*) main::line#2 = (byte*) main::line#1 [phi:main::@6->main::@3#0] -- register_copy
// [3] phi (byte) main::i#2 = (byte) main::i#1 [phi:main::@6->main::@3#1] -- register_copy
jmp __b3
}
// File Data
entities: .fill 2*$19, 0

View File

@ -0,0 +1,31 @@
(const nomodify byte*) SCREEN = (byte*) 1024
(const nomodify byte*) VIC_BG_COLOR = (byte*) 53280
(const nomodify byte*) VIC_RASTER = (byte*) 53266
(const word*) entities[(number) $19] = { fill( $19, 0) }
(void()) main()
(byte*~) main::$11 zp[2]:5 202.0
(byte~) main::$5 reg byte x 101.0
(byte~) main::$7 reg byte a 202.0
(byte~) main::$8 reg byte a 202.0
(byte~) main::$9 reg byte a 202.0
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@4
(label) main::@5
(label) main::@6
(label) main::@7
(byte) main::i
(byte) main::i#1 i zp[1]:2 202.0
(byte) main::i#2 i zp[1]:2 46.61538461538461
(byte*) main::line
(byte*) main::line#1 line zp[2]:3 101.0
(byte*) main::line#2 line zp[2]:3 33.666666666666664
zp[1]:2 [ main::i#2 main::i#1 ]
zp[2]:3 [ main::line#2 main::line#1 ]
reg byte x [ main::$5 ]
reg byte a [ main::$9 ]
reg byte a [ main::$8 ]
reg byte a [ main::$7 ]
zp[2]:5 [ main::$11 ]

View File

@ -284,11 +284,9 @@ lin16u_gen: {
__b1:
// for(word i=0; i<length; i++)
lda.z i+1
cmp #>$14
bcc __b2
bne !+
lda.z i
cmp #<$14
cmp #$14
bcc __b2
!:
// }
@ -463,11 +461,9 @@ divr16u: {
rol.z quotient+1
// if(rem>=divisor)
lda.z rem+1
cmp #>$14-1
bcc __b3
bne !+
lda.z rem
cmp #<$14-1
cmp #$14-1
bcc __b3
!:
// quotient++;

View File

@ -2913,11 +2913,9 @@ lin16u_gen: {
__b1:
// [73] if((word) lin16u_gen::i#2<(byte) $14) goto lin16u_gen::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$14
bcc __b2
bne !+
lda.z i
cmp #<$14
cmp #$14
bcc __b2
!:
jmp __breturn
@ -3218,11 +3216,9 @@ divr16u: {
rol.z quotient+1
// [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1
lda.z rem+1
cmp #>$14-1
bcc __b3_from___b2
bne !+
lda.z rem
cmp #<$14-1
cmp #$14-1
bcc __b3_from___b2
!:
jmp __b5
@ -3461,21 +3457,21 @@ Uplift Scope [RADIX]
Uplift Scope [print_ln]
Uplift Scope [print_cls]
Uplifting [print_char] best 14122 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
Uplifting [] best 14122 combination zp[2]:32 [ print_char_cursor#51 print_char_cursor#84 print_char_cursor#104 print_char_cursor#1 print_char_cursor#89 print_char_cursor#10 print_char_cursor#100 ] zp[2]:19 [ print_line_cursor#12 print_line_cursor#23 print_line_cursor#0 ] zp[2]:57 [ rem16u#0 ]
Uplifting [print_str] best 14122 combination zp[2]:15 [ print_str::str#10 print_str::str#13 print_str::str#0 ]
Uplifting [divr16u] best 13912 combination zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:24 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#0 ] zp[2]:39 [ divr16u::return#2 ] zp[2]:43 [ divr16u::return#3 ]
Uplifting [print_uchar] best 13864 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#3 print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [memset] best 13864 combination zp[2]:29 [ memset::dst#2 memset::dst#1 ]
Uplifting [lin16u_gen] best 13864 combination zp[2]:7 [ lin16u_gen::i#2 lin16u_gen::i#1 ] zp[2]:51 [ lin16u_gen::$6 ] zp[4]:9 [ lin16u_gen::val#2 lin16u_gen::val#1 lin16u_gen::val#0 ] zp[2]:13 [ lin16u_gen::lintab#4 lin16u_gen::lintab#3 lin16u_gen::lintab#6 ] zp[2]:37 [ lin16u_gen::ampl#0 ] zp[2]:45 [ lin16u_gen::stepf#0 ] zp[4]:47 [ lin16u_gen::step#0 ] zp[2]:3 [ lin16u_gen::max#3 ] zp[2]:41 [ lin16u_gen::stepi#0 ] zp[2]:5 [ lin16u_gen::min#3 ]
Uplifting [print_uint] best 13864 combination zp[2]:17 [ print_uint::w#10 print_uint::w#3 print_uint::w#4 print_uint::w#5 ]
Uplifting [main] best 13744 combination zp[1]:2 [ main::i#10 main::i#1 ] reg byte a [ main::$27 ] reg byte a [ main::$28 ] reg byte a [ main::$29 ]
Uplifting [print_char] best 14032 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
Uplifting [] best 14032 combination zp[2]:32 [ print_char_cursor#51 print_char_cursor#84 print_char_cursor#104 print_char_cursor#1 print_char_cursor#89 print_char_cursor#10 print_char_cursor#100 ] zp[2]:19 [ print_line_cursor#12 print_line_cursor#23 print_line_cursor#0 ] zp[2]:57 [ rem16u#0 ]
Uplifting [print_str] best 14032 combination zp[2]:15 [ print_str::str#10 print_str::str#13 print_str::str#0 ]
Uplifting [divr16u] best 13822 combination zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:24 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#0 ] zp[2]:39 [ divr16u::return#2 ] zp[2]:43 [ divr16u::return#3 ]
Uplifting [print_uchar] best 13774 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#3 print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [memset] best 13774 combination zp[2]:29 [ memset::dst#2 memset::dst#1 ]
Uplifting [lin16u_gen] best 13774 combination zp[2]:7 [ lin16u_gen::i#2 lin16u_gen::i#1 ] zp[2]:51 [ lin16u_gen::$6 ] zp[4]:9 [ lin16u_gen::val#2 lin16u_gen::val#1 lin16u_gen::val#0 ] zp[2]:13 [ lin16u_gen::lintab#4 lin16u_gen::lintab#3 lin16u_gen::lintab#6 ] zp[2]:37 [ lin16u_gen::ampl#0 ] zp[2]:45 [ lin16u_gen::stepf#0 ] zp[4]:47 [ lin16u_gen::step#0 ] zp[2]:3 [ lin16u_gen::max#3 ] zp[2]:41 [ lin16u_gen::stepi#0 ] zp[2]:5 [ lin16u_gen::min#3 ]
Uplifting [print_uint] best 13774 combination zp[2]:17 [ print_uint::w#10 print_uint::w#3 print_uint::w#4 print_uint::w#5 ]
Uplifting [main] best 13654 combination zp[1]:2 [ main::i#10 main::i#1 ] reg byte a [ main::$27 ] reg byte a [ main::$28 ] reg byte a [ main::$29 ]
Limited combination testing to 100 combinations of 128 possible.
Uplifting [RADIX] best 13744 combination
Uplifting [print_ln] best 13744 combination
Uplifting [print_cls] best 13744 combination
Uplifting [RADIX] best 13654 combination
Uplifting [print_ln] best 13654 combination
Uplifting [print_cls] best 13654 combination
Attempting to uplift remaining variables inzp[1]:2 [ main::i#10 main::i#1 ]
Uplifting [main] best 13744 combination zp[1]:2 [ main::i#10 main::i#1 ]
Uplifting [main] best 13654 combination zp[1]:2 [ main::i#10 main::i#1 ]
Coalescing zero page register [ zp[2]:22 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] ] with [ zp[2]:57 [ rem16u#0 ] ] - score: 2
Coalescing zero page register [ zp[2]:3 [ lin16u_gen::max#3 ] ] with [ zp[2]:37 [ lin16u_gen::ampl#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:26 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] ] with [ zp[2]:39 [ divr16u::return#2 ] ] - score: 1
@ -4047,11 +4043,9 @@ lin16u_gen: {
__b1:
// [73] if((word) lin16u_gen::i#2<(byte) $14) goto lin16u_gen::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$14
bcc __b2
bne !+
lda.z i
cmp #<$14
cmp #$14
bcc __b2
!:
jmp __breturn
@ -4331,11 +4325,9 @@ divr16u: {
rol.z quotient+1
// [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1
lda.z rem+1
cmp #>$14-1
bcc __b3_from___b2
bne !+
lda.z rem
cmp #<$14-1
cmp #$14-1
bcc __b3_from___b2
!:
jmp __b5
@ -4511,7 +4503,6 @@ Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
Replacing label __b2_from___b1 with __b2
Replacing label __b3_from___b2 with __b3
Replacing label __b3_from___b2 with __b3
Replacing label __b1_from___b3 with __b1
Removing instruction __b4_from_main:
Removing instruction lin16u_gen_from___b4:
@ -4840,7 +4831,7 @@ reg byte a [ divr16u::$2 ]
FINAL ASSEMBLER
Score: 11819
Score: 11729
// File Comments
// Linear table generator
@ -5315,11 +5306,9 @@ lin16u_gen: {
// for(word i=0; i<length; i++)
// [73] if((word) lin16u_gen::i#2<(byte) $14) goto lin16u_gen::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>$14
bcc __b2
bne !+
lda.z i
cmp #<$14
cmp #$14
bcc __b2
!:
// lin16u_gen::@return
@ -5589,11 +5578,9 @@ divr16u: {
// if(rem>=divisor)
// [119] if((word) divr16u::rem#6<(byte) $14-(byte) 1) goto divr16u::@3 -- vwuz1_lt_vbuc1_then_la1
lda.z rem+1
cmp #>$14-1
bcc __b3
bne !+
lda.z rem
cmp #<$14-1
cmp #$14-1
bcc __b3
!:
// divr16u::@5

View File

@ -36,11 +36,9 @@ main: {
__b1:
// for(i=0;i<6;i++)
lda.z i+1
cmp #>6
bcc __b2
bne !+
lda.z i
cmp #<6
cmp #6
bcc __b2
!:
// end()

View File

@ -2159,11 +2159,9 @@ main: {
__b1:
// [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>6
bcc __b2_from___b1
bne !+
lda.z i
cmp #<6
cmp #6
bcc __b2_from___b1
!:
// [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
@ -2961,26 +2959,26 @@ Uplift Scope [start]
Uplift Scope [end]
Uplift Scope [__start]
Uplifting [utoa_append] best 145211 combination zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:48 [ utoa_append::sub#0 ] zp[2]:50 [ utoa_append::return#0 ] zp[2]:46 [ utoa_append::buffer#0 ]
Uplifting [utoa] best 143907 combination zp[2]:16 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:44 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:41 [ utoa::buffer#3 ]
Uplifting [print_char] best 143598 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
Uplifting [] best 143598 combination zp[2]:25 [ print_char_cursor#36 print_char_cursor#52 print_char_cursor#49 print_char_cursor#12 print_char_cursor#1 print_char_cursor#54 print_char_cursor#73 ] zp[2]:10 [ print_line_cursor#10 print_line_cursor#22 print_line_cursor#0 ] zp[2]:35 [ Ticks#1 ] zp[2]:33 [ Ticks#0 ] zp[2]:27 [ last_time ]
Uplifting [sum] best 124698 combination reg byte y [ sum::i#3 sum::i#2 ] reg byte a [ sum::tmp#1 ] zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] zp[2]:5 [ sum::p#5 sum::p#2 ] reg byte x [ sum::page#3 sum::page#2 ] zp[2]:29 [ sum::return#2 ]
Uplifting [print_str] best 124698 combination zp[2]:18 [ print_str::str#2 print_str::str#0 ]
Uplifting [print_uchar] best 124680 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [print_uint_decimal] best 124680 combination zp[2]:31 [ print_uint_decimal::w#0 ]
Uplifting [print_uint] best 124680 combination zp[2]:37 [ print_uint::w#0 ]
Uplifting [main] best 124680 combination zp[2]:2 [ main::i#3 main::i#2 ]
Uplifting [RADIX] best 124680 combination
Uplifting [print_ln] best 124680 combination
Uplifting [MOS6526_CIA] best 124680 combination
Uplifting [MOS6569_VICII] best 124680 combination
Uplifting [MOS6581_SID] best 124680 combination
Uplifting [start] best 124680 combination
Uplifting [end] best 124680 combination
Uplifting [__start] best 124680 combination
Uplifting [utoa_append] best 145166 combination zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:48 [ utoa_append::sub#0 ] zp[2]:50 [ utoa_append::return#0 ] zp[2]:46 [ utoa_append::buffer#0 ]
Uplifting [utoa] best 143862 combination zp[2]:16 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:12 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:44 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:41 [ utoa::buffer#3 ]
Uplifting [print_char] best 143553 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 print_char::ch#2 ]
Uplifting [] best 143553 combination zp[2]:25 [ print_char_cursor#36 print_char_cursor#52 print_char_cursor#49 print_char_cursor#12 print_char_cursor#1 print_char_cursor#54 print_char_cursor#73 ] zp[2]:10 [ print_line_cursor#10 print_line_cursor#22 print_line_cursor#0 ] zp[2]:35 [ Ticks#1 ] zp[2]:33 [ Ticks#0 ] zp[2]:27 [ last_time ]
Uplifting [sum] best 124653 combination reg byte y [ sum::i#3 sum::i#2 ] reg byte a [ sum::tmp#1 ] zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] zp[2]:5 [ sum::p#5 sum::p#2 ] reg byte x [ sum::page#3 sum::page#2 ] zp[2]:29 [ sum::return#2 ]
Uplifting [print_str] best 124653 combination zp[2]:18 [ print_str::str#2 print_str::str#0 ]
Uplifting [print_uchar] best 124635 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [print_uint_decimal] best 124635 combination zp[2]:31 [ print_uint_decimal::w#0 ]
Uplifting [print_uint] best 124635 combination zp[2]:37 [ print_uint::w#0 ]
Uplifting [main] best 124635 combination zp[2]:2 [ main::i#3 main::i#2 ]
Uplifting [RADIX] best 124635 combination
Uplifting [print_ln] best 124635 combination
Uplifting [MOS6526_CIA] best 124635 combination
Uplifting [MOS6569_VICII] best 124635 combination
Uplifting [MOS6581_SID] best 124635 combination
Uplifting [start] best 124635 combination
Uplifting [end] best 124635 combination
Uplifting [__start] best 124635 combination
Attempting to uplift remaining variables inzp[1]:12 [ utoa::digit#2 utoa::digit#1 ]
Uplifting [utoa] best 124680 combination zp[1]:12 [ utoa::digit#2 utoa::digit#1 ]
Uplifting [utoa] best 124635 combination zp[1]:12 [ utoa::digit#2 utoa::digit#1 ]
Coalescing zero page register [ zp[2]:8 [ sum::s#4 sum::s#3 sum::s#2 ] ] with [ zp[2]:29 [ sum::return#2 ] ] - score: 1
Coalescing zero page register [ zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] ] with [ zp[2]:21 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] ] - score: 1
Coalescing zero page register [ zp[2]:13 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] ] with [ zp[2]:31 [ print_uint_decimal::w#0 ] ] - score: 1
@ -3071,11 +3069,9 @@ main: {
__b1:
// [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>6
bcc __b2_from___b1
bne !+
lda.z i
cmp #<6
cmp #6
bcc __b2_from___b1
!:
// [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
@ -3714,7 +3710,6 @@ Replacing instruction lda #0 with TXA
Replacing instruction ldy #0 with TAY
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Replacing label __b2_from___b1 with __b2
Replacing label __b2_from___b1 with __b2
Replacing label __b2_from___b2 with __b2
Replacing label __b1_from___b1 with __b1
Replacing label __b1_from___b1 with __b1
@ -4057,7 +4052,7 @@ reg byte x [ print_uchar::$2 ]
FINAL ASSEMBLER
Score: 99381
Score: 99336
// File Comments
// Print a number of zero-terminated strings, each followed by a newline.
@ -4117,11 +4112,9 @@ main: {
// for(i=0;i<6;i++)
// [8] if((word) main::i#3<(byte) 6) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>6
bcc __b2
bne !+
lda.z i
cmp #<6
cmp #6
bcc __b2
!:
// [9] phi from main::@1 to main::@3 [phi:main::@1->main::@3]

View File

@ -32,11 +32,9 @@ main: {
__b1:
// while (i < SQRT_COUNT)
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
lda #<print_screen

View File

@ -1145,11 +1145,9 @@ main: {
__b1:
// [3] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
// [4] phi from main::@1 to main::@7 [phi:main::@1->main::@7]
@ -1532,16 +1530,16 @@ Uplift Scope [MOS6569_VICII]
Uplift Scope [MOS6581_SID]
Uplift Scope [RADIX]
Uplifting [print_char] best 10785 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 ]
Uplifting [] best 10785 combination zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ]
Uplifting [print_uchar] best 10767 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [main] best 10767 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:18 [ main::$16 ]
Uplifting [memset] best 10767 combination zp[2]:12 [ memset::dst#2 memset::dst#1 ]
Uplifting [print_uint] best 10767 combination zp[2]:20 [ print_uint::w#0 ]
Uplifting [MOS6526_CIA] best 10767 combination
Uplifting [MOS6569_VICII] best 10767 combination
Uplifting [MOS6581_SID] best 10767 combination
Uplifting [RADIX] best 10767 combination
Uplifting [print_char] best 10740 combination reg byte a [ print_char::ch#3 print_char::ch#0 print_char::ch#1 ]
Uplifting [] best 10740 combination zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ]
Uplifting [print_uchar] best 10722 combination reg byte a [ print_uchar::$0 ] reg byte x [ print_uchar::$2 ] reg byte x [ print_uchar::b#2 print_uchar::b#0 print_uchar::b#1 ]
Uplifting [main] best 10722 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:18 [ main::$16 ]
Uplifting [memset] best 10722 combination zp[2]:12 [ memset::dst#2 memset::dst#1 ]
Uplifting [print_uint] best 10722 combination zp[2]:20 [ print_uint::w#0 ]
Uplifting [MOS6526_CIA] best 10722 combination
Uplifting [MOS6569_VICII] best 10722 combination
Uplifting [MOS6581_SID] best 10722 combination
Uplifting [RADIX] best 10722 combination
Coalescing zero page register [ zp[2]:6 [ main::i#10 main::i#3 ] ] with [ zp[2]:20 [ print_uint::w#0 ] ] - score: 1
Coalescing zero page register [ zp[2]:15 [ print_char_cursor#20 print_char_cursor#29 print_char_cursor#35 print_char_cursor#21 print_char_cursor#28 ] ] with [ zp[2]:2 [ main::i#12 main::i#2 ] ]
Coalescing zero page register [ zp[2]:18 [ main::$16 ] ] with [ zp[2]:12 [ memset::dst#2 memset::dst#1 ] ]
@ -1599,11 +1597,9 @@ main: {
__b1:
// [3] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
// [4] phi from main::@1 to main::@7 [phi:main::@1->main::@7]
@ -2137,7 +2133,7 @@ reg byte x [ print_uchar::$2 ]
FINAL ASSEMBLER
Score: 9762
Score: 9717
// File Comments
// C standard library string.h
@ -2184,11 +2180,9 @@ main: {
// while (i < SQRT_COUNT)
// [3] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
// [4] phi from main::@1 to main::@7 [phi:main::@1->main::@7]

View File

@ -113,13 +113,9 @@ main: {
__b1:
// while (i < SQRT_COUNT)
lda.z i+1
cmp #>SQRT_COUNT
bcs !__b2+
jmp __b2
!__b2:
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcs !__b2+
jmp __b2
!__b2:

View File

@ -4139,11 +4139,9 @@ main: {
__b1:
// [19] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
// [20] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
@ -5806,31 +5804,31 @@ Uplift Scope [RADIX]
Uplift Scope [print_ln]
Uplift Scope [print_cls]
Uplifting [utoa_append] best 102818 combination zp[2]:49 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:115 [ utoa_append::sub#0 ] zp[2]:117 [ utoa_append::return#0 ] zp[2]:113 [ utoa_append::buffer#0 ]
Uplifting [ultoa_append] best 102215 combination zp[4]:52 [ ultoa_append::value#2 ultoa_append::value#0 ultoa_append::value#1 ] reg byte x [ ultoa_append::digit#2 ultoa_append::digit#1 ] zp[4]:133 [ ultoa_append::sub#0 ] zp[4]:137 [ ultoa_append::return#0 ] zp[2]:131 [ ultoa_append::buffer#0 ]
Uplifting [utoa] best 100911 combination zp[2]:32 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:29 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:111 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:108 [ utoa::buffer#3 ]
Uplifting [print_char] best 100605 combination reg byte a [ print_char::ch#2 print_char::ch#0 ]
Uplifting [] best 100605 combination zp[2]:12 [ print_char_cursor#69 print_char_cursor#89 print_char_cursor#90 print_char_cursor#91 print_char_cursor#1 print_char_cursor#61 print_char_cursor#96 print_char_cursor#97 ] zp[2]:16 [ print_line_cursor#12 print_line_cursor#23 print_char_cursor#65 print_char_cursor#79 print_line_cursor#0 print_char_cursor#39 ] zp[2]:121 [ rem16u#0 ]
Uplifting [print_str] best 100605 combination zp[2]:14 [ print_str::str#10 print_str::str#11 print_str::str#0 ]
Uplifting [divr16u] best 100395 combination zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:38 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:36 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#2 divr16u::dividend#0 ] zp[2]:95 [ divr16u::return#2 ] zp[2]:99 [ divr16u::return#3 ]
Uplifting [ultoa] best 100261 combination zp[2]:47 [ ultoa::buffer#11 ultoa::buffer#14 ultoa::buffer#4 ] zp[4]:42 [ ultoa::value#2 ultoa::value#6 ultoa::value#1 ultoa::value#0 ] zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] reg byte a [ ultoa::$10 ] reg byte x [ ultoa::started#2 ultoa::started#4 ] zp[4]:127 [ ultoa::digit_value#0 ] reg byte a [ ultoa::$11 ] zp[2]:124 [ ultoa::buffer#3 ]
Uplifting [memset] best 100245 combination zp[2]:25 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:89 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:20 [ memset::num#2 ] zp[2]:22 [ memset::str#3 ]
Uplifting [main] best 100245 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:87 [ main::$33 ] zp[4]:61 [ main::$10 ] zp[4]:77 [ main::$12 ] zp[2]:81 [ main::sec100s#0 ] zp[4]:65 [ main::cyclecount#0 ]
Uplifting [print_uint_decimal] best 100245 combination zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ]
Uplifting [div32u16u] best 100245 combination zp[2]:101 [ div32u16u::quotient_lo#0 ] zp[4]:69 [ div32u16u::dividend#0 ] zp[4]:103 [ div32u16u::return#0 ] zp[4]:73 [ div32u16u::return#2 ] zp[2]:97 [ div32u16u::quotient_hi#0 ]
Uplifting [print_ulong_decimal] best 100245 combination zp[4]:83 [ print_ulong_decimal::w#0 ]
Uplifting [clock] best 100245 combination zp[4]:91 [ clock::return#0 ] zp[4]:57 [ clock::return#2 ]
Uplifting [MOS6526_CIA] best 100245 combination
Uplifting [MOS6569_VICII] best 100245 combination
Uplifting [MOS6581_SID] best 100245 combination
Uplifting [clock_start] best 100245 combination
Uplifting [RADIX] best 100245 combination
Uplifting [print_ln] best 100245 combination
Uplifting [print_cls] best 100245 combination
Uplifting [utoa_append] best 102773 combination zp[2]:49 [ utoa_append::value#2 utoa_append::value#0 utoa_append::value#1 ] reg byte x [ utoa_append::digit#2 utoa_append::digit#1 ] zp[2]:115 [ utoa_append::sub#0 ] zp[2]:117 [ utoa_append::return#0 ] zp[2]:113 [ utoa_append::buffer#0 ]
Uplifting [ultoa_append] best 102170 combination zp[4]:52 [ ultoa_append::value#2 ultoa_append::value#0 ultoa_append::value#1 ] reg byte x [ ultoa_append::digit#2 ultoa_append::digit#1 ] zp[4]:133 [ ultoa_append::sub#0 ] zp[4]:137 [ ultoa_append::return#0 ] zp[2]:131 [ ultoa_append::buffer#0 ]
Uplifting [utoa] best 100866 combination zp[2]:32 [ utoa::buffer#11 utoa::buffer#14 utoa::buffer#4 ] zp[2]:29 [ utoa::value#2 utoa::value#6 utoa::value#1 utoa::value#0 ] zp[1]:28 [ utoa::digit#2 utoa::digit#1 ] reg byte a [ utoa::$10 ] reg byte x [ utoa::started#2 utoa::started#4 ] zp[2]:111 [ utoa::digit_value#0 ] reg byte a [ utoa::$11 ] zp[2]:108 [ utoa::buffer#3 ]
Uplifting [print_char] best 100560 combination reg byte a [ print_char::ch#2 print_char::ch#0 ]
Uplifting [] best 100560 combination zp[2]:12 [ print_char_cursor#69 print_char_cursor#89 print_char_cursor#90 print_char_cursor#91 print_char_cursor#1 print_char_cursor#61 print_char_cursor#96 print_char_cursor#97 ] zp[2]:16 [ print_line_cursor#12 print_line_cursor#23 print_char_cursor#65 print_char_cursor#79 print_line_cursor#0 print_char_cursor#39 ] zp[2]:121 [ rem16u#0 ]
Uplifting [print_str] best 100560 combination zp[2]:14 [ print_str::str#10 print_str::str#11 print_str::str#0 ]
Uplifting [divr16u] best 100350 combination zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] zp[2]:38 [ divr16u::quotient#3 divr16u::return#0 divr16u::quotient#1 divr16u::quotient#2 ] reg byte a [ divr16u::$1 ] reg byte a [ divr16u::$2 ] reg byte x [ divr16u::i#2 divr16u::i#1 ] zp[2]:36 [ divr16u::dividend#3 divr16u::dividend#5 divr16u::dividend#1 divr16u::dividend#2 divr16u::dividend#0 ] zp[2]:95 [ divr16u::return#2 ] zp[2]:99 [ divr16u::return#3 ]
Uplifting [ultoa] best 100216 combination zp[2]:47 [ ultoa::buffer#11 ultoa::buffer#14 ultoa::buffer#4 ] zp[4]:42 [ ultoa::value#2 ultoa::value#6 ultoa::value#1 ultoa::value#0 ] zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ] reg byte a [ ultoa::$10 ] reg byte x [ ultoa::started#2 ultoa::started#4 ] zp[4]:127 [ ultoa::digit_value#0 ] reg byte a [ ultoa::$11 ] zp[2]:124 [ ultoa::buffer#3 ]
Uplifting [memset] best 100200 combination zp[2]:25 [ memset::dst#2 memset::dst#4 memset::dst#1 ] zp[2]:89 [ memset::end#0 ] reg byte x [ memset::c#4 ] zp[2]:20 [ memset::num#2 ] zp[2]:22 [ memset::str#3 ]
Uplifting [main] best 100200 combination zp[2]:8 [ main::j#2 main::j#1 main::j#0 ] zp[2]:10 [ main::s#2 main::s#1 main::s#0 ] zp[2]:2 [ main::i#12 main::i#2 ] zp[2]:6 [ main::i#10 main::i#3 ] zp[2]:4 [ main::sieve_i#2 main::sieve_i#1 ] zp[2]:87 [ main::$33 ] zp[4]:61 [ main::$10 ] zp[4]:77 [ main::$12 ] zp[2]:81 [ main::sec100s#0 ] zp[4]:65 [ main::cyclecount#0 ]
Uplifting [print_uint_decimal] best 100200 combination zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ]
Uplifting [div32u16u] best 100200 combination zp[2]:101 [ div32u16u::quotient_lo#0 ] zp[4]:69 [ div32u16u::dividend#0 ] zp[4]:103 [ div32u16u::return#0 ] zp[4]:73 [ div32u16u::return#2 ] zp[2]:97 [ div32u16u::quotient_hi#0 ]
Uplifting [print_ulong_decimal] best 100200 combination zp[4]:83 [ print_ulong_decimal::w#0 ]
Uplifting [clock] best 100200 combination zp[4]:91 [ clock::return#0 ] zp[4]:57 [ clock::return#2 ]
Uplifting [MOS6526_CIA] best 100200 combination
Uplifting [MOS6569_VICII] best 100200 combination
Uplifting [MOS6581_SID] best 100200 combination
Uplifting [clock_start] best 100200 combination
Uplifting [RADIX] best 100200 combination
Uplifting [print_ln] best 100200 combination
Uplifting [print_cls] best 100200 combination
Attempting to uplift remaining variables inzp[1]:28 [ utoa::digit#2 utoa::digit#1 ]
Uplifting [utoa] best 100245 combination zp[1]:28 [ utoa::digit#2 utoa::digit#1 ]
Uplifting [utoa] best 100200 combination zp[1]:28 [ utoa::digit#2 utoa::digit#1 ]
Attempting to uplift remaining variables inzp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ]
Uplifting [ultoa] best 100245 combination zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ]
Uplifting [ultoa] best 100200 combination zp[1]:41 [ ultoa::digit#2 ultoa::digit#1 ]
Coalescing zero page register [ zp[2]:34 [ divr16u::rem#5 divr16u::rem#10 divr16u::rem#4 divr16u::rem#11 divr16u::rem#6 divr16u::rem#0 divr16u::rem#1 divr16u::rem#2 ] ] with [ zp[2]:121 [ rem16u#0 ] ] - score: 2
Coalescing zero page register [ zp[2]:6 [ main::i#10 main::i#3 ] ] with [ zp[2]:18 [ print_uint_decimal::w#3 print_uint_decimal::w#2 print_uint_decimal::w#1 ] ] - score: 1
Coalescing zero page register [ zp[2]:20 [ memset::num#2 ] ] with [ zp[2]:89 [ memset::end#0 ] ] - score: 1
@ -6075,11 +6073,9 @@ main: {
__b1:
// [19] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcc __b2
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcc __b2
!:
// [20] phi from main::@1 to main::@3 [phi:main::@1->main::@3]
@ -7490,8 +7486,7 @@ Removing instruction jmp __b1
Succesful ASM optimization Pass5NextJumpElimination
Removing instruction lda.z digit_value+1
Succesful ASM optimization Pass5UnnecesaryLoadElimination
Fixing long branch [106] bcc __b2 to bcs
Fixing long branch [112] bcc __b2 to bcs
Fixing long branch [108] bcc __b2 to bcs
FINAL SYMBOL TABLE
(const nomodify struct MOS6526_CIA*) CIA2 = (struct MOS6526_CIA*) 56576
@ -7927,7 +7922,7 @@ zp[4]:31 [ ultoa::digit_value#0 ultoa_append::sub#0 ]
FINAL ASSEMBLER
Score: 82397
Score: 82322
// File Comments
// C standard library string.h
@ -8097,13 +8092,9 @@ main: {
// while (i < SQRT_COUNT)
// [19] if((word) main::i#12<(const nomodify byte) SQRT_COUNT) goto main::@2 -- vwuz1_lt_vbuc1_then_la1
lda.z i+1
cmp #>SQRT_COUNT
bcs !__b2+
jmp __b2
!__b2:
bne !+
lda.z i
cmp #<SQRT_COUNT
cmp #SQRT_COUNT
bcs !__b2+
jmp __b2
!__b2: