* Makefile.in, configure.in, configure,
[fw/sdcc] / src / regression / sub.c
index fd3a6f11597324d76de660a6571f43e93b8a72be..db28d2091c94afde4e16003523e5ab2872ed93ec 100644 (file)
@@ -1,17 +1,15 @@
-//#include "p16c84.h"
+#include "gpsim_assert.h"
 // Addition tests
 
 /* 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 1
+#define SUPPORT_BIT_TYPES 0
 
 /* Some compilers that support bit types do not support bit arithmetic 
  * (like bitx = bity + bitz;) */
 #define SUPPORT_BIT_ARITHMETIC 1
 
-unsigned char success=0;
 unsigned char failures=0;
-unsigned char dummy=0;
 
 #if SUPPORT_BIT_TYPES
 
@@ -38,11 +36,11 @@ unsigned char achar2 = 0;
 unsigned char achar3 = 0;
 unsigned char *acharP = 0;
 
-void done()
+void
+done()
 {
-
-  dummy++;
-
+  ASSERT(MANGLE(failures) == 0);
+  PASSED();
 }
 
 void sub_lit_from_uchar(void)
@@ -151,11 +149,10 @@ void sub_bits(void)
     failures++;
 #endif
 }
-#endif
 
-/* add_bit2uchar(void) - assumes bit0 = 1, achar0 = 7  */
+/* sub_bit2uchar(void) - assumes bit0 = 1, achar0 = 7  */
 
-void add_bit2uchar(void)
+void sub_bit2uchar(void)
 {
 
   achar0 -= bit0;
@@ -168,17 +165,62 @@ void add_bit2uchar(void)
 
 }
 
-void add_bit2uint(void)
+void sub_bit2uint(void)
 {
 
   if(aint0 != bit11)
     failures++;
 
-  aint0 += bit0;
-  if(aint0!=1)
+  aint0 -= bit0;
+  if(aint0!=0xffff)
     failures++;
 
 }
+#endif
+
+void sub_ucharFromLit(void)
+{
+
+  achar0 = 2 - achar0;
+
+  if(achar0 != 2)
+    failures++;
+
+
+  aint0 = 2 - aint0;
+
+  if(aint0 != 2)
+    failures++;
+
+  aint0--;
+
+  if(aint0 != 1)
+    failures++;
+
+  aint0 = 0x100 - aint0;
+
+  if(aint0 != 0xff)
+    failures++;
+
+  aint0 = 0xff00 - aint0;
+
+  if(aint0 != 0xfe01)
+    failures++;
+
+  aint0 = 0x0e01 - aint0;
+
+  if(aint0 != 0x1000)
+    failures++;
+
+  aint0 = 0x10ff - aint0;
+
+  if(aint0 != 0xff)
+    failures++;
+
+
+
+}
+
 void main(void)
 {
 
@@ -198,11 +240,13 @@ void main(void)
 
   achar0 = 7;
   bit0 = 1;
-  add_bit2uchar();
-  //add_bit2uint();
+  sub_bit2uchar();
+  sub_bit2uint();
 #endif
 
+  aint0 = 0;
+  achar0 = 0;
+  sub_ucharFromLit();
 
-  success = failures;
   done();
 }