CEETERM and register 15

69 views
Skip to first unread message

Frank Swarbrick

unread,
Jun 12, 2012, 4:24:39 PM6/12/12
to ASSEMBL...@listserv.uga.edu
First off please realize that I'm an assembler beginner.  I've fiddled with it here and there for 15 years, but I'm really just a COBOL programmer.  So please be gentle!  :-)

We have a vendor written, code supplied, subroutine that does for us a few things that COBOL can't (bit fiddling; posting of an ECB; etc.).  This same exact routine is called both by batch COBOL program and CICS COBOL programs.  It is not reentrant.  In order to make it reentrant I have been working on "LE-enabling" it.  This seems to work quite well!  But I ran in to something "weird" with CEETERM.  CEETERM RC=0 generates the following:

58F0 F098            013A0  1827+         L   15,=A(0)

5800 F098            013A0  1828+         L   0,=A(0)
58DD 0004            00004  1829+         L   13,4(13)
58E0 D00C            0000C  1830+         L   14,12(,13)
981C D018            00018  1831+         LM  1,12,24(13)
07FE                        1832+         BR  14

Problem?  The program uses register 15 as the base register.  Funny thing is that the code actually "works".  But it really doesn't. The first L sets R15 to 0.  Then the second L loads in to R0 from 152(,R15), but of course R15 is now 0, not the real base address it needs to be.  It's only coincidence that 152 bytes in to low core contains x'00000000'.  If I tried to use an RC of some other value it would still be set to 0.


I changed the program to use 14 instead of 15 for the base register and all is now fine.  But I don't see it documented that CEETERM should not be used when the base is R15.  Or is it just common practice to not use R15 as the base?  Other than this one program I don't see that R15 is generally used for that purpose even though it starts out with the correct address, which is probably why it was used in this case.  Specifically, the original code was this:
SUBR     CSECT

         USING *,RF    
         B     START   
         DC    CL8'SUBR'
START    DS    0H      
         SAVE  (14,12)  

Anyway, I have to wonder why CEETERM doesn't take a page from the RETURN macro, and use LA from an offset into "R0", i.e., if I had CEETERM RC=12,MODIFIER=8, we'd get something like this:

LA  15,12(0)  
LA  0,8(0)    
L   13,4(13)  
L   14,12(,13)
LM  1,12,24(13)
BR  14        

No base register needed, correct?  (This is one of those cases where "register 0" is really just "zero", right, no matter what value it actually holds?)


(Apologies to Russ Evans, if he is reading this, for taking an unexpected side trip to LE land.)

Hope I've not shown too much ignorance.


Thanks!
Frank

McKown, John

unread,
Jun 12, 2012, 4:53:26 PM6/12/12
to ASSEMBL...@listserv.uga.edu
The reason for the L in CEETERM is because you can do CEETERM RC=VARNAME,MODIFIER=MODNAME where VARNAME and MODNAME are fullword areas.

In general, in z/OS, you should __never__ use R0 (impossible actually), R1, R14, or R15 for a CSECT/RSECT base register. Many (most) IBM macros use these registers. And occassionally other registers as well.

For LE enabled assembler (I have written some), when I use a base register at all (not often any more), I use R11 for my first, then R10, R9, and so as as the module grows in size. In "modern" programming, you can avoid the use of a "base register" for code in almost every case by using relative instructions instead of based instructions. E.g. use LARL instead of LA for areas in the CSECT, and Jxx instead of Bxx for branching. If you load constant values, try to use LHI if possible. Do try to write reentrant code. If you do that, you can keep the modifiable values in the DSA, which is addressed by R13 and which is set up for you with the CEEENTRY and CEEDSA macros. For a constant which does not fit into a halfword, or maybe is packed decimal or characters, you can replace somethin like: L R7,FULLWORD with 2 instructions: LARL R7,FULLWORD followed by L R7,0(,R7), and the same with packed and characters. OK, that is a bit ugly, I admit.


