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