Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3532.c
blob7eebda4394e151c60dd54f7716f62e05ee2e7786
1 /* bug-3523.c
2 An issue in handling register arguments of asm functions with __preserves_regs specification.
3 */
5 #include <testfwk.h>
7 #pragma disable_warning 85
9 typedef struct tSpriteStruct {
10 char dummy;
11 signed char handle;
12 } SpriteStruct;
14 SpriteStruct sprites[2];
16 #if (defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_z80n)) && __SDCCCALL == 1
17 signed char SMS_addSprite (unsigned int y, unsigned int x_tile) __naked __preserves_regs(d,e,iyh,iyl) __sdcccall(1) {
18 __asm
19 ld a,l
20 ret
21 __endasm;
23 #elif defined(__SDCC_sm83) && __SDCCCALL == 1
24 signed char SMS_addSprite (unsigned int y, unsigned int x_tile) __naked __preserves_regs(d,e,iyh,iyl) __sdcccall(1) {
25 __asm
26 ld a,e
27 ret
28 __endasm;
30 #else
31 signed char SMS_addSprite (unsigned int y, unsigned int x_tile) {
32 return y;
34 #endif
36 void f(void) {
37 sprites[0].handle = SMS_addSprite(0, 0);
38 sprites[1].handle = SMS_addSprite(0, 0);
41 void
42 testBug (void) {
43 sprites[0].handle = -1;
44 sprites[1].handle = -1;
45 f();
46 ASSERT (sprites[0].handle == 0);
47 ASSERT (sprites[1].handle == 0);