Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!stanford.edu!leland.Stanford.EDU!jackk From: jackk@leland.Stanford.EDU (Jack Kouloheris) Newsgroups: comp.arch Subject: Re: register save Message-ID: <1991Mar12.010539.19017@leland.Stanford.EDU> Date: 12 Mar 91 01:05:39 GMT References: <1991Mar11.192116.1974@dgbt.doc.ca> <3241@crdos1.crd.ge.COM> Organization: AIR, Stanford University Lines: 28 In article <3241@crdos1.crd.ge.COM> davidsen@crdos1.crd.ge.com (bill davidsen) writes: >In article <1991Mar11.192116.1974@dgbt.doc.ca> don@dgbt.doc.ca (Donald McLachlan) writes: > >| The only way I can think to generalise this would be to always >| put the return address in a dedicated register. This would require that >| the "call" would first push the old contents onto the stack and then >| load in the new return address. > > The previous return info has to be saved, but not by the CALL >instruction. There are lots of non-recursive languages (FORTRAN) which >don't need to worry about another call and could save the return address >as needed. Also, a smart compiler would fake a CALL and let the target >procedure return directly to the caller when desirable.[possible. > People seem to be talking about this call/return mechanism as if i it is something novel.....This is the standard mechanism in the S/360, S/370, and S/390 systems and has been for more than 25 years. All the languages that don't allow recursion have a standard call/return convention via register 15. There is no hardware stack on the 370... the call intruction is usually an assembler macro that does a BALR 15 (Branch and Link Register). A convention is followed for creating a register save area, which is then filled via a Store Multiple instruction. If one always saves all registers on a call (as some compilers do), then a standard OS routine can traceback the call sequence via register 15 (as well as the contents of each register on entry to the call). Of course today optimizing compilers (as on the RS/6000) can save just the required register across a call.