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

Error: #40: expected an identifier

Dear All,

I am compiling following code.

__asm{ STMDB R0!, {LR} };
__asm{ MOV LR, R0 };
__asm{ LDMIA SP!, {R0} };
. .
.

But compiler is giving me following errors for each of above line.

error: #40: expected an identifier
error: #666: "asm" must be used with a function
error: #65: expected a ";"

Can anybody tell me the solution for it.
Please reply me asearly as possible.

Thanks & Regards,
Sachin D. Bhujbal

Parents
  • By giving you those messages, the compiler itself is giving you the solutions:

    Message: error: #40: expected an identifier
    Solution: Give it an identifier!

    Message: error: #666: "asm" must be used with a function
    Solution: Use it within a function!

    Message: error: #65: expected a ";"
    Solution: This is probably related to the other errors - fix them, and this will probably go away.

Reply
  • By giving you those messages, the compiler itself is giving you the solutions:

    Message: error: #40: expected an identifier
    Solution: Give it an identifier!

    Message: error: #666: "asm" must be used with a function
    Solution: Use it within a function!

    Message: error: #65: expected a ";"
    Solution: This is probably related to the other errors - fix them, and this will probably go away.

Children
  • Not exactly Andy - the OP is trying to use inline assembly in a way not supported. He would have known it had he bothered to read the compiler documentation, of course. Had he tried this - now look carefully mister OP -

    __asm void foo(void)
    {
            STMDB R0!, {R14}
            MOV R14, R0
            LDMIA SP!, {R0}
    }
    

    no errors would have been generated!

  • ... why are you doing this?

    What is it that you hope to achieve by injecting this raw assembler into your 'C' source?!

    You appear to have jumped straight into this without much study of the compiler documentation - that is extremely dangerous!!

    Sticking raw assembler in the middle of your 'C' source requires a thorough understanding of how both the compiler and the underlying target work