Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / iobit.c.in
blobae02b72871fe7d8ef060371426323527e80be021
1 /** Tests for bit access in I/O space.
3 pin: 0, 1, 2, 3, 4, 5, 6, 7
4 */
5 #include <testfwk.h>
7 #include <stdint.h>
9 #if (defined(__SDCC_pdk13) || defined(__SDCC_pdk14) || defined(__SDCC_pdk15) || defined(__SDCC_z80) || defined(__SDCC_z80n) || defined(__SDCC_z180) || defined(__SDCC_ez80_z80))
10 __sfr __at(0x10) PORT;
11 #elif defined(__SDCC_mcs51)
12 __sfr __at(0x99) PORT;
13 #else
14 unsigned char PORT;
15 #endif
17 #define PIN {pin}
19 void foo_a(void) {
20 static char cnt;
21 PORT = (cnt++ & 5) ? (PORT | (1<<PIN)) : (PORT & ~(1<<PIN));
24 void foo_b(void) {
25 static char cnt;
26 PORT = (cnt & (1<<5)) ? (PORT | (1<<PIN)) : (PORT & ~(1<<PIN));
27 cnt++;
30 void bar1(void) {
31 if (PORT & (1 << PIN))
32 foo_a();
35 void bar0(void) {
36 if (!(PORT & (1 << PIN)))
37 foo_a();
40 void
41 testBug (void)