Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!rochester!ritcv!ccivax!rb From: rb@ccivax.UUCP (rex ballard) Newsgroups: net.lang.c Subject: Re: Re: fast code and no morals Message-ID: <388@ccivax.UUCP> Date: Mon, 10-Feb-86 23:49:11 EST Article-I.D.: ccivax.388 Posted: Mon Feb 10 23:49:11 1986 Date-Received: Fri, 14-Feb-86 05:55:36 EST References: <842@megaron.UUCP> <1820@brl-tgr.ARPA> Reply-To: rb@ccivax.UUCP (What's in a name ?) Organization: CCI Telephony Systems Group, Rochester NY Lines: 49 In article <6365@utzoo.UUCP> henry@utzoo.UUCP (Henry Spencer) writes: >> > Assembler isn't portable, C is. ... >> >> "C" is as portable as Stonehedge!! At least assembler languages don't >> pretend to be portable. > >How curious. At U of T we routinely move C code among half a dozen or so >different processors (more than that if you count different C compilers >for things like the 68000). Compile it and it runs. > >C's portability is more than just pretense. Of course, you have to know >what you're doing when you write the code. When the same application or small routine has to on an 8085, 8086, 68000, 68010, PDP-11, and a VAX, and is subject to FREQUENT enhancement, and only two machines run UNIX, the less written in assembler, the better. Standard practice in this case is to run everything, including libraries through lint, all 8 compilers (Large and small model 68K on native and non-native), and be real specific about types. This is much better than having to maintain 8 different assembler versions. Even if 'fast but no morals' doesn't optimize as well on the VAX as it does on the 68K, it still runs. The examples are common profiler hot spots. bcopy(dest,src,len) REG char *dest,*src; REG USHORT len; { while(len--) *dest++=*src++; } may look prettier than bcopy(dest,src,len) REG char *dest,*src; REG USHORT len; { if(len) do{ *dest++=*src++; }while(--len) } but when you are calling bcopy to move 2k before the next interrupt hits, the extra 10us per iteration (dbgt vs. test,bra) can get real costly. Adding automatic backward detection (used in editors) would be difficult in assembler, but not in C.