From ceb271d0216cd3ffb9e90cc76bc67891466eabd2 Mon Sep 17 00:00:00 2001 From: jespergravgaard Date: Tue, 25 Dec 2018 17:44:43 +0100 Subject: [PATCH] Fixed tests. --- .../kc/examples/sinplotter/sine-plotter.kc | 5 +- src/test/ref/examples/3d/3d.asm | 4 +- src/test/ref/examples/3d/3d.log | 17 +++-- src/test/ref/examples/3d/perspective.asm | 4 +- src/test/ref/examples/3d/perspective.log | 11 +-- .../fastmultiply/fastmultiply8.kc.asm | 4 +- .../fastmultiply/fastmultiply8.kc.log | 11 +-- .../multiplexer/simple-multiplexer.asm | 4 +- .../multiplexer/simple-multiplexer.log | 10 +-- src/test/ref/examples/rotate/rotate.asm | 4 +- src/test/ref/examples/rotate/rotate.log | 12 ++-- .../ref/examples/scrolllogo/scrolllogo.asm | 4 +- .../ref/examples/scrolllogo/scrolllogo.log | 10 +-- src/test/ref/examples/showlogo/showlogo.asm | 4 +- src/test/ref/examples/showlogo/showlogo.log | 11 +-- .../ref/examples/sinplotter/sine-plotter.asm | 16 ++--- .../ref/examples/sinplotter/sine-plotter.cfg | 5 +- .../ref/examples/sinplotter/sine-plotter.log | 68 ++++++++----------- src/test/ref/examples/tetris/tetris.asm | 4 +- src/test/ref/examples/tetris/tetris.log | 10 +-- src/test/ref/test-kasm.asm | 4 +- src/test/ref/test-kasm.log | 11 +-- 22 files changed, 109 insertions(+), 124 deletions(-) diff --git a/src/test/kc/examples/sinplotter/sine-plotter.kc b/src/test/kc/examples/sinplotter/sine-plotter.kc index 3964b503c..4d0f427df 100644 --- a/src/test/kc/examples/sinplotter/sine-plotter.kc +++ b/src/test/kc/examples/sinplotter/sine-plotter.kc @@ -14,13 +14,10 @@ signed word[512] align($100) sin; signed word* sin2 = $1400; -kickasm {{ - .label pc_restore = * - .pc = $1400 +kickasm(pc sin2) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } - .pc = pc_restore }} void main() { diff --git a/src/test/ref/examples/3d/3d.asm b/src/test/ref/examples/3d/3d.asm index e97727c03..bc16c549e 100644 --- a/src/test/ref/examples/3d/3d.asm +++ b/src/test/ref/examples/3d/3d.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label SPRITES_XPOS = $d000 .label SPRITES_YPOS = $d001 @@ -35,8 +35,6 @@ .label COSQ = SINQ+$40 .label sx = 2 .label sy = 3 -bbegin: - jsr main main: { sei jsr sprites_init diff --git a/src/test/ref/examples/3d/3d.log b/src/test/ref/examples/3d/3d.log index 3b787d5bf..b9549e396 100644 --- a/src/test/ref/examples/3d/3d.log +++ b/src/test/ref/examples/3d/3d.log @@ -10609,6 +10609,9 @@ Removing instruction breturn: Removing instruction b1_from_sprites_init: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Removing instruction jmp b13 Removing instruction jmp b1 Removing instruction jmp b1 @@ -10616,9 +10619,11 @@ Removing instruction jmp b2 Removing instruction jmp b1 Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination -Fixing long branch [308] bne b1 to beq -Fixing long branch [976] bne b2 to beq -Fixing long branch [986] bne b1 to beq +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination +Fixing long branch [306] bne b1 to beq +Fixing long branch [974] bne b2 to beq +Fixing long branch [984] bne b1 to beq FINAL SYMBOL TABLE (label) @33 @@ -11242,11 +11247,11 @@ reg byte a [ calculate_matrix::$34 ] FINAL ASSEMBLER -Score: 85532 +Score: 85526 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label SPRITES_XPOS = $d000 @@ -11284,7 +11289,6 @@ Score: 85532 .label sx = 2 .label sy = 3 //SEG2 @begin -bbegin: //SEG3 @33 //SEG4 kickasm(location (const byte*) mulf_sqr1#0) {{ .for(var i=0;i<$200;i++) { .if(i<=159) { .byte round((i*i)/256) } .if(i>159 && i<=351 ) { .byte round(((i-256)*(i-256))/256) } .if(i>351) { .byte round(((512-i)*(512-i))/256) } } }} //SEG5 kickasm(location (const byte*) mulf_sqr2#0) {{ .for(var i=0;i<$200;i++) { .if(i<=159) { .byte round((-i-1)*(-i-1)/256) } .if(i>159 && i<=351 ) { .byte round(((255-i)*(255-i))/256) } .if(i>351) { .byte round(((i-511)*(i-511))/256) } } }} @@ -11297,7 +11301,6 @@ bbegin: //SEG12 kickasm(location (const byte*) SINQ_LO#0) {{ { .var min = -$1000 .var max = $1000 .var ampl = max-min; .for(var i=0;i<$140;i++) { .var rad = i*2*PI/256; .byte <(min+(ampl/2)+(ampl/2)*sin(rad)) } } }} //SEG13 kickasm(location (const byte*) SINQ_HI#0) {{ { .var min = -$1000 .var max = $1000 .var ampl = max-min; .for(var i=0;i<$140;i++) { .var rad = i*2*PI/256; .byte >(min+(ampl/2)+(ampl/2)*sin(rad)) } } }} //SEG14 [11] call main - jsr main //SEG15 [12] phi from @33 to @end [phi:@33->@end] //SEG16 @end //SEG17 main diff --git a/src/test/ref/examples/3d/perspective.asm b/src/test/ref/examples/3d/perspective.asm index ca08a6f96..988fae579 100644 --- a/src/test/ref/examples/3d/perspective.asm +++ b/src/test/ref/examples/3d/perspective.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label xr = $f0 .label yr = $f1 @@ -9,8 +9,6 @@ .label PERSP_Z = $2400 .label print_char_cursor = 4 .label print_line_cursor = 2 -bbegin: - jsr main main: { sei jsr mulf_init diff --git a/src/test/ref/examples/3d/perspective.log b/src/test/ref/examples/3d/perspective.log index e0990818a..ae147ec0f 100644 --- a/src/test/ref/examples/3d/perspective.log +++ b/src/test/ref/examples/3d/perspective.log @@ -3483,10 +3483,15 @@ Removing instruction breturn: Removing instruction b1_from_mulf_init: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Removing instruction jmp b1 Removing instruction jmp b1 Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (label) @27 @@ -3713,11 +3718,11 @@ reg byte a [ mulf_init::$10 ] FINAL ASSEMBLER -Score: 3787 +Score: 3781 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label xr = $f0 @@ -3729,11 +3734,9 @@ Score: 3787 .label print_char_cursor = 4 .label print_line_cursor = 2 //SEG2 @begin -bbegin: //SEG3 @27 //SEG4 kickasm(location (const signed byte*) PERSP_Z#0) {{ { .var d = 256.0 .var z0 = 5.0 .for(var z=0;z<$100;z++) { .if(z>127) { .byte round(d / (z0 - ((z - 256) / 64.0))); } else { .byte round(d / (z0 - (z / 64.0))); } } } }} //SEG5 [2] call main - jsr main //SEG6 [3] phi from @27 to @end [phi:@27->@end] //SEG7 @end //SEG8 main diff --git a/src/test/ref/examples/fastmultiply/fastmultiply8.kc.asm b/src/test/ref/examples/fastmultiply/fastmultiply8.kc.asm index 71f6d63bd..a6e3393d5 100644 --- a/src/test/ref/examples/fastmultiply/fastmultiply8.kc.asm +++ b/src/test/ref/examples/fastmultiply/fastmultiply8.kc.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label print_line_cursor = $400 .label ap = $fd @@ -7,8 +7,6 @@ .label cp = $ff .label mulf_sqr1 = $2000 .label mulf_sqr2 = $2200 -bbegin: - jsr main main: { .label at = 2 .label at_3 = 5 diff --git a/src/test/ref/examples/fastmultiply/fastmultiply8.kc.log b/src/test/ref/examples/fastmultiply/fastmultiply8.kc.log index f8e460f1a..fa8e22a4c 100644 --- a/src/test/ref/examples/fastmultiply/fastmultiply8.kc.log +++ b/src/test/ref/examples/fastmultiply/fastmultiply8.kc.log @@ -2549,6 +2549,9 @@ Removing instruction breturn: Removing instruction b1_from_print_cls: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b3 @@ -2556,6 +2559,8 @@ Removing instruction jmp b1 Removing instruction jmp b2 Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (label) @22 @@ -2697,11 +2702,11 @@ reg byte a [ fmul8::return#1 ] FINAL ASSEMBLER -Score: 10542 +Score: 10536 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label print_line_cursor = $400 @@ -2711,13 +2716,11 @@ Score: 10542 .label mulf_sqr1 = $2000 .label mulf_sqr2 = $2200 //SEG2 @begin -bbegin: //SEG3 @22 //SEG4 kickasm(location (const byte*) mulf_sqr1#0) {{ .for(var i=0;i<$200;i++) { .if(i<=159) { .byte round((i*i)/256) } .if(i>159 && i<=351 ) { .byte round(((i-256)*(i-256))/256) } .if(i>351) { .byte round(((512-i)*(512-i))/256) } } }} //SEG5 kickasm(location (const byte*) mulf_sqr2#0) {{ .for(var i=0;i<$200;i++) { .if(i<=159) { .byte round((-i-1)*(-i-1)/256) } .if(i>159 && i<=351 ) { .byte round(((255-i)*(255-i))/256) } .if(i>351) { .byte round(((i-511)*(i-511))/256) } } }} //SEG6 [3] call main //SEG7 [5] phi from @22 to main [phi:@22->main] - jsr main //SEG8 [4] phi from @22 to @end [phi:@22->@end] //SEG9 @end //SEG10 main diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.asm b/src/test/ref/examples/multiplexer/simple-multiplexer.asm index 7bb737703..041cf7aed 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.asm +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label SPRITES_XPOS = $d000 .label SPRITES_YPOS = $d001 @@ -22,8 +22,6 @@ .label plex_free_next = 3 .label plex_show_idx = 4 .label plex_sprite_msb = 5 -bbegin: - jsr main main: { sei jsr init diff --git a/src/test/ref/examples/multiplexer/simple-multiplexer.log b/src/test/ref/examples/multiplexer/simple-multiplexer.log index febb9e4bb..01b7f8d67 100644 --- a/src/test/ref/examples/multiplexer/simple-multiplexer.log +++ b/src/test/ref/examples/multiplexer/simple-multiplexer.log @@ -3945,6 +3945,9 @@ Removing instruction breturn: Removing instruction plexSetScreen1: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Skipping double jump to breturn in bne b8 Succesful ASM optimization Pass5DoubleJumpElimination Removing instruction jmp b7 @@ -3957,6 +3960,7 @@ Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination Removing instruction ldx m Succesful ASM optimization Pass5UnnecesaryLoadElimination +Removing instruction bbegin: Removing instruction b8: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp breturn @@ -4231,11 +4235,11 @@ reg byte a [ init::$6 ] FINAL ASSEMBLER -Score: 63466 +Score: 63460 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label SPRITES_XPOS = $d000 @@ -4260,14 +4264,12 @@ Score: 63466 .label plex_show_idx = 4 .label plex_sprite_msb = 5 //SEG2 @begin -bbegin: //SEG3 @12 //SEG4 kickasm(location (const byte*) YSIN#0) {{ .var min = 50 .var max = 250-21 .var ampl = max-min; .for(var i=0;i<256;i++) .byte round(min+(ampl/2)+(ampl/2)*sin(toRadians(360*i/256))) }} //SEG5 kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) .for (var y=0; y<21; y++) .for (var x=0;x<3; x++) .byte pic.getSinglecolorByte(x,y) }} //SEG6 [3] phi from @12 to @15 [phi:@12->@15] //SEG7 @15 //SEG8 [4] call main - jsr main //SEG9 [5] phi from @15 to @end [phi:@15->@end] //SEG10 @end //SEG11 main diff --git a/src/test/ref/examples/rotate/rotate.asm b/src/test/ref/examples/rotate/rotate.asm index fd2027af4..a4365bd7b 100644 --- a/src/test/ref/examples/rotate/rotate.asm +++ b/src/test/ref/examples/rotate/rotate.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label SPRITES_XPOS = $d000 .label SPRITES_YPOS = $d001 @@ -14,8 +14,6 @@ .label COS = $2000 .label SPRITE = $3000 .label SIN = COS+$40 -bbegin: - jsr main main: { sei jsr init diff --git a/src/test/ref/examples/rotate/rotate.log b/src/test/ref/examples/rotate/rotate.log index b6df32c2c..7df9c92a1 100644 --- a/src/test/ref/examples/rotate/rotate.log +++ b/src/test/ref/examples/rotate/rotate.log @@ -4160,6 +4160,9 @@ Removing instruction b4_from_b3: Removing instruction b8: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Skipping double jump to b4 in bne b12 Succesful ASM optimization Pass5DoubleJumpElimination Removing instruction jmp b7 @@ -4167,11 +4170,12 @@ Removing instruction jmp b1 Removing instruction jmp b1 Removing instruction jmp b3 Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: Removing instruction b12: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b4 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [134] bne b7 to beq +Fixing long branch [132] bne b7 to beq FINAL SYMBOL TABLE (label) @13 @@ -4483,11 +4487,11 @@ reg byte a [ mulf_init::$6 ] FINAL ASSEMBLER -Score: 34706 +Score: 34700 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label SPRITES_XPOS = $d000 @@ -4504,13 +4508,11 @@ Score: 34706 .label SPRITE = $3000 .label SIN = COS+$40 //SEG2 @begin -bbegin: //SEG3 @13 //SEG4 kickasm(location (const byte*) COS#0) {{ { .var min = -$7fff .var max = $7fff .var ampl = max-min; .for(var i=0;i<$140;i++) { .var rad = i*2*PI/256; .byte >round(min+(ampl/2)+(ampl/2)*cos(rad)) } } }} //SEG5 @16 //SEG6 kickasm(location (const byte*) SPRITE#0) {{ .var pic = LoadPicture("balloon.png", List().add($000000, $ffffff)) .for (var y=0; y<21; y++) .for (var x=0;x<3; x++) .byte pic.getSinglecolorByte(x,y) }} //SEG7 [3] call main - jsr main //SEG8 [4] phi from @16 to @end [phi:@16->@end] //SEG9 @end //SEG10 main diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.asm b/src/test/ref/examples/scrolllogo/scrolllogo.asm index 589860b97..d1096da13 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.asm +++ b/src/test/ref/examples/scrolllogo/scrolllogo.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label RASTER = $d012 .label BORDERCOL = $d020 @@ -21,8 +21,6 @@ .const XSIN_SIZE = $200 .label rem16u = 2 .label xsin_idx = 2 -bbegin: - jsr main main: { .const toD0181_return = (>(SCREEN&$3fff)<<2)|(>LOGO)>>2&$f sei diff --git a/src/test/ref/examples/scrolllogo/scrolllogo.log b/src/test/ref/examples/scrolllogo/scrolllogo.log index f16a8b035..2f154f8bc 100644 --- a/src/test/ref/examples/scrolllogo/scrolllogo.log +++ b/src/test/ref/examples/scrolllogo/scrolllogo.log @@ -7903,6 +7903,9 @@ Removing instruction b6: Removing instruction breturn: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Skipping double jump to b7 in bne b16 Skipping double jump to b7 in bne b16 Skipping double jump to b3 in beq b15 @@ -7925,6 +7928,7 @@ Removing instruction lda #0 Removing instruction lda #0 Removing instruction lda #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination +Removing instruction bbegin: Removing instruction b16: Removing instruction b15: Succesful ASM optimization Pass5UnusedLabelElimination @@ -8414,11 +8418,11 @@ reg byte a [ divr16u::$2 ] FINAL ASSEMBLER -Score: 41407 +Score: 41401 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label RASTER = $d012 @@ -8442,13 +8446,11 @@ Score: 41407 .label rem16u = 2 .label xsin_idx = 2 //SEG2 @begin -bbegin: //SEG3 @25 //SEG4 kickasm(location (const byte*) LOGO#0) {{ .var logoPic = LoadPicture("logo.png", List().add($444444, $808080, $000000, $ffffff)) .for (var y=0; y<6 ; y++) .for (var x=0;x<40; x++) .for(var cp=0; cp<8; cp++) .byte logoPic.getMulticolorByte(x,cp+y*8) }} //SEG5 [2] phi from @25 to @28 [phi:@25->@28] //SEG6 @28 //SEG7 [3] call main - jsr main //SEG8 [4] phi from @28 to @end [phi:@28->@end] //SEG9 @end //SEG10 main diff --git a/src/test/ref/examples/showlogo/showlogo.asm b/src/test/ref/examples/showlogo/showlogo.asm index e01939764..d81592211 100644 --- a/src/test/ref/examples/showlogo/showlogo.asm +++ b/src/test/ref/examples/showlogo/showlogo.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label BORDERCOL = $d020 .label BGCOL = $d021 @@ -15,8 +15,6 @@ .const DARK_GREY = $b .label SCREEN = $400 .label LOGO = $2000 -bbegin: - jsr main main: { .const toD0181_return = (>(SCREEN&$3fff)<<2)|(>LOGO)>>2&$f lda #WHITE diff --git a/src/test/ref/examples/showlogo/showlogo.log b/src/test/ref/examples/showlogo/showlogo.log index 7fd99dfa3..2b3b14f1b 100644 --- a/src/test/ref/examples/showlogo/showlogo.log +++ b/src/test/ref/examples/showlogo/showlogo.log @@ -1305,8 +1305,13 @@ Removing instruction b10: Removing instruction b1_from_b10: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (label) @4 @@ -1452,11 +1457,11 @@ zp ZP_WORD:4 [ fill::addr#2 fill::addr#0 fill::addr#1 ] FINAL ASSEMBLER -Score: 3578 +Score: 3572 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label BORDERCOL = $d020 @@ -1474,13 +1479,11 @@ Score: 3578 .label SCREEN = $400 .label LOGO = $2000 //SEG2 @begin -bbegin: //SEG3 @4 //SEG4 kickasm(location (const byte*) LOGO#0) {{ .var logoPic = LoadPicture("logo.png", List().add($444444, $808080, $000000, $ffffff)) .for (var y=0; y<6 ; y++) .for (var x=0;x<40; x++) .for(var cp=0; cp<8; cp++) .byte logoPic.getMulticolorByte(x,cp+y*8) }} //SEG5 [2] phi from @4 to @6 [phi:@4->@6] //SEG6 @6 //SEG7 [3] call main - jsr main //SEG8 [4] phi from @6 to @end [phi:@6->@end] //SEG9 @end //SEG10 main diff --git a/src/test/ref/examples/sinplotter/sine-plotter.asm b/src/test/ref/examples/sinplotter/sine-plotter.asm index 4e4c63749..05beb76e7 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.asm +++ b/src/test/ref/examples/sinplotter/sine-plotter.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label PROCPORT_DDR = 0 .const PROCPORT_DDR_MEMORY_MASK = 7 @@ -24,15 +24,6 @@ .const SIN_SIZE = $200 .label sin2 = $1400 .label rem16u = 2 -bbegin: - .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { - .word sin(toRadians([i*360]/512))*320 - } - .pc = pc_restore - - jsr main main: { .const vicSelectGfxBank1_toDd001_return = 3^(>SCREEN)>>6 .const toD0181_return = (>(SCREEN&$3fff)<<2)|(>BITMAP)>>2&$f @@ -789,3 +780,8 @@ fill: { bitmap_plot_bit: .fill $100, 0 .align $100 sin: .fill 2*$200, 0 +.pc = sin2 "Inline" + .for(var i=0; i<512; i++) { + .word sin(toRadians([i*360]/512))*320 + } + diff --git a/src/test/ref/examples/sinplotter/sine-plotter.cfg b/src/test/ref/examples/sinplotter/sine-plotter.cfg index b3c81721b..910b9c468 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.cfg +++ b/src/test/ref/examples/sinplotter/sine-plotter.cfg @@ -2,12 +2,9 @@ [0] phi() to:@29 @29: scope:[] from @begin - kickasm {{ .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { + kickasm(location (const signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } - .pc = pc_restore }} to:@32 @32: scope:[] from @29 diff --git a/src/test/ref/examples/sinplotter/sine-plotter.log b/src/test/ref/examples/sinplotter/sine-plotter.log index 850625e13..f35c96d7c 100644 --- a/src/test/ref/examples/sinplotter/sine-plotter.log +++ b/src/test/ref/examples/sinplotter/sine-plotter.log @@ -703,12 +703,9 @@ bitmap_plot::@return: scope:[bitmap_plot] from bitmap_plot (word) SIN_SIZE#0 ← (word/signed word/dword/signed dword) 512 (signed word[512]) sin#0 ← { fill( 512, 0) } (signed word*) sin2#0 ← ((signed word*)) (word/signed word/dword/signed dword) 5120 - kickasm {{ .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { + kickasm(location (signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } - .pc = pc_restore }} to:@32 main: scope:[main] from @32 @@ -2641,12 +2638,9 @@ FINAL CONTROL FLOW GRAPH [0] phi() to:@29 @29: scope:[] from @begin - kickasm {{ .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { + kickasm(location (const signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } - .pc = pc_restore }} to:@32 @32: scope:[] from @29 @@ -3766,14 +3760,7 @@ bbegin: jmp b29 //SEG3 @29 b29: -//SEG4 kickasm {{ .label pc_restore = * .pc = $1400 .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } .pc = pc_restore }} - .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { - .word sin(toRadians([i*360]/512))*320 - } - .pc = pc_restore - +//SEG4 kickasm(location (const signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } }} //SEG5 [2] phi from @29 to @32 [phi:@29->@32] b32_from_b29: jmp b32 @@ -5447,6 +5434,11 @@ fill: { bitmap_plot_bit: .fill $100, 0 .align $100 sin: .fill 2*$200, 0 +.pc = sin2 "Inline" + .for(var i=0; i<512; i++) { + .word sin(toRadians([i*360]/512))*320 + } + REGISTER UPLIFT POTENTIAL REGISTERS Equivalence Class zp ZP_BYTE:193 [ bitmap_init::$4 ] has ALU potential. @@ -5928,14 +5920,7 @@ bbegin: jmp b29 //SEG3 @29 b29: -//SEG4 kickasm {{ .label pc_restore = * .pc = $1400 .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } .pc = pc_restore }} - .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { - .word sin(toRadians([i*360]/512))*320 - } - .pc = pc_restore - +//SEG4 kickasm(location (const signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } }} //SEG5 [2] phi from @29 to @32 [phi:@29->@32] b32_from_b29: jmp b32 @@ -7381,6 +7366,11 @@ fill: { bitmap_plot_bit: .fill $100, 0 .align $100 sin: .fill 2*$200, 0 +.pc = sin2 "Inline" + .for(var i=0; i<512; i++) { + .word sin(toRadians([i*360]/512))*320 + } + ASSEMBLER OPTIMIZATIONS Removing instruction jmp b29 @@ -7504,6 +7494,7 @@ Replacing label b1_from_b1 with b1 Replacing label b1_from_b1 with b1 Removing instruction b29: Removing instruction b32_from_b29: +Removing instruction b32: Removing instruction bend_from_b32: Removing instruction vicSelectGfxBank1_toDd001_from_vicSelectGfxBank1: Removing instruction vicSelectGfxBank1_toDd001: @@ -7551,7 +7542,6 @@ Removing instruction b10_from_b1: Removing instruction b2_from_b10: Removing instruction b1_from_b1: Succesful ASM optimization Pass5RedundantLabelElimination -Removing instruction b32: Removing instruction bend: Removing instruction vicSelectGfxBank1: Removing instruction vicSelectGfxBank1_b1: @@ -7627,6 +7617,9 @@ Removing instruction breturn: Removing instruction b1_from_fill: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Skipping double jump to b2 in bne b10 Skipping double jump to b2 in bne b10 Skipping double jump to b3 in beq b15 @@ -7645,6 +7638,7 @@ Removing instruction jmp b1 Succesful ASM optimization Pass5NextJumpElimination Removing instruction lda #0 Succesful ASM optimization Pass5UnnecesaryLoadElimination +Removing instruction bbegin: Removing instruction b10: Removing instruction b15: Removing instruction b10: @@ -7653,8 +7647,8 @@ Removing unreachable instruction jmp b2 Removing unreachable instruction jmp b3 Removing unreachable instruction jmp b2 Succesful ASM optimization Pass5UnreachableCodeElimination -Fixing long branch [150] bcc b1 to bcs -Fixing long branch [156] bcc b1 to bcs +Fixing long branch [141] bcc b1 to bcs +Fixing long branch [147] bcc b1 to bcs FINAL SYMBOL TABLE (label) @29 @@ -8171,11 +8165,11 @@ reg byte a [ bitmap_init::$7 ] FINAL ASSEMBLER -Score: 28381 +Score: 28375 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label PROCPORT_DDR = 0 @@ -8202,20 +8196,11 @@ Score: 28381 .label sin2 = $1400 .label rem16u = 2 //SEG2 @begin -bbegin: //SEG3 @29 -//SEG4 kickasm {{ .label pc_restore = * .pc = $1400 .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } .pc = pc_restore }} - .label pc_restore = * - .pc = $1400 - .for(var i=0; i<512; i++) { - .word sin(toRadians([i*360]/512))*320 - } - .pc = pc_restore - +//SEG4 kickasm(location (const signed word*) sin2#0) {{ .for(var i=0; i<512; i++) { .word sin(toRadians([i*360]/512))*320 } }} //SEG5 [2] phi from @29 to @32 [phi:@29->@32] //SEG6 @32 //SEG7 [3] call main - jsr main //SEG8 [4] phi from @32 to @end [phi:@32->@end] //SEG9 @end //SEG10 main @@ -9437,4 +9422,9 @@ fill: { bitmap_plot_bit: .fill $100, 0 .align $100 sin: .fill 2*$200, 0 +.pc = sin2 "Inline" + .for(var i=0; i<512; i++) { + .word sin(toRadians([i*360]/512))*320 + } + diff --git a/src/test/ref/examples/tetris/tetris.asm b/src/test/ref/examples/tetris/tetris.asm index 851af6508..975c0cac2 100644 --- a/src/test/ref/examples/tetris/tetris.asm +++ b/src/test/ref/examples/tetris/tetris.asm @@ -1,5 +1,5 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" .label RASTER = $d012 .label BORDERCOL = $d020 @@ -61,8 +61,6 @@ .label current_piece_73 = 5 .label current_piece_74 = 5 .label current_piece_75 = 5 -bbegin: - jsr main main: { .label key_event = $14 .label render = $15 diff --git a/src/test/ref/examples/tetris/tetris.log b/src/test/ref/examples/tetris/tetris.log index 405e88d01..4bcc63d41 100644 --- a/src/test/ref/examples/tetris/tetris.log +++ b/src/test/ref/examples/tetris/tetris.log @@ -12249,6 +12249,9 @@ Removing instruction breturn: Removing instruction breturn: Removing instruction breturn: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin Skipping double jump to b3 in bne b17 Succesful ASM optimization Pass5DoubleJumpElimination Relabelling long label breturn_from_b6 to b3 @@ -12274,6 +12277,7 @@ Removing instruction jmp b2 Removing instruction jmp b3 Succesful ASM optimization Pass5NextJumpElimination Replacing instruction ldy ypos2 with TAY +Removing instruction bbegin: Removing instruction b17: Succesful ASM optimization Pass5UnusedLabelElimination Removing unreachable instruction jmp b3 @@ -13115,11 +13119,11 @@ reg byte a [ render_init::$5 ] FINAL ASSEMBLER -Score: 416966 +Score: 416960 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels .label RASTER = $d012 @@ -13183,14 +13187,12 @@ Score: 416966 .label current_piece_74 = 5 .label current_piece_75 = 5 //SEG2 @begin -bbegin: //SEG3 @23 //SEG4 kickasm(location (const byte*) CHARSET#0) {{ .var charset = LoadPicture("charset.png", List().add($000000, $ffffff, $523fa0, $77c1c9)) .for (var c=0; c<16; c++) .for (var y=0;y<8; y++) .byte charset.getMulticolorByte(c,y) }} //SEG5 [2] phi from @23 to @26 [phi:@23->@26] //SEG6 @26 //SEG7 [3] call main //SEG8 [5] phi from @26 to main [phi:@26->main] - jsr main //SEG9 [4] phi from @26 to @end [phi:@26->@end] //SEG10 @end //SEG11 main diff --git a/src/test/ref/test-kasm.asm b/src/test/ref/test-kasm.asm index 5f674d28a..ac6f7bbc3 100644 --- a/src/test/ref/test-kasm.asm +++ b/src/test/ref/test-kasm.asm @@ -1,10 +1,8 @@ .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" -bbegin: .byte 1, 2, 3 - jsr main main: { b2: inc $d020 diff --git a/src/test/ref/test-kasm.log b/src/test/ref/test-kasm.log index 75a1e3f8e..1ae4b4e2c 100644 --- a/src/test/ref/test-kasm.log +++ b/src/test/ref/test-kasm.log @@ -167,6 +167,11 @@ Succesful ASM optimization Pass5RedundantLabelElimination Removing instruction main_from_b1: Removing instruction bend: Succesful ASM optimization Pass5UnusedLabelElimination +Updating BasicUpstart to call main directly +Removing instruction jsr main +Succesful ASM optimization Pass5SkipBegin +Removing instruction bbegin: +Succesful ASM optimization Pass5UnusedLabelElimination FINAL SYMBOL TABLE (label) @1 @@ -178,22 +183,20 @@ FINAL SYMBOL TABLE FINAL ASSEMBLER -Score: 2852 +Score: 2846 //SEG0 Basic Upstart .pc = $801 "Basic" -:BasicUpstart(bbegin) +:BasicUpstart(main) .pc = $80d "Program" //SEG1 Global Constants & labels //SEG2 @begin -bbegin: //SEG3 @1 //SEG4 kickasm {{ .byte 1, 2, 3 }} .byte 1, 2, 3 //SEG5 [2] call main //SEG6 [4] phi from @1 to main [phi:@1->main] - jsr main //SEG7 [3] phi from @1 to @end [phi:@1->@end] //SEG8 @end //SEG9 main