How do you determine how many base registers to use? 
Author Message
 How do you determine how many base registers to use?

This has been an interesting discussion, and you all appear to be right and you
are all wrong.  The number of base registers needed is not necessarily dependent
upon program size if pre planning is done.

If the program is a "straight line" program, and no backward branching is done,
the base register can be stepped through the program.  If the program can be
subroutined, a BASR to each subroutine with a SAVE upon entry and a RESTORE on
exit can eliminate base register usage.  Planning ahead, and knowing how many
registers will be needed other than base will determine the number of bases
which can be allocated. i.e. If you aren't going to use many registers in the
actual program, assign plenty as bases at the start then don't sweat it.

John Bull

Quote:

> I need help in determining how many base registers are needed for a
> program. I know that a register can define up to 4096 bytes, but what
> items are used to count these bytes, and how do you do it? Can you use
> the program size given in the link output? I had been doing this by
> trial and error, but now I need a good technique because I have a few
> pgms which need mods and are using almost all of the available registers
> already. I have been told that the use of ADCONS could extend the base
> register concept if I exhaust the registers in one particularly large
> pgm I am working on, but I'm not sure how to do this. Any help would be
> appreciated on either of these topics.

> Thanks,
> Richard



Fri, 03 Aug 2001 03:00:00 GMT  
 How do you determine how many base registers to use?


Quote:
>... The number of base registers needed is not necessarily dependent
>upon program size if pre planning is done.

I'll second that: the main CSECT in ShowMVS contains over 90KB of code and
constants, yet it only uses 2 base registers to address them.  The program
was designed for growth right from the start, although I never though it
would get this big: it's over 16000 lines now and grows another 2000 lines
every year on the average.  Of course, one could argue against having such
a large compilation unit, but that's another matter.




Fri, 03 Aug 2001 03:00:00 GMT  
 How do you determine how many base registers to use?
So please share how you accomplish this in code!

Thanks,
Richard

Quote:



> >... The number of base registers needed is not necessarily dependent
> >upon program size if pre planning is done.

> I'll second that: the main CSECT in ShowMVS contains over 90KB of code and
> constants, yet it only uses 2 base registers to address them.  The program
> was designed for growth right from the start, although I never though it
> would get this big: it's over 16000 lines now and grows another 2000 lines
> every year on the average.  Of course, one could argue against having such
> a large compilation unit, but that's another matter.





Fri, 03 Aug 2001 03:00:00 GMT  
 How do you determine how many base registers to use?


Quote:
>So please share how you accomplish this in code!

Basically, the ShowMVS CSECT is divided into four areas and the LOCTR
opcode is extensively used to switch between areas.  99% of the LOCTR
instructions occur in macros (ShowMVS contains a dozen or so internal
macros and uses 250 external ones), so it's quite transparent.

The first area is the "low core", covered by R11, and contains a bunch of
BAL instructions and small routines.  The 2nd area is the literal pool,
which gets generated after the END statement (I'm not an LTORG fan for
some reason).  Most of the code is contained in "procedures" which use R12
as base reg and are generated in area 3 ("far" routines).  Literals
specified in the STRING macro are generated in area 4 and accessed via
16-bit offsets.

You can download ShowMVS from the tools&docs section of my Web page to see
how, exactly, it's done.


 http://members.home.net/gsf/



Sat, 04 Aug 2001 03:00:00 GMT  
 How do you determine how many base registers to use?
Gere's a simple, straightforward way to get by on one base register.

Main Routine
        GETMAIN Save/Workarea
        SAVE, etc.
        L       R15,ARTN1
        BASR    R14,R15
        L       R15,ARTN2
        BASR    R14,R15
        etc. for as many routines as you desire
        RESTORE etc.
        FREEMAIN        Save/Workarea
        BR      R14             JOB is complete
ARTN1   DC      A(ROUTINE1)
ARTN2   DC      A(ROUTINE2)
ARTNx   DC      A(ROUTINEx)
ROUTINE1        CSECT
        GETMAIN Save/Workarea
        SAVE, etc.
        Do stuff routine1 is supposed to.
        RESTORE, etc.
        FREEMAIN        Save/Workarea
        BR      R14             Routine is complete.
ROUTINE2        CSECT
        etc., etc., etc.

Quote:

> So please share how you accomplish this in code!

> Thanks,
> Richard




> > >... The number of base registers needed is not necessarily dependent
> > >upon program size if pre planning is done.

> > I'll second that: the main CSECT in ShowMVS contains over 90KB of code and
> > constants, yet it only uses 2 base registers to address them.  The program
> > was designed for growth right from the start, although I never though it
> > would get this big: it's over 16000 lines now and grows another 2000 lines
> > every year on the average.  Of course, one could argue against having such
> > a large compilation unit, but that's another matter.



--


Houston, TX  77082-2038     Homepage:  http://www.hal-pc.org/~jbull/


Sat, 04 Aug 2001 03:00:00 GMT  
 How do you determine how many base registers to use?


Quote:
>Here's a simple, straightforward way to get by on one base register.
>Main Routine
>    GETMAIN Save/Workarea
>    SAVE, etc.
>    L       R15,ARTN1
>    BASR    R14,R15
>    L       R15,ARTN2
>    BASR    R14,R15
>    etc. for as many routines as you desire
>    RESTORE etc.
>    FREEMAIN        Save/Workarea
>    BR      R14             JOB is complete
>ARTN1       DC      A(ROUTINE1)
>ARTN2       DC      A(ROUTINE2)
>ARTNx       DC      A(ROUTINEx)
>ROUTINE1    CSECT
>    GETMAIN Save/Workarea
>    SAVE, etc.
>    Do stuff routine1 is supposed to.
>    RESTORE, etc.
>    FREEMAIN        Save/Workarea
>    BR      R14             Routine is complete.
>ROUTINE2    CSECT
>    etc., etc., etc.

Yes, but ShowMVS does it all in one CSECT without ACONs; here is an
example:

             BALR R11,0
             USING BASEADDR,R11
  BASEADDR EQU *
             BAL   R14,HARDWARE
       .  .  .  .  .  .  .  .

  $LTORG   LOCTR                         ADDRESSABLE CODE
  BEGIN_PROC LH  R15,0(,R15)             demi-offset to far routine
         ALR   R15,R15                 offset to far routine
         ALR   R15,R11                 change offset to address
         BR    R15                     branch to far routine
       .  .  .  .  .  .  .  .  .  .  .
  HARDWARE BEGIN_PROC
 +$LTORG   LOCTR                         ADDRESSABLE CODE
 +HARDWARE BAL   R15,BEGIN_PROC          Go To Bootstrap
 +         DC    AL2((PROC0294-BASEADDR)/2) demi-offset to far rtne
 +$FARRTNE LOCTR                         FAR ROUTINES
 +PROC0294 BALR  R12,0                   LOCAL BASE
 +         USING *,R12




Sat, 04 Aug 2001 03:00:00 GMT  
 
 [ 24 post ]  Go to page: [1] [2]

 Relevant Pages 
 

 
Powered by phpBB® Forum Software