1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-12-26 18:29:54 +00:00

Added a bunch of test cases highlighting each known error

This commit is contained in:
jespergravgaard 2017-10-29 11:41:35 +01:00
parent 00f53c49b6
commit c4c60a5b36
14 changed files with 9656 additions and 33 deletions

View File

@ -1,8 +1,10 @@
Known Problems
- Increment/decrement of value pointed to by pointer does not work. eg. byte* BGCOL = $d020; (*BGCOL)++;
- Arrays / strings allocated inline destroy functions (because they are allocated where the call enters.
- Classic for() does not allow assignment as increment, eg. for(byte i=0;i<25;i=i+2) {}
- Range-based for does not recognize symbolic constants. The following gives a ParseTreeConstantEvaluator$NotConstantException - const byte* BITMAP = $2000; for(byte* b : BITMAP..BITMAP+$2000) { *b = 0; }
- (incd020.kc) Increment/decrement of value pointed to by pointer does not work. eg. byte* BGCOL = $d020; (*BGCOL)++;
- (inlinearrayproblem.kc) Arrays / strings allocated inline destroy functions (because they are allocated where the call enters.
- (forincrementassign.kc) Classic for() does not allow assignment as increment, eg. for(byte i=0;i<25;i=i+2) {}
- (forrangesymbolic.kc) Range-based for does not recognize symbolic constants. The following gives a ParseTreeConstantEvaluator$NotConstantException - const byte* BITMAP = $2000; for(byte* b : BITMAP..BITMAP+$2000) { *b = 0; }
- (wordexpr.kc) Expressions based on bytes but resulting in words are erronously infered as bytes - eg. yoffs = yoffs + 40*8;
- (useuninitialized.kc) Using an uninitialized variable fails in the optimizer phase. It should fail much earlier.
Features
- Move the main code into a main() function, and disallow code outside functions. The main function per default has no parameters and exits with RTS.

View File

@ -0,0 +1,83 @@
package dk.camelot64.kickc.test;
import dk.camelot64.kickc.Compiler;
import dk.camelot64.kickc.model.CompileError;
import dk.camelot64.kickc.model.Program;
import junit.framework.TestCase;
import org.antlr.v4.runtime.CharStream;
import org.antlr.v4.runtime.CharStreams;
import java.io.IOException;
import java.net.URISyntaxException;
/**
* Some failing tests highlighting errors/problems in KickC
*/
public class TestErrors extends TestCase {
ReferenceHelper helper;
String testPath;
public TestErrors() throws IOException {
testPath = "src/main/java/dk/camelot64/kickc/test/";
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
}
public void testIncD020() throws IOException, URISyntaxException {
compileAndCompare("incd020");
}
public void testUseUninitialized() throws IOException, URISyntaxException {
String filename = "useuninitialized";
compileAndCompare(filename);
}
public void testWordExpr() throws IOException, URISyntaxException {
String filename = "wordexpr";
compileAndCompare(filename);
}
public void testForRangeSymbolic() throws IOException, URISyntaxException {
String filename = "forrangesymbolic";
compileAndCompare(filename);
}
public void testInlineArrayProblem() throws IOException, URISyntaxException {
String filename = "inlinearrayproblem";
compileAndCompare(filename);
}
public void testForIncrementAssign() throws IOException, URISyntaxException {
String filename = "forincrementassign";
compileAndCompare(filename);
}
public void testCallConstParamProblem() throws IOException, URISyntaxException {
String filename = "callconstparamproblem";
compileAndCompare(filename);
}
private void compileAndCompare(String filename) throws IOException, URISyntaxException {
TestErrors tester = new TestErrors();
tester.testFile(filename);
}
private void testFile(String fileName) throws IOException, URISyntaxException {
String inputPath = testPath + fileName + ".kc";
System.out.println("Testing output for " + inputPath);
CharStream input = CharStreams.fromFileName(inputPath);
Compiler compiler = new Compiler();
Program program = compiler.compile(input);
boolean success = true;
success &= helper.testOutput(fileName, ".asm", program.getAsm().toString(false));
success &= helper.testOutput(fileName, ".sym", program.getScope().getSymbolTableContents(program));
success &= helper.testOutput(fileName, ".cfg", program.getGraph().toString(program));
success &= helper.testOutput(fileName, ".log", program.getLog().toString());
if (!success) {
fail("Output does not match reference!");
}
}
}

View File

@ -13,13 +13,13 @@ import java.net.URISyntaxException;
/**
* Compile a number of source files and compare the resulting assembler with expected output
*/
public class TestCompilationOutput extends TestCase {
public class TestPrograms extends TestCase {
ReferenceHelper helper;
String testPath;
public TestCompilationOutput() throws IOException {
public TestPrograms() throws IOException {
testPath = "src/main/java/dk/camelot64/kickc/test/";
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
}
@ -40,10 +40,6 @@ public class TestCompilationOutput extends TestCase {
compileAndCompare("literals");
}
public void testIncD020() throws IOException, URISyntaxException {
compileAndCompare("incd020");
}
public void testScroll() throws IOException, URISyntaxException {
compileAndCompare("scroll");
}
@ -144,11 +140,6 @@ public class TestCompilationOutput extends TestCase {
compileAndCompare("forrangemin");
}
public void testUseUninitialized() throws IOException, URISyntaxException {
String filename = "useuninitialized";
compileAndCompare(filename);
}
public void testUseUndeclared() throws IOException, URISyntaxException {
try {
compileAndCompare("useundeclared");
@ -161,7 +152,7 @@ public class TestCompilationOutput extends TestCase {
private void compileAndCompare(String filename) throws IOException, URISyntaxException {
TestCompilationOutput tester = new TestCompilationOutput();
TestPrograms tester = new TestPrograms();
tester.testFile(filename);
}

View File

@ -18,8 +18,6 @@ byte CSEL = %00001000;
byte* SCREEN = $400;
const byte* BITMAP = $2000;
// TODO: Make all arrays in-program allocations - byte[$100] plot_xlo;
// TODO: Create a fill-like array initialization - byte[$100] plot_xlo = { [x] = x&$f8 };
byte[] plot_xlo = $1000;
byte[] plot_xhi = $1100;
byte[] plot_ylo = $1200;
@ -30,8 +28,7 @@ void main() {
*BGCOL = 0;
*FGCOL = 0;
*D011 = BMM|DEN|RSEL|3;
//TODO: Add ability to cast byte* to word. *D018 = ((word)SCREEN/$40)|((word)BITMAP/$400);
*D018 = $18;
*D018 = $18; // Needs casting for *D018 = ((word)SCREEN/$40)|((word)BITMAP/$400);
initscreen();
initplottables();
// TODO: Error with constant identification of the parameters!
@ -40,7 +37,6 @@ void main() {
}
void line(byte x0, byte y0, byte x1, byte y1) {
//byte* plotter;
byte xd = x1-x0;
byte yd = y1-y0;
byte x = x0;
@ -48,11 +44,7 @@ void line(byte x0, byte y0, byte x1, byte y1) {
byte e = yd>>1;
do {
plot(x,y);
// TODO: Nice2have: Support array-initializer as words. plotter = { plot_xlo[x]+plot_ylo[y], plot_xhi[x]+plot_yhi[y] };
// TODO: Need2have: Ensure coalescing of plotter#0 and plotter#1 into a single live range equivalence class.
//<plotter = plot_xlo[x]+plot_ylo[y];
//>plotter = plot_xhi[x]+plot_yhi[y];
//*plotter = *plotter | plot_bit[x];
// TODO: Ensure coalescing of plotter#0 and plotter#1 into a single live range equivalence class.
x = x + 1;
e = e+yd;
if(xd<e) {
@ -63,7 +55,6 @@ void line(byte x0, byte y0, byte x1, byte y1) {
}
void initscreen() {
//TODO: Fix problem in interval-based for-loop: for(byte* b = BITMAP..BITMAP+$2000; b++)
for(byte* b = BITMAP; b!=BITMAP+$2000; b++) {
*b = 0;
}
@ -89,23 +80,20 @@ void initplottables() {
plot_ylo[y] = y&$7 | <yoffs;
plot_yhi[y] = >yoffs;
if((y&$7)==7) {
// TODO: Error: Identify 8*40 as a word constant (not a byte)
yoffs = yoffs + 320;
yoffs = yoffs + 320; // Needs better constant type inference for yoffs = yoffs + 40*8;
}
}
}
// TODO: Implement inline functions (will be perfect for plot)
void plot(byte x, byte y) {
// TODO: This assignment is needed - to avoid plotter var being destroyed during compilation. Find a way to eliminate it.
byte* plotter = BITMAP;
<plotter = plot_xlo[x]+plot_ylo[y];
>plotter = plot_xhi[x]+plot_yhi[y];
// TODO: Error - <plotter can overflow - and carry must then be added to the >plotter part. Requires new logic?
// TODO: <plotter can overflow - and carry must then be added to the >plotter part. Requires new logic?
*plotter = *plotter | plot_bit[x];
}
//TODO: Add a default main()-call.
main();

View File

@ -0,0 +1,10 @@
// Classic for() does not allow assignment as increment, eg. for(byte i=0;i<25;i=i+2) {}
// The following should give a program rendering a char on every second char of the first line - but results in a syntax error
byte* SCREEN = $0400;
main();
void main() {
for(byte i=0;i<40;i=i+2) {
SCREEN[i] = i;
}
}

View File

@ -0,0 +1,11 @@
// Range-based for does not recognize symbolic constants.
// The following should work but gives a not-constant exception
main();
void main() {
const byte* BITMAP = $2000;
for(byte* b : BITMAP..BITMAP+$2000) {
*b = $5a;
}
}

View File

@ -1,3 +1,6 @@
// Incrementing / decrementing pointer content should result in code modifying the memory location - eg. inc $d020.
// Currently it does not but instead leads to just reading the value a few times.
byte* BGCOL = $d020;
main();
void main() {

View File

@ -0,0 +1,11 @@
// Arrays / strings allocated inline destroy functions (because they are allocated where the call enters.
// The following places the text at the start of the main-function - and JSR's straight into the text - not the code.
byte* SCREEN = $0400;
main();
void main() {
byte[] txt = "qwe";
for( byte i : 0..3) {
SCREEN[i] = txt[i];
}
}

View File

@ -0,0 +1,218 @@
.const COLS = $d800
.const BGCOL = $d020
.const FGCOL = $d021
.const SCROLL = $d016
.const D018 = $d018
.const D011 = $d011
.const RST8 = $80
.const ECM = $40
.const BMM = $20
.const DEN = $10
.const RSEL = 8
.const D016 = $d016
.const MCM = $10
.const CSEL = 8
.const SCREEN = $400
.const BITMAP = $2000
.const plot_xlo = $1000
.const plot_xhi = $1100
.const plot_ylo = $1200
.const plot_yhi = $1300
.const plot_bit = $1400
jsr main
main: {
lda #0
sta BGCOL
sta FGCOL
lda #BMM|DEN|RSEL|3
sta D011
lda #$18
sta D018
jsr initscreen
jsr initplottables
lda #y0
sta line.y
ldx #$a
lda #x0
sta line.x
lda #$14
sta line.x1
jsr line
lda #y0
sta line.y
ldx #$28
lda #x0
sta line.x
lda #$28
sta line.x1
jsr line
rts
}
line: {
.const x0 = 0
.const y0 = 0
.label xd = 8
.label yd = 9
.label x = 3
.label y = 4
.label e = 5
.label x1 = 2
lda x1
sec
sbc x
sta xd
txa
sec
sbc y
sta yd
lda yd
lsr
sta e
b1:
ldx x
ldy y
jsr plot
inc x
lda e
clc
adc yd
sta e
lda xd
cmp e
bcs b2
inc y
lda e
sec
sbc xd
sta e
b2:
lda x1
clc
adc #1
cmp x
bcs b1
rts
}
plot: {
.label _0 = 10
.label _3 = 10
.label _6 = 10
.label plotter = 6
lda plot_xlo,x
sta _0
lda plot_ylo,y
clc
adc _0
sta plotter
lda #>BITMAP
sta plotter+1
lda plot_xhi,x
sta _3
lda plot_yhi,y
clc
adc _3
sta plotter+1
ldy #0
lda (plotter),y
sta _6
lda plot_bit,x
ora _6
sta (plotter),y
rts
}
initplottables: {
.label _6 = 2
.label yoffs = 6
ldy #$80
ldx #0
b1:
txa
and #$f8
sta plot_xlo,x
lda #>BITMAP
sta plot_xhi,x
tya
sta plot_bit,x
tya
lsr
tay
cpy #0
bne b10
ldy #$80
b2:
inx
cpx #0
bne b1
lda #0
sta yoffs
sta yoffs+1
ldx #0
b3:
txa
and #7
sta _6
lda yoffs
ora _6
sta plot_ylo,x
lda yoffs+1
sta plot_yhi,x
txa
and #7
cmp #7
bne b4
lda yoffs
clc
adc #<$140
sta yoffs
lda yoffs+1
adc #>$140
sta yoffs+1
b4:
inx
cpx #0
bne b3
rts
b10:
jmp b2
}
initscreen: {
.label b = 6
.label c = 6
lda #<BITMAP
sta b
lda #>BITMAP
sta b+1
b1:
ldy #0
lda #0
sta (b),y
inc b
bne !+
inc b+1
!:
lda b+1
cmp #>BITMAP+$2000
bne b1
lda b
cmp #<BITMAP+$2000
bne b1
lda #<SCREEN
sta c
lda #>SCREEN
sta c+1
b2:
ldy #0
lda #$14
sta (c),y
inc c
bne !+
inc c+1
!:
lda c+1
cmp #>SCREEN+$400
bne b2
lda c
cmp #<SCREEN+$400
bne b2
rts
}

View File

@ -0,0 +1,138 @@
@begin: scope:[] from
to:@5
@5: scope:[] from @begin
[0] call main param-assignment [ ]
to:@end
@end: scope:[] from @5
main: scope:[main] from @5
[1] *((const byte*) BGCOL#0) ← (byte) 0 [ ]
[2] *((const byte*) FGCOL#0) ← (byte) 0 [ ]
[3] *((const byte*) D011#0) ← (const byte) BMM#0|(const byte) DEN#0|(const byte) RSEL#0|(byte) 3 [ ]
[4] *((const byte*) D018#0) ← (byte) 24 [ ]
[5] call initscreen param-assignment [ ]
to:main::@1
main::@1: scope:[main] from main
[6] call initplottables param-assignment [ ]
to:main::@2
main::@2: scope:[main] from main::@1
[7] call line param-assignment [ ]
to:main::@3
main::@3: scope:[main] from main::@2
[8] call line param-assignment [ ]
to:main::@return
main::@return: scope:[main] from main::@3
[9] return [ ]
to:@return
line: scope:[line] from main::@2 main::@3
[10] (byte) line::y#0 ← phi( main::@2/(const byte) line::y0#0 main::@3/(const byte) line::y0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ]
[10] (byte) line::y1#2 ← phi( main::@2/(byte) 10 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ]
[10] (byte) line::x#0 ← phi( main::@2/(const byte) line::x0#0 main::@3/(const byte) line::x0#1 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ]
[10] (byte) line::x1#2 ← phi( main::@2/(byte) 20 main::@3/(byte) 40 ) [ line::x1#2 line::x#0 line::y1#2 line::y#0 ]
[11] (byte) line::xd#0 ← (byte) line::x1#2 - (byte) line::x#0 [ line::x1#2 line::x#0 line::y1#2 line::y#0 line::xd#0 ]
[12] (byte) line::yd#0 ← (byte) line::y1#2 - (byte) line::y#0 [ line::x1#2 line::x#0 line::y#0 line::xd#0 line::yd#0 ]
[13] (byte) line::e#0 ← (byte) line::yd#0 >> (byte) 1 [ line::x1#2 line::x#0 line::y#0 line::xd#0 line::yd#0 line::e#0 ]
to:line::@1
line::@1: scope:[line] from line line::@2
[14] (byte) line::e#3 ← phi( line/(byte) line::e#0 line::@2/(byte) line::e#6 ) [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 ]
[14] (byte) line::y#2 ← phi( line/(byte) line::y#0 line::@2/(byte) line::y#4 ) [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 ]
[14] (byte) line::x#2 ← phi( line/(byte) line::x#0 line::@2/(byte) line::x#1 ) [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 ]
[15] (byte) plot::x#0 ← (byte) line::x#2 [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 plot::x#0 ]
[16] (byte) plot::y#0 ← (byte) line::y#2 [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 plot::x#0 plot::y#0 ]
[17] call plot param-assignment [ line::x1#2 line::xd#0 line::yd#0 line::x#2 line::y#2 line::e#3 ]
to:line::@5
line::@5: scope:[line] from line::@1
[18] (byte) line::x#1 ← (byte) line::x#2 + (byte) 1 [ line::x1#2 line::xd#0 line::yd#0 line::y#2 line::e#3 line::x#1 ]
[19] (byte) line::e#1 ← (byte) line::e#3 + (byte) line::yd#0 [ line::x1#2 line::xd#0 line::yd#0 line::y#2 line::x#1 line::e#1 ]
[20] if((byte) line::xd#0>=(byte) line::e#1) goto line::@2 [ line::x1#2 line::xd#0 line::yd#0 line::y#2 line::x#1 line::e#1 ]
to:line::@3
line::@3: scope:[line] from line::@5
[21] (byte) line::y#1 ← (byte) line::y#2 + (byte) 1 [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::e#1 line::y#1 ]
[22] (byte) line::e#2 ← (byte) line::e#1 - (byte) line::xd#0 [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::y#1 line::e#2 ]
to:line::@2
line::@2: scope:[line] from line::@3 line::@5
[23] (byte) line::e#6 ← phi( line::@3/(byte) line::e#2 line::@5/(byte) line::e#1 ) [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::y#4 line::e#6 ]
[23] (byte) line::y#4 ← phi( line::@3/(byte) line::y#1 line::@5/(byte) line::y#2 ) [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::y#4 line::e#6 ]
[24] (byte~) line::$10 ← (byte) line::x1#2 + (byte) 1 [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::y#4 line::e#6 line::$10 ]
[25] if((byte) line::x#1<(byte~) line::$10) goto line::@1 [ line::x1#2 line::xd#0 line::yd#0 line::x#1 line::y#4 line::e#6 ]
to:line::@return
line::@return: scope:[line] from line::@2
[26] return [ ]
to:@return
plot: scope:[plot] from line::@1
[27] (byte~) plot::$0 ← (const byte[]) plot_xlo#0 *idx (byte) plot::x#0 [ plot::x#0 plot::y#0 plot::$0 ]
[28] (byte~) plot::$1 ← (const byte[]) plot_ylo#0 *idx (byte) plot::y#0 [ plot::x#0 plot::y#0 plot::$0 plot::$1 ]
[29] (byte~) plot::$2 ← (byte~) plot::$0 + (byte~) plot::$1 [ plot::x#0 plot::y#0 plot::$2 ]
[30] (byte*) plot::plotter#1 ← (const byte*) BITMAP#0 lo= (byte~) plot::$2 [ plot::x#0 plot::y#0 plot::plotter#1 ]
[31] (byte~) plot::$3 ← (const byte[]) plot_xhi#0 *idx (byte) plot::x#0 [ plot::x#0 plot::y#0 plot::plotter#1 plot::$3 ]
[32] (byte~) plot::$4 ← (const byte[]) plot_yhi#0 *idx (byte) plot::y#0 [ plot::x#0 plot::plotter#1 plot::$3 plot::$4 ]
[33] (byte~) plot::$5 ← (byte~) plot::$3 + (byte~) plot::$4 [ plot::x#0 plot::plotter#1 plot::$5 ]
[34] (byte*) plot::plotter#2 ← (byte*) plot::plotter#1 hi= (byte~) plot::$5 [ plot::x#0 plot::plotter#2 ]
[35] (byte~) plot::$6 ← * (byte*) plot::plotter#2 [ plot::x#0 plot::plotter#2 plot::$6 ]
[36] (byte~) plot::$7 ← (const byte[]) plot_bit#0 *idx (byte) plot::x#0 [ plot::plotter#2 plot::$6 plot::$7 ]
[37] (byte~) plot::$8 ← (byte~) plot::$6 | (byte~) plot::$7 [ plot::plotter#2 plot::$8 ]
[38] *((byte*) plot::plotter#2) ← (byte~) plot::$8 [ ]
to:plot::@return
plot::@return: scope:[plot] from plot
[39] return [ ]
to:@return
initplottables: scope:[initplottables] from main::@1
[40] phi() [ ]
to:initplottables::@1
initplottables::@1: scope:[initplottables] from initplottables initplottables::@2
[41] (byte) initplottables::bit#3 ← phi( initplottables/(byte) 128 initplottables::@2/(byte) initplottables::bit#4 ) [ initplottables::x#2 initplottables::bit#3 ]
[41] (byte) initplottables::x#2 ← phi( initplottables/(byte) 0 initplottables::@2/(byte) initplottables::x#1 ) [ initplottables::x#2 initplottables::bit#3 ]
[42] (byte~) initplottables::$0 ← (byte) initplottables::x#2 & (byte) 248 [ initplottables::x#2 initplottables::bit#3 initplottables::$0 ]
[43] *((const byte[]) plot_xlo#0 + (byte) initplottables::x#2) ← (byte~) initplottables::$0 [ initplottables::x#2 initplottables::bit#3 ]
[44] *((const byte[]) plot_xhi#0 + (byte) initplottables::x#2) ← >(const byte*) BITMAP#0 [ initplottables::x#2 initplottables::bit#3 ]
[45] *((const byte[]) plot_bit#0 + (byte) initplottables::x#2) ← (byte) initplottables::bit#3 [ initplottables::x#2 initplottables::bit#3 ]
[46] (byte) initplottables::bit#1 ← (byte) initplottables::bit#3 >> (byte) 1 [ initplottables::x#2 initplottables::bit#1 ]
[47] if((byte) initplottables::bit#1!=(byte) 0) goto initplottables::@10 [ initplottables::x#2 ]
to:initplottables::@2
initplottables::@2: scope:[initplottables] from initplottables::@1 initplottables::@10
[48] (byte) initplottables::bit#4 ← phi( initplottables::@10/(byte) initplottables::bit#1 initplottables::@1/(byte) 128 ) [ initplottables::x#2 initplottables::bit#4 ]
[49] (byte) initplottables::x#1 ← ++ (byte) initplottables::x#2 [ initplottables::x#1 initplottables::bit#4 ]
[50] if((byte) initplottables::x#1!=(byte) 0) goto initplottables::@1 [ initplottables::x#1 initplottables::bit#4 ]
to:initplottables::@3
initplottables::@3: scope:[initplottables] from initplottables::@2 initplottables::@4
[51] (byte*) initplottables::yoffs#2 ← phi( initplottables::@4/(byte*) initplottables::yoffs#4 initplottables::@2/(byte) 0 ) [ initplottables::y#2 initplottables::yoffs#2 ]
[51] (byte) initplottables::y#2 ← phi( initplottables::@4/(byte) initplottables::y#1 initplottables::@2/(byte) 0 ) [ initplottables::y#2 initplottables::yoffs#2 ]
[52] (byte~) initplottables::$6 ← (byte) initplottables::y#2 & (byte) 7 [ initplottables::y#2 initplottables::yoffs#2 initplottables::$6 ]
[53] (byte~) initplottables::$7 ← < (byte*) initplottables::yoffs#2 [ initplottables::y#2 initplottables::yoffs#2 initplottables::$6 initplottables::$7 ]
[54] (byte~) initplottables::$8 ← (byte~) initplottables::$6 | (byte~) initplottables::$7 [ initplottables::y#2 initplottables::yoffs#2 initplottables::$8 ]
[55] *((const byte[]) plot_ylo#0 + (byte) initplottables::y#2) ← (byte~) initplottables::$8 [ initplottables::y#2 initplottables::yoffs#2 ]
[56] (byte~) initplottables::$9 ← > (byte*) initplottables::yoffs#2 [ initplottables::y#2 initplottables::yoffs#2 initplottables::$9 ]
[57] *((const byte[]) plot_yhi#0 + (byte) initplottables::y#2) ← (byte~) initplottables::$9 [ initplottables::y#2 initplottables::yoffs#2 ]
[58] (byte~) initplottables::$10 ← (byte) initplottables::y#2 & (byte) 7 [ initplottables::y#2 initplottables::yoffs#2 initplottables::$10 ]
[59] if((byte~) initplottables::$10!=(byte) 7) goto initplottables::@4 [ initplottables::y#2 initplottables::yoffs#2 ]
to:initplottables::@7
initplottables::@7: scope:[initplottables] from initplottables::@3
[60] (byte*) initplottables::yoffs#1 ← (byte*) initplottables::yoffs#2 + (word) 320 [ initplottables::y#2 initplottables::yoffs#1 ]
to:initplottables::@4
initplottables::@4: scope:[initplottables] from initplottables::@3 initplottables::@7
[61] (byte*) initplottables::yoffs#4 ← phi( initplottables::@3/(byte*) initplottables::yoffs#2 initplottables::@7/(byte*) initplottables::yoffs#1 ) [ initplottables::y#2 initplottables::yoffs#4 ]
[62] (byte) initplottables::y#1 ← ++ (byte) initplottables::y#2 [ initplottables::y#1 initplottables::yoffs#4 ]
[63] if((byte) initplottables::y#1!=(byte) 0) goto initplottables::@3 [ initplottables::y#1 initplottables::yoffs#4 ]
to:initplottables::@return
initplottables::@return: scope:[initplottables] from initplottables::@4
[64] return [ ]
to:@return
initplottables::@10: scope:[initplottables] from initplottables::@1
to:initplottables::@2
initscreen: scope:[initscreen] from main
[65] phi() [ ]
to:initscreen::@1
initscreen::@1: scope:[initscreen] from initscreen initscreen::@1
[66] (byte*) initscreen::b#2 ← phi( initscreen/(const byte*) BITMAP#0 initscreen::@1/(byte*) initscreen::b#1 ) [ initscreen::b#2 ]
[67] *((byte*) initscreen::b#2) ← (byte) 0 [ initscreen::b#2 ]
[68] (byte*) initscreen::b#1 ← ++ (byte*) initscreen::b#2 [ initscreen::b#1 ]
[69] if((byte*) initscreen::b#1!=(const byte*) BITMAP#0+(word) 8192) goto initscreen::@1 [ initscreen::b#1 ]
to:initscreen::@2
initscreen::@2: scope:[initscreen] from initscreen::@1 initscreen::@2
[70] (byte*) initscreen::c#2 ← phi( initscreen::@2/(byte*) initscreen::c#1 initscreen::@1/(const byte*) SCREEN#0 ) [ initscreen::c#2 ]
[71] *((byte*) initscreen::c#2) ← (byte) 20 [ initscreen::c#2 ]
[72] (byte*) initscreen::c#1 ← ++ (byte*) initscreen::c#2 [ initscreen::c#1 ]
[73] if((byte*) initscreen::c#1!=(const byte*) SCREEN#0+(word) 1024) goto initscreen::@2 [ initscreen::c#1 ]
to:initscreen::@return
initscreen::@return: scope:[initscreen] from initscreen::@2
[74] return [ ]
to:@return

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,169 @@
(label) @5
(label) @begin
(label) @end
(byte*) BGCOL
(const byte*) BGCOL#0 BGCOL = (word) 53280
(byte*) BITMAP
(const byte*) BITMAP#0 BITMAP = (word) 8192
(byte) BMM
(const byte) BMM#0 BMM = (byte) 32
(byte*) COLS
(const byte*) COLS#0 COLS = (word) 55296
(byte) CSEL
(const byte) CSEL#0 CSEL = (byte) 8
(byte*) D011
(const byte*) D011#0 D011 = (word) 53265
(byte*) D016
(const byte*) D016#0 D016 = (word) 53270
(byte*) D018
(const byte*) D018#0 D018 = (word) 53272
(byte) DEN
(const byte) DEN#0 DEN = (byte) 16
(byte) ECM
(const byte) ECM#0 ECM = (byte) 64
(byte*) FGCOL
(const byte*) FGCOL#0 FGCOL = (word) 53281
(byte) MCM
(const byte) MCM#0 MCM = (byte) 16
(byte) RSEL
(const byte) RSEL#0 RSEL = (byte) 8
(byte) RST8
(const byte) RST8#0 RST8 = (byte) 128
(byte*) SCREEN
(const byte*) SCREEN#0 SCREEN = (word) 1024
(byte*) SCROLL
(const byte*) SCROLL#0 SCROLL = (word) 53270
(void()) initplottables()
(byte~) initplottables::$0 reg byte a 22.0
(byte~) initplottables::$10 reg byte a 22.0
(byte~) initplottables::$6 $6 zp ZP_BYTE:2 11.0
(byte~) initplottables::$7 reg byte a 22.0
(byte~) initplottables::$8 reg byte a 22.0
(byte~) initplottables::$9 reg byte a 22.0
(label) initplottables::@1
(label) initplottables::@10
(label) initplottables::@2
(label) initplottables::@3
(label) initplottables::@4
(label) initplottables::@7
(label) initplottables::@return
(byte) initplottables::bit
(byte) initplottables::bit#1 reg byte y 33.0
(byte) initplottables::bit#3 reg byte y 6.6000000000000005
(byte) initplottables::bit#4 reg byte y 7.333333333333333
(byte) initplottables::x
(byte) initplottables::x#1 reg byte x 16.5
(byte) initplottables::x#2 reg byte x 8.25
(byte) initplottables::y
(byte) initplottables::y#1 reg byte x 16.5
(byte) initplottables::y#2 reg byte x 6.0
(byte*) initplottables::yoffs
(byte*) initplottables::yoffs#1 yoffs zp ZP_PTR_BYTE:6 22.0
(byte*) initplottables::yoffs#2 yoffs zp ZP_PTR_BYTE:6 6.111111111111112
(byte*) initplottables::yoffs#4 yoffs zp ZP_PTR_BYTE:6 11.0
(void()) initscreen()
(label) initscreen::@1
(label) initscreen::@2
(label) initscreen::@return
(byte*) initscreen::b
(byte*) initscreen::b#1 b zp ZP_PTR_BYTE:6 16.5
(byte*) initscreen::b#2 b zp ZP_PTR_BYTE:6 16.5
(byte*) initscreen::c
(byte*) initscreen::c#1 c zp ZP_PTR_BYTE:6 16.5
(byte*) initscreen::c#2 c zp ZP_PTR_BYTE:6 16.5
(void()) line((byte) line::x0 , (byte) line::y0 , (byte) line::x1 , (byte) line::y1)
(byte~) line::$10 reg byte a 22.0
(label) line::@1
(label) line::@2
(label) line::@3
(label) line::@5
(label) line::@return
(byte) line::e
(byte) line::e#0 e zp ZP_BYTE:5 4.0
(byte) line::e#1 e zp ZP_BYTE:5 14.666666666666666
(byte) line::e#2 e zp ZP_BYTE:5 22.0
(byte) line::e#3 e zp ZP_BYTE:5 4.800000000000001
(byte) line::e#6 e zp ZP_BYTE:5 11.0
(byte) line::x
(byte) line::x#0 x zp ZP_BYTE:3 1.0
(byte) line::x#1 x zp ZP_BYTE:3 4.125
(byte) line::x#2 x zp ZP_BYTE:3 8.75
(byte) line::x0
(const byte) line::x0#0 x0 = (byte) 0
(const byte) line::x0#1 x0 = (byte) 10
(byte) line::x1
(byte) line::x1#2 x1 zp ZP_BYTE:2 0.8125
(byte) line::xd
(byte) line::xd#0 xd zp ZP_BYTE:8 1.5999999999999999
(byte) line::y
(byte) line::y#0 y zp ZP_BYTE:4 1.0
(byte) line::y#1 y zp ZP_BYTE:4 11.0
(byte) line::y#2 y zp ZP_BYTE:4 6.571428571428571
(byte) line::y#4 y zp ZP_BYTE:4 11.0
(byte) line::y0
(const byte) line::y0#0 y0 = (byte) 0
(const byte) line::y0#1 y0 = (byte) 20
(byte) line::y1
(byte) line::y1#2 reg byte x 1.0
(byte) line::yd
(byte) line::yd#0 yd zp ZP_BYTE:9 1.0714285714285714
(void()) main()
(label) main::@1
(label) main::@2
(label) main::@3
(label) main::@return
(void()) plot((byte) plot::x , (byte) plot::y)
(byte~) plot::$0 $0 zp ZP_BYTE:10 2.0
(byte~) plot::$1 reg byte a 4.0
(byte~) plot::$2 reg byte a 4.0
(byte~) plot::$3 $3 zp ZP_BYTE:10 2.0
(byte~) plot::$4 reg byte a 4.0
(byte~) plot::$5 reg byte a 4.0
(byte~) plot::$6 $6 zp ZP_BYTE:10 2.0
(byte~) plot::$7 reg byte a 4.0
(byte~) plot::$8 reg byte a 4.0
(label) plot::@return
(byte*) plot::plotter
(byte*) plot::plotter#1 plotter zp ZP_PTR_BYTE:6 1.0
(byte*) plot::plotter#2 plotter zp ZP_PTR_BYTE:6 1.5
(byte) plot::x
(byte) plot::x#0 reg byte x 1.5454545454545456
(byte) plot::y
(byte) plot::y#0 reg byte y 2.5
(byte[]) plot_bit
(const byte[]) plot_bit#0 plot_bit = (word) 5120
(byte[]) plot_xhi
(const byte[]) plot_xhi#0 plot_xhi = (word) 4352
(byte[]) plot_xlo
(const byte[]) plot_xlo#0 plot_xlo = (word) 4096
(byte[]) plot_yhi
(const byte[]) plot_yhi#0 plot_yhi = (word) 4864
(byte[]) plot_ylo
(const byte[]) plot_ylo#0 plot_ylo = (word) 4608
zp ZP_BYTE:2 [ line::x1#2 initplottables::$6 ]
reg byte x [ line::y1#2 ]
zp ZP_BYTE:3 [ line::x#2 line::x#0 line::x#1 ]
zp ZP_BYTE:4 [ line::y#2 line::y#0 line::y#4 line::y#1 ]
zp ZP_BYTE:5 [ line::e#3 line::e#0 line::e#6 line::e#2 line::e#1 ]
reg byte x [ initplottables::x#2 initplottables::x#1 ]
reg byte y [ initplottables::bit#3 initplottables::bit#4 initplottables::bit#1 ]
reg byte x [ initplottables::y#2 initplottables::y#1 ]
zp ZP_PTR_BYTE:6 [ initplottables::yoffs#2 initplottables::yoffs#4 initplottables::yoffs#1 initscreen::b#2 initscreen::b#1 initscreen::c#2 initscreen::c#1 plot::plotter#1 plot::plotter#2 ]
zp ZP_BYTE:8 [ line::xd#0 ]
zp ZP_BYTE:9 [ line::yd#0 ]
reg byte x [ plot::x#0 ]
reg byte y [ plot::y#0 ]
reg byte a [ line::$10 ]
zp ZP_BYTE:10 [ plot::$0 plot::$3 plot::$6 ]
reg byte a [ plot::$1 ]
reg byte a [ plot::$2 ]
reg byte a [ plot::$4 ]
reg byte a [ plot::$5 ]
reg byte a [ plot::$7 ]
reg byte a [ plot::$8 ]
reg byte a [ initplottables::$0 ]
reg byte a [ initplottables::$7 ]
reg byte a [ initplottables::$8 ]
reg byte a [ initplottables::$9 ]
reg byte a [ initplottables::$10 ]

View File

@ -1,4 +1,5 @@
// Use an uninitialized variable - should fail gracefully!
// Currently it gets into the optimization phase, where the optimization runs into problems understanding the assignment/usage-graph and ends up failing on an exception
main();
void main() {

View File

@ -0,0 +1,10 @@
// Expressions based on bytes but resulting in words are erronously type infered as bytes - eg. b = b + 40*8;
main();
void main() {
word b = 0;
for(byte i : 0..10) {
b = b + 40*8;
}
}