Question: I have the following ARM assembly code:

```
mov r0, SP
mov r1, LR
bl func

```

Is there a way of calling the function func using C code? something like `func(SP, LR)`

Thanks!

Answer: 
Depends on what exactly you want to do and what compiler you use.
With `gcc` something like this could work:

```
extern void func(void*, void*);
void foo()
{
    int dummy[4];
    func(&dummy, __builtin_return_address(0));
}

```

This might not always give you the exact stack pointer, though. As per [godbolt](https://godbolt.org/g/aFvbrK) it produces the following assembly code:

```
foo():
    push    {lr}
    sub     sp, sp, #20
    mov     r1, lr
    mov     r0, sp
    bl      func(void*, void*)
    add     sp, sp, #20
    ldr     pc, [sp], #4

```
Use output registers to place `LR` and `SP` in variables:

```
void *lr, *sp;

asm ("mov %0, sp" : "=r" (sp));
asm ("mov %0, lr" : "=r" (lr));
func(lr, sp);

```