Imported Upstream version 2.9.0
[debian/cc1111] / support / regression / tests / bug1535242.c
1 /* saving "bits" test for mcs51/stack-auto.
2  */
3 #include <testfwk.h>
4
5 #if defined(SDCC_mcs51)
6 #include <8052.h>
7 #include <stdbool.h>
8
9 bool manipulate_bits(bool x) using 2
10 {
11         return x;
12 }
13
14 bool complement(bool x)
15 {
16         return !x;
17 }
18
19 #endif
20
21 void
22 testSaveBits(void)
23 {
24 #if defined(SDCC_mcs51)
25
26   //enable the interrupt and set it
27   ET2 = 1;
28   EA = 1;
29   TF2 = 1;
30
31   //this will pass b0 cleared, test whether it will arrive cleared
32   if (complement(false))
33   {
34     EA = 0;
35     ASSERT(1);
36   }
37   else
38   {
39     EA = 0;
40     ASSERT(0);
41   }
42
43 #else
44   ASSERT(1);
45 #endif
46 }
47
48 #if defined(SDCC_mcs51)
49 void T2_isr (void) interrupt 5 using 2
50 {
51   //do not clear flag ET2 so it keeps interrupting !
52
53   //this will set b0
54   manipulate_bits(true);
55 }
56 #endif