Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: H300 assembly introducing artifacts

Re: H300 assembly introducing artifacts

From: Brandon Low <lostlogic_at_lostlogicx.com>
Date: 2005-12-21

All of the code in rockbox that uses the accumulators moves out of them
with movclr, so it should be. If I have occasion to revisit that
solution, I'll make sure to test with clearing it manually.

The solution I settled on for that code snippet was:

  asm ("sub.l %[x0],%[x]\
    \n\tsub.l %[y0],%[y1]\
    \n\tsub.l %[x0],%[x1]\
    \n\tmuls.l %[y1],%[x]\
    \n\tdivs.l %[x1],%[x]\
    \n\tadd.l %[y0],%[x]"
       : [x] "+d" (x), [x1] "+d" (x1), [y1] "+d" (y1)
       : [x0] "r" (x0), [y0] "r" (y0) );
  return x;

Thanks and happy holidays,

Brandon

On Wed, 12/21/05 at 01:42:58 +0100, Kaggen wrote:
> Is acc0 cleared before this asm code is executed?
>
> Happy Holidays,
> Anders
>
> Brandon Low wrote:
>
> >Well there's a faster way to do it, and it doesn't cause stupidity, so
> >I'll go with that.
> >
> >Brandon
> >
> >On Tue, 12/20/05 at 16:05:21 -0600, Brandon Low wrote:
> >
> >
> >>I'm working on optimizing Tremor and have run into a quandry. The
> >>following set of code snippets should do exactly the same thing, but I'm
> >>getting bad artifacts when I use the assembly version, and not when I
> >>use the plain-old-C version. Any thoughts are welcome.
> >>
> >>#if defined(CPU_COLDFIRE) && !defined(SIMULATOR)
> >> asm ("mac.l %[y0],%[x0],%%acc0\
> >> \n\tmsac.l %[y0],%[x],%%acc0\
> >> \n\tmac.l %[y1],%[x],%%acc0\
> >> \n\tmsac.l %[y1],%[x0],%%acc0\
> >> \n\tmovclr.l %%acc0,%[x]\
> >> \n\tsub.l %[x0],%[x1]\
> >> \n\tdivs.l %[x1],%[x]\
> >> \n\nadd.l %[y0],%[x]"
> >> : [x] "+d" (x), [x1] "+d" (x1)
> >> : [x0] "r" (x0), [y0] "r" (y0), [y1] "r" (y1)
> >> : "cc" );
> >> return x;
> >>#else
> >> return y0+((y1-y0)*(x-x0))/(x1-x0);
> >>#endif
> >>
> >>Thanks,
> >>
> >>Brandon
> >>
> >>
> >
> >
> >
Received on Wed Dec 21 03:59:39 2005


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa