Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / interrupt.c.in
blob176d917206fb973e16762675970dee8c4d69b77e
1 /** Interrupt tests.
2 regbank: 0,1
3 */
4 #include <testfwk.h>
6 #if defined(__SDCC_mcs51)
8 #include <8052.h>
10 volatile long lA = 12345;
11 volatile long lB = 67890;
12 volatile long lC = 0;
14 #endif
16 void
17 testInterrupt (void)
19 #if defined(__SDCC_mcs51)
20 register long x = lC;
22 //enable the interrupt and set it
23 ET2 = 1;
24 EA = 1;
25 TF2 = 1;
27 while (TF2)
28 ; //wait until serviced
29 ASSERT (lC + x == 74474);
30 #else
31 ASSERT (1);
32 #endif
35 #if defined(__SDCC_mcs51)
36 // Timer2 interrupt service routine
37 // with register and (stack)spil usage
38 void
39 T2_isr (void) __interrupt (5) __using({regbank})
41 long a, b, c;
42 a = lA + 0xBABE;
43 b = lB + 0xBEEB;
44 c = a ^ b;
45 lC = c;
46 TF2 = 0;
48 #endif