AnsweredAssumed Answered

Embedded assembly in Keil

Question asked by obid.matic on Oct 5, 2016
Latest reply on Oct 6, 2016 by obid.matic


I would like to implement some kind of fault handling mechanism, which would store some CPU registers, PC, etc. in flash if error occurs.

I tried to store SP value within HardFault Handler like this:

1.__asm void HardFault_Handler(void)
3.  MRS r0, MSP
4.  B __cpp(FaultHandler_Common)

Then, I would branch to another function called FaultHandler_Common, where I would have current SP available as a function argument.

Everything compile, except that Keil shows 2 messages:

1. At the line 1 (in upper example) it shows:  " error: expected '(' after 'asm' "

2. At the line 3 (in upper example) it shows:  " error: use of undeclared identifier 'MRS' "

Do I have to change something thate those messages will not be shown?