From: mkelly@mystix.cs.uoregon.edu (Michael A. Kelly)
Subject: Re: Help! making an assembly routine faster
Organization: University of Oregon Computer and Information Sciences Dept.
Date: Fri, 20 Nov 1992 02:13:40 GMT


>On the 040, the instructions can overlap quite a bit. I guess that the
>modification of a data register prevented the overlap. I suggest that
>you try storing the constant 0xFF in a free data register and doing
>the compare with the data register. Register to register compares should
>always be faster than immediate to register compares.

I did that, and it doesn't seem to make any difference.  My timings are to
the 1/10000 of a tick.

>It should be quite hard to improve speed from the longer code.  I bet it took
>quite a few minutes to write it.  :-)

About 120, although I didn't do it all in one sitting so it's hard to say :^/

>I do have an idea that you could try, if you still feel like the code should
>be improved.
>Instead of having a jump table, you could probably use a table of jumps. :-)

It did make a very slight difference in the long version, but no difference
it the short version.  I think this is mostly because I still have to deal
with the mask in the short version, so it really didn't change much.

>Note that I removed the special checks for 0 and 255. I think they are
>mostly wasted, but it's possible they speed things with masks with large
>solid areas.

Removing them makes the long version faster, and the short version slower.

Here's the new long version, in its entirety.  Enjoy.

(This file must be converted with BinHex 4.0)
:$%0[F(P0BA0V,Q0`G!"338083e"$9!!!!!!@#!!!!!$YpJ%"!2%!!"A1J$CQGfG
BB&#!L!H!F'!)F!"JF!#!K`!!K3L!F!!!!!C`H!F)GQ"SGQG`L'!!F)#(!'D'CRD
)#)KhChKi!(J!K`L)J!!!!!#!#!"h!!#!B!!!!!!!#!#!!!!!!)#!!(!!!!!!!)!
!!(!!!!!)F)!!#!!!!!!!!)!)"`!!J!!!!!!(#!!"0$"8"38&!a)d3)LFJ69!U"0
5P'K&L,NhDL3#G2&%d@Z5Iq1cTGMj9*GERM*hIAjVhRRLZhhYLhhqlAeBq(aTE[p
!f3k5TrAYql(%I[p%jaFm5h-kA8L6djVNaAr-e'ebGAPdBUeSc#BPZF&LYKa@12$
k-9#D*TEA**rm8&aljDd6YIjl9Yr+50bNZe*9p[4d4QA0$4kf'Qf!qk`"4'GVadV
1jYhEfi$H[4M)M2LK1rNrK1hkNlQRk4XH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QUFaIj)"!,pi'U3!"J!!!C)!!0M9!!!"GJ!!&&!R5J!!:


-- 
_____________________________________________________________________________
Michael A. Kelly                                               Senior Partner
mkelly@cs.uoregon.edu                                      High Risk Ventures
_____________________________________________________________________________