cpu% cat getcallerpc.s
TEXT getcallerpc(SB), $0
        MOVL    v+0(FP), AX
        MOVL    -4(AX), AX
        RET

> .globl        getcallerpc
> getcallerpc:
>       movl    0(%esp),%edx
>       movl    -4(%edx),%eax
>       ret

not quite.  0(%esp) is going to be the saved %eip.

getcallerpc:
        movl 4(%esp), %eax
        movl -4(%eax), %eax

or

uint
getcallerpc(void *a)
{
        return ((uint*)a)[-1];
}

russ

Reply via email to