Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!haven!ames!elroy!gryphon!cadovax!ucla-an!sm.unisys.com!ism780c!news From: news@ism780c.isc.com (News system) Newsgroups: comp.lang.c Subject: Re: what is BSS and BSSEND Message-ID: <24403@ism780c.isc.com> Date: 10 Mar 89 22:05:13 GMT References: <15487@cup.portal.com> <15498@cup.portal.com> <396@rb-dc1.UUCP> Reply-To: marv@ism780.UUCP (Marvin Rubenstein) Distribution: usa Organization: Interactive Systems Corp., Santa Monica CA Lines: 57 In article <396@rb-dc1.UUCP> shapiro@rb-dc1.SanDiego.gould.UUCP (Michael Shapiro) writes: >In article <15498@cup.portal.com> Tim_CDC_Roberts@cup.portal.com writes: > >The IBM 704 used negative indexing. The original FORTRAN comiler >stored arrays backwards. The symbolic definition of the array name >went on the end, so the assembler supported it. Programmers used >backward tables in assembly language and newer assemblers also had the >BES pseudo-op. (Dim recollection!!! Can anyone confirm/deny/provide >alternate?) I have been responding to this via e-mail. But since there several almost correct answers, I thought I should set the record straight. 1. The 704 assembler did provide the BES pseudo-op. 2. The original FORTRAN compiler did store arrays 'backward' 3. 1 and 2 were not related. The pseudo-op was invented before FORTRAN. Furthermore, FORTRAN did not output assembly code. 4. BES was provided to simplify declaring arrays that were stored FORWARD. The following Assembly code shows a two instruction loop for zeroing every second word of a forward stored array (i.e. X(1),X(3)...X(9)): WITH BSS WITH BES -------- -------- AXT 10,1 AXT 10,1 set index to 10 STZ X+10,1 STZ X,1 store zero at address minus index TIX *-1,1,2 TIX *-1,1,2 if current index is >2, decremment by 2 ... ... and branch X BSS 10 X BES 10 | | | +--- Reserve 10 words X is address of 11th word +-------------------- Reserve 10 words X is address of first word The heart of the matter was TIX. This instruction conditionally DECREMENTS the contents of an index register and branches. So the index register is initialized to the array size and counted down. In the case of FORTRAN the index register was initialized to the initial value and counted up. It was the choice to count up in the DO loop along with the fact that indexing was by subtraction that led to FORTRAN arrays being stored backward. Below is the compiled code for a FORTRN loop that does the same as the above. FORTRAN GENERATED CODE -------------- ------------------ DO 100, i=1,10,2 AXT 1,1 set index to 1 100 X(I)=0; STZ X+1,1 X(I) = 0 TXI *+1,1,2 increment I by 2 and branch (to next) TXL *-2,1,10 loop if I <= 10 Note that the 704 did not have a single instruction for incrementing and branching, so the FORTRAN loop control used two instructions instead of one. This is one reason people thought assembly would always be needed. BTW, in the days when still had REAL programmers :-), loops were called "TIX loops". Marv Rubinstein -- World's oldest active programmer