Function calls from ASM

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by Fklein23 on Wed Jul 23 13:03:08 MST 2014
I have the following assembly function:

        .global PixelRotDelay

  movr1,r1             // approximately 12.3 nanosecs per mov
  movr1,r1             // approximately 12.3 nanosecs per mov
  bx lr                   // function return

When I call this function from C code, This is the disassembly of the caller:

450           PixelRotDelay();
0000a306:   bl      0x68d4 <PixelRotDelay>

... and this works fine and does just what I want. the bx,lr instruction returns to the right place and the stack is back to its original, pre-function call, state.

But, I need to embed calls to this function from inside assembly language, too, because the function injects a precisely calibrated delay, which is needed in dozens of places.

Unfortunately, this code, inside an assembly language function:

      bl  PixelRotDelay

crashes the stack.

What am I doing wrong???