Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!inria!timpit0!cnetlu!andrejp From: andrejp@cnetlu.UUCP (Pierre Andr{) Newsgroups: comp.sys.atari.st Subject: Sozobon C compiler Summary: A few fixes provided. Help appreciated Keywords: bugs Message-ID: <785@cnetlu.UUCP> Date: 20 Feb 89 10:00:36 GMT Organization: Ctre Nat Etudes Telecom, 22301 LANNION, FRANCE Lines: 67 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 | +-----------------------------------------------------------------------+