Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.sys.m68k Subject: Incidentally ... (was Re: Recent Motorola ad) Message-ID: <6134@mimsy.UUCP> Date: Sat, 4-Apr-87 04:53:38 EST Article-I.D.: mimsy.6134 Posted: Sat Apr 4 04:53:38 1987 Date-Received: Sun, 5-Apr-87 10:08:53 EST References: <362@sbcs.UUCP> <1466@ncr-sd.SanDiego.NCR.COM> <580@plx.UUCP> <73@eps2.UUCP> Distribution: comp Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 22 > while (wy--) { > j = wx; > while (j--) { (The above is an inner loop.) Such loops should usually (always?) be written as while (--j >= 0) ---assuming j is signed. Why? They both do the same thing, but a dumb compiler will turn the former into `move j to tmp; decrement j; test tmp; branch if zero', while the same dumb compiler will turn the latter into `decrement j; branch if negative'. Details will vary depending on condition codes, but the former is often four instructions, and the latter two. On a Vax, the second version is sometimes a single instruction. Of course, a smart compiler will generate the same code for both. That is wonderful---if you have a smart compiler. Better check! -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu