1 /* generic pointer comparison
7 #if !((defined __SDCC_stm8) && defined (__SDCC_MODEL_LARGE))
8 #define CAN_ASSIGN_VOID_TO_FPTR 1
9 #pragma disable_warning 244
12 char eq(void * p1
, void * p2
)
17 char neq(void * p1
, void * p2
)
22 char smaller(void * p1
, void * p2
)
27 char greater(void * p1
, void * p2
)
32 char __xdata
* xp0
= NULL
;
33 char __xdata
* xp1
= (char __xdata
*)0x0001;
34 char __idata
* ip0
= NULL
;
35 char __idata
* ip1
= (char __idata
*)0x0001;
36 char __pdata
* pp0
= NULL
;
37 char __pdata
* pp1
= (char __pdata
*)0x0001;
38 char __code
* cp0
= NULL
;
39 char __code
* cp1
= (char __code
*)0x0001;
40 void (* fp0
)(void) = NULL
;
41 void (* fp1
)(void) = (void (*)(void))0x0001;
42 #if defined (__SDCC_MODEL_HUGE)
43 void (* fpE
)(void) = (void (*)(void))0x7E8000; //SDCC assumes banked pointers have physical address != 0
44 void (* fpF
)(void) = (void (*)(void))0x7F8000; //choose the banks to be mapped to 0x8000 for the test
47 char * gp2
= (char __pdata
*)0x0002;
52 #if defined (__SDCC_MODEL_HUGE)
53 char __code
* cp2
= (char __code
*)0x0002;
54 void (* fp2
)(void) = (void (*)(void))0x0002;
56 ASSERT (eq(cp2
, fp2
));
57 ASSERT (smaller(fpE
, fpF
));
74 ASSERT (eq(xp0
, ip0
));
75 ASSERT (eq(xp0
, pp0
));
76 ASSERT (eq(xp0
, cp0
));
77 #ifdef CAN_ASSIGN_VOID_TO_FPTR
78 ASSERT (eq(xp0
, fp0
));
80 ASSERT (eq(xp0
, gp0
));
82 #if defined(__SDCC_mcs51) || defined(__SDCC_ds390)
83 ASSERT (neq(xp1
, ip1
));
84 ASSERT (neq(xp1
, pp1
));
85 ASSERT (neq(xp1
, cp1
));
86 ASSERT (neq(xp1
, fp1
));
87 ASSERT (neq(xp1
, gp2
));
89 ASSERT (smaller(xp1
, ip1
) || greater(xp1
, ip1
));
90 ASSERT (smaller(xp1
, pp1
) || greater(xp1
, pp1
));
91 ASSERT (smaller(xp1
, cp1
) || greater(xp1
, cp1
));
92 ASSERT (smaller(xp1
, fp1
) || greater(xp1
, fp1
));
93 ASSERT (smaller(xp1
, gp2
) || greater(xp1
, gp2
));
95 ASSERT (!smaller(xp0
, ip0
) && !greater(xp0
, ip0
));
96 ASSERT (!smaller(xp0
, pp0
) && !greater(xp0
, pp0
));
97 ASSERT (!smaller(xp0
, cp0
) && !greater(xp0
, cp0
));
98 ASSERT (!smaller(xp0
, fp0
) && !greater(xp0
, fp0
));
99 ASSERT (!smaller(xp0
, gp0
) && !greater(xp0
, gp0
));
101 #ifdef CAN_ASSIGN_VOID_TO_FPTR
102 ASSERT (eq(cp1
, fp1
));
104 ASSERT (smaller(pp1
, gp2
));