I think there is one small problem with what I write below. I think the 
assembler will not "0-base" LITCSECT. What I am trying to say is a little hard 
to describe but LITCSECT will have an *assembled* address starting with the 
length of your first CSECT. DC A(LITCSECT) will be assembled with that address, 
and your 0-based literal offsets will not get relocated quite enough.

So start LITCSECT first:

LITCSECT CSECT
MAIN     CSECT
  Main program logic
  Record table
LITCSECT CSECT
         LTORG 
  ...
         END

Check the assembly to make sure DC A(LITCSECT) assembles as zeroes. 

Charles

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Charles Mills
Sent: Tuesday, December 12, 2017 6:33 AM
To: [email protected]
Subject: Re: Address of a =LITERAL

I don't know why I keep thinking about this but I believe I have a solution. It 
will give you exactly what you wanted, effectively DC A(=literal). It is a hack 
and a kludge and I would not do it myself, but I believe it will work.

A. Add a separate CSECT to your code following the record layout. Let's call it 
LITCSECT. Ahead of your table establish addressability on it with USING 
LITCSECT,0. Put a LTORG in the CSECT. That will collect all of your literals in 
that CSECT.

B. In your table, a three-step process. You might want to put this in a macro 
to avoid screwing it up. At each spot that you want your literal pointer:

1. DC A(LITCSECT)

That will generate an RLD so that whatever gets assembled into the word, at 
load time MVS will add the load address of LITCSECT to it.

2. ORG *-4
   LA 0,=literal

That will (a.) generate your desired literal following LTORG in LITCSECT; and 
(b.) overlay the A(LITCSECT) with 41000xxx where xxx is the offset of the 
generated literal into LITCSECT.

3. ORG *-4
   DC  X'0'
   ORG *+3

That will get rid of the 41.

So you now have 00000xxx in the table, where xxx is the offset of the literal 
into LITCSECT, and an RLD that at load time will relocate the word by the 
address of LITCSECT.

QED

Charles

Reply via email to