Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.lang.c Subject: Re: C Floating point arithmetic Message-ID: <128@hadron.UUCP> Date: Wed, 18-Dec-85 03:06:14 EST Article-I.D.: hadron.128 Posted: Wed Dec 18 03:06:14 1985 Date-Received: Fri, 20-Dec-85 02:15:08 EST References: <706@lasspvax.UUCP> <7849@ucla-cs.ARPA> <984@turtlevax.UUCP> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Distribution: net Organization: Hadron, Inc., Fairfax, VA Lines: 34 Keywords: VAX11 Architecture Handbook Summary: One-instruction move & sxt/zero In article <984@turtlevax.UUCP> ken@turtlevax.UUCP (Ken Turkowski) writes: >However, if an int is a long, and your C compiler does all operations >on longs, then it takes at least one extra instruction to either sign- >or zero-extend a short or char to a long. So to add two shorts, you have: > move16 _a,r0 > ext32 r0 > move16 _b,r1 > ext32 r1 > add32 r1,r0 > move16 r0,_a >Rather than > move16 _a,r0 > add16 _b,r0 > move16 r0,_a >Or > add16 _b,_a >Can you say "order of magnitude in speed difference"? How about: cvtwl _a,r0 cvtwl _b,r1 addl2 r1,r0 cvtlw r0,_a Or, better, addw2 _b,_a This is legitimate VAX code. Can you say "efficient orthogonal architecture"? Five times fast? ;-) [No, Cottrell hasn't converted me. It just happens to be true. Programs should still be written readably and, consequently, portably.] -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}