Deutsch English Français Italiano |
<e806e59cb5dde61f2cc719617362c35a@www.novabbs.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder9.news.weretis.net!i2pn.org!i2pn2.org!.POSTED!not-for-mail From: mitchalsup@aol.com (MitchAlsup1) Newsgroups: comp.arch Subject: Re: ALTER, ASSIGN and labels-as-values Date: Mon, 27 May 2024 23:59:29 +0000 Organization: Rocksolid Light Message-ID: <e806e59cb5dde61f2cc719617362c35a@www.novabbs.org> References: <v1ep4i$1ptf$1@gal.iecc.com> <v1ns43$2260p$1@dont-email.me> <2024May11.173149@mips.complang.tuwien.ac.at> <v1preb$2jn47$1@dont-email.me> <2024May12.110053@mips.complang.tuwien.ac.at> <6124140226e28fd4afec0b435bdbeca1@www.novabbs.org> <2024May18.104040@mips.complang.tuwien.ac.at> <v2ang4$2smfg$1@dont-email.me> <34sk4jdhf1crb73jdns37e462ciumq5fjp@4ax.com> <v2ubim$3908a$1@dont-email.me> <2024May26.105139@mips.complang.tuwien.ac.at> <raH4O.2057$dWi1.1038@fx42.iad> <2024May27.100509@mips.complang.tuwien.ac.at> <b90fed6881dbe30d030bb5dd04e8e78c@www.novabbs.org> <Lp75O.28910$9xU7.3666@fx17.iad> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="2427303"; mail-complaints-to="usenet@i2pn2.org"; posting-account="65wTazMNTleAJDh/pRqmKE7ADni/0wesT78+pyiDW8A"; User-Agent: Rocksolid Light X-Rslight-Site: $2y$10$UUbbf5n/p5vcJkzr4lVfHeO6FQrjjrC2GhyXuen9ZVdxytDrUARv. X-Spam-Checker-Version: SpamAssassin 4.0.0 X-Rslight-Posting-User: ac58ceb75ea22753186dae54d967fed894c3dce8 Bytes: 3631 Lines: 59 EricP wrote: > MitchAlsup1 wrote: >> Anton Ertl wrote: >> >>> EricP <ThatWouldBeTelling@thevillage.com> writes: >>>> Don't forget Fortran's alternate returns, indicated by a * in the arg >>>> list. >>>> A caller subroutine passes *labels in the args list, and callee decides >>>> which *label-arg it wants to return to in the RETURN statement constant >>>> expression. (This is not ambiguous because in Fortran function return >>>> values are done by assignment to the function name, not the return >>>> statement expression.) >>>> >>>> call Foo (*100, *200) >>>> ... >>>> 100 >>>> ... >>>> 200 >>>> ... >>>> end >>>> >>>> subroutine Foo (*, *) >>>> ... >>>> return 1 ! Return to callers first * label arg >>>> ... >>>> return 2 ! Return to callers second * label arg >>>> ... >>>> end >> >>> Interesting. Rudimentary explicit continuation-passing style at the >>> dawn of programming languages. Of course, these days it would mean >>> that you better not use the common call and return instructions, >>> because the branch prediction for the return would be wrong if return >>> 1 or return 2 would be used. But using plain jump for the call and >>> indirect jumps for the returns should be efficient on modern CPUs. >> >> That is why the subroutine returns a value and the return point >> implements the switch (control transfer to proper label. >> >> {You DO NOT return to the label, you return normally and then go to the >> >> proper label.} > You still could do it by callee loading the arg address to register > and jumping directly there. > If it uses callee stack cleanup then you load the reg and pop the > stack before jumping. > If it uses caller stack cleanup then since caller controls what jump > addresses are passed to the callee, caller follows labels 100 and 200 > each with stack cleanup code then continues normally. > If it doesn't use a stack at all, as I understand IBM Fortran did, > then it doesn't need cleanup. IBM FORTRAN used a list of register store areas--thus pretty much like a stack, just without the ability to be reentrant or recursive.