mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-10 12:31:09 +00:00
Added a nested loop test.
This commit is contained in:
parent
007a5d34b4
commit
b4d5685222
@ -53,6 +53,12 @@ public class TestCompilationOutput extends TestCase {
|
||||
tester.testFile("loopsplit");
|
||||
}
|
||||
|
||||
public void testLoopNest() throws IOException, URISyntaxException {
|
||||
TestCompilationOutput tester = new TestCompilationOutput();
|
||||
tester.testFile("loopnest");
|
||||
}
|
||||
|
||||
|
||||
private void testFile(String fileName) throws IOException, URISyntaxException {
|
||||
String inputPath = testPath + fileName + ".kc";
|
||||
System.out.println("Testing output for " + inputPath);
|
||||
|
33
src/dk/camelot64/kickc/test/loopnest.kc
Normal file
33
src/dk/camelot64/kickc/test/loopnest.kc
Normal file
@ -0,0 +1,33 @@
|
||||
byte* SCREEN = $0400;
|
||||
|
||||
main();
|
||||
|
||||
void main() {
|
||||
byte i=100;
|
||||
do {
|
||||
byte j=100;
|
||||
do {
|
||||
nest1();
|
||||
} while (--j>0)
|
||||
} while (--i>0)
|
||||
}
|
||||
|
||||
void nest1() {
|
||||
byte i=100;
|
||||
do {
|
||||
byte j=100;
|
||||
do {
|
||||
nest2();
|
||||
} while (--j>0)
|
||||
} while (--i>0)
|
||||
}
|
||||
|
||||
void nest2() {
|
||||
byte i=100;
|
||||
do {
|
||||
byte j=100;
|
||||
do {
|
||||
*SCREEN = j;
|
||||
} while (--j>0)
|
||||
} while (--i>0)
|
||||
}
|
69
src/dk/camelot64/kickc/test/ref/loopnest.asm
Normal file
69
src/dk/camelot64/kickc/test/ref/loopnest.asm
Normal file
@ -0,0 +1,69 @@
|
||||
BBEGIN:
|
||||
jsr main
|
||||
BEND:
|
||||
main:
|
||||
main__B1_from_main:
|
||||
lda #100
|
||||
sta 2
|
||||
main__B1_from_B3:
|
||||
main__B1:
|
||||
main__B2_from_B1:
|
||||
lda #100
|
||||
sta 3
|
||||
main__B2_from_B5:
|
||||
main__B2:
|
||||
jsr nest1
|
||||
main__B5:
|
||||
dec 3
|
||||
lda 3
|
||||
bne main__B2_from_B5
|
||||
main__B3:
|
||||
dec 2
|
||||
lda 2
|
||||
bne main__B1_from_B3
|
||||
main__Breturn:
|
||||
rts
|
||||
nest1:
|
||||
nest1__B1_from_nest1:
|
||||
lda #100
|
||||
sta 4
|
||||
nest1__B1_from_B3:
|
||||
nest1__B1:
|
||||
nest1__B2_from_B1:
|
||||
lda #100
|
||||
sta 5
|
||||
nest1__B2_from_B5:
|
||||
nest1__B2:
|
||||
jsr nest2
|
||||
nest1__B5:
|
||||
dec 5
|
||||
lda 5
|
||||
bne nest1__B2_from_B5
|
||||
nest1__B3:
|
||||
dec 4
|
||||
lda 4
|
||||
bne nest1__B1_from_B3
|
||||
nest1__Breturn:
|
||||
rts
|
||||
nest2:
|
||||
nest2__B1_from_nest2:
|
||||
lda #100
|
||||
sta 6
|
||||
nest2__B1_from_B3:
|
||||
nest2__B1:
|
||||
nest2__B2_from_B1:
|
||||
lda #100
|
||||
sta 7
|
||||
nest2__B2_from_B2:
|
||||
nest2__B2:
|
||||
lda 7
|
||||
sta 1024
|
||||
dec 7
|
||||
lda 7
|
||||
bne nest2__B2_from_B2
|
||||
nest2__B3:
|
||||
dec 6
|
||||
lda 6
|
||||
bne nest2__B1_from_B3
|
||||
nest2__Breturn:
|
||||
rts
|
62
src/dk/camelot64/kickc/test/ref/loopnest.cfg
Normal file
62
src/dk/camelot64/kickc/test/ref/loopnest.cfg
Normal file
@ -0,0 +1,62 @@
|
||||
@BEGIN: from
|
||||
[0] call main param-assignment [ ]
|
||||
to:@END
|
||||
@END: from @BEGIN
|
||||
main: from @BEGIN
|
||||
to:main::@1
|
||||
main::@1: from main main::@3
|
||||
[1] (byte) main::i#2 ← phi( main/(byte) 100 main::@3/(byte) main::i#1 ) [ ]
|
||||
to:main::@2
|
||||
main::@2: from main::@1 main::@5
|
||||
[2] (byte) main::j#2 ← phi( main::@1/(byte) 100 main::@5/(byte) main::j#1 ) [ ]
|
||||
[3] call nest1 param-assignment [ main::j#2 main::i#2 ]
|
||||
to:main::@5
|
||||
main::@5: from main::@2
|
||||
[4] (byte) main::j#1 ← -- (byte) main::j#2 [ main::j#1 main::i#2 ]
|
||||
[5] if((byte) main::j#1>(byte) 0) goto main::@2 [ main::j#1 main::i#2 ]
|
||||
to:main::@3
|
||||
main::@3: from main::@5
|
||||
[6] (byte) main::i#1 ← -- (byte) main::i#2 [ main::i#1 ]
|
||||
[7] if((byte) main::i#1>(byte) 0) goto main::@1 [ main::i#1 ]
|
||||
to:main::@return
|
||||
main::@return: from main::@3
|
||||
[8] return [ ]
|
||||
to:@RETURN
|
||||
nest1: from main::@2
|
||||
to:nest1::@1
|
||||
nest1::@1: from nest1 nest1::@3
|
||||
[9] (byte) nest1::i#2 ← phi( nest1/(byte) 100 nest1::@3/(byte) nest1::i#1 ) [ ]
|
||||
to:nest1::@2
|
||||
nest1::@2: from nest1::@1 nest1::@5
|
||||
[10] (byte) nest1::j#2 ← phi( nest1::@1/(byte) 100 nest1::@5/(byte) nest1::j#1 ) [ ]
|
||||
[11] call nest2 param-assignment [ nest1::j#2 nest1::i#2 ]
|
||||
to:nest1::@5
|
||||
nest1::@5: from nest1::@2
|
||||
[12] (byte) nest1::j#1 ← -- (byte) nest1::j#2 [ nest1::j#1 nest1::i#2 ]
|
||||
[13] if((byte) nest1::j#1>(byte) 0) goto nest1::@2 [ nest1::j#1 nest1::i#2 ]
|
||||
to:nest1::@3
|
||||
nest1::@3: from nest1::@5
|
||||
[14] (byte) nest1::i#1 ← -- (byte) nest1::i#2 [ nest1::i#1 ]
|
||||
[15] if((byte) nest1::i#1>(byte) 0) goto nest1::@1 [ nest1::i#1 ]
|
||||
to:nest1::@return
|
||||
nest1::@return: from nest1::@3
|
||||
[16] return [ ]
|
||||
to:@RETURN
|
||||
nest2: from nest1::@2
|
||||
to:nest2::@1
|
||||
nest2::@1: from nest2 nest2::@3
|
||||
[17] (byte) nest2::i#2 ← phi( nest2/(byte) 100 nest2::@3/(byte) nest2::i#1 ) [ nest2::i#2 ]
|
||||
to:nest2::@2
|
||||
nest2::@2: from nest2::@1 nest2::@2
|
||||
[18] (byte) nest2::j#2 ← phi( nest2::@1/(byte) 100 nest2::@2/(byte) nest2::j#1 ) [ nest2::j#2 nest2::i#2 ]
|
||||
[19] *((word) 1024) ← (byte) nest2::j#2 [ nest2::j#2 nest2::i#2 ]
|
||||
[20] (byte) nest2::j#1 ← -- (byte) nest2::j#2 [ nest2::j#1 nest2::i#2 ]
|
||||
[21] if((byte) nest2::j#1>(byte) 0) goto nest2::@2 [ nest2::j#1 nest2::i#2 ]
|
||||
to:nest2::@3
|
||||
nest2::@3: from nest2::@2
|
||||
[22] (byte) nest2::i#1 ← -- (byte) nest2::i#2 [ nest2::i#1 ]
|
||||
[23] if((byte) nest2::i#1>(byte) 0) goto nest2::@1 [ nest2::i#1 ]
|
||||
to:nest2::@return
|
||||
nest2::@return: from nest2::@3
|
||||
[24] return [ ]
|
||||
to:@RETURN
|
2278
src/dk/camelot64/kickc/test/ref/loopnest.log
Normal file
2278
src/dk/camelot64/kickc/test/ref/loopnest.log
Normal file
File diff suppressed because it is too large
Load Diff
41
src/dk/camelot64/kickc/test/ref/loopnest.sym
Normal file
41
src/dk/camelot64/kickc/test/ref/loopnest.sym
Normal file
@ -0,0 +1,41 @@
|
||||
(label) @BEGIN
|
||||
(label) @END
|
||||
(byte*) SCREEN
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@5
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 zp byte:2
|
||||
(byte) main::i#2 zp byte:2
|
||||
(byte) main::j
|
||||
(byte) main::j#1 zp byte:3
|
||||
(byte) main::j#2 zp byte:3
|
||||
|
||||
(void()) nest1()
|
||||
(label) nest1::@1
|
||||
(label) nest1::@2
|
||||
(label) nest1::@3
|
||||
(label) nest1::@5
|
||||
(label) nest1::@return
|
||||
(byte) nest1::i
|
||||
(byte) nest1::i#1 zp byte:4
|
||||
(byte) nest1::i#2 zp byte:4
|
||||
(byte) nest1::j
|
||||
(byte) nest1::j#1 zp byte:5
|
||||
(byte) nest1::j#2 zp byte:5
|
||||
|
||||
(void()) nest2()
|
||||
(label) nest2::@1
|
||||
(label) nest2::@2
|
||||
(label) nest2::@3
|
||||
(label) nest2::@return
|
||||
(byte) nest2::i
|
||||
(byte) nest2::i#1 zp byte:6
|
||||
(byte) nest2::i#2 zp byte:6
|
||||
(byte) nest2::j
|
||||
(byte) nest2::j#1 zp byte:7
|
||||
(byte) nest2::j#2 zp byte:7
|
||||
|
Loading…
x
Reference in New Issue
Block a user