PDP-11 stack use

utzoo!watmath!watcgl!dmmartindale utzoo!watmath!watcgl!dmmartindale
Mon Jan 17 22:17:12 AEST 1983


Note that the "blank word" in the PDP11 stack layout is always BELOW the
local variables, not between them and the saved registers.  One word of
space is reserved by csv, but if the routine has any local variables
one of these will use this word, and the stack address below all of the
locals becomes the "blank word".  Thus, unless an arithmetic temporary has
been stored on the stack, (sp) is always a free word, and so when calling
another routine, the last argument can be stuffed directly rather than using
auto-decrement addressing.  This saves a tiny bit of time, but the real
saving comes when adjusting the stack after that routine's return.  If you
passed only one word of arguments, no adjustment is necessary, if there
were two arguments you can use a tst (sp)+ instead of a cmp (sp)+,(sp)+, and
for three arguments you can use cmp instead of add.  Since an awful lot
of subroutine calls will have 1, 2, or 3 arguments this saving is worthwhile.



More information about the Comp.sources.unix mailing list