title: Branching to a c symbol from thumb inline assembly
body: <p>I'm on a Cortex-M0+ device (Thumb only) and I'm trying to dynamically generate some code in ram and then jump to it, like so:</p>
  
  <pre><code>uint16_t code_buf[18];
  ...
  void jump() {
    register volatile uint32_t* PASET asm("r0") = &amp;(PA-&gt;OUTSET.reg);
    register volatile uint32_t* PACLR asm("r1") = &amp;(PA-&gt;OUTCLR.reg);
    register uint32_t set asm("r2") = startset;
    register uint32_t cl0 asm("r3") = clears[0];
    register uint32_t cl1 asm("r4") = clears[1];
    register uint32_t cl2 asm("r5") = clears[2];
    register uint32_t cl3 asm("r6") = clears[3];
    register uint32_t dl0 asm("r8") = delays[0];
    register uint32_t dl1 asm("r9") = delays[1];
    register uint32_t dl2 asm("r10") = delays[2];
    register uint32_t dl3 asm("r11") = delays[3];
    asm volatile (
      "bl code_buf\n"
       : [set]"+r" (set) : [PASET]"r" (PASET), [PACLR]"r" (PACLR), [cl0]"r" (cl0), [cl1]"r" (cl1), [cl2]"r" (cl2), [cl3]"r" (cl3), [dl0]"r" (dl0), [dl1]"r" (dl1), [dl2]"r" (dl2), [dl3]"r" (dl3) : "lr"
    );
  }
  </code></pre>
  
  <p>The code in code_buf will use the arguments passed via registers (that's why I'm forcing specific registers).
  This code compiles fine, but when I look at the disassembly the branch instruction has been changed to</p>
  
  <pre><code>     a14:   f004 ebb0   blx 0x5178
  </code></pre>
  
  <p>Which would try to switch the cpu to ARM mode and cause a HardFault. Is there a way to force the assembler to keep the branch as a simple bl?</p>