[ucsim-z80] Fix #3828: uCsim SM83 flags simulation
[sdcc.git] / sdcc / support / regression / tests / bug3223041.c
blob3d9aa3c33b253b14754077cdd9b5f5574c763ee2
1 /*
2 * bug3223041.c
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_sdcc99
9 #endif
11 #include <stdbool.h>
13 #if 0
14 #define CAST(x) (x ? true : false)
15 #else
16 #define CAST(x) (x)
17 #endif
19 bool and(bool a, bool b, bool c, bool d)
21 return a & b & c & d;
24 bool or(bool a, bool b, bool c, bool d)
26 return a | b | c | d;
29 bool xor(bool a, bool b, bool c, bool d)
31 return a ^ b ^ c ^ d;
34 void
35 testBug(void)
37 unsigned char i, x;
38 for (i=0; i<16; i++)
40 ASSERT( and(CAST(i&0x01), CAST(i&0x02), CAST(i&0x04), CAST(i&0x08)) == (i==15) );
41 ASSERT( or (CAST(i&0x01), CAST(i&0x02), CAST(i&0x04), CAST(i&0x08)) == (i!= 0) );
42 x = i ^ (i>>1);
43 x = x ^ (x>>2);
44 ASSERT( xor(CAST(i&0x01), CAST(i&0x02), CAST(i&0x04), CAST(i&0x08)) == (x & 0x01) );