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 from an assembly file into a C++ function

Hi,

I need to :

1. Inline an assembly code that modifies Stack pointer directly (__asm directive is not allowed to modify stack pointer) in a C++ file.

What is the best option? A function call to a label is not an option since I need to manually update Stack Pointer. I need to inline.

I read I can create SRC file. Can I create SRC from the C++ compiler ? if so what is the Directive/Flag? --SRC didn't work.

#prama asm was unrecognized pragma. perhaps because I'm not creating SRC.

Thanks.

Parents
  • These all work -

    __set_MSP (newstack); // Built into CMSIS
    __set_PSP (newstack);
    
    __asm void __SetMsp(uint32_t stack)  // If you don't want to call CMSIS for some reason
    {
        MSR     PSP,R0
        BX      LR
    }
    
    __asm void __setPsp(uint32_t stack)
    {
        MSR     PSP,R0
        BX      LR
    }
    

Reply
  • These all work -

    __set_MSP (newstack); // Built into CMSIS
    __set_PSP (newstack);
    
    __asm void __SetMsp(uint32_t stack)  // If you don't want to call CMSIS for some reason
    {
        MSR     PSP,R0
        BX      LR
    }
    
    __asm void __setPsp(uint32_t stack)
    {
        MSR     PSP,R0
        BX      LR
    }
    

Children
No data