Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!seismo!rutgers!princeton!allegra!ulysses!mhuxt!ihnp4!alberta!ubc-vision!fornax!chapman
From: chapman@fornax.UUCP
Newsgroups: comp.sys.m68k,comp.sys.intel
Subject: Re: Recent Motorola ad seen in Byte
Message-ID: <280@fornax.uucp>
Date: Fri, 8-May-87 01:54:36 EDT
Article-I.D.: fornax.280
Posted: Fri May 8 01:54:36 1987
Date-Received: Sun, 10-May-87 09:15:07 EDT
References: <8705030305.AA18195@cory.Berkeley.EDU>
Organization: School of Computing Science, SFU, Burnaby, B.C. Canada
Lines: 58
Xref: mnetor comp.sys.m68k:468 comp.sys.intel:232
> >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.
>
.
. 68020 comments
.
> P.S. I didn't test this code... but it's almost a children's exercise
> anyway.
>
> -Matt
Yes, well, the problem with children is they often make mistakes.
1. The code you have produced does not meet the original "challenge"
I made to the original poster who was wondering why specific
registers and why a single instruction. Your code does not all
fit in the 68010's cache. Lest you think this is picky I will point
out that I chose the simplest of the string instructions as an example;
others would take even more code and use more registers.
2. Duplicating the function has now used up a general purpose register.
One of the advantages of the "all in one" type instruction is that
internal temporaries can be used.
3. You have not implemented FFS, you have implemented a much simpler version.
FFS is (operand order may be wrong):
FFS ,,,
is a byte address of the bit string origin
is a bit offset into the bit string at which the search
begins; if the source is not a register this may be more than 32
bits
is the length of the field to be checked in bits
is where the bit position of the first set bit
is placed
*** REPLACE THIS LINE WITH YOUR MESSAGE ***
--
{watmath,seismo,uw-beaver}!ubc-vision!fornax!sfulccr!chapman
or ...!ubc-vision!sfucmpt!chapman