summaryrefslogtreecommitdiff
path: root/src/regression/or1.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
committerXavier ASUS <xavi92psx@gmail.com>2019-10-18 00:31:54 +0200
commit268a53de823a6750d6256ee1fb1e7707b4b45740 (patch)
tree42c1799a9a82b2f7d9790ee9fe181d72a7274751 /src/regression/or1.c
downloadsdcc-gas-268a53de823a6750d6256ee1fb1e7707b4b45740.tar.gz
sdcc-3.9.0 fork implementing GNU assembler syntax
This fork aims to provide better support for stm8-binutils
Diffstat (limited to 'src/regression/or1.c')
-rw-r--r--src/regression/or1.c198
1 files changed, 198 insertions, 0 deletions
diff --git a/src/regression/or1.c b/src/regression/or1.c
new file mode 100644
index 0000000..b828eb0
--- /dev/null
+++ b/src/regression/or1.c
@@ -0,0 +1,198 @@
+#include "gpsim_assert.h"
+
+/* bit types are not ANSI - so provide a way of disabling bit types
+ * if this file is used to test other compilers besides SDCC */
+#define SUPPORT_BIT_TYPES 0
+
+unsigned char failures=0;
+
+#if SUPPORT_BIT_TYPES
+bit bit0 = 0;
+bit bit1 = 0;
+bit bit2 = 0;
+#endif
+
+unsigned int uint0 = 0;
+unsigned int uint1 = 0;
+unsigned char uchar0 = 0;
+unsigned char uchar1 = 0;
+unsigned long ulong0 = 0;
+unsigned long ulong1 = 0;
+
+void
+done()
+{
+ ASSERT(MANGLE(failures) == 0);
+ PASSED();
+}
+
+// uchar0 = 0;
+void or_lit2uchar(void)
+{
+
+ if(uchar0)
+ failures++;
+
+ uchar0 |= 1;
+
+ if(uchar0 != 1)
+ failures++;
+
+ uchar0 |= 2;
+
+ if(uchar0 != 3)
+ failures++;
+
+ uchar0 |= 0x0e;
+
+ if(uchar0 != 0x0f)
+ failures++;
+
+}
+
+
+void or_lit2uint(void)
+{
+
+ if(uint0)
+ failures++;
+
+ uint0 |= 1;
+ if(uint0 != 1)
+ failures++;
+
+ uint0 |= 2;
+ if(uint0 != 3)
+ failures++;
+
+ uint0 |= 0x100;
+ if(uint0 != 0x103)
+ failures++;
+
+ uint0 |= 0x102;
+ if(uint0 != 0x103)
+ failures++;
+
+ uint0 |= 0x303;
+ if(uint0 != 0x303)
+ failures++;
+
+}
+
+void or_lit2ulong(void)
+{
+
+ if(ulong0)
+ failures++;
+
+ ulong0 |= 1;
+ if(ulong0 != 1)
+ failures++;
+
+ ulong0 |= 2;
+ if(ulong0 != 3)
+ failures++;
+
+ ulong0 |= 0x100;
+ if(ulong0 != 0x103)
+ failures++;
+
+ ulong0 |= 0x102;
+ if(ulong0 != 0x103)
+ failures++;
+
+ ulong0 |= 0x303;
+ if(ulong0 != 0x303)
+ failures++;
+
+ ulong0 |= 0x80000000;
+ if(ulong0 != 0x80000303)
+ failures++;
+
+}
+
+/*-----------*/
+void or_uchar2uchar(void)
+{
+
+ uchar0 |= uchar1;
+
+ if(uchar0 != 1)
+ failures++;
+
+ uchar1 |= 0x0f;
+
+ uchar0 = uchar1 | 0x10;
+
+ if(uchar0 != 0x1f)
+ failures++;
+}
+
+void or_uint2uint(void)
+{
+ uint0 |= uint1;
+
+ if(uint0 != 1)
+ failures++;
+
+ uint1 |= 0x0f;
+
+ uint0 = uint1 | 0x10;
+
+ if(uint0 != 0x1f)
+ failures++;
+
+}
+
+#if SUPPORT_BIT_TYPES
+void or_bits1(void)
+{
+
+ bit0 = bit0 | bit1 | bit2;
+
+}
+
+void or_bits2(void)
+{
+
+ bit0 = bit1 | bit2;
+
+}
+#endif
+
+void main(void)
+{
+
+ or_lit2uchar();
+ or_lit2uint();
+ or_lit2ulong();
+
+ uchar0=0;
+ uchar1=1;
+ or_uchar2uchar();
+
+ uint0=0;
+ uint1=1;
+ or_uint2uint();
+
+#if SUPPORT_BIT_TYPES
+ or_bits1();
+ if(bit0)
+ failures++;
+
+ or_bits2();
+ if(bit0)
+ failures++;
+
+ bit1=1;
+ or_bits1();
+ if(!bit0)
+ failures++;
+
+ or_bits2();
+ if(!bit0)
+ failures++;
+#endif
+
+ done();
+}