HP 3000 Manuals

MANIPULATING RBMs [ MPE Segmenter Reference Manual ] MPE/iX 5.0 Documentation


MPE Segmenter Reference Manual

MANIPULATING RBMs 

Although the compilers and the Segmenter provide the required RBM
management in most circumstances, you may want to take explicit control
of RBMs for one of the following reasons:

 *  To use common code from another USL file.

 *  To change the number of code segments associated with a program.

 *  To create more efficient programs by relocating or purging RBMs or
    activating/deactivating a version of an RBM.

RBMs are units of source code which have been compiled into a User
Subprogram Library (USL). More than one version of an RBM may be compiled
into the same USL, and the various RBMs may be generated by different
compilers.  This "subprogram compatibility" is possible because all of
the HP 3000 compilers output information in exactly the same format,
generated by the same file system.  The HP 3000 gives you two options for
controlling RBMs:  compiler control and Segmenter control.

Compiler Control of RBMs 

You can embed control commands ($CONTROL) in your source code which
direct the compiler to do the following:

 *  Assign specified RBMs to specified segments.

 *  Limit the size of the segments that can be generated.

 *  Tell the compiler to generate code only for the subprogram(s)
    supplied in the text file, suppressing generation of the outer block.

 *  Give the main (outer block) RBM the specified name.

Refer to Appendices A through F for information about the compiler
$CONTROL commands, or to the reference manuals for the various languages
if you need more detailed information.

To manipulate your code after the compiler has translated it into RBMs
and placed the RBMs in a USL, you can use the Segmenter.  Segmenter
control provides you with different capabilities than compiler control;
of the options listed above, the only points of overlap are the
assignment of RBMs to specific segments and the specification of segment
size.

Further, as the compiler options listed above indicate, the compiler's
management of RBMs is limited to control of segmentation.  The Segmenter
gives you this capability and several others as well.  While $CONTROL
commands allow you to make some some preliminary decisions about
segmentation, Segmenter commands provide you with fine-tuning
capabilities, which you would be likely to want after you have run your
program at least once and know where it could be improved.

Since the HP 3000 allows you to manipulate RBMs with the Segmenter as
well as the compiler, you can do such fine tuning without having to
recompile any code.

Managing RBMs With The Segmenter 

