who called a C routine - get it from the stack frame

dave at lsuc.UUCP dave at lsuc.UUCP
Wed Dec 17 00:45:49 AEST 1986


I just came across this code I wrote 5 years ago on a PDP-11/45
running v6:

/ returns the address of the caller's return pointer
.globl	_pcret
_pcret:
	mov	2(r5),r0	/ pc of caller of caller
	rts	pc

Looking back at the application, I see now that doing it this way
was silly as well as non-portable. I wanted a function to do
different things depending on which function called it. Much better
just to pass that information as an argument. However, if anyone
out there has a PDP-11 running v6, this might work. Call it
pcret.s and invoke it as pcret(), of course.

David Sherman
Toronto
-- 
{ ihnp4!utzoo  seismo!mnetor  utai  watmath  decvax!utcsri  } !lsuc!dave



More information about the Comp.unix.wizards mailing list