[comp.lang.c] what is BSS and BSSEND

HyperDriven@cup.portal.com (Joseph C McDonald) (03/07/89)

hello everyone,
I have a somewhat simple question: when I instruct my compiler to convert
C code to asm I have some things in there called BSS and BSSEND. Now I think
that they are the unitialized variables but I am curious about the meanings
of BSS and BSSEND what do they stand for? If I had to guess I would say
that it stood for Before Stack Segment and Before Stack Segment END, but
it is only a guess and my luck with guesses and C is not too good right now.
    Anyone know for sure what they stand for?
       Thanks
      -=Joseph=-
 HyperDriven@portal.cup.com

Tim_CDC_Roberts@cup.portal.com (03/08/89)

In article <15487@cup.portal.com>, Joseph C McDonald asks:

> ... what to BSS and BSSEND stand for?

Time to open our ancient history tomes.  I am sure some other poster will
be able to provide the original assembler to define these pseudo-ops, but
"BSS" stands for "Block Starting with Symbol".  It is typically an
assembler pseudo-op to reserve storage without initialization.  Your
C compiler is probably gathering the uninitialized items into one location.
Of course, in C this is a little contradictory, since no item is truly
uninitialized.

The Control Data assemblers for NOS and for NOS/VE still use "BSS" to
define storage.  Unverifiable rumor holds that there used to be a "BES"
pseudo for "Block Ending at Symbol", although it is difficult to see a
practical use for such a beast.

- Tim_CDC_Roberts@cup.portal.com                     Control Data...
...!sun!portal!cup.portal.com!tim_cdc_roberts         ...or it will control you

gwyn@smoke.BRL.MIL (Doug Gwyn ) (03/08/89)

In article <15487@cup.portal.com> HyperDriven@cup.portal.com (Joseph C McDonald) writes:
>    Anyone know for sure what they stand for?

Yes, but since this question burns up an immense amount of net bandwidth
every couple of years, I don't think we should discuss it here.  Why does
it matter where the names came from, anyway?  The historical origin of
the name "BSS" has little to do with its current usage.

shapiro@rb-dc1.UUCP (Mike Shapiro) (03/10/89)

In article <15498@cup.portal.com> Tim_CDC_Roberts@cup.portal.com writes:
>In article <15487@cup.portal.com>, Joseph C McDonald asks:
>
>> ... what to BSS and BSSEND stand for?

    <<< some deleted >>>

>The Control Data assemblers for NOS and for NOS/VE still use "BSS" to
>define storage.  Unverifiable rumor holds that there used to be a "BES"
>pseudo for "Block Ending at Symbol", although it is difficult to see a
>practical use for such a beast.


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?)

-- 

Michael Shapiro, Gould/General Systems Division
15378 Avenue of Science, San Diego, CA 92128
(619)485-0910    UUCP: ...sdcsvax!ncr-sd!rb-dc1!shapiro

albaugh@dms.UUCP (Mike Albaugh) (03/10/89)

From article <15498@cup.portal.com>, by Tim_CDC_Roberts@cup.portal.com:
> In article <15487@cup.portal.com>, Joseph C McDonald asks:
> 
>> ... what to BSS and BSSEND stand for?
> 
> ... "BSS" stands for "Block Starting with Symbol"....
> The Control Data assemblers for NOS and for NOS/VE still use "BSS" to
> define storage.  Unverifiable rumor holds that there used to be a "BES"
> pseudo for "Block Ending at Symbol", although it is difficult to see a
> practical use for such a beast.

	IBM 1401 and 1620 "SPS" assemblers had BES, having exactly this
meaning. One practical use for such a beast was to declare arrays to be
accessed from Fortran which, because of the way indexing worked on the 70[49]*
series were referenced _backwards_. There was, of course, no hardware reason
to do this on the 1401 or 1620, but getting EQUIVALENCE to work might have been
a thrill, so it was done for backward (pun intended) compatability. You might
also use such a construct to declare a software stack which grew down...

	I remain unconvinced that this is the C meaning, though. I was told
by a *nix guru (albeit self-proclaimed) that stands for Blank (Storage/Static)
(Section/Segment). I would guess that only dmr could answer definitively.

> 
> - Tim_CDC_Roberts@cup.portal.com                     Control Data...
> ...!sun!portal!cup.portal.com!tim_cdc_roberts         ...or it will control you

news@ism780c.isc.com (News system) (03/11/89)

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

andyj@hobbiton.prime.com (03/14/89)

The pseudo-op BTS (Block Terminated by Symbol) was used in a manner
analogous to BES (Block Ended by Symbol) for those people who preferred
to use zero-based indexing instead of one-based indexing.  In this case,
the symbol was defined as the last entry in the block, rather than one
past the end of the block.