--
John McKown
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets�

9151 Boulevard 26 . N. Richland Hills . TX 76010
(817) 255-3225 phone .
john....@healthmarkets.com . www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or proprietary information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. HealthMarkets� is the brand name for products underwritten and issued by the insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance Company�, Mid-West National Life Insurance Company of TennesseeSM and The MEGA Life and Health Insurance Company.SM

Frank Swarbrick

unread,
Jun 12, 2012, 5:20:03 PM6/12/12
to ASSEMBL...@listserv.uga.edu
So it sounds like the original author should have never used R15 in the first place for the base register.  OK.

The program doesn't use any macros other than the CEE ones I just added and ABEND.  But I'll see if I can find a free register other than 14 (or 15 or 0 or 1!).  It's pretty much used every other register at some point in the program, but hopefully I can get around that.

I've been reading about "baseless" programming and all new code I've added uses it, but at this point it don't want to make too many changes to it.  So is your suggestion to use RC=RETCODE,MODIFIER=MOD and have those two as part of my automatic storage area?  Actually, if I do that I can probably get away (for now) with leaving it using R15, since those fields will be based on R13.

I will try this out.  Thanks for your help!!!!
Frank


>________________________________
> From: "McKown, John" <John....@healthmarkets.com>
>To: ASSEMBL...@LISTSERV.UGA.EDU
>Sent: Tuesday, June 12, 2012 2:53 PM
>Subject: Re: CEETERM and register 15

McKown, John

unread,
Jun 12, 2012, 5:39:25 PM6/12/12
to ASSEMBL...@listserv.uga.edu
You can continue to use R15, if you really must. And it should work if you do put the return code and modifer (both!) in the DSA area.

Steve Comstock

unread,
Jun 12, 2012, 5:40:00 PM6/12/12
to ASSEMBL...@listserv.uga.edu
[top posting]

http://www.trainersfriend.com/Language_Environment_courses/m512descr.htm

is multi-lingual: COBOL, PL/I, C, Assembler - take your choice


[You forgot to set your Reply-to back to the list]
http://www.trainersfriend.com/Language_Environment_courses/m512descr.htm

is multi-lingual: COBOL, PL/I, C, Assembler - take your choice


--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
+ Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
for training dollars at
http://www.trainersfriend.com/ROI/roi.html

Frank Swarbrick

unread,
Jun 12, 2012, 5:43:10 PM6/12/12
to ASSEMBL...@listserv.uga.edu
I wouldn't say I "must", but I will say I "might".
:-)

btw, did you know your posts and showing up twice?  For me, anyway.

Frank


>________________________________
> From: "McKown, John" <John....@healthmarkets.com>
>To: ASSEMBL...@LISTSERV.UGA.EDU

>Sent: Tuesday, June 12, 2012 3:39 PM

Frank Swarbrick

unread,
Jun 12, 2012, 6:18:49 PM6/12/12
to ASSEMBL...@listserv.uga.edu
Thanks Steve.  I'm not sure that can be justified for one person, but if you give me a good price...!

I'm not sure how to set my "reply-to" in Yahoo mail.  I haven't head that I have this issue on other listservs, though.  Hmmm...

Frank


>________________________________
> From: Steve Comstock <st...@trainersfriend.com>
>To: ASSEMBL...@LISTSERV.UGA.EDU
>Sent: Tuesday, June 12, 2012 3:40 PM

Tom Marchant

unread,
Jun 13, 2012, 8:54:08 AM6/13/12
to ASSEMBL...@listserv.uga.edu
On Tue, 12 Jun 2012 15:53:26 -0500, McKown, John wrote:

>For LE enabled assembler (I have written some), when I
>use a base register at all (not often any more),

I think that you try too hard to eliminate the use of base
registers. They are still needed for data.


>you can avoid the use of a "base register" for code in
>almost every case by using relative instructions...

Right. The exception is for an indexed branch.

