1 /* Keyword "critical" tests.
5 #if defined(__SDCC_mcs51)
18 //must be at least 2 bytes big and volatile
19 volatile big global_var
= { 0 };
23 get_global (void) __critical
29 #if defined(__SDCC_mcs51) || defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r2ka) || defined(__SDCC_r3ka) || defined(__SDCC_hc08) || defined(__SDCC_s08) || defined(__SDCC_mos6502) || defined(__SDCC_mos65c02) || defined(__SDCC_tlcs90) || defined(__SDCC_stm8)
30 // Check that param offsets are correctly adjusted for critial functions
31 long critical_function(long a
, long b
, long c
) __critical
40 inline long critical_function_inline(long a
, long b
, long c
) __critical
54 #if defined(__SDCC_mcs51)
58 //enable the interrupt and set it
63 __critical x
.a
= global_var
.a
;
69 for (i
= 10; i
!= 0; i
--)
71 __critical x
.a
= global_var
.a
;
77 //check the interrupt has run at all
81 //check the interrupts are still enabled
87 #if defined(__SDCC_mcs51) || defined(__SDCC_z80) || defined(__SDCC_z180) || defined(__SDCC_r2k) || defined(__SDCC_r2ka) || defined(__SDCC_r3ka) || defined(__SDCC_hc08) || defined(__SDCC_s08) || defined(__SDCC_mos6502) || defined(__SDCC_mos65c02) || defined(__SDCC_tlcs90) || defined(__SDCC_stm8)
88 ASSERT(critical_function(11, 1, 1) == 13);
89 ASSERT(critical_function(5, 1, 1) == 3);
90 ASSERT(critical_function(5, 11, 1) == 15);
91 ASSERT(critical_function_inline(11, 1, 1) == 13);
92 ASSERT(critical_function_inline(5, 1, 1) == 3);
93 ASSERT(critical_function_inline(5, 11, 1) == 15);
97 #if defined(__SDCC_mcs51)
99 T2_isr (void) __interrupt (5) __using (2)
101 //do not clear flag ET2 so it keeps interrupting !
103 if (global_var
.b
== 0)
105 global_var
.c
= global_var
.b
;