mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-01 13:30:50 +00:00
Fixed error in boolean fragments.
This commit is contained in:
parent
0ca54a97ad
commit
3e39383963
@ -1,5 +1,5 @@
|
||||
lda #1
|
||||
cmp #{c1}
|
||||
beq !+
|
||||
lda #1
|
||||
lda #0
|
||||
!:
|
||||
eor #1
|
@ -1,5 +1,5 @@
|
||||
lda #1
|
||||
cpx #{c1}
|
||||
beq !+
|
||||
lda #1
|
||||
lda #0
|
||||
!:
|
||||
eor #1
|
@ -1,5 +1,5 @@
|
||||
lda #1
|
||||
cpy #{c1}
|
||||
beq !+
|
||||
lda #1
|
||||
lda #0
|
||||
!:
|
||||
eor #1
|
@ -49,6 +49,11 @@ public class TestPrograms {
|
||||
compileAndCompare("wfragment1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTravis1() throws IOException, URISyntaxException {
|
||||
compileAndCompare("travis1");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUninitialized() throws IOException, URISyntaxException {
|
||||
compileAndCompare("uninitialized");
|
||||
|
20
src/test/kc/travis1.kc
Normal file
20
src/test/kc/travis1.kc
Normal file
@ -0,0 +1,20 @@
|
||||
// Adding a missing word-fragment for Travis Fisher
|
||||
|
||||
import "print"
|
||||
|
||||
byte action_count = 0;
|
||||
const byte READY_FRAMES = 5;
|
||||
|
||||
void main() {
|
||||
for(byte i:0..5)
|
||||
if(game_ready())
|
||||
print_str_ln("ready!@");
|
||||
}
|
||||
|
||||
bool game_ready() {
|
||||
if (action_count == 0)
|
||||
action_count = READY_FRAMES;
|
||||
print_str_ln("ready@");
|
||||
action_count--;
|
||||
return (action_count==0);
|
||||
}
|
120
src/test/ref/travis1.asm
Normal file
120
src/test/ref/travis1.asm
Normal file
@ -0,0 +1,120 @@
|
||||
// Adding a missing word-fragment for Travis Fisher
|
||||
.pc = $801 "Basic"
|
||||
:BasicUpstart(main)
|
||||
.pc = $80d "Program"
|
||||
.const READY_FRAMES = 5
|
||||
.label print_char_cursor = 7
|
||||
.label print_line_cursor = 5
|
||||
main: {
|
||||
.label i = 2
|
||||
lda #0
|
||||
sta i
|
||||
tax
|
||||
lda #<$400
|
||||
sta print_line_cursor
|
||||
lda #>$400
|
||||
sta print_line_cursor+1
|
||||
lda #<$400
|
||||
sta print_char_cursor
|
||||
lda #>$400
|
||||
sta print_char_cursor+1
|
||||
b1:
|
||||
jsr game_ready
|
||||
cmp #0
|
||||
bne b3
|
||||
b2:
|
||||
inc i
|
||||
lda i
|
||||
cmp #6
|
||||
bne b7
|
||||
rts
|
||||
b7:
|
||||
lda print_line_cursor
|
||||
sta print_char_cursor
|
||||
lda print_line_cursor+1
|
||||
sta print_char_cursor+1
|
||||
jmp b1
|
||||
b3:
|
||||
lda print_line_cursor
|
||||
sta print_char_cursor
|
||||
lda print_line_cursor+1
|
||||
sta print_char_cursor+1
|
||||
lda #<str
|
||||
sta print_str_ln.str
|
||||
lda #>str
|
||||
sta print_str_ln.str+1
|
||||
jsr print_str_ln
|
||||
jmp b2
|
||||
str: .text "ready!@"
|
||||
}
|
||||
// Print a zero-terminated string followed by a newline
|
||||
// print_str_ln(byte* zeropage(3) str)
|
||||
print_str_ln: {
|
||||
.label str = 3
|
||||
jsr print_str
|
||||
jsr print_ln
|
||||
rts
|
||||
}
|
||||
// Print a newline
|
||||
print_ln: {
|
||||
b1:
|
||||
lda print_line_cursor
|
||||
clc
|
||||
adc #$28
|
||||
sta print_line_cursor
|
||||
bcc !+
|
||||
inc print_line_cursor+1
|
||||
!:
|
||||
lda print_line_cursor+1
|
||||
cmp print_char_cursor+1
|
||||
bcc b1
|
||||
bne !+
|
||||
lda print_line_cursor
|
||||
cmp print_char_cursor
|
||||
bcc b1
|
||||
!:
|
||||
rts
|
||||
}
|
||||
// Print a zero-terminated string
|
||||
// print_str(byte* zeropage(3) str)
|
||||
print_str: {
|
||||
.label str = 3
|
||||
b1:
|
||||
ldy #0
|
||||
lda (str),y
|
||||
cmp #'@'
|
||||
bne b2
|
||||
rts
|
||||
b2:
|
||||
ldy #0
|
||||
lda (str),y
|
||||
sta (print_char_cursor),y
|
||||
inc print_char_cursor
|
||||
bne !+
|
||||
inc print_char_cursor+1
|
||||
!:
|
||||
inc str
|
||||
bne !+
|
||||
inc str+1
|
||||
!:
|
||||
jmp b1
|
||||
}
|
||||
game_ready: {
|
||||
cpx #0
|
||||
bne b1
|
||||
ldx #READY_FRAMES
|
||||
b1:
|
||||
lda #<str
|
||||
sta print_str_ln.str
|
||||
lda #>str
|
||||
sta print_str_ln.str+1
|
||||
jsr print_str_ln
|
||||
dex
|
||||
lda #1
|
||||
cpx #0
|
||||
beq !+
|
||||
lda #0
|
||||
!:
|
||||
rts
|
||||
str: .text "ready@"
|
||||
}
|
96
src/test/ref/travis1.cfg
Normal file
96
src/test/ref/travis1.cfg
Normal file
@ -0,0 +1,96 @@
|
||||
@begin: scope:[] from
|
||||
[0] phi()
|
||||
to:@21
|
||||
@21: scope:[] from @begin
|
||||
[1] phi()
|
||||
[2] call main
|
||||
to:@end
|
||||
@end: scope:[] from @21
|
||||
[3] phi()
|
||||
main: scope:[main] from @21
|
||||
[4] phi()
|
||||
to:main::@1
|
||||
main::@1: scope:[main] from main main::@7
|
||||
[5] (byte) main::i#2 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@7/(byte) main::i#1 )
|
||||
[5] (byte) action_count#13 ← phi( main/(byte/signed byte/word/signed word/dword/signed dword) 0 main::@7/(byte) action_count#11 )
|
||||
[5] (byte*) print_line_cursor#24 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@7/(byte*) print_line_cursor#14 )
|
||||
[5] (byte*) print_char_cursor#30 ← phi( main/((byte*))(word/signed word/dword/signed dword) 1024 main::@7/(byte*~) print_char_cursor#41 )
|
||||
[6] call game_ready
|
||||
[7] (bool) game_ready::return#0 ← (bool) game_ready::return#1
|
||||
to:main::@5
|
||||
main::@5: scope:[main] from main::@1
|
||||
[8] (bool~) main::$0 ← (bool) game_ready::return#0
|
||||
[9] if((bool~) main::$0) goto main::@3
|
||||
to:main::@2
|
||||
main::@2: scope:[main] from main::@3 main::@5
|
||||
[10] (byte) main::i#1 ← ++ (byte) main::i#2
|
||||
[11] if((byte) main::i#1!=(byte/signed byte/word/signed word/dword/signed dword) 6) goto main::@7
|
||||
to:main::@return
|
||||
main::@return: scope:[main] from main::@2
|
||||
[12] return
|
||||
to:@return
|
||||
main::@7: scope:[main] from main::@2
|
||||
[13] (byte*~) print_char_cursor#41 ← (byte*) print_line_cursor#14
|
||||
to:main::@1
|
||||
main::@3: scope:[main] from main::@5
|
||||
[14] (byte*~) print_char_cursor#43 ← (byte*) print_line_cursor#14
|
||||
[15] call print_str_ln
|
||||
to:main::@2
|
||||
print_str_ln: scope:[print_str_ln] from game_ready::@1 main::@3
|
||||
[16] (byte*) print_line_cursor#22 ← phi( game_ready::@1/(byte*) print_line_cursor#24 main::@3/(byte*) print_line_cursor#14 )
|
||||
[16] (byte*) print_char_cursor#27 ← phi( game_ready::@1/(byte*) print_char_cursor#30 main::@3/(byte*~) print_char_cursor#43 )
|
||||
[16] (byte*) print_str_ln::str#2 ← phi( game_ready::@1/(const string) game_ready::str main::@3/(const string) main::str )
|
||||
[17] (byte*) print_str::str#0 ← (byte*) print_str_ln::str#2
|
||||
[18] call print_str
|
||||
to:print_str_ln::@1
|
||||
print_str_ln::@1: scope:[print_str_ln] from print_str_ln
|
||||
[19] phi()
|
||||
[20] call print_ln
|
||||
to:print_str_ln::@return
|
||||
print_str_ln::@return: scope:[print_str_ln] from print_str_ln::@1
|
||||
[21] return
|
||||
to:@return
|
||||
print_ln: scope:[print_ln] from print_str_ln::@1
|
||||
[22] phi()
|
||||
to:print_ln::@1
|
||||
print_ln::@1: scope:[print_ln] from print_ln print_ln::@1
|
||||
[23] (byte*) print_line_cursor#13 ← phi( print_ln/(byte*) print_line_cursor#22 print_ln::@1/(byte*) print_line_cursor#14 )
|
||||
[24] (byte*) print_line_cursor#14 ← (byte*) print_line_cursor#13 + (byte/signed byte/word/signed word/dword/signed dword) 40
|
||||
[25] if((byte*) print_line_cursor#14<(byte*) print_char_cursor#17) goto print_ln::@1
|
||||
to:print_ln::@return
|
||||
print_ln::@return: scope:[print_ln] from print_ln::@1
|
||||
[26] return
|
||||
to:@return
|
||||
print_str: scope:[print_str] from print_str_ln
|
||||
[27] phi()
|
||||
to:print_str::@1
|
||||
print_str::@1: scope:[print_str] from print_str print_str::@2
|
||||
[28] (byte*) print_char_cursor#17 ← phi( print_str/(byte*) print_char_cursor#27 print_str::@2/(byte*) print_char_cursor#4 )
|
||||
[28] (byte*) print_str::str#2 ← phi( print_str/(byte*) print_str::str#0 print_str::@2/(byte*) print_str::str#1 )
|
||||
[29] if(*((byte*) print_str::str#2)!=(byte) '@') goto print_str::@2
|
||||
to:print_str::@return
|
||||
print_str::@return: scope:[print_str] from print_str::@1
|
||||
[30] return
|
||||
to:@return
|
||||
print_str::@2: scope:[print_str] from print_str::@1
|
||||
[31] *((byte*) print_char_cursor#17) ← *((byte*) print_str::str#2)
|
||||
[32] (byte*) print_char_cursor#4 ← ++ (byte*) print_char_cursor#17
|
||||
[33] (byte*) print_str::str#1 ← ++ (byte*) print_str::str#2
|
||||
to:print_str::@1
|
||||
game_ready: scope:[game_ready] from main::@1
|
||||
[34] if((byte) action_count#13!=(byte/signed byte/word/signed word/dword/signed dword) 0) goto game_ready::@5
|
||||
to:game_ready::@1
|
||||
game_ready::@1: scope:[game_ready] from game_ready game_ready::@5
|
||||
[35] (byte) action_count#10 ← phi( game_ready::@5/(byte) action_count#13 game_ready/(const byte) READY_FRAMES#0 )
|
||||
[36] call print_str_ln
|
||||
to:game_ready::@4
|
||||
game_ready::@4: scope:[game_ready] from game_ready::@1
|
||||
[37] (byte) action_count#11 ← -- (byte) action_count#10
|
||||
[38] (bool) game_ready::return#1 ← (byte) action_count#11 == (byte/signed byte/word/signed word/dword/signed dword) 0
|
||||
to:game_ready::@return
|
||||
game_ready::@return: scope:[game_ready] from game_ready::@4
|
||||
[39] return
|
||||
to:@return
|
||||
game_ready::@5: scope:[game_ready] from game_ready
|
||||
[40] phi()
|
||||
to:game_ready::@1
|
1638
src/test/ref/travis1.log
Normal file
1638
src/test/ref/travis1.log
Normal file
File diff suppressed because it is too large
Load Diff
69
src/test/ref/travis1.sym
Normal file
69
src/test/ref/travis1.sym
Normal file
@ -0,0 +1,69 @@
|
||||
(label) @21
|
||||
(label) @begin
|
||||
(label) @end
|
||||
(byte) READY_FRAMES
|
||||
(const byte) READY_FRAMES#0 READY_FRAMES = (byte/signed byte/word/signed word/dword/signed dword) 5
|
||||
(byte) action_count
|
||||
(byte) action_count#10 reg byte x 2.0
|
||||
(byte) action_count#11 reg byte x 1.25
|
||||
(byte) action_count#13 reg byte x 5.0
|
||||
(bool()) game_ready()
|
||||
(label) game_ready::@1
|
||||
(label) game_ready::@4
|
||||
(label) game_ready::@5
|
||||
(label) game_ready::@return
|
||||
(bool) game_ready::return
|
||||
(bool) game_ready::return#0 reg byte a 22.0
|
||||
(bool) game_ready::return#1 reg byte a 4.333333333333333
|
||||
(const string) game_ready::str str = (string) "ready@"
|
||||
(void()) main()
|
||||
(bool~) main::$0 reg byte a 22.0
|
||||
(label) main::@1
|
||||
(label) main::@2
|
||||
(label) main::@3
|
||||
(label) main::@5
|
||||
(label) main::@7
|
||||
(label) main::@return
|
||||
(byte) main::i
|
||||
(byte) main::i#1 i zp ZP_BYTE:2 11.0
|
||||
(byte) main::i#2 i zp ZP_BYTE:2 3.142857142857143
|
||||
(const string) main::str str = (string) "ready!@"
|
||||
(byte*) print_char_cursor
|
||||
(byte*) print_char_cursor#17 print_char_cursor zp ZP_WORD:7 40.6
|
||||
(byte*) print_char_cursor#27 print_char_cursor zp ZP_WORD:7 5.0
|
||||
(byte*) print_char_cursor#30 print_char_cursor zp ZP_WORD:7 3.25
|
||||
(byte*) print_char_cursor#4 print_char_cursor zp ZP_WORD:7 101.0
|
||||
(byte*~) print_char_cursor#41 print_char_cursor zp ZP_WORD:7 22.0
|
||||
(byte*~) print_char_cursor#43 print_char_cursor zp ZP_WORD:7 22.0
|
||||
(byte[]) print_hextab
|
||||
(byte*) print_line_cursor
|
||||
(byte*) print_line_cursor#13 print_line_cursor zp ZP_WORD:5 204.0
|
||||
(byte*) print_line_cursor#14 print_line_cursor zp ZP_WORD:5 19.27777777777778
|
||||
(byte*) print_line_cursor#22 print_line_cursor zp ZP_WORD:5 3.0
|
||||
(byte*) print_line_cursor#24 print_line_cursor zp ZP_WORD:5 3.25
|
||||
(void()) print_ln()
|
||||
(label) print_ln::@1
|
||||
(label) print_ln::@return
|
||||
(byte*) print_screen
|
||||
(void()) print_str((byte*) print_str::str)
|
||||
(label) print_str::@1
|
||||
(label) print_str::@2
|
||||
(label) print_str::@return
|
||||
(byte*) print_str::str
|
||||
(byte*) print_str::str#0 str zp ZP_WORD:3 2.0
|
||||
(byte*) print_str::str#1 str zp ZP_WORD:3 202.0
|
||||
(byte*) print_str::str#2 str zp ZP_WORD:3 101.5
|
||||
(void()) print_str_ln((byte*) print_str_ln::str)
|
||||
(label) print_str_ln::@1
|
||||
(label) print_str_ln::@return
|
||||
(byte*) print_str_ln::str
|
||||
(byte*) print_str_ln::str#2 str zp ZP_WORD:3 2.0
|
||||
|
||||
zp ZP_BYTE:2 [ main::i#2 main::i#1 ]
|
||||
zp ZP_WORD:3 [ print_str_ln::str#2 print_str::str#2 print_str::str#0 print_str::str#1 ]
|
||||
zp ZP_WORD:5 [ print_line_cursor#13 print_line_cursor#22 print_line_cursor#24 print_line_cursor#14 ]
|
||||
zp ZP_WORD:7 [ print_char_cursor#17 print_char_cursor#27 print_char_cursor#30 print_char_cursor#41 print_char_cursor#43 print_char_cursor#4 ]
|
||||
reg byte x [ action_count#10 action_count#13 action_count#11 ]
|
||||
reg byte a [ game_ready::return#0 ]
|
||||
reg byte a [ main::$0 ]
|
||||
reg byte a [ game_ready::return#1 ]
|
Loading…
Reference in New Issue
Block a user