1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-11-20 02:32:36 +00:00

Added rasterbar test program

This commit is contained in:
jespergravgaard 2018-01-15 22:16:25 +01:00
parent 13bd9509d1
commit 08f2e3a6b8
10 changed files with 2477 additions and 7 deletions

View File

@ -20,7 +20,7 @@ public class CompileLog {
/**
* Should fragment synthesis be verbose.
*/
private boolean verboseFragmentLog = false;
private boolean verboseFragmentLog = true;
/**
* Should ASM optimization be verbose.
@ -35,7 +35,7 @@ public class CompileLog {
/**
* Should the log be output to System.out while being built
*/
private boolean sysOut = false;
private boolean sysOut = true;
public CompileLog() {
this.log = new StringBuilder();

View File

@ -363,6 +363,10 @@ class AsmFragmentTemplateSynthesisRule {
// Rewrite Assignments to *Z1 from A
synths.add(new AsmFragmentTemplateSynthesisRule("_deref_pbuz1=(.*z1.*)", null, null, "vbuaa=$1", "ldy #0\n" + "sta ({z1}),y", null));
// Rewrite _deref_pb.z1_ to _vb.aa_ (if no other Z1s)
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)_deref_pb(.)z1_(.*)", ".*z1.*z1.*|.*z1.*=.*|.*yy.*", "ldy #0\n"+"lda ({z1}),y", "$1vb$2aa_$3", null, mapZ));
// OLD STYLE REWRITES - written when only one rule could be taken
//synths.add(new AsmFragmentTemplateSynthesisRule("(.*)=(.*)_(band|bor|bxor|plus)_(vb.aa)", ".*=vb.aa_.*", null, "$1=$4_$3_$2", null, null));
@ -496,6 +500,7 @@ class AsmFragmentTemplateSynthesisRule {
// Convert INC/DEC to +1/-1 ( ..._inc_xxx... -> ...xxx_plus_1_... / ..._dec_xxx... -> ...xxx_minus_1_... )
synths.add(new AsmFragmentTemplateSynthesisRule("vb(.)aa=_inc_(.*)", null, null, "vb$1aa=$2_plus_1", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("vb(.)aa=_dec_(.*)", null, null, "vb$1aa=$2_minus_1", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("vw(.)z1=_inc_vw(.z.)", null, null, "vw$1z1=vw$2_plus_1", null, null));
// Synthesize XX/YY using AA
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)=(.*)vbuxx(.*)", ".*=.*aa.*|.*derefidx_vb.xx.*", "txa", "$1=$2vbuaa$3", null, null));
@ -515,6 +520,7 @@ class AsmFragmentTemplateSynthesisRule {
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)=p..([cz].)_(plus|minus|bor|bxor)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("p..([cz].)=(.*)_(sethi|setlo|plus|minus)_(.*)", null, null, "vwu$1=$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("(.*)=p..([cz].)_(sethi|setlo|plus|minus)_(.*)", null, null, "$1=vwu$2_$3_$4", null, null));
synths.add(new AsmFragmentTemplateSynthesisRule("p..([cz].)=_(inc|dec)_p..([cz].)", null, null, "vwu$1=_$2_vwu$3", null, null));
return synths;
}

View File

@ -0,0 +1,2 @@
cmp #{c1}
beq {la1}

View File

@ -42,12 +42,16 @@ public class TestPrograms {
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
}
@Test
@Test
public void testRasterBars() throws IOException, URISyntaxException {
compileAndCompare("raster-bars");
}
@Test
public void testComparisons() throws IOException, URISyntaxException {
compileAndCompare("test-comparisons");
}
@Test
public void testMemAlignment() throws IOException, URISyntaxException {
compileAndCompare("mem-alignment");

View File

@ -20,6 +20,19 @@ const byte* SPRITES_COLS = $d027;
const byte* COLS = $d800;
const byte BLACK = 0;
const byte WHITE = 1;
const byte RED = 2;
const byte BLACK = $0;
const byte WHITE = $1;
const byte RED = $2;
const byte CYAN = $3;
const byte PURPLE = $4;
const byte GREEN = $5;
const byte BLUE = $6;
const byte YELLOW = $7;
const byte ORANGE = $8;
const byte BROWN = $9;
const byte PINK = $a;
const byte DARK_GREY= $b;
const byte GREY = $c;
const byte LIGHT_GREEN = $d;
const byte LIGHT_BLUE = $e;
const byte LIGHT_GREY = $f;

View File

@ -0,0 +1,71 @@
import "c64.kc"
void main() {
asm {
sei
}
do {
do {} while (*RASTER!=$a);
do {} while (*RASTER!=$b);
raster();
} while (true);
}
byte[] rastercols = { $b, $0, $b, $b, $c, $b, $c, $c, $f, $c, $f, $f, $1, $f, $1, $1, $f, $1, $f, $f, $c, $f, $c, $c, $b, $c, $b, $b, $0, $b, $0, $ff };
void raster() {
asm {
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
}
byte i = 0;
byte col = rastercols[i];
do {
*BGCOL = col;
*BORDERCOL = col;
col = rastercols[++i];
asm {
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
}
} while (col!=$ff);
}

View File

@ -0,0 +1,74 @@
.pc = $801 "Basic"
:BasicUpstart(main)
.pc = $80d "Program"
.const RASTER = $d012
.const BORDERCOL = $d020
.const BGCOL = $d021
jsr main
main: {
sei
b2:
lda RASTER
cmp #$a
bne b2
b3:
lda RASTER
cmp #$b
bne b3
jsr raster
jmp b2
}
raster: {
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
lda rastercols+0
ldx #0
b1:
sta BGCOL
sta BORDERCOL
inx
lda rastercols,x
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
nop
cmp #$ff
bne b1
rts
}
rastercols: .byte $b, 0, $b, $b, $c, $b, $c, $c, $f, $c, $f, $f, 1, $f, 1, 1, $f, 1, $f, $f, $c, $f, $c, $c, $b, $c, $b, $b, 0, $b, 0, $ff

View File

@ -0,0 +1,45 @@
@begin: scope:[] from
[0] phi() [ ] ( )
to:@2
@2: scope:[] from @begin
[1] phi() [ ] ( )
[2] call main param-assignment [ ] ( )
to:@end
@end: scope:[] from @2
[3] phi() [ ] ( )
main: scope:[main] from @2
asm { sei }
to:main::@2
main::@2: scope:[main] from main main::@2 main::@7
[5] if(*((const byte*) RASTER#0)!=(byte/signed byte/word/signed word) 10) goto main::@2 [ ] ( main:2 [ ] )
to:main::@3
main::@3: scope:[main] from main::@2 main::@3
[6] if(*((const byte*) RASTER#0)!=(byte/signed byte/word/signed word) 11) goto main::@3 [ ] ( main:2 [ ] )
to:main::@5
main::@5: scope:[main] from main::@3
[7] phi() [ ] ( main:2 [ ] )
[8] call raster param-assignment [ ] ( main:2 [ ] )
to:main::@7
main::@7: scope:[main] from main::@5
[9] if(true) goto main::@2 [ ] ( main:2 [ ] )
to:main::@return
main::@return: scope:[main] from main::@7
[10] return [ ] ( main:2 [ ] )
to:@return
raster: scope:[raster] from main::@5
asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop }
[12] (byte) raster::col#0 ← *((const byte[]) rastercols#0+(byte/signed byte/word/signed word) 0) [ raster::col#0 ] ( main:2::raster:8 [ raster::col#0 ] )
to:raster::@1
raster::@1: scope:[raster] from raster raster::@1
[13] (byte) raster::i#2 ← phi( raster/(byte/signed byte/word/signed word) 0 raster::@1/(byte) raster::i#1 ) [ raster::col#2 raster::i#2 ] ( main:2::raster:8 [ raster::col#2 raster::i#2 ] )
[13] (byte) raster::col#2 ← phi( raster/(byte) raster::col#0 raster::@1/(byte) raster::col#1 ) [ raster::col#2 raster::i#2 ] ( main:2::raster:8 [ raster::col#2 raster::i#2 ] )
[14] *((const byte*) BGCOL#0) ← (byte) raster::col#2 [ raster::col#2 raster::i#2 ] ( main:2::raster:8 [ raster::col#2 raster::i#2 ] )
[15] *((const byte*) BORDERCOL#0) ← (byte) raster::col#2 [ raster::i#2 ] ( main:2::raster:8 [ raster::i#2 ] )
[16] (byte) raster::i#1 ← ++ (byte) raster::i#2 [ raster::i#1 ] ( main:2::raster:8 [ raster::i#1 ] )
[17] (byte) raster::col#1 ← *((const byte[]) rastercols#0 + (byte) raster::i#1) [ raster::col#1 raster::i#1 ] ( main:2::raster:8 [ raster::col#1 raster::i#1 ] )
asm { nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop nop }
[19] if((byte) raster::col#1!=(byte/word/signed word) 255) goto raster::@1 [ raster::col#1 raster::i#1 ] ( main:2::raster:8 [ raster::col#1 raster::i#1 ] )
to:raster::@return
raster::@return: scope:[raster] from raster::@1
[20] return [ ] ( main:2::raster:8 [ ] )
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,30 @@
(label) @2
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = ((byte*))(word) 53281
(byte*) BORDERCOL
(const byte*) BORDERCOL#0 BORDERCOL = ((byte*))(word) 53280
(byte*) RASTER
(const byte*) RASTER#0 RASTER = ((byte*))(word) 53266
(void()) main()
(label) main::@2
(label) main::@3
(label) main::@5
(label) main::@7
(label) main::@return
(void()) raster()
(label) raster::@1
(label) raster::@return
(byte) raster::col
(byte) raster::col#0 reg byte a 4.0
(byte) raster::col#1 reg byte a 101.0
(byte) raster::col#2 reg byte a 152.5
(byte) raster::i
(byte) raster::i#1 reg byte x 75.75
(byte) raster::i#2 reg byte x 67.33333333333333
(byte[]) rastercols
(const byte[]) rastercols#0 rastercols = { (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 0, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 1, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 15, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 12, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 0, (byte/signed byte/word/signed word) 11, (byte/signed byte/word/signed word) 0, (byte/word/signed word) 255 }
reg byte a [ raster::col#2 raster::col#0 raster::col#1 ]
reg byte x [ raster::i#2 raster::i#1 ]