struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bp.c
blob5ef54776fb9022a2e432a5436a6c8bd4c3d515bc
1 /* Base pointer tests, specifically for the z80.
2 */
3 #include <testfwk.h>
4 #include <string.h>
6 int
7 verifyBlock(char *p, char val, int len)
9 while (len--) {
10 if (*p++ != val) {
11 return 0;
14 return 1;
17 int
18 spoil(int a)
20 return a;
23 #if defined(__SDCC_pic14) || defined(__SDCC_pdk14)
25 // test devices with much less memory
26 #define ABOVE_MEM_SIZE 20
27 #define ABOVE_MEM_TEST_SIZE 17
28 #define BELOW_MEM_SIZE 10
29 #define BELOW_MEM_TEST_SIZE 7
31 #elif defined(__SDCC_mcs51) || defined(__SDCC_pic16) || defined(__SDCC_pdk15) || defined(__SDCC_STACK_AUTO)
33 // test devices with much less
34 #define ABOVE_MEM_SIZE 30
35 #define ABOVE_MEM_TEST_SIZE 17
36 #define BELOW_MEM_SIZE 20
37 #define BELOW_MEM_TEST_SIZE 7
39 #else
41 #define ABOVE_MEM_SIZE 400
42 #define ABOVE_MEM_TEST_SIZE 17
43 #define BELOW_MEM_SIZE 200
44 #define BELOW_MEM_TEST_SIZE 74
46 #endif
48 void
49 testBP(void)
51 char above[ABOVE_MEM_SIZE];
52 int f;
53 char below[BELOW_MEM_SIZE];
55 memset(above, ABOVE_MEM_TEST_SIZE, sizeof(above));
56 memset(below, BELOW_MEM_TEST_SIZE, sizeof(below));
58 ASSERT(verifyBlock(above, ABOVE_MEM_TEST_SIZE, sizeof(above)));
59 ASSERT(verifyBlock(below, BELOW_MEM_TEST_SIZE, sizeof(below)));
61 f = spoil(-5);
62 spoil(f);
64 ASSERT(verifyBlock(above, ABOVE_MEM_TEST_SIZE, sizeof(above)));
65 ASSERT(verifyBlock(below, BELOW_MEM_TEST_SIZE, sizeof(below)));