mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-09-08 17:54:40 +00:00
Added minimal PHI clobber example.
This commit is contained in:
parent
f63a540d15
commit
ee5499a313
@ -1,4 +1,5 @@
|
||||
Known Problems
|
||||
- Clobber can occur in PHI-statements. Example: scroll-clobber.kc. c#1/c#2 (A-register) is clobbered by //SEG18 [6] phi (byte*) main::nxt#4 = (const byte[]) TEXT#0 -- zpptrby1=cowo1
|
||||
|
||||
Features
|
||||
- Add support for expressions in data initializers.
|
||||
|
@ -24,6 +24,10 @@ public class TestCompilationOutput extends TestCase {
|
||||
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
|
||||
}
|
||||
|
||||
public void testScrollClobber() throws IOException, URISyntaxException {
|
||||
compileAndCompare("scroll-clobber");
|
||||
}
|
||||
|
||||
public void testHalfscii() throws IOException, URISyntaxException {
|
||||
compileAndCompare("halfscii");
|
||||
}
|
||||
|
31
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm
Normal file
31
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.asm
Normal file
@ -0,0 +1,31 @@
|
||||
.const SCREEN = $400
|
||||
.const SCROLL = $d016
|
||||
TEXT: .text "01234567@"
|
||||
jsr main
|
||||
main: {
|
||||
.label nxt = 2
|
||||
ldx #0
|
||||
lda #<TEXT
|
||||
sta nxt
|
||||
lda #>TEXT
|
||||
sta nxt+1
|
||||
b1:
|
||||
ldy #0
|
||||
lda (nxt),y
|
||||
cmp #'@'
|
||||
bne b2
|
||||
lda #<TEXT
|
||||
sta nxt
|
||||
lda #>TEXT
|
||||
sta nxt+1
|
||||
lda TEXT
|
||||
b2:
|
||||
inx
|
||||
sta SCREEN,x
|
||||
inc nxt
|
||||
bne !+
|
||||
inc nxt+1
|
||||
!:
|
||||
jmp b1
|
||||
rts
|
||||
}
|
27
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.cfg
Normal file
27
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.cfg
Normal file
@ -0,0 +1,27 @@
|
||||
@begin: scope:[] from
|
||||
[0] call main param-assignment [ ]
|
||||
to:@end
|
||||
@end: scope:[] from @begin
|
||||
main: scope:[main] from @begin
|
||||
[1] phi() [ ]
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@2
|
||||
[2] (byte) main::i#3 ← phi( main/(byte) 0 main::@2/(byte) main::i#1 ) [ main::nxt#3 main::i#3 ]
|
||||
[2] (byte*) main::nxt#3 ← phi( main/(const byte[]) TEXT#0 main::@2/(byte*) main::nxt#1 ) [ main::nxt#3 main::i#3 ]
|
||||
[3] (byte) main::c#0 ← * (byte*) main::nxt#3 [ main::nxt#3 main::i#3 main::c#0 ]
|
||||
[4] if((byte) main::c#0!=(byte) '@') goto main::@2 [ main::nxt#3 main::i#3 main::c#0 ]
|
||||
to:main::@3
|
||||
main::@3: scope:[main] from main::@1
|
||||
[5] (byte) main::c#1 ← * (const byte[]) TEXT#0 [ main::i#3 main::c#1 ]
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@1 main::@3
|
||||
[6] (byte*) main::nxt#4 ← phi( main::@1/(byte*) main::nxt#3 main::@3/(const byte[]) TEXT#0 ) [ main::i#3 main::c#2 main::nxt#4 ]
|
||||
[6] (byte) main::c#2 ← phi( main::@1/(byte) main::c#0 main::@3/(byte) main::c#1 ) [ main::i#3 main::c#2 main::nxt#4 ]
|
||||
[7] (byte) main::i#1 ← ++ (byte) main::i#3 [ main::i#1 main::c#2 main::nxt#4 ]
|
||||
[8] *((const byte*) SCREEN#0 + (byte) main::i#1) ← (byte) main::c#2 [ main::i#1 main::nxt#4 ]
|
||||
[9] (byte*) main::nxt#1 ← ++ (byte*) main::nxt#4 [ main::nxt#1 main::i#1 ]
|
||||
[10] if(true) goto main::@1 [ main::nxt#1 main::i#1 ]
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
[11] return [ ]
|
||||
to:@return
|
1427
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log
Normal file
1427
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.log
Normal file
File diff suppressed because it is too large
Load Diff
28
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym
Normal file
28
src/main/java/dk/camelot64/kickc/test/ref/scroll-clobber.sym
Normal file
@ -0,0 +1,28 @@
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte*) SCREEN
|
||||
(const byte*) SCREEN#0 SCREEN = (word) 1024
|
||||
(byte*) SCROLL
|
||||
(const byte*) SCROLL#0 SCROLL = (word) 53270
|
||||
(byte[]) TEXT
|
||||
(const byte[]) TEXT#0 TEXT = (string) "tst @"
|
||||
(void()) main()
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@return
|
||||
(byte) main::c
|
||||
(byte) main::c#0 reg byte a 16.5
|
||||
(byte) main::c#1 reg byte a 22.0
|
||||
(byte) main::c#2 reg byte a 16.5
|
||||
(byte) main::i
|
||||
(byte) main::i#1 reg byte x 8.25
|
||||
(byte) main::i#3 reg byte x 4.4
|
||||
(byte*) main::nxt
|
||||
(byte*) main::nxt#1 nxt zp ZP_PTR_BYTE:2 11.0
|
||||
(byte*) main::nxt#3 nxt zp ZP_PTR_BYTE:2 11.0
|
||||
(byte*) main::nxt#4 nxt zp ZP_PTR_BYTE:2 7.333333333333333
|
||||
|
||||
reg byte x [ main::i#3 main::i#1 ]
|
||||
reg byte a [ main::c#2 main::c#0 main::c#1 ]
|
||||
zp ZP_PTR_BYTE:2 [ main::nxt#4 main::nxt#3 main::nxt#1 ]
|
18
src/main/java/dk/camelot64/kickc/test/scroll-clobber.kc
Normal file
18
src/main/java/dk/camelot64/kickc/test/scroll-clobber.kc
Normal file
@ -0,0 +1,18 @@
|
||||
byte* SCREEN = $0400;
|
||||
byte* SCROLL = $d016;
|
||||
byte[] TEXT = "tst @";
|
||||
main();
|
||||
|
||||
void main() {
|
||||
byte* nxt = TEXT;
|
||||
byte i=0;
|
||||
do {
|
||||
byte c = *nxt;
|
||||
if(c=='@') {
|
||||
nxt = TEXT;
|
||||
c = *nxt;
|
||||
}
|
||||
SCREEN[++i] = c;
|
||||
nxt++;
|
||||
} while (true)
|
||||
}
|
Loading…
Reference in New Issue
Block a user