mirror of
https://gitlab.com/camelot/kickc.git
synced 2024-11-17 12:08:54 +00:00
Added inline ASM clobber test.
This commit is contained in:
parent
09dd676363
commit
f46aba8c9b
@ -28,6 +28,10 @@ public class TestPrograms extends TestCase {
|
|||||||
compileAndCompare("bitmap-bresenham");
|
compileAndCompare("bitmap-bresenham");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testAsmClobber() throws IOException, URISyntaxException {
|
||||||
|
compileAndCompare("asm-clobber");
|
||||||
|
}
|
||||||
|
|
||||||
public void testInlineAsm() throws IOException, URISyntaxException {
|
public void testInlineAsm() throws IOException, URISyntaxException {
|
||||||
compileAndCompare("inline-asm");
|
compileAndCompare("inline-asm");
|
||||||
}
|
}
|
||||||
|
21
src/main/java/dk/camelot64/kickc/test/asm-clobber.kc
Normal file
21
src/main/java/dk/camelot64/kickc/test/asm-clobber.kc
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Tests that inline ASM clobbering is taken into account when assigning registers
|
||||||
|
byte* SCREEN = $0400;
|
||||||
|
void main() {
|
||||||
|
// First loop with no clobber
|
||||||
|
for(byte i : 0..100) {
|
||||||
|
for(byte j: 0..100) {
|
||||||
|
SCREEN[i] = j;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Then loop with clobbering A&X
|
||||||
|
for(byte k : 0..100) {
|
||||||
|
for(byte l: 0..100) {
|
||||||
|
asm {
|
||||||
|
// Clobber all registers
|
||||||
|
eor #$55
|
||||||
|
tax
|
||||||
|
};
|
||||||
|
SCREEN[k] = l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.asm
Normal file
37
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.asm
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
.pc = $801 "Basic"
|
||||||
|
:BasicUpstart(main)
|
||||||
|
.pc = $80d "Program"
|
||||||
|
.const SCREEN = $400
|
||||||
|
jsr main
|
||||||
|
main: {
|
||||||
|
.label l = 2
|
||||||
|
ldx #0
|
||||||
|
b1:
|
||||||
|
lda #0
|
||||||
|
b2:
|
||||||
|
sta SCREEN,x
|
||||||
|
clc
|
||||||
|
adc #1
|
||||||
|
cmp #$65
|
||||||
|
bne b2
|
||||||
|
inx
|
||||||
|
cpx #$65
|
||||||
|
bne b1
|
||||||
|
ldy #0
|
||||||
|
b3:
|
||||||
|
lda #0
|
||||||
|
sta l
|
||||||
|
b4:
|
||||||
|
eor #$55
|
||||||
|
tax
|
||||||
|
lda l
|
||||||
|
sta SCREEN,y
|
||||||
|
inc l
|
||||||
|
lda l
|
||||||
|
cmp #$65
|
||||||
|
bne b4
|
||||||
|
iny
|
||||||
|
cpy #$65
|
||||||
|
bne b3
|
||||||
|
rts
|
||||||
|
}
|
39
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.cfg
Normal file
39
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.cfg
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
@begin: scope:[] from
|
||||||
|
to:@1
|
||||||
|
@1: scope:[] from @begin
|
||||||
|
[0] call main param-assignment [ ]
|
||||||
|
to:@end
|
||||||
|
@end: scope:[] from @1
|
||||||
|
main: scope:[main] from @1
|
||||||
|
[1] phi() [ ]
|
||||||
|
to:main::@1
|
||||||
|
main::@1: scope:[main] from main main::@5
|
||||||
|
[2] (byte) main::i#4 ← phi( main/(byte) 0 main::@5/(byte) main::i#1 ) [ main::i#4 ]
|
||||||
|
to:main::@2
|
||||||
|
main::@2: scope:[main] from main::@1 main::@2
|
||||||
|
[3] (byte) main::j#2 ← phi( main::@1/(byte) 0 main::@2/(byte) main::j#1 ) [ main::i#4 main::j#2 ]
|
||||||
|
[4] *((const byte*) SCREEN#0 + (byte) main::i#4) ← (byte) main::j#2 [ main::i#4 main::j#2 ]
|
||||||
|
[5] (byte) main::j#1 ← ++ (byte) main::j#2 [ main::i#4 main::j#1 ]
|
||||||
|
[6] if((byte) main::j#1!=(byte) 101) goto main::@2 [ main::i#4 main::j#1 ]
|
||||||
|
to:main::@5
|
||||||
|
main::@5: scope:[main] from main::@2
|
||||||
|
[7] (byte) main::i#1 ← ++ (byte) main::i#4 [ main::i#1 ]
|
||||||
|
[8] if((byte) main::i#1!=(byte) 101) goto main::@1 [ main::i#1 ]
|
||||||
|
to:main::@3
|
||||||
|
main::@3: scope:[main] from main::@5 main::@7
|
||||||
|
[9] (byte) main::k#4 ← phi( main::@5/(byte) 0 main::@7/(byte) main::k#1 ) [ main::k#4 ]
|
||||||
|
to:main::@4
|
||||||
|
main::@4: scope:[main] from main::@3 main::@4
|
||||||
|
[10] (byte) main::l#2 ← phi( main::@3/(byte) 0 main::@4/(byte) main::l#1 ) [ main::k#4 main::l#2 ]
|
||||||
|
asm { eor#$55tax }
|
||||||
|
[12] *((const byte*) SCREEN#0 + (byte) main::k#4) ← (byte) main::l#2 [ main::k#4 main::l#2 ]
|
||||||
|
[13] (byte) main::l#1 ← ++ (byte) main::l#2 [ main::k#4 main::l#1 ]
|
||||||
|
[14] if((byte) main::l#1!=(byte) 101) goto main::@4 [ main::k#4 main::l#1 ]
|
||||||
|
to:main::@7
|
||||||
|
main::@7: scope:[main] from main::@4
|
||||||
|
[15] (byte) main::k#1 ← ++ (byte) main::k#4 [ main::k#1 ]
|
||||||
|
[16] if((byte) main::k#1!=(byte) 101) goto main::@3 [ main::k#1 ]
|
||||||
|
to:main::@return
|
||||||
|
main::@return: scope:[main] from main::@7
|
||||||
|
[17] return [ ]
|
||||||
|
to:@return
|
1871
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.log
Normal file
1871
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.log
Normal file
File diff suppressed because it is too large
Load Diff
30
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.sym
Normal file
30
src/main/java/dk/camelot64/kickc/test/ref/asm-clobber.sym
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
(label) @1
|
||||||
|
(label) @begin
|
||||||
|
(label) @end
|
||||||
|
(byte*) SCREEN
|
||||||
|
(const byte*) SCREEN#0 SCREEN = (word) 1024
|
||||||
|
(void()) main()
|
||||||
|
(label) main::@1
|
||||||
|
(label) main::@2
|
||||||
|
(label) main::@3
|
||||||
|
(label) main::@4
|
||||||
|
(label) main::@5
|
||||||
|
(label) main::@7
|
||||||
|
(label) main::@return
|
||||||
|
(byte) main::i
|
||||||
|
(byte) main::i#1 reg byte x 16.5
|
||||||
|
(byte) main::i#4 reg byte x 24.599999999999998
|
||||||
|
(byte) main::j
|
||||||
|
(byte) main::j#1 reg byte a 151.5
|
||||||
|
(byte) main::j#2 reg byte a 151.5
|
||||||
|
(byte) main::k
|
||||||
|
(byte) main::k#1 reg byte y 16.5
|
||||||
|
(byte) main::k#4 reg byte y 20.499999999999996
|
||||||
|
(byte) main::l
|
||||||
|
(byte) main::l#1 l zp ZP_BYTE:2 151.5
|
||||||
|
(byte) main::l#2 l zp ZP_BYTE:2 101.0
|
||||||
|
|
||||||
|
reg byte x [ main::i#4 main::i#1 ]
|
||||||
|
reg byte a [ main::j#2 main::j#1 ]
|
||||||
|
reg byte y [ main::k#4 main::k#1 ]
|
||||||
|
zp ZP_BYTE:2 [ main::l#2 main::l#1 ]
|
Loading…
Reference in New Issue
Block a user