FWIW: System 360 uses what was called the 'push down save area' as part of
the function calling convention. Each routine declared and creates local
storage for the registers. Being reentrant was certainly possible and
many languages such as the Algol and APL families were. It's funny since
S/360 was the first architecture I knew deeply (*i.e.* got paid to
program), and working on support for York/APL at the time (and began
learning the Univac 1100 too), I just thought this was natural until I
began to learn about other processors ISA's like the PDP-11 family that had
an SP.
I remember, thinking -- this is so cool.
But as you said, originally early Fortran and Cobol didn't require same.
The typical calling conventions was something like this was pretty standard
for the S/360:
WORKAREA DSECT , Reentrant work area (stack like function)
DS 18F Save area
FIELD1 DS F Some variable
FIELD2 DS F Another variable
WORKLEN EQU *-WORKAREA Length of reentrant work area
SUBRTN1 RSECT , HLASM will perform reentrant checking
STM R14,R12,12(R13) Save registers at entry
LR R12,R15 Set code base register
USING SUBRTN1,R12 Establish code addressability
LGHI R0,WORKLEN Get length of reentrant work area
STORAGE OBTAIN, Obtain reentrant work area
X
LENGTH=(0) ..Length is in R0
ST R1,8(,R13) Forward chain in prev save area
ST R13,4(,R1) Backward chain in next save area
L R14,20(,R13) Get R1 at entry (parameters)
LR R13,R1 Set up new save area/reentrant workarea
USING WORKAREA,R13 Establish work area addressability
LM R2,R3,0(R14) Get addresses of parameters
STM R2,R3,FIELD1 Save parameter addresses for later
…
*** Subroutine Logic goes here
…
LR R1,R13 Address to be released
L R13,4(,R13) Address of prior save area
LGHI R0,WORKLEN Length of storage to release
STORAGE RELEASE, Release reentrant work area
X
ADDRESS=(1), ..Address in R1
X
LENGTH=(0) ..Length in R0
LM R14,R12,12(R13) Restore registers
OI 15(R13),X'01' This bit on means this save area
is inactive
BR R14 Return to caller
On Thu, Jan 23, 2020 at 12:47 AM Peter Jeremy <peter(a)rulingia.com> wrote:
=> coff since it's non-Unix
On 2020-Jan-22 13:42:44 -0500, Noel Chiappa <jnc(a)mercury.lcs.mit.edu>
wrote:
Pretty interesting machine, if you study its
instruction set, BTW; with no
stack, subroutines are 'interesting'.
"no stack" was fairly standard amongst early computers. Note the the IBM
S/360 doesn't have a stack..
The usual approach to subroutines was to use some boilerplate as part of
the
"call" or function prologue that stashed a return address in a known
location (storing it in the word before the function entry or patching the
"return" branch were common aproaches). Of course this made recursion
"hard" (re-entrancy typically wasn't an issue) and Fortran and Cobol (at
least of that vintage) normally don't support recursion for that reason.
--
Peter Jeremy
_______________________________________________
COFF mailing list
COFF(a)minnie.tuhs.org
https://minnie.tuhs.org/cgi-bin/mailman/listinfo/coff