Topic
2 replies Latest Post - ‏2010-08-26T15:04:53Z by ygdura
ygdura
ygdura
2 Posts
ACCEPTED ANSWER

Pinned topic The value read by "rdch" instruction

‏2010-08-21T16:12:27Z |
Hello Guys,

Can any one help? I am trying to read a message from an SPE inbound mailbox using "rdch" assembly instuction, BUT every time I get "0".

Here is the piece of code

unsigned int rdmsg()
{
__asm__("rdch $3,$SPU_RdInMbox");
}

unsinged int m=rdmsg();

By the way, if I use one of the following functions:

unsinged int m=spu_readch(SPU_RdInMbox);
unsinged int m=spu_read_in_mbox();

the program reads the message correctly.

regards,
You
Updated on 2010-08-26T15:04:53Z at 2010-08-26T15:04:53Z by ygdura
  • jk-
    jk-
    43 Posts
    ACCEPTED ANSWER

    Re: The value read by "rdch" instruction

    ‏2010-08-23T02:27:18Z  in response to ygdura
    Hi,

    Your inline asm syntax is incorrect - you need to specify that a register is updated with the result of your ASM, and not just assume that r3 will be preserved (and returned from the function). Something like this:

    
    unsigned 
    
    int rdmsg(
    
    void) 
    { unsigned 
    
    int x; __asm__(
    "rdch %0, $SPU_RdInMbox" : 
    "=r"(x)); 
    
    return x; 
    }
    


    However, this is exactly what the spu_readch function does, there is no need to rewrite it.
    • ygdura
      ygdura
      2 Posts
      ACCEPTED ANSWER

      Re: The value read by "rdch" instruction

      ‏2010-08-26T15:04:53Z  in response to jk-
      Thank you JK,
      I did copy the same code you proposed, but I still have the same problem. I get zeros.

      The reason behind using this approach to check if it is faster than using the "spu_readch" function.

      By the way, I am using GNU g++ compiler.
      regards,
      Youssef