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

Reply via email to