This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430X intrinsics for reading general-purpose registers

Using _get_R5_register(void) generates 

        MOV.W     R5,r15
        MOVX.W    r15,dst
        MOVX.W    #0,dst+2

but you actually want

        MOVX.A    R5,dst

right?

For now I'm inlining assembly to get the job done, but I'd appreciate feedback on whether I'm doing this right.  My console output confirms that I'm passing the 
--silicon_version=mspx option to the compiler.

Mateja

  • There are two separate, but related, issues here.

    The first issue is: Why does the compiler issue the extra MOV involving R15?  That is a performance bug.  It only occurs when the type of "dst" is long.  Thus I don't expect this bug to have widespread impact.  I submitted SDSCM00035775 to the SDOWP system.  Feel free to query status with the SDOWP link in my sig below.

    The second issue is: Why doesn't compiler use MOVX.A?  Well, _get_R5_register is documented to return a 16-bit wide unsigned short.  It is always going to return exactly that, without regard for the type of dst.  And MOVX.A, in effect, returns a 20-bit wide result, not a 16-bit wide result.

    Thanks and regards,

    -George

     

  • First issue:  I agree that this is a performance bug, and thank you kindly for submitting the ticket.

    Second issue:  On an extended architecture, R5 is 20 bits wide, so when I call _get_R5_register() I expect to get the whole register, not just the lowest 16 bits.  Yes, I can easily write a line of assembly to get the job done, but I thought it would make more sense that on an extended architecture, _get_R5_register() (and related intrinsics) would return an unsigned long.

    Thanks for your attention to this,

    Mateja

  • _get_R5_register is documented to return only 16 bits.  It does not change behavior when building for an extended architecture.  

    Thanks and regards,

    -George