>use LARL instead of LA for areas in the CSECT

That's fine for code or anything else that is (at least)
halfword aligned.

>use LHI if possible.

Agreed. Also AHI, etc.

>For a constant which does not fit into a halfword, or
>maybe is packed decimal or characters, you can replace
>somethin like: L R7,FULLWORD with 2 instructions:
>LARL R7,FULLWORD followed by L R7,0(,R7), and the same
>with packed and characters. OK, that is a bit ugly, I admit.

Yes, it is ugly. And unnecessary unless you are trying to
eliminate all base registers. That's why I don't like the
term "baseless code".

--
Tom Marchant

Tom Marchant

unread,
Jun 13, 2012, 8:54:22 AM6/13/12
to ASSEMBL...@listserv.uga.edu
On Tue, 12 Jun 2012 14:20:03 -0700, Frank Swarbrick wrote:

>So it sounds like the original author should have never used
>R15 in the first place for the base register.

Right. The linkage conventions call for the preservation
of registers 2-13 only. Register 13 is the address of your
save area. You should also beware that register 2 is used
by TRT. That leaves registers 3-12 that are useful as base
registers.

>I've been reading about "baseless" programming

I really wish people wouldn't call it "baseless". Base
registers are still necessary and attempts to avoid them
altogether results in the kind of strange coding that John
McKown included in his other post.

--
Tom Marchant

Bhuvanakumar Shanmugam

unread,
Jun 13, 2012, 8:55:08 AM6/13/12
to ASSEMBL...@listserv.uga.edu
I am not in office today and will have no access to emails. Sorry for any inconvenience caused.

Please do not print this email unless it is absolutely necessary.

The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments.

WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

www.wipro.com

McKown, John

unread,
Jun 13, 2012, 9:32:04 AM6/13/12
to ASSEMBL...@listserv.uga.edu
> -----Original Message-----
> From: IBM Mainframe Assembler List
> [mailto:ASSEMBL...@LISTSERV.UGA.EDU] On Behalf Of Tom Marchant
> Sent: Wednesday, June 13, 2012 7:54 AM
> To: ASSEMBL...@LISTSERV.UGA.EDU
> Subject: Re: CEETERM and register 15
<next>
>
> I really wish people wouldn't call it "baseless". Base
> registers are still necessary and attempts to avoid them
> altogether results in the kind of strange coding that John
> McKown included in his other post.
>
> --
> Tom Marchant

OK, if not "baseless", what would be an accurate yet easy to type word or phrase? I'm willing to change terminology to be more accurate. In my usual coding, I have something like:

PGM CEEENTRY ...,BASE=R11
DROP R11
LARL R11,CONSTANTS
USING (CONSTANTS,ECONSTANTS),R11
...
CONSTANTS DS 0D
... DEFINE MY CONSTANT VALUES
LTORG *
ECONSTANTS EQU *-1
END PGM

I use LARL, but an LA or LAY could be used, if placed before the DROP. Oh, and since I can't get CEEENTRY to use an RSECT, I also use the RENT assembler option to help flag mistakes in where I define a variable.

--
John McKown
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets(r)

9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone *
john....@healthmarkets.com * www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or proprietary information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. HealthMarkets(r) is the brand name for products underwritten and issued by the insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance Company(r), Mid-West National Life Insurance Company of TennesseeSM and The MEGA Life and Health Insurance Company.SM

Frank Swarbrick

unread,
Jun 13, 2012, 11:22:12 AM6/13/12
to ASSEMBL...@listserv.uga.edu
I agree with your dislike of the term "baseless".  But I do not know the proper term.  Is there one?
Frank


>________________________________
> From: Tom Marchant <m42tom-...@YAHOO.COM>
>To: ASSEMBL...@LISTSERV.UGA.EDU
>Sent: Wednesday, June 13, 2012 6:54 AM


>Subject: Re: CEETERM and register 15
>

Reply all
Reply to author
Forward
0 new messages