Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rochester!pt.cs.cmu.edu!sei!sei.cmu.edu!firth From: firth@sei.cmu.edu (Robert Firth) Newsgroups: comp.arch Subject: Re: An idea I'm kicking around Message-ID: <1061@aw.sei.cmu.edu> Date: Mon, 20-Apr-87 13:52:22 EST Article-I.D.: aw.1061 Posted: Mon Apr 20 13:52:22 1987 Date-Received: Tue, 21-Apr-87 01:02:19 EST References: <12884@watnot.UUCP> Sender: netnews@sei.cmu.edu Reply-To: firth@bd.sei.cmu.edu.UUCP (Robert Firth) Distribution: comp Organization: Carnegie-Mellon University, SEI, Pgh, Pa Lines: 34 In article <12884@watnot.UUCP> watmath!watnot!ccplumb (Colin Plumb) writes: > I've been dreaming up A RISCy architecture in my spare time... >What if JSR moved the return address into another register? If the register >was R0 (A register hardwired with the constant 0), you'd have a JMP. To nest >JSR's, the called procedure would need to save this register, but it needs to >save registers for locals anyway, so it shouldn't be too much of a hassle. >As far as a compiler is concerned, the return register is just another reg >that's trashed by all function calls and needs to be restored before exit... As someone who has implemented several languages on several machines, perhaps my thoughts might be helpful. In the majority of the codegenerators I've written, the first instruction of a procedure retrieves the return link from the place where the hardware put it. For example, the CA LSI-2 stores the return link inline before the called routine, so if you want recursion or reentrancy you've got to move it. The PDP-11 puts it on the SP stack, so if you want to allocate local variables towards high addresses you have to pop it off again or grow two stacks. And so on. The machines I've liked best stored the return link in a register. Not just for that reason; in addition they have both been very clean pieces of hardware (thanks, Perkin-Elmer, for the PE3200; thanks, MIPS, for MIPS), but one aspect of that cleanliness is that they don't try to tell language implementors how to think. You definitely have my vote for using a register. Another issue is the right operand of the JSR. Most machines seem to use the "effective address" as the operand, so whereas LOAD F will fetch the VALUE in F, JSR F will jump to the ADDRESS of F. I have never liked this. You lose nothing, and gain a lot, by evaluating the operand in Rmode, so that JSR #F calls F, JSR F calls the thing pointed to by F, and JSR Reg calls the thing whose value has been computed in the register. But this is an eccentric view.