struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3101.c
blobf47b6ed47a4ab1d6266274d93ecaef33a549bc1f
1 /* bug-3101.c
2 A bug in gbz80 code generation when storing a value in l or h onto the stack.
3 */
5 #include <testfwk.h>
7 #include <stdio.h>
8 #include <string.h>
10 typedef unsigned char UBYTE;
11 typedef unsigned int UWORD;
12 typedef int WORD;
14 typedef struct {
15 WORD x, y;
16 } fly_coord_t;
18 fly_coord_t flies[3]; // = {{(14 * 8), (5 * 8)}, {(6 * 8), (9 * 8)}, {(22 * 8), (12 * 8)}};
19 fly_coord_t * fly_ptr;
21 UBYTE __temp_i, __temp_j, __temp_k, __temp_l, __temp_m;
23 int my_puts(const char *s)
25 ASSERT (!strcmp(s, "ok"));
28 fly_coord_t * find_firefly(UBYTE tile_x, UBYTE tile_y) {
29 UBYTE ff_tile_x, ff_tile_y;
30 for (__temp_i = 0; __temp_i < 3; __temp_i++) {
31 fly_ptr = &flies[__temp_i];
33 ff_tile_x = fly_ptr->x >> 3, ff_tile_y = fly_ptr->y >> 3;
35 if ((ff_tile_x >= tile_x) && (ff_tile_x <= tile_x + 2) &&
36 (ff_tile_y >= tile_y) && (ff_tile_y <= tile_y + 1)) return fly_ptr;
38 return 0;
41 UBYTE dizzy_catches_firefly(UBYTE tile_x, UBYTE tile_y, UBYTE id) {
42 id;
43 fly_coord_t * temp_fly;
44 temp_fly = find_firefly(tile_x, tile_y);
45 if (temp_fly) my_puts("ok"); else my_puts("fail");
46 return 0;
50 void
51 testBug(void)
53 flies[0].x=7*8; flies[0].y=16*8+5;
54 flies[1].x=11*8+2; flies[1].y=14*8+3;
55 flies[2].x=18*8; flies[2].y=5*8+1;
56 dizzy_catches_firefly(10, 14, 0);