[comp.sys.atari.st] Sozobon C compiler

andrejp@cnetlu.UUCP (Pierre Andr{) (02/20/89)

I got into a few problems while trying to recompile the Sozobon C
compiler: can somebody confirm them and/or give fixes ?

A) dependencies on host compiler characteristics:

1) in struct gnode, a few fields (gr1, gr2, grno) declared as
   char are assigned negative values. Must replace char by short on
   machines with no signed chars. There might be other instances
   of this feature.
2) in i_exp(), sign extensions for constants depend on what types
   char and short are on the host compiler. Correction follows:
   =  l = np->g_offs;
   =  switch (osz) {   /* JPA make the following independant of compiler */
   =  case 1:
   =     if (l & 128) l |= (-128);     /* JPA was  l = (char) l;  */
   =     else l &=127;
   =     break;
   =  case 2:
   =     if (l & 32768) l |= (-32768);   /* JPA was  l = (short) l; */
   =     else l &=32767;
   =     break;
   =  }
3) related to the same point, it is unclear to me what icon_ty should
   return when assigned a constant value of, say 65535, to an unsigned
   int. Is "(int)val" [passed to isintv()] meant to be -1 in such a case ?

B) missing return values

1) function m_fldas() has a random return value
   should append "else return 0;" at end of function
2) the same must apply to asm_stmt(), but I don't know
   the proper return value.

C) bad code generated:

1) the preprocessor construct "#if sth <=" behaves incorrectly:
   cause unknown.
       example:    #define BITS 15
                   #if BITS <= 12
                    (following text not skipped !)
2) the compiler may generate "clr.l AREG", which is a bad addressing
   mode. example   register char *p;
                   p = NULL;
   this happened in top itself, in function getfun().
3) when passing an unsigned char to a function, a sign extension occurs
   instead of a zero-extension. Bug found in onearg(); correction follows:
   =  switch (np->g_sz) {
   =  case 1:
   =     if (np->g_ty == ET_U) /* pushing an unsigned char ? JPA */
   =        addcode(np,     /* do NOT use clr.w/move.b ! JPA */
   =           "\tmove.b\tA,d0\n\tand.w\t#255,d0\n\tmove.w\td0,-(sp)\n");
   =     else
   =        addcode(np,
   =           "\tmove.b\tA,d0\n\text.w\td0\n\tmove.w\td0,-(sp)\n");
   =     return 2;
4) bad expression evaluation have been found. Cause unknown.
   example     long b;
               b = !(b==0);  /* "not" (!) operator forgotten here */

+-----------------------------------------------------------------------+
|                               +-France--------+          C N E T      |
|     Jean-Pierre ANDRE         ! T E L E C O M !     route de Tregastel|
|                               +---------------+       22301 LANNION   |
|   uucp: ...!mcvax!inria!cnetlu!andrejp                   FRANCE       |
|      or andrejp@lannion.cnet.fr                                       |
|   Minicom (3614+MNC): ANDRE/9605 1596            Tel +33-96.05.22.48  |
+-----------------------------------------------------------------------+

hyc@math.lsa.umich.edu (Howard Chu) (02/21/89)

I was going to try compiling ARC with Sozobon, to see if it would
produce any smaller/faster code than MWC, but I think I'm going to
abandon that idea now. The preprocessor won't handle boolean expressions
on #if lines correctly. e.g.
	#if MACRO1 || MACRO2

generates the message "must be constant" or something to that effect.
It *really* doesn't like using an #undef'ed name either. My copy of K&R
doesn't really say very much about what the preprocessor is supposed to
do in those situations, so I guess it's more a problem for me, not a bug.

In any case, I guess I'm stuck with MWC until Turbo comes along, or maybe
if I can get decent library routines for GCC. 

I just ordered and received the source code for the MWC library. Pretty
handy to have, since there seem to be some useful functions there that
I can't find anywhere in my 2.00 Lexicon, nor the 2.1 and 3.0.6 update
pages... Interesting to note that the library sources say they're for
3.0.9, but I've only heard of a 3.0.6 in their 3.0 release... Ah well.

Added a Unix-style setbuffer() to the stdio lib, using a 30K file buffer
in ARC seems to speed up ARC'ing on floppies by about 30%, for large files.
Not a bad gain for such a cheap addition... (But figure it at up to 90K
more memory required, when adding files to an existing archive it needs
at least 3 buffers.)
--
  /
 /_ , ,_.                      Howard Chu
/ /(_/(__                University of Michigan
    /           Computing Center          College of LS&A
   '              Unix Project          Information Systems