struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-2708.c
blobc6a136d43f041a3ef5f30f06a81c6c0142fb2aee
1 /* bug-2708.c
2 The STM8 peephole optimizer didn't like indirect addressing modes in inline asm.
3 */
5 #include <testfwk.h>
6 #include <stdint.h>
8 #ifdef __SDCC
9 #pragma std_c99
10 #endif
12 uint8_t *cp;
14 void f1(void)
16 *cp >>= 1;
19 #ifdef __SDCC_stm8
21 void f2(void)
24 __asm
25 srl [_cp]
26 __endasm;
29 void f3(void)
31 __asm
32 ldw y, _cp
33 srl (y)
34 __endasm;
37 void f4(void)
39 __asm
40 ld a, [_cp]
41 srl a
42 ld [_cp], a
43 __endasm;
46 void f5(void)
48 __asm
49 clrw x
50 srl ([_cp], x)
51 __endasm;
54 #else
56 #define f2 f1
57 #define f3 f1
58 #define f4 f1
59 #define f5 f1
61 #endif
64 void testBug(void)
66 uint8_t c;
67 cp = &c;
69 c = 0xaa;
70 f1();
71 ASSERT(c == 0x55);
73 c = 0xaa;
74 f2();
75 ASSERT(c == 0x55);
77 c = 0xaa;
78 f3();
79 ASSERT(c == 0x55);
81 c = 0xaa;
82 f4();
83 ASSERT(c == 0x55);
85 c = 0xaa;
86 f5();
87 ASSERT(c == 0x55);