1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-04-07 06:37:31 +00:00

Optimized & minimized spline sample program. Added test demonstrating struct array initializer problem #223

This commit is contained in:
Jesper Gravgaard 2019-07-16 22:32:41 +02:00
parent 33b506902f
commit bef7663023
7 changed files with 52 additions and 18 deletions

View File

@ -0,0 +1,7 @@
lda ({z1}),y
pha
iny
lda ({z1}),y
sta {z1}+1
pla
sta {z1}

View File

@ -35,6 +35,13 @@ public class TestPrograms {
public TestPrograms() {
}
/*
@Test
public void testProblemArrayStructInit() throws IOException, URISyntaxException {
compileAndCompare("problem-array-struct-init");
}
*/
/*
@Test
public void testProblemInlineStructReturn() throws IOException, URISyntaxException {
@ -42,6 +49,7 @@ public class TestPrograms {
}
*/
@Test
public void testSplines() throws IOException, URISyntaxException {
compileAndCompare("complex/splines/simple-splines");

View File

@ -10,10 +10,8 @@ const char* PRINT_SCREEN = 0x0400;
const char* BITMAP_SCREEN = 0x5c00;
const char* BITMAP_GRAPHICS = 0x6000;
enum SegmentType { MOVE_TO, SPLINE_TO, LINE_TO};
struct Segment {
enum SegmentType type;
enum SegmentType { MOVE_TO, SPLINE_TO, LINE_TO} type;
struct SplineVector16 to;
struct SplineVector16 via;
};

View File

@ -0,0 +1,21 @@
// Demonstrates problem with initializing array of structs
struct Point {
char x;
char y;
};
struct Point[] points = {
{ 1, 2 },
{ 3, 4 },
{ 5, 6 }
};
void main() {
const char* SCREEN = 0x0400;
char idx = 0;
for ( char i: 0..2) {
SCREEN[idx++] = points[i].x;
SCREEN[idx++] = points[i].y;
}
}

View File

@ -1225,5 +1225,5 @@ bitmap_init: {
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
// True type letter a
// True type letter c
letter_c: .fill 9*$15, 0

View File

@ -1689,12 +1689,12 @@ SYMBOL TABLE SSA
(struct SplineVector16[9]) SPLINE_8SEG
(struct SplineVector16[9]) SPLINE_8SEG#0
(const byte) SPLINE_TO = (byte) 1
(const byte) Segment::SegmentType::LINE_TO = (byte) 2
(const byte) Segment::SegmentType::MOVE_TO = (byte) 0
(const byte) Segment::SegmentType::SPLINE_TO = (byte) 1
(struct SplineVector16) Segment::to
(byte) Segment::type
(struct SplineVector16) Segment::via
(const byte) SegmentType::LINE_TO = (byte) 2
(const byte) SegmentType::MOVE_TO = (byte) 0
(const byte) SegmentType::SPLINE_TO = (byte) 1
(signed word) SplineVector16::x
(signed word) SplineVector16::y
(signed dword) SplineVector32::x
@ -8112,7 +8112,7 @@ bitmap_init: {
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
// True type letter a
// True type letter c
letter_c: .fill 9*$15, 0
REGISTER UPLIFT POTENTIAL REGISTERS
@ -8691,8 +8691,8 @@ Uplift Scope [sgn_u16] 14: zp ZP_WORD:27 [ sgn_u16::w#2 sgn_u16::w#0 sgn_u16::w#
Uplift Scope [SplineVector16]
Uplift Scope [SplineVector32]
Uplift Scope [bitmap_clear]
Uplift Scope [SegmentType]
Uplift Scope [Segment]
Uplift Scope [Segment::SegmentType]
Uplift Scope []
Uplifting [bitmap_line] best 81770 combination zp ZP_WORD:18 [ bitmap_line::y#15 bitmap_line::y#7 bitmap_line::y#13 bitmap_line::y#4 bitmap_line::y#0 bitmap_line::y1#1 bitmap_line::y1#0 bitmap_line::y#1 bitmap_line::y#2 ] zp ZP_WORD:20 [ bitmap_line::x#7 bitmap_line::x#6 bitmap_line::x#15 bitmap_line::x#13 bitmap_line::x#0 bitmap_line::x1#1 bitmap_line::x1#0 bitmap_line::x#12 bitmap_line::x#1 ] zp ZP_WORD:16 [ bitmap_line::e#3 bitmap_line::e#0 bitmap_line::e#6 bitmap_line::e#1 bitmap_line::e#2 ] zp ZP_WORD:22 [ bitmap_line::e1#3 bitmap_line::e1#6 bitmap_line::e1#0 bitmap_line::e1#2 bitmap_line::e1#1 ] zp ZP_WORD:14 [ bitmap_line::y2#11 bitmap_line::y2#13 bitmap_line::y2#0 ] zp ZP_WORD:12 [ bitmap_line::x2#10 bitmap_line::x2#13 bitmap_line::x2#0 ] zp ZP_WORD:85 [ bitmap_line::dy#0 ] zp ZP_WORD:93 [ bitmap_line::sy#0 ] zp ZP_WORD:81 [ bitmap_line::dx#0 ] zp ZP_WORD:89 [ bitmap_line::sx#0 ]
@ -8708,8 +8708,8 @@ Uplifting [sgn_u16] best 77601 combination zp ZP_WORD:27 [ sgn_u16::w#2 sgn_u16:
Uplifting [SplineVector16] best 77601 combination
Uplifting [SplineVector32] best 77601 combination
Uplifting [bitmap_clear] best 77601 combination
Uplifting [SegmentType] best 77601 combination
Uplifting [Segment] best 77601 combination
Uplifting [Segment::SegmentType] best 77601 combination
Uplifting [] best 77601 combination
Attempting to uplift remaining variables inzp ZP_BYTE:11 [ bitmap_plot_spline_8seg::n#2 bitmap_plot_spline_8seg::n#1 ]
Uplifting [bitmap_plot_spline_8seg] best 77601 combination zp ZP_BYTE:11 [ bitmap_plot_spline_8seg::n#2 bitmap_plot_spline_8seg::n#1 ]
@ -10649,7 +10649,7 @@ bitmap_init: {
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
// True type letter a
// True type letter c
letter_c: .fill 9*$15, 0
ASSEMBLER OPTIMIZATIONS
@ -10880,12 +10880,12 @@ FINAL SYMBOL TABLE
(struct SplineVector16[9]) SPLINE_8SEG
(const struct SplineVector16[9]) SPLINE_8SEG#0 SPLINE_8SEG = { fill( 9, 0) }
(const byte) SPLINE_TO SPLINE_TO = (byte) 1
(const byte) Segment::SegmentType::LINE_TO LINE_TO = (byte) 2
(const byte) Segment::SegmentType::MOVE_TO MOVE_TO = (byte) 0
(const byte) Segment::SegmentType::SPLINE_TO SPLINE_TO = (byte) 1
(struct SplineVector16) Segment::to
(byte) Segment::type
(struct SplineVector16) Segment::via
(const byte) SegmentType::LINE_TO LINE_TO = (byte) 2
(const byte) SegmentType::MOVE_TO MOVE_TO = (byte) 0
(const byte) SegmentType::SPLINE_TO SPLINE_TO = (byte) 1
(signed word) SplineVector16::x
(signed word) SplineVector16::y
(signed dword) SplineVector32::x
@ -13117,6 +13117,6 @@ bitmap_init: {
bitmap_plot_ylo: .fill $100, 0
bitmap_plot_yhi: .fill $100, 0
bitmap_plot_bit: .fill $100, 0
// True type letter a
// True type letter c
letter_c: .fill 9*$15, 0

View File

@ -26,12 +26,12 @@
(struct SplineVector16[9]) SPLINE_8SEG
(const struct SplineVector16[9]) SPLINE_8SEG#0 SPLINE_8SEG = { fill( 9, 0) }
(const byte) SPLINE_TO SPLINE_TO = (byte) 1
(const byte) Segment::SegmentType::LINE_TO LINE_TO = (byte) 2
(const byte) Segment::SegmentType::MOVE_TO MOVE_TO = (byte) 0
(const byte) Segment::SegmentType::SPLINE_TO SPLINE_TO = (byte) 1
(struct SplineVector16) Segment::to
(byte) Segment::type
(struct SplineVector16) Segment::via
(const byte) SegmentType::LINE_TO LINE_TO = (byte) 2
(const byte) SegmentType::MOVE_TO MOVE_TO = (byte) 0
(const byte) SegmentType::SPLINE_TO SPLINE_TO = (byte) 1
(signed word) SplineVector16::x
(signed word) SplineVector16::y
(signed dword) SplineVector32::x