Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

trick to improve procedure calls on PDP-11

2 views
Skip to first unread message

Jun Woong

unread,
Jul 10, 2009, 2:54:46 AM7/10/09
to
Is there any reference that explains the stack frame used in Unix on
PDP-11?

Reading the paper titled "The C Language Calling Sequence" by Dennis
Ritchie I have a few questions on old computers that I've never used
and about which it's difficult to find detailed information.

I asked my question at comp.unix.programmer three days ago and failed
to get a convincing answer but reference to this group and hints on
the issue; you can find the posting here:

http://groups.google.co.kr/group/comp.unix.programmer/browse_frm/thread/f7f1a9a21e3aabe2

I copy the question from it:

[copy starts]
In the paper named "The C Language Calling Sequence," Dennis Ritchie
introduces a trick used to improve procedure calls on PDP-11:

When sp is used to push arguments onto the stack, it must be
readjusted after each call to throw away the arguments. However, if
an extra word is left at the end of the stack, calls with only one
argument need only move this argument top of the stack, and sp need
not be adjusted after the call. Since many calls have one argument,
this is attractive.

with a caveat:

When using this technique special care must be taken to handle
nested calls and calls with active expression temporaries.

I tried to figure out how exactly it works, but failed. The "Red
Zone" used on x86-64 seems similar to it even if the "Red Zone" is
allowed only for leaf calls. In order to make signals work using the
same stack frame, I think the trick above has the extra word
protected by sp, but then it is obscure how the caveat should be
understood.

Could anyone shed light on this?
[copy ends]

The biggest problem in understanding the trick is the caller's
status saved below the incomming arguments:

[copy starts again]
Saving the caller's status below incomming arguments seems to me that
the callee has to adjust sp anyway, ...
[copy ends]

even if the trick seems to work only when sp need not be adjusted
across calls.

Am I missing anything here?


(question duplicated without cross-posting for I think the issue is
getting to be off-topic there.)


--
Jun, Woong (woong at icu.ac.kr)

0 new messages