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