1 /** Test the bitwise operators.
3 type: char, short, long
10 testTwoOpBitwise(void)
12 {storage
} {attr
} {type
} left
, right
;
14 left
= ({type
})0x3df7;
15 right
= ({type
})0xc1ec;
17 ASSERT(({type
})(left
& right
) == ({type
})0x1E4);
18 ASSERT(({type
})(right
& left
) == ({type
})0x1E4);
19 ASSERT(({type
})(left
& 0xc1ec) == ({type
})0x1E4);
20 ASSERT(({type
})(0x3df7 & right
) == ({type
})0x1E4);
22 #ifndef __SDCC_pdk14 // Lack of memory
23 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
24 ASSERT(({type
})(left
| right
) == ({type
})0xFDFF);
25 ASSERT(({type
})(right
| left
) == ({type
})0xFDFF);
26 ASSERT(({type
})(left
| 0xc1ec) == ({type
})0xFDFF);
27 ASSERT(({type
})(0x3df7 | right
) == ({type
})0xFDFF);
29 ASSERT(({type
})(left
^ right
) == ({type
})0xFC1B);
30 ASSERT(({type
})(right
^ left
) == ({type
})0xFC1B);
31 ASSERT(({type
})(left
^ 0xc1ec) == ({type
})0xFC1B);
32 ASSERT(({type
})(0x3df7 ^ right
) == ({type
})0xFC1B);
34 #if defined (__alpha__) || defined (__x86_64__) || defined(__sparc64__) || defined(__PPC64__) || defined (__aarch64__)
35 /* long is 64 bits on 64 bit machines */
36 ASSERT(({type
})(~left
) == ({type
})0xFFFFFFFFFFFFC208);
38 ASSERT(({type
})(~left
) == ({type
})0xFFFFC208);
50 /* always false if right literal == 0 */
69 * result: if, left: var, right: literal
80 /* nothing for true */
93 /* nothing for true */
156 /* literal with zero bytes */
164 #ifndef __SDCC_pdk14 // Lack of memory
184 * result: bit, left: var, right: literal
193 {attr
} int a
= 0x1234;
196 * result: if, left: var, right: literal
200 /* nothing for true */
207 /* nothing for true */
212 #ifndef __SDCC_pdk14 // Lack of memory
213 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
226 /* or with zero: result is left */
230 /* nothing for true */
239 /* nothing for true */
264 {attr
} int a
= 0x1234;
267 * result: if, left: var, right: literal
276 /* nothing for true */
281 #ifndef __SDCC_pdk14 // Lack of memory
282 #if !(defined (__SDCC_pdk15) && defined(__SDCC_STACK_AUTO)) // Lack of code memory
290 /* nothing for true */
296 /* literal with 0xff bytes */
309 /* literal with zero bytes */
326 testBug_1777758(void)