Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!princeton!caip!brl-adm!brl-smoke!rgh%inmet.uucp@BRL.Arpa From: rgh%inmet.uucp@BRL.Arpa Newsgroups: net.lang.c Subject: Re: C vs. FORTRAN (was: What should be added to C) Message-ID: <1241@brl-smoke.ARPA> Date: Tue, 10-Jun-86 12:38:08 EDT Article-I.D.: brl-smok.1241 Posted: Tue Jun 10 12:38:08 1986 Date-Received: Fri, 20-Jun-86 04:22:15 EDT Sender: news@brl-smoke.ARPA Lines: 46 GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV From: Barry Margolin Subject: Re: C vs. FORTRAN (was: What should be added to C) To: info-c@BRL-SMOKE.ARPA Return-Path: Redistributed: Xerox-Info-C^.x@XEROX.ARPA Received: from BRL-AOS.ARPA by Xerox.COM ; 02 JUN 86 16:44:00 PDT Received: from brl-smoke.arpa by AOS.BRL.ARPA id a015999; 2 Jun 86 17:29 EDT Received: from USENET by SMOKE.BRL.ARPA id a005720; 2 Jun 86 17:02 EDT Newsgroups: net.lang.c Message-ID: <2157@mit-eddie.MIT.EDU> GVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGVGV In article <900@ttrdc.UUCP> levy@ttrdc.UUCP (Daniel R. Levy) writes: >By the way, this does raise a question in my mind about how the convention >of 1, not 0, being the lower bound subscript for an array is gotten around >efficiently in implementations of Fortran. In the case of one-dimensional arrays, of course, it can be handled at compile time. A good optimizer can also recognize the common patterns of looping over multidimensional arrays, so that the offset can be simply incrememented rather than requiring subscript calculations on each iteration (some of the earliest work on Fortran compilers involved this type of optimization). > It sounds like it is a royal, CPU- >wasting pain to have to subtract that pesky correction factor from the ag- >gregate subscript in coming up with an offset for the address of the array >element from the base of the array the way Fortran does, unless the computer >has a hardwired way of accessing an object in memory based on a base address >(base of the array), an offset (calculated from the subscripts), and a >correction factor (based on how the array was dimensioned) residing in regis- >ters and added together automatically. >I think I recall from days of yore in assembly language programming that >the IBM 360/370 architecture was set up to allow just this, not surprising >for a machine from the original inventors of Fortran. But what about other >machines, especially the more powerful (scalar) ones? Do they all share this >multiple-offset-addressing capability? (Not that this would be advantageous >in Fortran only; C could also use such a feature when accessing multiply- >dimensioned arrays of the type "array[][][]...".) I think many mainframes have such addressing modes. -- Barry Margolin ARPA: barmar@MIT-Multics UUCP: ..!genrad!mit-eddie!barmar