Browse Prior Art Database

Automatic Local Labels

IP.com Disclosure Number: IPCOM000120147D
Original Publication Date: 1991-Mar-01
Included in the Prior Art Database: 2005-Apr-02
Document File: 3 page(s) / 91K

Publishing Venue

IBM

Related People

Lyon, LE: AUTHOR

Abstract

This article addresses the problem, in assembler programming, of providing the safety of full labels without their distraction, and the visual simplicity of relative addressing without its dangers.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 49% of the total text.

Automatic Local Labels

      This article addresses the problem, in assembler
programming, of providing the safety of full labels without their
distraction, and the visual simplicity of relative addressing without
its dangers.

      Program labels provide a symbolic way of specifying memory
addresses.  The following code segment for the IBM System/370
illustrates this:
                ..   ...
                LM   W1,W3,SEARCH   Prepare to search the table
      LABEL1    TM   FLAGS,ACTIVE   If this entry is active
                BNZ  LABEL2    .. then go check it out
                BXLE W1,W2,LABEL1   .. else loop for the next
                B    ALLQUIET  .. until all are checked
      LABEL2    L    W2,ACTVCB Get the active control block
                ..   ...

      When maintaining a program, it is sometimes necessary to modify
a section of code and, in such cases, if labels are present, it is
important to know if they are strictly for local use or if some
distant code segment also branches to them.  The assembler's
cross-reference list resolves this, but turning back and forth to
that is distracting, especially when one is analyzing the code to
determine what modifications are needed.  A coding convention, such
as beginning labels with "LL" if and only if they are strictly local
labels, is helpful, but the labels are still distracting, especially
as one wonders if the convention has been faithfully followed by
other people maintaining the code.  One way around this is to use
relative addressing instead of labels.  For example:
           ..        ...
           LM        W1,W3,SEARCH        Prepare to search
      the table
           TM        FLAGS,ACTIVE   If this entry is active
   BNZ       *+12                .. then go check it out
   BXLE      W1,W2,*-8           .. else loop for the next
   B         ALLQUIET            .. until all are checked
   L         W2,ACTVCB           Get the active control block
           ..        ...

      But this is a very dangerous practice, as it is easy to make an
error in calculating the displacement or when the code is modified.
Relative addressing is not allowed in programs IBM distributes.
A Local Label Macro

      LLAB is a macro that automatically generates local labels.  It
maintains two variable symbols, &BACK and &SKIP, for branching back
to the previous local label and for skipping forward to the next
local label.  LLAB is used as if it were a computer instruction, and
the actual instruction is given as LLAB's arguments.  The above
example thus becomes:
      ..   ...
      LM   W1,W3,SEARCH   Prepare to search the table
           ...