Thanks.

When I started programming in ASSEMBLER (and teaching) in the mid 1980s,
I didn't think much about base registers in the beginning. I also used one base register when starting the mainline, and I used BAL R5,SUBR and BR R5 to manage my internal
subroutines. This worked OK for me.

This changed dramatically, when I was in charge starting from 1988 in a big insurance company with a large ASSEMBLER code base. The programs there had typical sizes of 20.000 lines and more, they used SP macros (structured programming) and many site-spezific special purpose macros and they had macros to organize the internal subroutines, where the internal subs created their own base registers. The module sizes were large, most of the time more than
16 times 4k.

The typical module layout is as follows:

Mainline CSECT ... covered by two base regs (for example 13 and 12)
LTORG
Mainline Static Data
First Subroutine ... covered by two base regs (for example 10 and 11)
LTORG
First Subroutine local Static Data
Second Subroutine ... covered by two base regs (again 10 and 11)
LTORG
Second Subroutine local Static Data
.. and so on

You may notice, that 4 registers are sufficient to create very large programs. Register 13 is used as base register for the mainline AND for the local save area.

There are variants of this scheme:

- maybe you don't need two base regs on the subroutines

- maybe your program must be RENT, then the startup macro builts a DSECT
where all the automatic data is collected, and the startup macro allocates dynamic space for it. In this case, of course, reg 13 cannot be used as base register for the static save area, because it must point to the beginning of the automatic area
in the RENT case.

In 2013, I was in charge of maintaining the macro library of this insurance company,
and I changed the macros to support code sections without base registers.
The module in this case looks much the same as above, but the base registers
now don't point to the beginning of the CSECT and subroutines, but rather
to the end. The code sections are not covered with base registers, and the
B instructions are changed to J instructions using the well-known IBM mechanisms
(this is MVS, BTW).

In the "lucky" case, a change of parameters in the startup macro and a simple recompile is sufficient to convert a program to baseless. But in reality, this is rare,
because most of the time there are some inline definitions in some macros
which need additional work.

Since mid 2021, I am again in charge for the macro library :-)
after a 6 year intermission. The company lost a lot of old folks with good ASSEMBLER
knowledge by retirement. My work here will hopefully last until 2026,
when the company plans to finally migrate the applications to other platforms.

HTH, kind regards

Bernd




Am 02.04.2022 um 18:25 schrieb Charles Mills:
A couple of things.

One, yes, my assertion that it is easy was based on my own experience primarily
with modest-sized programs that I had written myself -- in some cases years 
earlier.
If you are talking about 10,000 lines of spaghetti enhanced over the years by 
lots of folks,
with embedded local macros and various cleverness, then it could be a large and 
fraught project.

...

b. I think all of my programs use a code base register. One code base register. 
One.
I am advocating for (i) getting rid of "4K anxiety" and (ii) freeing up a 
register or two
in those old programs with two or three code base registers.

Reply via email to