ARM DSP FUNCTIONS

Richard Earnshaw rearnsha@arm.com
Fri Aug 21 14:04:00 GMT 2009


On Thu, 2009-08-20 at 18:25 +0200, Riaan Pieters, CellAir wrote:
> Hi,
> 
> I am using GCC on the ARM946, I want to use the DSP functions of the ARM, I
> do the following:
> 
> static inline spx_word32_t MULT16_16(spx_word16_t x, spx_word16_t y) {
>   int res;
>   asm ("smulbb  %0,%1,%2;\n"
>               : "=&r"(res)
>               : "%r"(x),"r"(y));
>   return(res);
> }
> 
> I get a "bad command" error.
> 
> 
> Firstly, is this possible?
Yes

> If so, what do I need to do to be able to do this
Well, you don't really say enough to make it clear what's going wrong
for you.  However, are you specifying the CPU on the command line when
compiling?  I suspect not, otherwise you might already have noticed that
the compiler can already generate smulbb without recourse to assembly
language.

static inline int MULT16_16(short x, short y) {
  return x * y;
}

short w, x;

int main() { w = MULT16_16(w,x); }

arm-eabi-gcc -c -mcpu=arm946e-s test.c

Assembly code generated for the above is:

main:
        @ args = 0, pretend = 0, frame = 0
        @ frame_needed = 0, uses_anonymous_args = 0
        @ link register save eliminated.
        ldr     r3, .L2
        ldr     r1, .L2+4
        ldrh    r2, [r3, #0]
        ldrh    r1, [r1, #0]
        smulbb  r2, r1, r2
        strh    r2, [r3, #0]    @ movhi
        bx      lr

For this case you'll get similar code with your asm statement, but it's
far better to let the compiler pick the instruction if it can; then it
can optimize things further if the chance arises.

R.



More information about the Gcc-help mailing list