This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: asm ("...") on PPC


On 24 Feb 2000, Bill Pringlemeir wrote:

> >>>>> "Geir" == Geir Frode Raanes <geirfrs@invalid.ed.ntnu.no> writes:
> 
>     Geir> I am attemting to create the tightest loop possible on my
 
> The @ha and @l are the high and low 16 bits of the ioptr.  Immediate
> instructions can only load 16 bits of data.

Ahhh. That I suppose explains the strange xxxADJ macros in the
vxWorks PowerQUICC BSP. Guess we are back to the usual RTFMF.
 
> I would suggest that you don't use the label linejeloop.  I would use 
> the 'local labels'.  Like 10: and then 'bdnz+ 10b'.  Sorry if that isn't 
> PPC assembler I have coded on the ARM and AVR since my PPC days.

Does this give shorter address modes or just cleaner syntax?

> opps... I have to ask this, did you put line-feeds in the string?

Didn't actually give it much thought. The GCC docs state that I
should use semicolons ";" for separators and keep all instructions
on the same line. I just tried breaking up the lines and it worked.

> Here is a version that I think might work.
> 
>     asm volatile ("    mtctr %3     \n"         /* crt = linjeteller */
>                   "    subi %0,4    \n"         /* ioptr--  */
>                   "    subi %1,4    \n"         /* memptr-- */
>                   "10: lwzu r9,4(%0)\n"         /* get source [++ioptr] */
>                   "    stwu r9,4(%1)\n"         /* store target [++memptr] */
>                   "    bdnz+ 10b    \n"         /* loop until crt == 0 */ "
>     : "=b" (ioptr), "=b" (memptr)
>     :  "0" (ioptr),  "1" (memptr), "r" (linjeteller)
>     : "r9", "ctr" );

Your version is, of cause, much safer. However, if the purpose is to
purify the eventual assembly output then the following produces
assembly listings indistinguishable from the GCC produced assembly:
(using tab stops)

asm volatile ("mtctr %3          \n"  /* crt = linjeteller */
              "\tsubi %0,0,4     \n"  /* ioptr--  */
              "\tsubi %1,0,4     \n"  /* memptr-- */
              "10:\tlwzu 9,4(%0) \n"  /* get source [++ioptr] */
              "\tstwu 9,4(%1)    \n"  /* store target [++memptr] */
              "\tbdnz+ 10b         "  /* loop until crt == 0 */
              : "=b" (ioptr), "=b" (memptr)
              :  "0" (ioptr),  "1" (memptr), "r" (linjeteller)
              : "r9", "ctr" );

Here of cause I took the register naming convention suggested by
Ian Lance Taylor to heart. Though GAS does understand "r9" and
"ctr" in the 'affected' field. Besides, Windriver use "rX"  for
register names exclusively in their BSP.

But what is the difference between the "b" - base address register,
and "r" - general register argument restrictions for PowerPC?

 
--
  ******************************************************
  Never ever underestimate the power of human stupidity.
  -Robert Anson Heinlein

		GeirFRS@invalid.and.so.forth
  ******************************************************


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]