Xref: utzoo comp.unix.wizards:16680 comp.lang.c:19188 Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!oliveb!sun!david@sun.com From: david@sun.com (there IS no ``average'' SubGenius) Newsgroups: comp.unix.wizards,comp.lang.c Subject: Re: Optimal for loop on the 68020. Message-ID: <108192@sun.Eng.Sun.COM> Date: 6 Jun 89 03:21:49 GMT References: <11993@well.UUCP> Sender: david@sun.Eng.Sun.COM Lines: 54 The Sun 680x0 compiler has been able to generate dbcc loops for a long time. However, the loop has to be written in a particular form. Here are some examples compiled with the SunOS 3.5 cc: 1. register short s; for (s = 127; s != -1; s--) ; moveq #127,d7 LY00001: dbra d7,LY00001 2a. register int i; for (i = 127; i != -1; i--) ; moveq #127,d6 LY00003: subql #1,d6 moveq #-1,d7 cmpl d7,d6 jne LY00003 (Oops!) 2b. register int i; i = 127; while (--i != -1) ; moveq #127,d6 L20: dbra d6,L20 clrw d6 subql #1,d6 jcc L20 3. extern int x; register short s; s = 127; while (x >= 0 && --s != -1) ; moveq #127,d7 L15: tstl _x dblt d7,L15 P.S. Sun users might want to look at the PR_LOOP macros in . -- David DiGiacomo, Sun Microsystems, Mt. View, CA sun!david david@sun.com