Path: utzoo!attcan!uunet!mcvax!philmds!leo From: leo@philmds.UUCP (Leo de Wit) Newsgroups: comp.lang.c Subject: Re: C vs. FORTRAN Message-ID: <546@philmds.UUCP> Date: 3 Jul 88 06:25:23 GMT References: <3136@phoenix.Princeton.EDU> <225800038@uxe.cso.uiuc.edu> <797@garth.UUCP> <5173@ihlpf.ATT.COM> <852@garth.UUCP> Reply-To: leo@philmds.UUCP (Leo de Wit) Organization: Philips I&E DTS Eindhoven Lines: 42 In article <852@garth.UUCP> smryan@garth.UUCP (Steven Ryan) writes: >>|>and therefore no necessity of copying parameters to a stack. They >>|>can be statically compiled in. This is only a benefit on some >>|>architectures. >> >>What do you mean by 'statically compiled in'? The references still need to >>be copied; they (the references) are just copied to a fixed location >>instead of to a relative position off the argument pointer (which points >>into the stack). > >Fortran argument list are sometimes assigned static memory by the compiler. >Except for arguments which are subscripted arrays, the compiler will know >the addresses of the will be put into the argument list (assuming variables >are staticcally allocated and not stack allocated). The overhead for passing >arguments is then computing expressions and stuffing away their values (same >for either language) and getting the parameter list address in the proper >register. The 'stuffing away of values' could well be more effective with stack addressing modes than with putting values in a static allocated list. The stack modes do typically 'lower sp and put value at sp' (note: one instruction) while the allocated lists need an offset (unless you load the first address in an address register, but that's an instruction extra compared to C; the sp needs not to be 'loaded'). How does FORTRAN b.t.w. handle the situation that there is a variable arguments list (cf. printf()) ? Seems a bit difficult with 'static lists'. Probably does not.... > >Any language which supports recursion must allocate local variables and >parameter lists on the stack. The address of variables must be computed >at runtime. So for static and 'static parameter list' variables. Even if you load a register with the base of the list, you address the variables in it relative to this base. That is as much computation as addressing relative a frame pointer. On a paging system it may even take more, as the stack pages are more likely to be in core than data pages - although a stack pointer may behave weird, it will generally move in a relative small area. Leo.