Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug1505956.c
blob7b9d2537d179d83836c95331183561807ed1bf6b
1 /*
2 bug3037889.c
3 All mnemonics need to be on separate lines now. So this is no longer allowed
4 #define NOP2 __asm nop nop __endasm;
5 */
7 #include <testfwk.h>
9 #if defined __SDCC_mcs51 || defined __SDCC_ds390
11 #define TEST_MACRO_20() { \
12 /*this macro has 20 instructions in it*/ \
13 __asm \
14 nop \
15 nop \
16 nop \
17 nop \
18 nop \
19 nop \
20 nop \
21 nop \
22 nop \
23 nop \
24 nop \
25 nop \
26 nop \
27 nop \
28 nop \
29 nop \
30 nop \
31 nop \
32 nop \
33 nop \
34 __endasm; \
37 volatile unsigned char testvar = 0;
39 void bug1406219 (void)
41 if ( testvar > 0 )
43 /* this code generates an error :
44 ?ASxxxx-Error-<a> in line 493 of err.asm
45 <a> machine specific addressing or addressing mode error
46 removing err.rel
48 (the generated jnc cannot branch the entire distance of the if statement.)
51 TEST_MACRO_20();
52 TEST_MACRO_20();
54 TEST_MACRO_20();
55 TEST_MACRO_20();
57 TEST_MACRO_20();
58 TEST_MACRO_20();
60 TEST_MACRO_20();
62 testvar = 0;
65 // macro with __asm/__endasm pair
66 #define NOP1 do { __asm nop __endasm; } while (0)
68 // multi-line macro with __asm/__endasm pair and operands
69 #define NOP2 do { __asm cpl a \
70 cpl a \
71 __endasm; } while (0)
73 #define NOP4 do { __asm inc a \
74 inc a \
75 dec a \
76 dec a \
77 __endasm; } while (0)
78 #define NOP8 do { NOP4; NOP4; } while (0)
79 #define NOP16 do { NOP8; NOP8; } while (0)
80 #define NOP32 do { NOP16; NOP16; } while (0)
81 #define NOP64 do { NOP32; NOP32; } while (0)
84 volatile char t;
86 void bug1505956 (void)
88 volatile unsigned char i;
90 for( i=0; i<100; i++ )
92 t++;
93 NOP64;
94 NOP32;
95 NOP16;
96 NOP8;
97 // NOP4;
98 NOP2;
99 // NOP1;
102 t++;
105 // macro without __asm/__endasm pair
106 #define GETC \
107 clr a \
108 movc a,@a+dptr
110 void bug_DS400_ROM (void)
112 __asm
113 GETC ;comment
114 __endasm;
117 // macro with other macro
118 #define ADDRESS _count
119 #define RECURSIVE __asm inc ADDRESS \
120 inc ADDRESS \
121 __endasm
123 void bug3407198 (void)
125 RECURSIVE;
128 #else
130 #define RECURSIVE
132 #endif
134 __data char count = 0;
136 // __asm ... __endasm must stay one C statement
137 char bug3407279 (char x)
139 if (x)
140 RECURSIVE;
141 return count;
144 void testBug(void)
146 ASSERT(bug3407279(0) == 0);