Getting the PC value in ARM assembly

Posted by PaulH on Stack Overflow See other posts from Stack Overflow or by PaulH
Published on 2010-04-27T18:11:36Z Indexed on 2010/04/27 18:13 UTC
Read the original article Hit count: 381

Filed under:
|
|

I have a Windows Mobile 6 ARMV4I project where I would like to get the value of the program counter.

The function is declared like this:

extern "C" unsigned __int32 GetPC();

My assembly code looks like this:

GetPC FUNCTION
    EXPORT GetPC
    ldr r0, [r15]   ; load the PC value in to r0
    mov pc, lr      ; return the value of r0
ENDFUNC

But, when I call the GetPC() function, I get the same number every time. So, I'm assuming my assembly isn't doing what I think it's doing. Can anybody point out what I may be doing wrong?

Thanks, PaulH

© Stack Overflow or respective owner

Related posts about arm

Related posts about assembly