The Segmenter identifies each RBM by its procedure name (the name you
gave it in your source code), which can be fifteen alphanumeric
characters with an initial alphabetic character.  SPL also allows the
apostrophe (') except as initial character.  The Segmenter also
identifies each RBM by a unique "version index."

THE VERSION INDEX.  Since you can compile more than one version of an RBM
into the same USL, several Segmenter commands allow you to specify which
version of an RBM you wish to access.  The index (also called index
integer, version number, index parameter, or version index) is the value
which lets you state which version you want the Segmenter to use.  You
can specify the index in all commands which allow you to specify the name
of an RBM as a parameter.  Its use is always optional:  the Segmenter
uses only one version of an RBM during any one preparation process, and
the default is the most recent active version of the specified RBM. The
index designations and defaults are as follows:

--------------------------------------------------------------------------------------
                             INDEX=n                      INDEX=0 (Default)

--------------------------------------------------------------------------------------

ALL COMMANDS EXCEPT CEASE    nth version, active or       most recent active version
AND USE                      inactive

--------------------------------------------------------------------------------------

CEASE                        nth version, active or       most recent active version
                             inactive

--------------------------------------------------------------------------------------

USE                          nth version, active or       most recent inactive version
                             inactive

--------------------------------------------------------------------------------------

Study the -CEASE and -USE commands in Section IV of this manual for more
information about why the index works differently with them than with the
other Segmenter commands.

In the following example, the programmer has used the -LISTUSL command to
verify the contents of a USL. The command lists the segment names and the
RBMs associated with each.  The USL in the printout contains only the
segment SEG'. Four versions of the RBM ABC are associated with SEG'; the
oldest version (the first one compiled into the USL) is known to the
Segmenter by the index 4 and appears on the bottom in this listing.  Note
that although the Segmenter knows each RBM by its index, the index
numbers do not actually appear on the listing.  (Refer to Figure 2-4 for
an explanation of the fields in this listing.)

     -USL MYUSL 

     -LISTUSL 

     USL FILE MYUSL.PUB.WHITMAN

     SEG'
        ABC                      16  P  A  C  N  R    **1**
        ABC                      16  P  I  C  N  R    **2**
        ABC                      16  P  I  C  N  R    **3**
        ABC                      16  P  I  C  N  R    **4**

     FILE SIZE           144000
     DIR. USED               70               INFO USED              130
     DIR. GARB.               0               INFO GARB.               0
     DIR. AVAIL.          14310               INFO AVAIL.         127050

Each RBM retains its particular index until an RBM is deleted from or
added to the USL. Then the index is reset.  With a deletion, all older
versions (those with higher index numbers than the deleted RBM) receive a
new index:  their old value minus one.  With an addition, the newest RBM
receives the index 1 and all older versions receive their old value plus
one.  Thus, while each RBM's index number is unique, it is not fixed.  An
illustration will help you visualize each situation:

ABC **1**           ABC **1**                               ABC **1**
ABC **2**           -------             ABC **1**           ABC **2;previously 1**
ABC **3**           ABC **2**           ABC **2**           ABC **3;previously 2**
ABC **4**           ABC **3**           ABC **3**           ABC **4;previously 3**

Before deletion     After deletion      Before Addition     After Addition
of version 2.       of version 2.       of new version.     of new version.

There will not always be a correspondence between the way the Segmenter
accesses the RBM versions and the way they appear in your listing.  In
fact, the listing order and the access order will correspond exactly only
until you move RBMs from one segment to another.  When you do this, the
RBM in effect takes its index number with it:  that is, the third version
is still the third version to the Segmenter even if it changes its
position within the USL.

This next example shows the currently-managed USL before and after we
have used the command

     -NEWSEG SEGASK, ABC (1)

to move version 1 of RBM ABC from the segment SEG' to the segment SEGASK.

SEG'                                        SEG'
    ABC **1 - to be moved**                     ABC **2**
    ABC **2**                                   XYZ **1**
    XYZ **1**                                   XYZ **2**
    XYZ **2**

SEGASK                                      SEGASK
    ABC **4**                                   ABC **1 - moved**
    ABC **5**                                   ABC **4**
                                                ABC **5**

As you will see in the following discussion, the index significantly
increases your power and flexibility in manipulating RBMs.  However, to
use it successfully you will need to keep your own records, either
on-line or off-line, of what is in the various versions.  You will also
have to remember how the Segmenter uses the index and how the
correspondence between the order of accessing and the order of your USL
listings can change.

CONTROLLING AND ALTERING SEGMENTATION.  You can override the Segmenter's
default manipulations of RBMs, using Segmenter commands to:

 *  Control segment association.

 *  Purge RBMs.

 *  Activate/deactivate RBMs.

 *  Add new RBMs to a USL.

 *  Transfer RBMs from other USLs to the one you are currently using.

Note:  the final item is discussed under Managing the USL.

Controlling Segment Association.  The -NEWSEG command allows you to
change the segment name associated with an RBM, thus assigning the RBM to
a different code segment the next time it is prepared onto a program
file.  With the command

     -NEWSEG SUB, TIMESTWO

you are associating the RBM TIMESTWO with the segment named SUB. Whatever
segment association TIMESTWO had previously no longer exists, since each
RBM can be associated with only one segment.

Purging RBMs.  If you have revised a program, you may have completely
changed a subroutine or removed it from your program altogether.  You can
use the Segmenter to purge one or more versions of the RBM, or the entire
segment in which the RBM resides.  With the command

     -PURGERBM UNIT,MAIN,2

we are purging the second-newest version of the RBM MAIN .

With

     -PURGERBM UNIT, MAIN

the Segmenter will purge the most recent active version of the RBM MAIN,
since we specified no index.

If we specify

     -PURGERBM SEGMENT, MAIN

the Segmenter will purge the entire segment in which the RBM MAIN
resides.

If we input only

     -PURGERBM,MAIN

without specifying either UNIT or SEGMENT, the Segmenter defaults to
UNIT, thus shortening the amount of information you must type when you
are managing RBMs as well as protecting you from accidentally purging
more RBMs (or more versions of an RBM) than you intend to.

Figure 2-1 illustrates the use of the -PURGERBM command.

Activating/Deactivating RBMs.  Segmenter commands allow you to activate
or deactivate RBMs according to various "entry points." An entry point is
any location in a routine to which control can be passed by another
routine.  The first executable statement of a main program or a procedure
is an implicit entry point.  Called the "primary entry point", it is the
natural beginning point for execution.  The allowance of multiple entry
points permits you to begin execution of a main program or procedure at
various secondary entry points.

Each RBM is identified to the operating system by the symbolic name, or
label, of the primary entry point for the program unit which resides in
the RBM. In Figure 2-2, we have compiled a simple FORTRAN program and
then used the -LISTUSL command to verify the contents of the USL. Since
we did not specify a name for our main RBM when we compiled, the
operating system gives it the default symbolic name MAIN'. The subroutine
is identified as TIMESTWO, the specified name of its primary entry point.
Note that the RBMs are further identified by their association with the
segment SEG', to which they will belong after preparation.

An "activity bit" is associated with each entry point (the primary entry
point and any secondary entry points).  This bit determines whether the
program unit currently can be entered at the corresponding entry point;
that is, the bit determines whether you can start executing your program
at that location.  When a compiler writes an RBM to a USL file, all entry
points are set to the active (entry allowed) state and the compiler
deactivates any active versions of a particular RBM already in the USL.
With the Segmenter, you can switch any activity bit in the USL to the
inactive (entry disallowed) state and back again, if you wish.  (See the
-CEASE and -USE commands, Section IV.)

     :SEGMENTER 

     HP32050A.03.00 SEGMENTER/3000 HEWLETT-PACKARD CO. 1986

     -USL $OLDPASS 
     -LISTUSL 

     USL FILE $OLDPASS

     SEG'
        TIMESTWO       16  P  A  C  N  R
          MAIN'          32  OB A  C  N

       FILE SIZE      144000
       DIR. USED          70              INFO USED        130
       DIR. GARB.          0              INFO GARB.         0
       DIR. AVAIL.     14310              INFO AVAIL.   127050

      -NEWSEG SUB,TIMESTWO 
      -PURGERBM MAIN'          **Add segment SUB.  Put RBM TIMESTWO
                                   into SUB.  Delete RBM MAIN'**

     -LISTUSL 

     USL FILE $OLDPASS
       SUB
          TIMESTWO        16  P  A  C  N  R
       SEG'           **Null segment**

       FILE SIZE      144000
       DIR. USED          76              INFO USED        130
       DIR. GARB.         31              INFO GARB.       112
       DIR. AVAIL.     14302              INFO. AVAIL.  127050

     -PURGERBM SEGMENT, SEG' 

     -LISTUSL 

     USL FILE $OLDPASS

       SUB
          TIMESTWO             16  P  A  C  N  R

      FILE SIZE       144000
      DIR. USED           76               INFO USED        130
      DIR. GARB.          73               INFO GARB.       130
      DIR. AVAIL       14302               INFO AVAIL.   127050

          Figure 2-1.  Using the Segmenter -PURGERBM Command 

     :FORTRAN SEG8 

     PAGE 0001   HP32102B.00.07
     00001000  $CONTROL FREE
     INTEGER A(4)
     ACCEPT A
     CALL TIMESTWO(A)
     DISPLAY A
     STOP
     END

     SUBROUTINE TIMESTWO(A1)
     INTEGER A1(4)
     DO 1 I=1,4
     1 A1(I)=A1(I)*2
     RETURN
     END

     ****       GLOBAL STATISTICS       ****
           NO ERRORS,     NO WARNINGS   ****
     TOTAL COMPILATION TIME   0:00:01
     TOTAL ELAPSED TIME       0:00:03
      END OF COMPILE

     :SEGMENTER 

     HP32050A.03.00 SEGMENTER/3000 HEWLETT-PACKARD CO. 1986
     -USL $OLDPASS 
     -LISTUSL 

     USL FILE $OLDPASS

     SEG'
        TIMESTWO           16  P  A  C  N  R
        MAIN'              32  OB A  C  N

     FILE SIZE          144000
     DIR. USED              70             INFO USED        130
     DIR. GARB.             73             INFO. GARB.      130
     DIR. AVAIL.         14302             INFO. AVAIL.  127050

          Figure 2-2.  Procedure Entry Points 

The control given you over the activity/inactivity of entry points is a
very important feature, since it allows you to associate many versions of
an RBM with one segment, selectively deactivating those you don't want
prepared into the program file.  For large applications this is an
invaluable aid, making costly recompiles unnecessary during test phases.
Suppose, for example, that you make a change to a subprogram, compile it
into a USL, and then prepare your program from this USL, having
deactivated the first-version RBM. If the change turns out to be the
source of a serious bug in the program, you could simply deactivate the
new version and reactivate the previous version.  Your program would be
quickly returned to functional status without the need for time-consuming
and costly recompilation.

In a similar way, the activate/deactivate control also increases your
power and flexibility during the program design stages.  You can
construct alternative programs, varying your main program and one or more
subprograms at a time, and test them without having to recompile the
entire program each time you change something.

When the Segmenter prepares a program file from the USL, all RBMs having
at least one active entry point are extracted from the USL for
segmentation in the program file.  Those associated with identical
segment names are placed in the same segment.  To permit the creation of
a program file that can be executed properly, only one outer-block or
main-program RBM can have active entry points, along with the RBMs for
the subprograms or procedures.  The presence in a USL of two active RBMs
of the same name will cause a prepare failure.  Thus, through your
manipulations with the -CEASE and -USE commands, you could have several
active RBMs of the same name in a USL file, but must de-activate all but
one of the RBMs before trying to prepare the USL into a program file.

In Figure 2-3, we use the -CEASE command to deactivate the two most
recent versions of the RBM ABC, and the -USE command to activate a
previous version.  Then we use -LISTUSL to verify the contents of the
USL.

Note that index information is not part of the data provided by the
-LISTUSL command.  You must remember the listing order and the associated
index numbers.

With both the -CEASE and -USE commands, the index 0 is assumed if you do
not specify an index number.  For the -CEASE command, 0 indicates the
most recent active version.  For the -USE command, it indicates the most
recent inactive version.

As with the -PURGERBM command, you can use -CEASE and -USE to
activate/deactivate a single entry point within a specified RBM, all
entry points in the specified RBM, or all entry points in all RBMs
associated with the specified segment name.  The default is the single
entry point associated with the specified name.

Putting Additional RBMs in a USL.  As you are designing and changing
programs, you may need to put additional RBMs in a USL, either by copying
already-existing code from another USL or adding new RBMs.  The
procedures for copying code are covered in the discussion following this
one (Managing User Subprogram Libraries).  To add new RBMs, you simply
create a source file with the new subroutine(s) and compile it into the
USL. With the compiler command

     :FORTRAN SUB72, MASTRUSL

we instruct the compiler to compile the new subroutine SUB72 into the
previously-created USL MASTRUSL.

     :SEGMENTER 

     HP32050A.03.00 SEGMENTER/3000 (C) HEWLETT-PACKARD CO. 1986

     -USL $OLDPASS 
     -LISTUSL 

     USL FILE $OLDPASS.PUB.SPL

     SEG'
                                             **INDEX**
        ABC                 1  P  A  C  N  R **1, 0  Most recent active**
        ABC                 1  P  I  C  N  R **2**
        ABC                 1  P  I  C  N  R **3**
        ABC                 1  P  I  C  N  R **4**

      FILE SIZE     144000(  620.  0)
      DIR. USED        307(    1.107)     INFO USED          4(    0.  4)
      DIR. GARB.         0(    0.  0)     INFO GARB.         0(    0.  0)
      DIR. AVAIL.    14071(   60. 71)     INFO AVAIL.   127374(   535.174)

     -CEASE ABC(1) 
     -USE ABC(2) 
     -LISTUSL 
     USL FILE $OLDPASS.PUB.SPL

     SEG'
                                           **INDEX**
        ABC                 1  P  I  C  N  R **1**
        ABC                 1  P  A  C  N  R **2, 0  Most recent active**
        ABC                 1  P  I  C  N  R **3**
        ABC                 1  P  I  C  N  R **4**

     FILE SIZE    144000(   620.  0)
     DIR. USED       307(     1.107)     INFO USED         4(   0.  4)
     DIR. GARB.        0(     0.  0)     INFO GARB.        0(   0.  0)
     DIR. AVAIL.   14071(    60. 71)     INFO AVAIL.  127374(  535.174)

          Figure 2-3.  Using the Segmenter -CEASE and -USE Commands 

If you wish, you can embed the compiler command SEGMENT in your source
file to assign the new RBM to a specific segment:

     $CONTROL SEGMENT=SEG2
         SUBROUTINE SUB72
             .
             .
             .

Or you could allow the compiler defaults to operate and later use the
Segmenter to alter segmentation, if necessary.



MPE/iX 5.0 Documentation