Initial revision
authorkeie <none@none>
Wed, 6 Feb 1985 21:06:03 +0000 (21:06 +0000)
committerkeie <none@none>
Wed, 6 Feb 1985 21:06:03 +0000 (21:06 +0000)
lang/cem/ctest/READ_ME [new file with mode: 0644]
lang/cem/ctest/ctconv/conv.c [new file with mode: 0644]
lang/cem/ctest/ctconv/conv.cem.g [new file with mode: 0644]
lang/cem/ctest/ctconv/run [new file with mode: 0644]

diff --git a/lang/cem/ctest/READ_ME b/lang/cem/ctest/READ_ME
new file mode 100644 (file)
index 0000000..5b213c4
--- /dev/null
@@ -0,0 +1,43 @@
+The test are subdivided into several directories.
+Only the directory ctgen contains more than one program, but it
+is an exception anyhow.
+All other directories contain one program, say test.c.
+It is translated with a file test.cem as result.
+This test is run, producing output on test.cem.r.
+The 'expected' output is distributed on files named test.cem.g.
+The run files in these directories use the makefile in this
+directory to create the ...cem, ....cem.r files.
+After creating the ....cem.r files a diff is run between the .r
+and .g files. The output of these diffs is preceded by the line
+comparing ....cem
+Not all differences are caused by errors.
+Part of the output in the subdirectory ctmargt is a printout
+of the current environment variables. These will differ per
+user.
+The expected output in the directory ctconv is for a compiler
+that considers char's as unsigned quantaties.
+The expected output in all directories is generated using
+16-bit arithmetic, using 32-bit arithmetic will cause several
+discrepancies to occur with the expected output in the ...cem.g
+files.
+
+If any other differences with the expected output occur, the error
+causing the diffence has to be rooted out by a person with some
+experience with the kit. Most errors will be caused by the
+backend programs, so looking at the assembly code generated by
+such a backend from EM code is a good strategy when looking for
+a cause.
+
+The programs in the directory ctgen are structured somewhat
+differently. This directory contains a file 'OPS' with a
+prototype program. This prototype program performs all C
+arithmetic operations on a few operands. The operands are
+X, Y, S, Z1, Z2. X, Y and S can be arbitrary expressions,
+but S is used as a shift count and must be less then 16 (32).
+Z1 and Z2 must be lvalue's.
+The name ISTART indicates global declarations and LSTART
+indicates local declarations.
+The files ....sed (e.g. test.sed) are used
+to produce legal C programs from the OPS file, in which
+the result of all expressions is printed.
+The programs are run in the way described above.
diff --git a/lang/cem/ctest/ctconv/conv.c b/lang/cem/ctest/ctconv/conv.c
new file mode 100644 (file)
index 0000000..7c948db
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * (c) copyright 1983 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ *
+ *          This product is part of the Amsterdam Compiler Kit.
+ *
+ * Permission to use, sell, duplicate or disclose this software must be
+ * obtained in writing. Requests for such permissions may be sent to
+ *
+ *      Dr. Andrew S. Tanenbaum
+ *      Wiskundig Seminarium
+ *      Vrije Universiteit
+ *      Postbox 7161
+ *      1007 MC Amsterdam
+ *      The Netherlands
+ *
+ */
+
+/* Author: E.G. Keizer */
+
+main() {
+       t1() ;
+       return 0 ;
+}
+
+t1() {
+       char c ; int i ; long l ; unsigned u ; float f ;
+
+       /* test conversions */
+
+       /* first some conversions on constants */
+
+       printf("(int) '\\377' = %d\n",(int) '\377') ;
+       printf("(long) -1 = %ld\n",(long) -1 ) ;
+       printf("(float) 12 = %f\n",(float) 12 ) ;
+       printf("(int) 3.14 = %d\n",(int) 3.14 ) ;
+       printf("(int) 32767L = %d\n",(int) 32767L ) ;
+       printf("(int) -32768L = %d\n",(int) -32768L ) ;
+       printf("(char) 128L = %d\n",(char) 128L) ;
+       printf("(char) 0377 = %d\n",(char) 0377 ) ;
+       printf("(char) -1 = %d\n",(char) -1 ) ;
+       printf("(char) 10000 = %d\n",(char) 10000 ) ;
+
+       /* conversions from characters */
+       printf("From character\n") ;
+       c = 127 ;
+       i=c ;
+       l=c ;
+       u=c ;
+       f=c ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+       c = -1 ;
+       i=c ;
+       l=c ;
+       u=c ;
+       f=c ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+       c = 0377 ;
+       i=c ;
+       l=c ;
+       u=c ;
+       f=c ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+
+       /* from integer */
+       printf("From integer\n") ;
+       i= -64 ;
+       c=i ;
+       l=i ;
+       u=i ;
+       f=i ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+
+       /* from long */
+       printf("From long\n") ;
+       l = -3 ;
+       c = l ;
+       i = l ;
+       u = l ;
+       f = l ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+
+       printf("From float\n") ;
+       f = 121.5 ;
+       c = f ;
+       i = f ;
+       u = f ;
+       l = f ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+       f = 1e-4 ;
+       c = f ;
+       i = f ;
+       u = f ;
+       l = f ;
+       printf("\tchar %5d, int %6d, unsigned %6o, long %11ld, float %f\n",c,i,u,l,f) ;
+       f = 3276.6e1 ;
+       i = f ;
+       u = f ;
+       l = f ;
+       printf("\tint %6d, unsigned %6o, long %11ld, float %f\n",i,u,l,f) ;
+       f = 1223432e3 ;
+       l = f ;
+       printf("\tlong %11ld, float %f\n",l,f) ;
+
+       /* some special cases */
+       {
+               int a[4] ;
+
+               l = 3 ; a[3]= -17 ;
+               printf("a[l] (l==%ld) %d\n",l,a[l]) ;
+               printf("a[3l] %d\n",a[3l] ) ;
+
+       }
+       return 0 ;
+}
diff --git a/lang/cem/ctest/ctconv/conv.cem.g b/lang/cem/ctest/ctconv/conv.cem.g
new file mode 100644 (file)
index 0000000..af5a607
--- /dev/null
@@ -0,0 +1,25 @@
+(int) '\377' = 255
+(long) -1 = -1
+(float) 12 = 12.000000
+(int) 3.14 = 3
+(int) 32767L = 32767
+(int) -32768L = -32768
+(char) 128L = 128
+(char) 0377 = 255
+(char) -1 = 255
+(char) 10000 = 16
+From character
+       char   127, int    127, unsigned    177, long         127, float 127.000000
+       char   255, int    255, unsigned    377, long         255, float 255.000000
+       char   255, int    255, unsigned    377, long         255, float 255.000000
+From integer
+       char   192, int    -64, unsigned 177700, long         -64, float -64.000000
+From long
+       char   253, int     -3, unsigned 177775, long          -3, float -3.000000
+From float
+       char   121, int    121, unsigned    171, long         121, float 121.500000
+       char     0, int      0, unsigned      0, long           0, float 0.000100
+       int  32766, unsigned  77776, long       32766, float 32766.000000
+       long  1223432064, float 1223432064.000000
+a[l] (l==3) -17
+a[3l] -17
diff --git a/lang/cem/ctest/ctconv/run b/lang/cem/ctest/ctconv/run
new file mode 100644 (file)
index 0000000..f101417
--- /dev/null
@@ -0,0 +1 @@
+make "P=conv" -fsk ../makefile ${1-gen}