levy@ttrdc.UUCP (Daniel R. Levy) (12/25/87)
In article <9934@mimsy.UUCP>, chris@mimsy.UUCP (Chris Torek) writes: >In article <1453@cuuxb.ATT.COM> mmengel@cuuxb.ATT.COM (Marc W. Mengel) writes: >>Fortran uses copy-in copy-out address passing.... >Some FORTRAN compilers may indeed use copy-in/copy-out (I believe this >is usually called `value-result'), but I think it is not mandated. UNIX f77 uses pass-by-address for FORTRAN parameter passing, but still implements a copy-in copy-out scheme where this would make a difference (i.e., where an operation is not atomic, as for arithmetic on complex numbers). Therefore, a routine like this: subroutine multd(d1,d2,d3) double precision d1, d2, d3 d3 = d1 * d2 return end produces object code like this: multd_: fmuld3 *4(%ap),*0(%ap),*8(%ap) ret &0 whereas subroutine multc(c1,c2,c3) complex c1, c2, c3 c3 = c1 * c2 return end produces: multc_: fmuls3 *4(%ap),*0(%ap),%r0 /* r0 = c1.real * c2.real */ movw 0(%ap),%r1 movw 4(%ap),%r2 fmuls3 4(%r2),4(%r1),%r1 /* r1 = c1.imag * c2.imag */ fsubs2 %r1,%r0 /* real part of result = r0 - r1 */ movw %r0,0(%fp) /* save it in a temporary */ movw 4(%ap),%r0 fmuls3 *0(%ap),4(%r0),%r0 /* r0 = c1.real * c2.imag */ movw 0(%ap),%r1 fmuls3 *4(%ap),4(%r1),%r1 /* r1 = c1.imag * c2.real */ fadds2 %r1,%r0 /* imag. part of result = r0 + r1 */ movw %r0,4(%fp) /* save it in a temporary */ movw 0(%fp),*8(%ap) /* store real part of result */ movw 8(%ap),%r0 movw 4(%fp),4(%r0) /* then imaginary part of result */ ret &0 So, you see, the FORTRAN compiler has covered its tail with respect to aliasing of arguments. (I believe this is the way the compiler is "supposed" to behave.) -- |------------Dan Levy------------| Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, | an Engihacker @ | <most AT&T machines>}!ttrdc!ttrda!levy | AT&T Computer Systems Division | Disclaimer? Huh? What disclaimer??? |--------Skokie, Illinois--------|