This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Inline Assembly coding

  • Note: This was originally posted on 22nd July 2011 at http://forums.arm.com

    Hi,

    I'm trying to store the value of integer b into the address pointed to by c.
    Could you please check the Macro definition of STORE_REG and tell me if its correct?

    Thanks a lot...
  • Note: This was originally posted on 11th August 2011 at http://forums.arm.com

    Hi

    The general format for ARM inline assembly is,
    asm(code : output operand list : input operand list : clobber list);

    In the example given by you, output operand list and clobber list are present. "cc" in the clobber list mentions that the instruction will modify condition code flags.

    You may go through the below link for more info,

    http://www.ethernut.de/en/documents/arm-inline-asm.html
    - Divya


    Hi,
    I am also a newbie of asm. Can any one help to explain below GCC function codes, what are the meaning of the :"cc"?
    Thanks in advance!
    -----------------------------------

    static inline unsigned int read_cpuid(void)
    {
    unsigned int val;

    /* Main ID register (MIDR) */
    asm("mrc        p15, 0, %0, c0, c0, 0"
           : "=r" (val)
           :
       : "cc"); //What's this means?

    return val;
    }
    --------------------------------
  • Note: This was originally posted on 11th August 2011 at http://forums.arm.com

    Hi,
    I am also a newbie of asm. Can any one help to explain below GCC function codes, what are the meaning of the :"cc"?
    Thanks in advance!
    -----------------------------------

    static inline unsigned int read_cpuid(void)
    {
    unsigned int val;

    /* Main ID register (MIDR) */
    asm("mrc        p15, 0, %0, c0, c0, 0"
        : "=r" (val)
        :
       : "cc"); //What's this means?

    return val;
    }
    --------------------------------
  • Note: This was originally posted on 22nd July 2011 at http://forums.arm.com


    Hi,

    I'm trying to store the value of integer b into the address pointed to by c.
    Could you please check the Macro definition of STORE_REG and tell me if its correct?

    Thanks a lot...


    I don't know anything at inline assembly but


    are you sure you need the & into your macro ?
    and I think the both value must be specified as source.

    try

    #define STORE_REG(src, dest) asm("str %[source], [%[result]]" : : [result] "r"(dest), [source] "r"(src))


    while c is a pointeur you need to use it's value and not it's address.
    that's without any warranty !!
  • Note: This was originally posted on 22nd July 2011 at http://forums.arm.com

    Try STORE_REG( c, b );

    Currently it looks like you are trying to write the pointer into the address held in the integer, which I'm pretty sure you are not wanting to do.