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.

Compiler/AM3357: _asm statement in C function

Part Number: AM3357

Tool/software: TI C/C++ Compiler

Hi,

I see that TI uses the following in their source code (for example in file "cpu.c" from StarterWare V2.0.1.1):

/*
**
** Wrapper function for the IRQ disable function
**
*/
void CPUirqd(void)
{
    /* Disable IRQ in CPSR */
    asm("    mrs     r0, CPSR\n\t"
        "    orr     r0, r0, #0x80\n\t"
        "    msr     CPSR_c, r0");
}

At the same time TI says there might be a problem using _asm statement within a C function body:

e2e.ti.com/.../830220

Just to make shure I want to ask if the implementation above could cause any troubles or if one should write the following instead (code from the link above):

__asm("    .sect \".text:CPUirqd\"\n"
          "    .clink\n"
          "    .global CPUirqd\n"
          "CPUirqd:\n"
        "    mrs     r0, CPSR\n\t"
        "    orr     r0, r0, #0x80\n\t"
        "    msr     CPSR_c, r0\n\t"
        "    bx      lr");

I'm looking forward getting a clear statement from a TI compiler expert. Thanks.

Regards,
Patrick

  • Pruf said:
    I'm looking forward getting a clear statement from a TI compiler expert.

    That statement is in the section titled The __asm Statement in the ARM compiler manual.

    That section discusses __asm generally.  As to this specific situation, the preferred implementation is a function in an assembly source file.  I cannot say why the StarterWare development team did it differently.

    Thanks and regards,

    -George

  • George,

    Thanks for your response. We will rewrite all the functions in the file "cpu.c" in a conventional asm file. This way I think there will be no question mark left open.

    Regards,
    Patrick