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

SVC_Handler for Cortex M0

Note: This was originally posted on 25th October 2012 at http://forums.arm.com

Hello

we are trying to find  a short implementation for the SVCHandler interrupt.
I want to do exactly like described here, but then a working version for the Cortex-m0:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0203j/BABFGEFG.html

and here:

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0179b/ar01s02s07.html

we have no experts at assembly and the only thing we need is to get the svc number and arguments.
But if someone can explain me how the svc handler works I would be greatly helped.
And maybe someone can point me in the right direction on how to return values : "[font=Verdana, Tahoma, Arial, Helvetica, sans-serif][size=2]Any return value must also be passed back to the caller by modifying the stacked register values[/size][/font]".

Thank you in advance!

Martijn
Parents
  • Note: This was originally posted on 26th October 2012 at http://forums.arm.com

    Thank you so much!

    This works great:


    ;--------- SVC HANDLER --------------
    SVC_Handler  PROC
            ;  EXPORT  SVC_Handler            [WEAK]
            IMPORT SVC_Handler_main
            MOVS  R0, #4
            MOV   R1, LR
            TST   R0, R1
            BEQ   stacking_used_MSP
            MRS   R0, PSP ; first parameter - stacking was using PSP
            LDR   R1, =SVC_Handler_main
            BX    R1
    stacking_used_MSP
            MRS   R0, MSP ; first parameter - stacking was using MSP
            LDR   R1, =SVC_Handler_main
            BX    R1
            ENDP
    ;--------- END SVC HANDLER --------------



    the compiler gave an error on __cpp

    And thank you for the explanation on the svc number!
Reply
  • Note: This was originally posted on 26th October 2012 at http://forums.arm.com

    Thank you so much!

    This works great:


    ;--------- SVC HANDLER --------------
    SVC_Handler  PROC
            ;  EXPORT  SVC_Handler            [WEAK]
            IMPORT SVC_Handler_main
            MOVS  R0, #4
            MOV   R1, LR
            TST   R0, R1
            BEQ   stacking_used_MSP
            MRS   R0, PSP ; first parameter - stacking was using PSP
            LDR   R1, =SVC_Handler_main
            BX    R1
    stacking_used_MSP
            MRS   R0, MSP ; first parameter - stacking was using MSP
            LDR   R1, =SVC_Handler_main
            BX    R1
            ENDP
    ;--------- END SVC HANDLER --------------



    the compiler gave an error on __cpp

    And thank you for the explanation on the svc number!
Children
No data