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

Added some simple test programs for the manual.

This commit is contained in:
jespergravgaard 2018-04-24 10:05:48 +02:00
parent 34909f47d8
commit 34d8afcaae
10 changed files with 65 additions and 2 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

@ -143,6 +143,12 @@ public class AsmFragmentInstanceSpec {
operator != null &&
(operator.getOperator().equals("-") || operator.getOperator().equals("+"))) {
signature.append("1");
} else if(
rValue2 instanceof ConstantInteger &&
((ConstantInteger) rValue2).getValue() == 2 &&
operator != null &&
(operator.getOperator().equals("-") || operator.getOperator().equals("+"))) {
signature.append("2");
} else if(
rValue2 instanceof ConstantInteger &&
((ConstantInteger) rValue2).getValue() <= 7 &&

View File

@ -0,0 +1 @@
eor #$ff

View File

@ -0,0 +1,2 @@
clc
adc #2

View File

@ -0,0 +1,2 @@
inx
inx

View File

@ -0,0 +1,2 @@
iny
iny

View File

@ -44,6 +44,21 @@ public class TestPrograms {
AsmFragmentTemplateUsages.logUsages(log, false, false, false, false, false, false);
}
@Test
public void testHelloWorld() throws IOException, URISyntaxException {
compileAndCompare("helloworld");
}
@Test
public void testHelloWorld2() throws IOException, URISyntaxException {
compileAndCompare("helloworld2");
}
@Test
public void testChessboard() throws IOException, URISyntaxException {
compileAndCompare("chessboard");
}
@Test
public void testFragmentSynth() throws IOException, URISyntaxException {
compileAndCompare("fragment-synth");

View File

@ -0,0 +1,16 @@
// Draws a chess board in the upper left corner of the screen
void main() {
byte* screen = $0400;
byte* colors = $d800;
byte color = 1;
for( byte row: 0..7) {
for( byte column: 0..7) {
screen[column] = $a0;
colors[column] = color;
color = color^1;
}
color = color^1;
screen = screen+40;
colors = colors+40;
}
}

View File

@ -0,0 +1,5 @@
import "print"
void main() {
print_str("hello world!@");
print_ln();
}

View File

@ -0,0 +1,14 @@
byte* screen = $400;
void main() {
byte* hello = "hello world!@";
print_spaced(screen, hello);
print_spaced(screen+40, hello);
}
void print_spaced(byte* at, byte* msg) {
byte j=0;
for(byte i=0; msg[i]!='@'; i++) {
screen[j] = msg[i];
j = j + 2;
}
}