Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bp.c
1 /* Base pointer tests, specifically for the z80.
2  */
3 #include <testfwk.h>
4 #include <string.h>
5
6 int
7 verifyBlock(char *p, char val, int len)
8 {
9   while (len--) {
10     if (*p++ != val) {
11       return 0;
12     }
13   }
14   return 1;
15 }
16
17 int
18 spoil(int a)
19 {
20   return a;
21 }
22
23 #if defined(SDCC_mcs51) || defined(SDCC_pic16)
24
25 // test devices with much less memory
26 #define ABOVE_MEM_SIZE       30
27 #define ABOVE_MEM_TEST_SIZE  17
28 #define BELOW_MEM_SIZE       20
29 #define BELOW_MEM_TEST_SIZE   7
30
31 #else
32
33 #define ABOVE_MEM_SIZE      400
34 #define ABOVE_MEM_TEST_SIZE  17
35 #define BELOW_MEM_SIZE      200
36 #define BELOW_MEM_TEST_SIZE  74
37
38 #endif
39
40 void
41 testBP(void)
42 {
43   char above[ABOVE_MEM_SIZE];
44   int f;
45   char below[BELOW_MEM_SIZE];
46
47   memset(above, ABOVE_MEM_TEST_SIZE, sizeof(above));
48   memset(below, BELOW_MEM_TEST_SIZE, sizeof(below));
49
50   ASSERT(verifyBlock(above, ABOVE_MEM_TEST_SIZE, sizeof(above)));
51   ASSERT(verifyBlock(below, BELOW_MEM_TEST_SIZE, sizeof(below)));
52
53   f = spoil(-5);
54   spoil(f);
55
56   ASSERT(verifyBlock(above, ABOVE_MEM_TEST_SIZE, sizeof(above)));
57   ASSERT(verifyBlock(below, BELOW_MEM_TEST_SIZE, sizeof(below)));
58
59 }