[Cbe-oss-dev] spu-gcc inline asm

Phil Pratt-Szeliga pcpratts at syr.edu
Sat Jul 18 00:32:49 EST 2009


Hello,

I am doing something for google summer of code (I am working on opencl
for gcc) and I am having trouble jumping
to a function that is downloaded at runtime.

The first step is to jump to a function with arguments.  It works
using inline assembly using no arguments, but I can't
figure out how to make it work with an argument.  Is the spu-gcc
inline assembly syntax different?

Sincerely,
Phil Pratt-Szeliga


/* spu_example.c */
/* compile with: spu-gcc spu_example.c*/

void function1(unsigned long long arg)
{
    printf("hello world %llu\n", arg);
}

int main(unsigned long long spe_id, unsigned long long
program_data_ea, unsigned long long env) {

  /* works fine */
  function1(10);

  /* works fine */
  unsigned long long arg1 = 20;
  asm("andbi $3,$3,20;\
       brsl $0, function1;");

  /* gives me the compiler error #1 */
  asm ("andbi $3,$3,%0"
      : /* no output args */
      : "r" (arg1)
      );
  asm("brsl $0, function1");
}


/* Compiler error #1:

/tmp/ccyF7J51.s: Assembler messages:
/tmp/ccyF7J51.s:249: Warning: Treating '$2' as a symbol.
/tmp/ccmkHyG2.o: In function `main':
spu.c:(.text+0x3a0): undefined reference to `$2'
collect2: ld returned 1 exit status

*/


More information about the cbe-oss-dev mailing list