summaryrefslogtreecommitdiff
path: root/support/regression/tests/bug1535242.c
blob: 37b07aad516af8c1c8f5121174418daf2ddcfdfb (plain) (blame)
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
/* saving "bits" test for mcs51/stack-auto.
 */
#include <testfwk.h>

#if defined(__SDCC_mcs51)
#include <8052.h>
#include <stdbool.h>

bool
manipulate_bits (bool x) __using 2
{
  return x;
}

bool
complement (bool x)
{
  return !x;
}
#endif

void
testSaveBits (void)
{
#if defined(__SDCC_mcs51)
  //enable the interrupt and set it
  ET2 = 1;
  EA = 1;
  TF2 = 1;

  //this will pass b0 cleared, test whether it will arrive cleared
  if (complement(false))
    {
      EA = 0;
      ASSERT (1);
    }
  else
    {
      EA = 0;
      ASSERT (0);
    }
#else
  ASSERT (1);
#endif
}

#if defined(__SDCC_mcs51)
void
T2_isr (void) __interrupt 5 __using 2
{
  //do not clear flag ET2 so it keeps interrupting !

  //this will set b0
  manipulate_bits (true);
}
#endif