[ucsim-z80] Fix #3828: uCsim SM83 flags simulation
[sdcc.git] / sdcc / support / regression / tests / largeoddstruct.c.in
blobed948350794bbb1db00d2b4cf89aca51ea43f99c
1 /* Test large structs of odd size
2 Some ports use block move instructions for handling large objects, in particular
3 for assignment, read and write via pointers, passing as parameters and returning.
4 Sometimes the code path is slightly different for objects of odd size, which is
5 not covered well in other tests.
6 width: 8, 40, 56
7 */
9 #include <testfwk.h>
11 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
12 struct largeoddstruct
14 unsigned char c0;
15 unsigned _BitInt({width}) bi;
16 unsigned char c1;
20 const struct largeoddstruct struct0 = {0xaa, 23, 0x55};
21 struct largeoddstruct struct1 = {0xa5, 42, 0x5a};
23 #if !defined (__SDCC_hc08) && !defined (__SDCC_s08) && !defined (__SDCC_ds390) && !defined (__SDCC_mos6502) && !defined (__SDCC_mos65c02) // struct return not yet supported
24 struct largeoddstruct f0(void)
26 return (struct0);
29 struct largeoddstruct f1(void)
31 return (struct1);
33 #endif
34 #if 0 // Bug #3803.
35 struct largeoddstruct f2(struct largeoddstruct *p)
37 return (*p);
39 #endif
40 void f3(struct largeoddstruct *p)
42 struct1 = *p;
45 void compare0(struct largeoddstruct s0)
47 ASSERT(s0.c0 == 0xaa);
48 ASSERT(s0.bi == 23);
49 ASSERT(s0.c1 == 0x55);
52 void compare1(struct largeoddstruct s1)
54 ASSERT(s1.c0 == 0xa5);
55 ASSERT(s1.bi == 42);
56 ASSERT(s1.c1 == 0x5a);
58 #endif
60 void testLargeOddStruct (void)
62 #if __SDCC_BITINT_MAXWIDTH >= {width} // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
63 #if !defined (__SDCC_hc08) && !defined (__SDCC_s08) && !defined (__SDCC_ds390) && !defined (__SDCC_mos6502) && !defined (__SDCC_mos65c02) // struct return not yet supported
64 struct largeoddstruct s;
65 s = f0();
66 compare0 (s);
68 s = f1();
69 compare1 (s);
70 #endif
71 #if 0
72 s = f2(&struct1);
73 compare1 (s);
74 #endif
75 #ifndef __SDCC_ds390 // struct return support incomplete for ds390
76 f3(&struct0);
77 compare0 (struct1);
78 #endif
79 #endif