C vs. FORTRAN

Leo de Wit leo at philmds.UUCP
Sun Jul 3 16:25:23 AEST 1988


In article <852 at garth.UUCP> smryan at 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.



More information about the Comp.lang.c mailing list