Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.m68k,comp.sys.intel Subject: Re: Recent Motorola ad seen in Byte Message-ID: <8705030305.AA18195@cory.Berkeley.EDU> Date: Sat, 2-May-87 23:05:38 EDT Article-I.D.: cory.8705030305.AA18195 Posted: Sat May 2 23:05:38 1987 Date-Received: Sun, 3-May-87 08:43:38 EDT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 33 Xref: mnetor comp.sys.m68k:440 comp.sys.intel:219 >1. how would you code a string instruction like FFS (find first set bit) > to fit in something like the 68010's single instruction looping > feature/cache? moveq.l #31,D0 move.l ea,D1 loop asl.l #1,D1 dbcs loop Notes: You could just as easily specify 7, and use byte operations to find the first set bit in a byte. The routine above checks bits MSB first. You can, of course, use lsr instead to check bits LSB first. (remember to take 32 - the count afterword for longword operations) You can add an outer loop to check any size item by using (A0)+ for the EA on the MOVE (and setting up A0) when loading the initial data into D1, followed by, say, a BEQ if you also want to check for an end of string. Remember that the outer loop would only execute once every 32 cached loops (97% of the instructions are cached) assuming you use longword operations. And, of course, it would all fit into a 68020's cache. The DBcc instruction quite versitile. Even though the 68000/68010's DBcc (not sure about 68020) only supports word decrements on the data register, it is quite simple to support 32 bit counts with the addition of an outer loop (another two instructions... a subi.l, and a branch). Maximum efficiency would give 65536 inner loops for every 1 outer loop, or a .0015 PERCENT loss over a DBcc which used the full 32 bits of the data register. P.S. I didn't test this code... but it's almost a children's exercise anyway. -Matt