Calling ARM assembly from C, GCC (bare metal)

前端 未结 4 478
广开言路
广开言路 2021-02-06 06:07

I am trying to do some bare-metal programming in ARM with GCC and testing on QEMU. Whenever I call into an ARM label from C, my program hangs. I have a simple example of code

4条回答
  •  忘了有多久
    2021-02-06 06:54

    In order to call an ARM mode function defined in assembly from a THUMB mode function defined in C, you need to define a symbol in assembly as a function, and the tools (Linaro gcc) will produce a blx instruction instead of bl.

    Example:

    @ Here, we suppose that this part of code is inside of .code 32
    
    .type fn, %function
    
    fn:
       mov  pc, lr
    

提交回复
热议问题