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.

Problem with __asm() syntax

Other Parts Discussed in Thread: CC2538

Hi All,

While compiling below code for cc2538 using ccsv5 on ubunt 12.04.

*
 * \addtogroup cc2538-cpu
 * @{
 *
 * \file
 * Implementations of interrupt control on the cc2538 Cortex-M3 micro
 */
/*---------------------------------------------------------------------------*/
unsigned long __attribute__((naked))
cpu_cpsie(void)
{
  unsigned long ret;

  /* Read PRIMASK and enable interrupts */
  __asm("    mrs     r0, PRIMASK\n"
        "    cpsie   i\n"
        "    bx      lr\n"
        : "=r" (ret));

  /* The inline asm returns, we never reach here.
   * We add a return statement to keep the compiler happy */
  return ret;
}
/*---------------------------------------------------------------------------*/
unsigned long __attribute__((naked))
cpu_cpsid(void)
{
  unsigned long ret;

  /* Read PRIMASK and disable interrupts */
  __asm("    mrs     r0, PRIMASK\n"
        "    cpsid   i\n"
        "    bx      lr\n"
        : "=r" (ret));

  /* The inline asm returns, we never reach here.
   * We add a return statement to keep the compiler happy */
  return ret;
}
/*---------------------------------------------------------------------------*/

/** @} */

I got Type#18 expected a ")"    error at : "=r" (ret)); and apart from that I am getting some warning they are

Type#1173-D attribute "naked" and Type#551-D variable "ret" is used.

Please let me know how to resolve them.

I am not familiar with assemble code and is above code is good way of writing interrupt control.If not let me know how to modify the above one.

Thanks in ADVANCE,

Jagas