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:
parent
34909f47d8
commit
34d8afcaae
@ -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();
|
||||
|
@ -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 &&
|
||||
|
@ -0,0 +1 @@
|
||||
eor #$ff
|
@ -0,0 +1,2 @@
|
||||
clc
|
||||
adc #2
|
@ -0,0 +1,2 @@
|
||||
inx
|
||||
inx
|
@ -0,0 +1,2 @@
|
||||
iny
|
||||
iny
|
@ -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");
|
||||
|
16
src/test/java/dk/camelot64/kickc/test/kc/chessboard.kc
Normal file
16
src/test/java/dk/camelot64/kickc/test/kc/chessboard.kc
Normal 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;
|
||||
}
|
||||
}
|
5
src/test/java/dk/camelot64/kickc/test/kc/helloworld.kc
Normal file
5
src/test/java/dk/camelot64/kickc/test/kc/helloworld.kc
Normal file
@ -0,0 +1,5 @@
|
||||
import "print"
|
||||
void main() {
|
||||
print_str("hello world!@");
|
||||
print_ln();
|
||||
}
|
14
src/test/java/dk/camelot64/kickc/test/kc/helloworld2.kc
Normal file
14
src/test/java/dk/camelot64/kickc/test/kc/helloworld2.kc
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user