struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / banked.c.in
blob3c1104e1e4d9a01294f87a625793c223b515ed0f
1 /* banked.c
2 returntype: char, int, long
3 */
4 #include <testfwk.h>
6 #if defined(__SDCC_z80) || defined(__SDCC_z80n) || defined(__SDCC_z180) /*|| defined(__SDCC_sm83)*/ || defined(__SDCC_ez80_z80)
7 #define DO_CHECK
8 #endif
10 static unsigned char bank;
11 #ifdef DO_CHECK
12 {returntype} c_ab(unsigned a, unsigned b) __banked;
13 {returntype} f_ab(unsigned a) __banked __z88dk_fastcall;
14 {returntype} c_51(unsigned a, unsigned b) __banked;
15 {returntype} f_51(unsigned a) __banked __z88dk_fastcall;
16 #endif
18 void
19 testBanked(void)
21 ASSERT (bank == 0);
22 #ifdef DO_CHECK
23 ASSERT (c_ab(0x0e, 0x4) == ({returntype})0xabe4);
24 ASSERT (bank == 0);
25 ASSERT (f_ab(0x4e) == ({returntype})0xab4e);
26 ASSERT (bank == 0);
27 ASSERT (c_51(0x02, 0xd) == ({returntype})0x51d2);
28 ASSERT (bank == 0);
29 ASSERT (f_51(0x2d) == ({returntype})0x2d51);
30 ASSERT (bank == 0);
31 #endif
35 #ifdef DO_CHECK
36 void set_bank(void) __naked
38 __asm
39 set_bank::
40 ld (_bank), a
41 ret
42 __endasm;
44 void get_bank(void) __naked
46 __asm
47 get_bank::
48 ld a, (_bank)
49 ret
50 __endasm;
52 #pragma bank 0xab
53 {returntype} c_ab(unsigned a, unsigned b) __banked
55 return bank * 0x100 + a * 16 + b;
57 {returntype} f_ab(unsigned a) __banked __z88dk_fastcall
59 return bank * 0x100 + a;
61 #pragma bank 0x51
62 {returntype} c_51(unsigned a, unsigned b) __banked
64 return bank * 0x100 + b * 16 + a;
66 {returntype} f_51(unsigned a) __banked __z88dk_fastcall
68 return bank + a * 0x100;
70 #endif