mirror of
https://gitlab.com/camelot/kickc.git
synced 2025-01-11 04:29:53 +00:00
Added a test of nested struct definitions.
This commit is contained in:
parent
88c26c2507
commit
eee018847c
@ -2223,6 +2223,11 @@ public class TestProgramsFast extends TestPrograms {
|
|||||||
compileAndCompare("struct-directives.c");
|
compileAndCompare("struct-directives.c");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStruct44() throws IOException {
|
||||||
|
compileAndCompare("struct-44.c");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStruct43() throws IOException {
|
public void testStruct43() throws IOException {
|
||||||
compileAndCompare("struct-43.c");
|
compileAndCompare("struct-43.c");
|
||||||
|
67
src/test/kc/struct-44.c
Normal file
67
src/test/kc/struct-44.c
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
// Demonstrates nested struct/enum definitions.
|
||||||
|
|
||||||
|
struct Circle {
|
||||||
|
unsigned int radius;
|
||||||
|
struct Point {
|
||||||
|
unsigned int x;
|
||||||
|
unsigned int y;
|
||||||
|
} center;
|
||||||
|
enum Color {
|
||||||
|
COL_BLACK,
|
||||||
|
COL_WHITE,
|
||||||
|
COL_RED
|
||||||
|
} color;
|
||||||
|
} circle = { 100, { 200, 300 }, COL_RED };
|
||||||
|
|
||||||
|
|
||||||
|
struct Circle c2 = { 50, { 150, 350 }, COL_WHITE };
|
||||||
|
|
||||||
|
void main(void) {
|
||||||
|
print_circle(circle);
|
||||||
|
print_ln();
|
||||||
|
print_circle(c2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_circle(struct Circle c) {
|
||||||
|
print_str("r:");
|
||||||
|
print_uint(c.radius);
|
||||||
|
print_str(" c:(");
|
||||||
|
print_uint(c.center.x);
|
||||||
|
print_str(",");
|
||||||
|
print_uint(c.center.y);
|
||||||
|
print_str(") ");
|
||||||
|
print_uchar(c.color);
|
||||||
|
}
|
||||||
|
|
||||||
|
char HEX[] = "0123456789abcdef";
|
||||||
|
|
||||||
|
void print_uint(unsigned int i) {
|
||||||
|
print_char(HEX[BYTE1(i)>>4]);
|
||||||
|
print_char(HEX[BYTE1(i)&0x0f]);
|
||||||
|
print_char(HEX[BYTE0(i)>>4]);
|
||||||
|
print_char(HEX[BYTE0(i)&0x0f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_uchar(unsigned char c) {
|
||||||
|
print_char(HEX[c>>4]);
|
||||||
|
print_char(HEX[c&0x0f]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_str(char * str) {
|
||||||
|
while(*str)
|
||||||
|
print_char(*(str++));
|
||||||
|
}
|
||||||
|
|
||||||
|
char * screen_line = (char*)0x0400 + 40*10;
|
||||||
|
char screen_idx = 0;
|
||||||
|
|
||||||
|
void print_char(char c) {
|
||||||
|
screen_line[screen_idx++] = c;
|
||||||
|
if(screen_idx==40)
|
||||||
|
print_ln();
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_ln() {
|
||||||
|
screen_line +=40;
|
||||||
|
screen_idx = 0;
|
||||||
|
}
|
246
src/test/ref/struct-44.asm
Normal file
246
src/test/ref/struct-44.asm
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
// Demonstrates nested struct/enum definitions.
|
||||||
|
// Commodore 64 PRG executable file
|
||||||
|
.file [name="struct-44.prg", type="prg", segments="Program"]
|
||||||
|
.segmentdef Program [segments="Basic, Code, Data"]
|
||||||
|
.segmentdef Basic [start=$0801]
|
||||||
|
.segmentdef Code [start=$80d]
|
||||||
|
.segmentdef Data [startAfter="Code"]
|
||||||
|
.segment Basic
|
||||||
|
:BasicUpstart(main)
|
||||||
|
.const COL_WHITE = 1
|
||||||
|
.const COL_RED = 2
|
||||||
|
.const OFFSET_STRUCT_CIRCLE_CENTER = 2
|
||||||
|
.const OFFSET_STRUCT_CIRCLE_COLOR = 6
|
||||||
|
.const OFFSET_STRUCT_POINT_Y = 2
|
||||||
|
.label screen_line = $b
|
||||||
|
.segment Code
|
||||||
|
main: {
|
||||||
|
// print_circle(circle)
|
||||||
|
lda circle
|
||||||
|
sta.z print_circle.c_radius
|
||||||
|
lda circle+1
|
||||||
|
sta.z print_circle.c_radius+1
|
||||||
|
lda circle+OFFSET_STRUCT_CIRCLE_CENTER
|
||||||
|
sta.z print_circle.c_center_x
|
||||||
|
lda circle+OFFSET_STRUCT_CIRCLE_CENTER+1
|
||||||
|
sta.z print_circle.c_center_x+1
|
||||||
|
lda circle+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y
|
||||||
|
sta.z print_circle.c_center_y
|
||||||
|
lda circle+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y+1
|
||||||
|
sta.z print_circle.c_center_y+1
|
||||||
|
lda circle+OFFSET_STRUCT_CIRCLE_COLOR
|
||||||
|
sta.z print_circle.c_color
|
||||||
|
lda #<$400+$28*$a
|
||||||
|
sta.z screen_line
|
||||||
|
lda #>$400+$28*$a
|
||||||
|
sta.z screen_line+1
|
||||||
|
jsr print_circle
|
||||||
|
// print_ln()
|
||||||
|
jsr print_ln
|
||||||
|
// print_circle(c2)
|
||||||
|
lda c2
|
||||||
|
sta.z print_circle.c_radius
|
||||||
|
lda c2+1
|
||||||
|
sta.z print_circle.c_radius+1
|
||||||
|
lda c2+OFFSET_STRUCT_CIRCLE_CENTER
|
||||||
|
sta.z print_circle.c_center_x
|
||||||
|
lda c2+OFFSET_STRUCT_CIRCLE_CENTER+1
|
||||||
|
sta.z print_circle.c_center_x+1
|
||||||
|
lda c2+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y
|
||||||
|
sta.z print_circle.c_center_y
|
||||||
|
lda c2+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y+1
|
||||||
|
sta.z print_circle.c_center_y+1
|
||||||
|
lda c2+OFFSET_STRUCT_CIRCLE_COLOR
|
||||||
|
sta.z print_circle.c_color
|
||||||
|
jsr print_circle
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
// print_circle(word zp(2) c_radius, word zp(4) c_center_x, word zp(6) c_center_y, byte zp(8) c_color)
|
||||||
|
print_circle: {
|
||||||
|
.label c_radius = 2
|
||||||
|
.label c_center_x = 4
|
||||||
|
.label c_center_y = 6
|
||||||
|
.label c_color = 8
|
||||||
|
// print_str("r:")
|
||||||
|
ldx #0
|
||||||
|
lda #<str
|
||||||
|
sta.z print_str.str
|
||||||
|
lda #>str
|
||||||
|
sta.z print_str.str+1
|
||||||
|
jsr print_str
|
||||||
|
// print_uint(c.radius)
|
||||||
|
jsr print_uint
|
||||||
|
// print_str(" c:(")
|
||||||
|
lda #<str1
|
||||||
|
sta.z print_str.str
|
||||||
|
lda #>str1
|
||||||
|
sta.z print_str.str+1
|
||||||
|
jsr print_str
|
||||||
|
// print_uint(c.center.x)
|
||||||
|
lda.z c_center_x
|
||||||
|
sta.z print_uint.i
|
||||||
|
lda.z c_center_x+1
|
||||||
|
sta.z print_uint.i+1
|
||||||
|
jsr print_uint
|
||||||
|
// print_str(",")
|
||||||
|
lda #<str2
|
||||||
|
sta.z print_str.str
|
||||||
|
lda #>str2
|
||||||
|
sta.z print_str.str+1
|
||||||
|
jsr print_str
|
||||||
|
// print_uint(c.center.y)
|
||||||
|
lda.z c_center_y
|
||||||
|
sta.z print_uint.i
|
||||||
|
lda.z c_center_y+1
|
||||||
|
sta.z print_uint.i+1
|
||||||
|
jsr print_uint
|
||||||
|
// print_str(") ")
|
||||||
|
lda #<str3
|
||||||
|
sta.z print_str.str
|
||||||
|
lda #>str3
|
||||||
|
sta.z print_str.str+1
|
||||||
|
jsr print_str
|
||||||
|
// print_uchar(c.color)
|
||||||
|
jsr print_uchar
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
.segment Data
|
||||||
|
str: .text "r:"
|
||||||
|
.byte 0
|
||||||
|
str1: .text " c:("
|
||||||
|
.byte 0
|
||||||
|
str2: .text ","
|
||||||
|
.byte 0
|
||||||
|
str3: .text ") "
|
||||||
|
.byte 0
|
||||||
|
}
|
||||||
|
.segment Code
|
||||||
|
print_ln: {
|
||||||
|
// screen_line +=40
|
||||||
|
lda #$28
|
||||||
|
clc
|
||||||
|
adc.z screen_line
|
||||||
|
sta.z screen_line
|
||||||
|
bcc !+
|
||||||
|
inc.z screen_line+1
|
||||||
|
!:
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
// print_str(byte* zp(9) str)
|
||||||
|
print_str: {
|
||||||
|
.label str = 9
|
||||||
|
__b1:
|
||||||
|
// while(*str)
|
||||||
|
ldy #0
|
||||||
|
lda (str),y
|
||||||
|
cmp #0
|
||||||
|
bne __b2
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
__b2:
|
||||||
|
// print_char(*(str++))
|
||||||
|
ldy #0
|
||||||
|
lda (str),y
|
||||||
|
jsr print_char
|
||||||
|
// print_char(*(str++));
|
||||||
|
inc.z str
|
||||||
|
bne !+
|
||||||
|
inc.z str+1
|
||||||
|
!:
|
||||||
|
jmp __b1
|
||||||
|
}
|
||||||
|
// print_uint(word zp(2) i)
|
||||||
|
print_uint: {
|
||||||
|
.label i = 2
|
||||||
|
// BYTE1(i)
|
||||||
|
lda.z i+1
|
||||||
|
// BYTE1(i)>>4
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
// print_char(HEX[BYTE1(i)>>4])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// BYTE1(i)
|
||||||
|
lda.z i+1
|
||||||
|
// BYTE1(i)&0x0f
|
||||||
|
and #$f
|
||||||
|
// print_char(HEX[BYTE1(i)&0x0f])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// BYTE0(i)
|
||||||
|
lda.z i
|
||||||
|
// BYTE0(i)>>4
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
// print_char(HEX[BYTE0(i)>>4])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// BYTE0(i)
|
||||||
|
lda.z i
|
||||||
|
// BYTE0(i)&0x0f
|
||||||
|
and #$f
|
||||||
|
// print_char(HEX[BYTE0(i)&0x0f])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
// print_uchar(byte zp(8) c)
|
||||||
|
print_uchar: {
|
||||||
|
.label c = 8
|
||||||
|
// c>>4
|
||||||
|
lda.z c
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
lsr
|
||||||
|
// print_char(HEX[c>>4])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// c&0x0f
|
||||||
|
lda #$f
|
||||||
|
and.z c
|
||||||
|
// print_char(HEX[c&0x0f])
|
||||||
|
tay
|
||||||
|
lda HEX,y
|
||||||
|
jsr print_char
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
// print_char(byte register(A) c)
|
||||||
|
print_char: {
|
||||||
|
// screen_line[screen_idx++] = c
|
||||||
|
stx.z $ff
|
||||||
|
ldy.z $ff
|
||||||
|
sta (screen_line),y
|
||||||
|
// screen_line[screen_idx++] = c;
|
||||||
|
inx
|
||||||
|
// if(screen_idx==40)
|
||||||
|
cpx #$28
|
||||||
|
bne __breturn
|
||||||
|
// print_ln()
|
||||||
|
jsr print_ln
|
||||||
|
ldx #0
|
||||||
|
rts
|
||||||
|
__breturn:
|
||||||
|
// }
|
||||||
|
rts
|
||||||
|
}
|
||||||
|
.segment Data
|
||||||
|
HEX: .text "0123456789abcdef"
|
||||||
|
.byte 0
|
||||||
|
circle: .word $64, $c8, $12c
|
||||||
|
.byte COL_RED
|
||||||
|
c2: .word $32, $96, $15e
|
||||||
|
.byte COL_WHITE
|
160
src/test/ref/struct-44.cfg
Normal file
160
src/test/ref/struct-44.cfg
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
|
||||||
|
void main()
|
||||||
|
main: scope:[main] from
|
||||||
|
[0] print_circle::c_radius#0 = *((word*)&circle)
|
||||||
|
[1] print_circle::c_center_x#0 = *((word*)(struct Point*)&circle+OFFSET_STRUCT_CIRCLE_CENTER)
|
||||||
|
[2] print_circle::c_center_y#0 = *((word*)(struct Point*)&circle+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y)
|
||||||
|
[3] print_circle::c_color#0 = *((byte*)&circle+OFFSET_STRUCT_CIRCLE_COLOR)
|
||||||
|
[4] call print_circle
|
||||||
|
to:main::@1
|
||||||
|
main::@1: scope:[main] from main
|
||||||
|
[5] phi()
|
||||||
|
[6] call print_ln
|
||||||
|
to:main::@2
|
||||||
|
main::@2: scope:[main] from main::@1
|
||||||
|
[7] print_circle::c_radius#1 = *((word*)&c2)
|
||||||
|
[8] print_circle::c_center_x#1 = *((word*)(struct Point*)&c2+OFFSET_STRUCT_CIRCLE_CENTER)
|
||||||
|
[9] print_circle::c_center_y#1 = *((word*)(struct Point*)&c2+OFFSET_STRUCT_CIRCLE_CENTER+OFFSET_STRUCT_POINT_Y)
|
||||||
|
[10] print_circle::c_color#1 = *((byte*)&c2+OFFSET_STRUCT_CIRCLE_COLOR)
|
||||||
|
[11] call print_circle
|
||||||
|
to:main::@return
|
||||||
|
main::@return: scope:[main] from main::@2
|
||||||
|
[12] return
|
||||||
|
to:@return
|
||||||
|
|
||||||
|
void print_circle(word print_circle::c_radius , word print_circle::c_center_x , word print_circle::c_center_y , byte print_circle::c_color)
|
||||||
|
print_circle: scope:[print_circle] from main main::@2
|
||||||
|
[13] print_circle::c_color#2 = phi( main/print_circle::c_color#0, main::@2/print_circle::c_color#1 )
|
||||||
|
[13] print_circle::c_center_y#2 = phi( main/print_circle::c_center_y#0, main::@2/print_circle::c_center_y#1 )
|
||||||
|
[13] print_circle::c_center_x#2 = phi( main/print_circle::c_center_x#0, main::@2/print_circle::c_center_x#1 )
|
||||||
|
[13] print_circle::c_radius#2 = phi( main/print_circle::c_radius#0, main::@2/print_circle::c_radius#1 )
|
||||||
|
[13] screen_line#61 = phi( main/(byte*) 1024+(word)$28*$a, main::@2/screen_line#25 )
|
||||||
|
[14] call print_str
|
||||||
|
to:print_circle::@1
|
||||||
|
print_circle::@1: scope:[print_circle] from print_circle
|
||||||
|
[15] print_uint::i#0 = print_circle::c_radius#2
|
||||||
|
[16] call print_uint
|
||||||
|
to:print_circle::@2
|
||||||
|
print_circle::@2: scope:[print_circle] from print_circle::@1
|
||||||
|
[17] phi()
|
||||||
|
[18] call print_str
|
||||||
|
to:print_circle::@3
|
||||||
|
print_circle::@3: scope:[print_circle] from print_circle::@2
|
||||||
|
[19] print_uint::i#1 = print_circle::c_center_x#2
|
||||||
|
[20] call print_uint
|
||||||
|
to:print_circle::@4
|
||||||
|
print_circle::@4: scope:[print_circle] from print_circle::@3
|
||||||
|
[21] phi()
|
||||||
|
[22] call print_str
|
||||||
|
to:print_circle::@5
|
||||||
|
print_circle::@5: scope:[print_circle] from print_circle::@4
|
||||||
|
[23] print_uint::i#2 = print_circle::c_center_y#2
|
||||||
|
[24] call print_uint
|
||||||
|
to:print_circle::@6
|
||||||
|
print_circle::@6: scope:[print_circle] from print_circle::@5
|
||||||
|
[25] phi()
|
||||||
|
[26] call print_str
|
||||||
|
to:print_circle::@7
|
||||||
|
print_circle::@7: scope:[print_circle] from print_circle::@6
|
||||||
|
[27] print_uchar::c#0 = print_circle::c_color#2
|
||||||
|
[28] call print_uchar
|
||||||
|
to:print_circle::@return
|
||||||
|
print_circle::@return: scope:[print_circle] from print_circle::@7
|
||||||
|
[29] return
|
||||||
|
to:@return
|
||||||
|
|
||||||
|
void print_ln()
|
||||||
|
print_ln: scope:[print_ln] from main::@1 print_char::@1
|
||||||
|
[30] screen_line#56 = phi( main::@1/screen_line#24, print_char::@1/screen_line#53 )
|
||||||
|
[31] screen_line#25 = screen_line#56 + $28
|
||||||
|
to:print_ln::@return
|
||||||
|
print_ln::@return: scope:[print_ln] from print_ln
|
||||||
|
[32] return
|
||||||
|
to:@return
|
||||||
|
|
||||||
|
void print_str(byte* print_str::str)
|
||||||
|
print_str: scope:[print_str] from print_circle print_circle::@2 print_circle::@4 print_circle::@6
|
||||||
|
[33] screen_line#68 = phi( print_circle/screen_line#61, print_circle::@2/screen_line#24, print_circle::@4/screen_line#24, print_circle::@6/screen_line#24 )
|
||||||
|
[33] screen_idx#68 = phi( print_circle/0, print_circle::@2/screen_idx#25, print_circle::@4/screen_idx#25, print_circle::@6/screen_idx#25 )
|
||||||
|
[33] print_str::str#8 = phi( print_circle/print_circle::str, print_circle::@2/print_circle::str1, print_circle::@4/print_circle::str2, print_circle::@6/print_circle::str3 )
|
||||||
|
to:print_str::@1
|
||||||
|
print_str::@1: scope:[print_str] from print_str print_str::@3
|
||||||
|
[34] screen_line#22 = phi( print_str/screen_line#68, print_str::@3/screen_line#24 )
|
||||||
|
[34] screen_idx#22 = phi( print_str/screen_idx#68, print_str::@3/screen_idx#25 )
|
||||||
|
[34] print_str::str#5 = phi( print_str/print_str::str#8, print_str::@3/print_str::str#4 )
|
||||||
|
[35] if(0!=*print_str::str#5) goto print_str::@2
|
||||||
|
to:print_str::@return
|
||||||
|
print_str::@return: scope:[print_str] from print_str::@1
|
||||||
|
[36] return
|
||||||
|
to:@return
|
||||||
|
print_str::@2: scope:[print_str] from print_str::@1
|
||||||
|
[37] print_char::c#6 = *print_str::str#5
|
||||||
|
[38] call print_char
|
||||||
|
to:print_str::@3
|
||||||
|
print_str::@3: scope:[print_str] from print_str::@2
|
||||||
|
[39] print_str::str#4 = ++ print_str::str#5
|
||||||
|
to:print_str::@1
|
||||||
|
|
||||||
|
void print_uint(word print_uint::i)
|
||||||
|
print_uint: scope:[print_uint] from print_circle::@1 print_circle::@3 print_circle::@5
|
||||||
|
[40] print_uint::i#3 = phi( print_circle::@1/print_uint::i#0, print_circle::@3/print_uint::i#1, print_circle::@5/print_uint::i#2 )
|
||||||
|
[41] print_uint::$0 = byte1 print_uint::i#3
|
||||||
|
[42] print_uint::$1 = print_uint::$0 >> 4
|
||||||
|
[43] print_char::c#0 = HEX[print_uint::$1]
|
||||||
|
[44] call print_char
|
||||||
|
to:print_uint::@1
|
||||||
|
print_uint::@1: scope:[print_uint] from print_uint
|
||||||
|
[45] print_uint::$3 = byte1 print_uint::i#3
|
||||||
|
[46] print_uint::$4 = print_uint::$3 & $f
|
||||||
|
[47] print_char::c#1 = HEX[print_uint::$4]
|
||||||
|
[48] call print_char
|
||||||
|
to:print_uint::@2
|
||||||
|
print_uint::@2: scope:[print_uint] from print_uint::@1
|
||||||
|
[49] print_uint::$6 = byte0 print_uint::i#3
|
||||||
|
[50] print_uint::$7 = print_uint::$6 >> 4
|
||||||
|
[51] print_char::c#2 = HEX[print_uint::$7]
|
||||||
|
[52] call print_char
|
||||||
|
to:print_uint::@3
|
||||||
|
print_uint::@3: scope:[print_uint] from print_uint::@2
|
||||||
|
[53] print_uint::$9 = byte0 print_uint::i#3
|
||||||
|
[54] print_uint::$10 = print_uint::$9 & $f
|
||||||
|
[55] print_char::c#3 = HEX[print_uint::$10]
|
||||||
|
[56] call print_char
|
||||||
|
to:print_uint::@return
|
||||||
|
print_uint::@return: scope:[print_uint] from print_uint::@3
|
||||||
|
[57] return
|
||||||
|
to:@return
|
||||||
|
|
||||||
|
void print_uchar(byte print_uchar::c)
|
||||||
|
print_uchar: scope:[print_uchar] from print_circle::@7
|
||||||
|
[58] print_uchar::$0 = print_uchar::c#0 >> 4
|
||||||
|
[59] print_char::c#4 = HEX[print_uchar::$0]
|
||||||
|
[60] call print_char
|
||||||
|
to:print_uchar::@1
|
||||||
|
print_uchar::@1: scope:[print_uchar] from print_uchar
|
||||||
|
[61] print_uchar::$2 = print_uchar::c#0 & $f
|
||||||
|
[62] print_char::c#5 = HEX[print_uchar::$2]
|
||||||
|
[63] call print_char
|
||||||
|
to:print_uchar::@return
|
||||||
|
print_uchar::@return: scope:[print_uchar] from print_uchar::@1
|
||||||
|
[64] return
|
||||||
|
to:@return
|
||||||
|
|
||||||
|
void print_char(byte print_char::c)
|
||||||
|
print_char: scope:[print_char] from print_str::@2 print_uchar print_uchar::@1 print_uint print_uint::@1 print_uint::@2 print_uint::@3
|
||||||
|
[65] screen_idx#54 = phi( print_str::@2/screen_idx#22, print_uchar/screen_idx#22, print_uchar::@1/screen_idx#25, print_uint/screen_idx#22, print_uint::@1/screen_idx#25, print_uint::@2/screen_idx#25, print_uint::@3/screen_idx#25 )
|
||||||
|
[65] screen_line#53 = phi( print_str::@2/screen_line#22, print_uchar/screen_line#22, print_uchar::@1/screen_line#24, print_uint/screen_line#22, print_uint::@1/screen_line#24, print_uint::@2/screen_line#24, print_uint::@3/screen_line#24 )
|
||||||
|
[65] print_char::c#7 = phi( print_str::@2/print_char::c#6, print_uchar/print_char::c#4, print_uchar::@1/print_char::c#5, print_uint/print_char::c#0, print_uint::@1/print_char::c#1, print_uint::@2/print_char::c#2, print_uint::@3/print_char::c#3 )
|
||||||
|
[66] screen_line#53[screen_idx#54] = print_char::c#7
|
||||||
|
[67] screen_idx#23 = ++ screen_idx#54
|
||||||
|
[68] if(screen_idx#23!=$28) goto print_char::@return
|
||||||
|
to:print_char::@1
|
||||||
|
print_char::@1: scope:[print_char] from print_char
|
||||||
|
[69] phi()
|
||||||
|
[70] call print_ln
|
||||||
|
to:print_char::@return
|
||||||
|
print_char::@return: scope:[print_char] from print_char print_char::@1
|
||||||
|
[71] screen_line#24 = phi( print_char/screen_line#53, print_char::@1/screen_line#25 )
|
||||||
|
[71] screen_idx#25 = phi( print_char/screen_idx#23, print_char::@1/0 )
|
||||||
|
[72] return
|
||||||
|
to:@return
|
2332
src/test/ref/struct-44.log
Normal file
2332
src/test/ref/struct-44.log
Normal file
File diff suppressed because one or more lines are too long
102
src/test/ref/struct-44.sym
Normal file
102
src/test/ref/struct-44.sym
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
constant byte COL_RED = 2
|
||||||
|
constant byte COL_WHITE = 1
|
||||||
|
constant byte* HEX[] = "0123456789abcdef"
|
||||||
|
constant byte OFFSET_STRUCT_CIRCLE_CENTER = 2
|
||||||
|
constant byte OFFSET_STRUCT_CIRCLE_COLOR = 6
|
||||||
|
constant byte OFFSET_STRUCT_POINT_Y = 2
|
||||||
|
struct Circle c2 loadstore mem[7] = { radius: $32, center: { x: $96, y: $15e }, color: COL_WHITE }
|
||||||
|
struct Circle circle loadstore mem[7] = { radius: $64, center: { x: $c8, y: $12c }, color: COL_RED }
|
||||||
|
void main()
|
||||||
|
void print_char(byte print_char::c)
|
||||||
|
byte print_char::c
|
||||||
|
byte print_char::c#0 reg byte a 202.0
|
||||||
|
byte print_char::c#1 reg byte a 202.0
|
||||||
|
byte print_char::c#2 reg byte a 202.0
|
||||||
|
byte print_char::c#3 reg byte a 202.0
|
||||||
|
byte print_char::c#4 reg byte a 202.0
|
||||||
|
byte print_char::c#5 reg byte a 202.0
|
||||||
|
byte print_char::c#6 reg byte a 2002.0
|
||||||
|
byte print_char::c#7 reg byte a 11608.0
|
||||||
|
void print_circle(word print_circle::c_radius , word print_circle::c_center_x , word print_circle::c_center_y , byte print_circle::c_color)
|
||||||
|
struct Circle print_circle::c
|
||||||
|
struct Point print_circle::c_center
|
||||||
|
word print_circle::c_center_x
|
||||||
|
word print_circle::c_center_x#0 c_center_x zp[2]:4 1.3333333333333333
|
||||||
|
word print_circle::c_center_x#1 c_center_x zp[2]:4 1.3333333333333333
|
||||||
|
word print_circle::c_center_x#2 c_center_x zp[2]:4 2.5
|
||||||
|
word print_circle::c_center_y
|
||||||
|
word print_circle::c_center_y#0 c_center_y zp[2]:6 2.0
|
||||||
|
word print_circle::c_center_y#1 c_center_y zp[2]:6 2.0
|
||||||
|
word print_circle::c_center_y#2 c_center_y zp[2]:6 1.5
|
||||||
|
byte print_circle::c_color
|
||||||
|
byte print_circle::c_color#0 c_color zp[1]:8 4.0
|
||||||
|
byte print_circle::c_color#1 c_color zp[1]:8 4.0
|
||||||
|
byte print_circle::c_color#2 c_color zp[1]:8 1.0714285714285714
|
||||||
|
word print_circle::c_radius
|
||||||
|
word print_circle::c_radius#0 c_radius zp[2]:2 1.0
|
||||||
|
word print_circle::c_radius#1 c_radius zp[2]:2 1.0
|
||||||
|
word print_circle::c_radius#2 c_radius zp[2]:2 7.5
|
||||||
|
constant byte* print_circle::str[3] = "r:"
|
||||||
|
constant byte* print_circle::str1[5] = " c:("
|
||||||
|
constant byte* print_circle::str2[2] = ","
|
||||||
|
constant byte* print_circle::str3[3] = ") "
|
||||||
|
void print_ln()
|
||||||
|
void print_str(byte* print_str::str)
|
||||||
|
byte* print_str::str
|
||||||
|
byte* print_str::str#4 str zp[2]:9 2002.0
|
||||||
|
byte* print_str::str#5 str zp[2]:9 1026.25
|
||||||
|
byte* print_str::str#8 str zp[2]:9 101.0
|
||||||
|
void print_uchar(byte print_uchar::c)
|
||||||
|
byte~ print_uchar::$0 reg byte a 202.0
|
||||||
|
byte~ print_uchar::$2 reg byte a 202.0
|
||||||
|
byte print_uchar::c
|
||||||
|
byte print_uchar::c#0 c zp[1]:8 53.25
|
||||||
|
void print_uint(word print_uint::i)
|
||||||
|
byte~ print_uint::$0 reg byte a 202.0
|
||||||
|
byte~ print_uint::$1 reg byte a 202.0
|
||||||
|
byte~ print_uint::$10 reg byte a 202.0
|
||||||
|
byte~ print_uint::$3 reg byte a 202.0
|
||||||
|
byte~ print_uint::$4 reg byte a 202.0
|
||||||
|
byte~ print_uint::$6 reg byte a 202.0
|
||||||
|
byte~ print_uint::$7 reg byte a 202.0
|
||||||
|
byte~ print_uint::$9 reg byte a 202.0
|
||||||
|
word print_uint::i
|
||||||
|
word print_uint::i#0 i zp[2]:2 22.0
|
||||||
|
word print_uint::i#1 i zp[2]:2 22.0
|
||||||
|
word print_uint::i#2 i zp[2]:2 22.0
|
||||||
|
word print_uint::i#3 i zp[2]:2 33.61538461538461
|
||||||
|
byte screen_idx
|
||||||
|
byte screen_idx#22 reg byte x 128.05555555555557
|
||||||
|
byte screen_idx#23 reg byte x 15001.5
|
||||||
|
byte screen_idx#25 reg byte x 423.66666666666663
|
||||||
|
byte screen_idx#54 reg byte x 10804.5
|
||||||
|
byte screen_idx#68 reg byte x 134.0
|
||||||
|
byte* screen_line
|
||||||
|
byte* screen_line#22 screen_line zp[2]:11 128.05555555555557
|
||||||
|
byte* screen_line#24 screen_line zp[2]:11 649.7575757575758
|
||||||
|
byte* screen_line#25 screen_line zp[2]:11 13750.5
|
||||||
|
byte* screen_line#53 screen_line zp[2]:11 6321.999999999999
|
||||||
|
byte* screen_line#56 screen_line zp[2]:11 110004.0
|
||||||
|
byte* screen_line#61 screen_line zp[2]:11 13.0
|
||||||
|
byte* screen_line#68 screen_line zp[2]:11 145.0
|
||||||
|
|
||||||
|
zp[2]:2 [ print_circle::c_radius#2 print_circle::c_radius#0 print_circle::c_radius#1 print_uint::i#3 print_uint::i#0 print_uint::i#1 print_uint::i#2 ]
|
||||||
|
zp[2]:4 [ print_circle::c_center_x#2 print_circle::c_center_x#0 print_circle::c_center_x#1 ]
|
||||||
|
zp[2]:6 [ print_circle::c_center_y#2 print_circle::c_center_y#0 print_circle::c_center_y#1 ]
|
||||||
|
zp[1]:8 [ print_circle::c_color#2 print_circle::c_color#0 print_circle::c_color#1 print_uchar::c#0 ]
|
||||||
|
zp[2]:9 [ print_str::str#5 print_str::str#8 print_str::str#4 ]
|
||||||
|
zp[2]:11 [ screen_line#22 screen_line#68 screen_line#61 screen_line#25 screen_line#56 screen_line#24 screen_line#53 ]
|
||||||
|
reg byte a [ print_char::c#7 print_char::c#6 print_char::c#4 print_char::c#5 print_char::c#0 print_char::c#1 print_char::c#2 print_char::c#3 ]
|
||||||
|
reg byte x [ screen_idx#54 screen_idx#22 screen_idx#68 screen_idx#25 screen_idx#23 ]
|
||||||
|
reg byte a [ print_uint::$0 ]
|
||||||
|
reg byte a [ print_uint::$1 ]
|
||||||
|
reg byte a [ print_uint::$3 ]
|
||||||
|
reg byte a [ print_uint::$4 ]
|
||||||
|
reg byte a [ print_uint::$6 ]
|
||||||
|
reg byte a [ print_uint::$7 ]
|
||||||
|
reg byte a [ print_uint::$9 ]
|
||||||
|
reg byte a [ print_uint::$10 ]
|
||||||
|
reg byte a [ print_uchar::$0 ]
|
||||||
|
reg byte a [ print_uchar::$2 ]
|
||||||
|
mem[7] [ circle ]
|
||||||
|
mem[7] [ c2 ]
|
Loading…
x
Reference in New Issue
Block a user