Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

A CSECT without an LTORG but uses literals

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Tue Mar 29, 2011 3:05 pm    Post subject: A CSECT without an LTORG but uses literals
Reply with quote

Hi,

Everything(including literals) that is referenced in a control section has to be resolved into (base adress + displacement) at the time of assembly.

Is it possible to have a control section which has literals referenced in it but the control section does not have "LTORG ," statement used towards the end. Please note that there has to be only 1 CSECT in the source file.

I tried to do something like this in a test program but got the expected assembler error ASMA307E: No active USING for operand =C'0123456

So far I have got different opinions on this topic. I am a bit confused. Will appreciate opinions from the forum.

The test program is pasted below:
Code:
         YREGS                                                   
*                                                               
ROUTNT   CSECT                                                   
ROUTNT   RMODE 24                                               
ROUTNT   AMODE 24                                               
*                                                               
SETUP    EQU   *                                                 
         STM   R14,R12,12(R13)    * SAVE CALLER'S REGS           
         USING *,R12              * R12 IS BASE                 
         BALR  R12,R0             * START FROM HERE             
*                                                               
         ST    R13,SAVEA+4        * SAVE CALLER'S SAVE AREA ADDR
         LA    R13,SAVEA          * LOAD LOCAL SAVE AREA ADDR   
*                                                               
MAIN     EQU   *                                                 
         WTO   'ROUTNT STARTED..'                               
         CLC   FILL1(10),=C'0123456789'                         
         WTO   'ROUTNT ENDED OK.'                               
*                                                               
EXIT     EQU   *                                                 
         L     R13,SAVEA+4        * LOAD CALLER'S SAVE AREA ADDR
         LM    R14,R12,12(R13)    * RESTORE CALLER'S REGS       
         LA    R15,0              * LOAD RETURN CODE             
         BR    R14                * RETURN TO CALLER             
*                                                               
WORK     EQU   *                                                 
SAVEA    DS    18F                                               
FILL1    DC    CL78'<=WORK AREA ENDS HERE.'                     
*                                                               
         END   ROUTNT                                           
[/code]
Back to top
View user's profile Send private message

Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 29, 2011 3:57 pm    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Place an LTORG after the FILL1 label and move the BALR before the USING.

Without viewing the Assembly, that's all that can be advised.

R12 is your CSECT base and all literals are defined to R12.

Are you DROPPING R12 somewhere in the code?

That would do it....

Bill
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Tue Mar 29, 2011 4:06 pm    Post subject: Re: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Bill O'Boyle wrote:
Place an LTORG after the FILL1 label and move the BALR before the USING.

Without viewing the Assembly, that's all that can be advised.

R12 is your CSECT base and all literals are defined to R12.

Are you DROPPING R12 somewhere in the code?

That would do it....

Bill


Thanks Bill.
The code will indeed run when changed as per your suggestion. But please have a look at my question again. My question is "Whether it is possible to successfully assemble this program without the use of LTORG statement?"

I know there are a few issues with this code:
1) BALR should be placed before using(but it does not affect assembly).
2) R12 is not dropped anywhere.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Mar 29, 2011 5:59 pm    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Quote:
So far I have got different opinions on this topic. I am a bit confused. Will appreciate opinions from the forum.


seems You forgot to ask the only one worth listening to .... the manual icon_biggrin.gif
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ASMR1020/5.31?SHELF=ASMSH030&DT=20080711003624

run two assemblies (1) with the ltorg (2) without

You will see in case (1)
Code:
Symbol   Type   Id     Address  Length   Owner Id Flags Alias-of
          PC 00000001 00000000 00000000             00
ROUTNT    SD 00000002 00000000 0000014A             01

a private ( unnamed ) csect with length 0
a named csect with length ( program length + literal pool length )
while in case (2)
Code:
Symbol   Type   Id     Address  Length     LD ID  Flags Alias-of
          PC 00000001 00000000 0000000A             00
ROUTNT    SD 00000002 00000010 0000013E             01

a private ( unnamed ) csect with length (literal pool length )
a named csect with length ( program length )

the behavior has been there for ages - just tested with
MVS38J and IFOX00
MVS38J and TACHYON assembler
OS/390 2.9 and HLASM R3.0 (PTF UQ46683)

and IIRC there is no way to address an unnamed csect
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 988
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Mar 29, 2011 6:06 pm    Post subject:
Reply with quote

You need a LTORG statement somewhere in the code after the literals. If it's omitted, the literals are placed after the CSECT's END statement.

Why would you want to leave the LTORG statement out anyway? The only variation of placement of LTORG that I've come across is to move it, say, between the BR R14 and the define constant for WORK. This was a 'tweak' done because some of the the literals were just past addressability. Moving them earlier managed to keep everything within addressable bounds, so an extra base register was not needed.

Garry.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Mar 29, 2011 6:19 pm    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

If you don't specify an LTORG, then literals will be stacked after the END statement by the Assembler. I just confirmed this with a small sub-program of under 4K.

Note that it's always a good idea to specify LTORG's and is a requirement for every 4K of addressability if the program exceeds 4K. Otherwise, you'll get an addressability error during Assembly.

A quick observance. Instead of using R12 as your base, use (for example), R3 instead.

The reason for this suggestion is because, if you ever decide to make the program/sub-program LE compliant, R12 contains the address of the LE "CAA" (Common Anchor Area).

Bill
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Mar 29, 2011 6:38 pm    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Quote:
If you don't specify an LTORG, then literals will be stacked after the END statement by the Assembler. I just confirmed this with a small sub-program of under 4K.

Note that it's always a good idea to specify LTORG's and is a requirement for every 4K of addressability if the program exceeds 4K. Otherwise, you'll get an addressability error during Assembly.


I beg to differ...
if You do not specify a LTORG You get the error message
whatever the csect size the Literal pool will be generated in a private csect at the end of the <current> csect

the only thing necessary is the proper addressing coverage of the whole csect

tested added some more registers to the USING and adding two 4000 bytes coinstants

tested with ltorg and without

here are the relevant using and csects maps

with the ltorg

Code:
Stmt  -----Location----- Action ----------------Using----------------- Reg Max     Last Label and Using Text
        Count      Id           Type          Value    Range     Id        Disp    Stmt
  25  00000004  00000002 USING  ORDINARY    00000004 00001000 00000002  12 000EC     50 *,R12,R11,R10,R9,R8
  25  00000004  00000002 USING  ORDINARY    00001004 00001000 00000002  11 00000
  25  00000004  00000002 USING  ORDINARY    00002004 00001000 00000002  10 0003C     39
  25  00000004  00000002 USING  ORDINARY    00003004 00001000 00000002   9 00000
  25  00000004  00000002 USING  ORDINARY    00004004 00001000 00000002   8 00000



Symbol   Type   Id     Address  Length   Owner Id Flags Alias-of
          PC 00000001 00000000 00000000             00
ROUTNT    SD 00000002 00000000 0000204A             01



without

Code:
Stmt  -----Location----- Action ----------------Using----------------- Reg Max     Last Label and Using Text
        Count      Id           Type          Value    Range     Id    Disp    Stmt
  25  00000014  00000002 USING  ORDINARY    00000014 00001000 00000002  12 000EC     50 *,R12,R11,R10,R9,R8
  25  00000014  00000002 USING  ORDINARY    00001014 00001000 00000002  11 00000
  25  00000014  00000002 USING  ORDINARY    00002014 00001000 00000002  10 00000
  25  00000014  00000002 USING  ORDINARY    00003014 00001000 00000002   9 00000
  25  00000014  00000002 USING  ORDINARY    00004014 00001000 00000002   8 00000


Symbol   Type   Id     Address  Length   Owner Id Flags Alias-of
          PC 00000001 00000000 0000000A             00
ROUTNT    SD 00000002 00000010 0000203A             01
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Mar 29, 2011 6:41 pm    Post subject:
Reply with quote

The "problem" is that by coding the YREGS statement BEFORE the CSECT statement, you have, in effect, established TWO CSECTS - with the first one being unnamed.
Since YREGS does nothing more than equate R* names to the general registers, it does not have to be coded before the first CSECT.
If you move it to just after the AMODE instruction, you will end up with only ONE CSECT, and will not need the LTORG statement. To echo Enrico's post, the result will be:
Code:
                                              External Symbol Dictionary
Symbol   Type   Id     Address  Length   Owner Id Flags Alias-of       
ROUTNT    SD 00000001 00000000 000000FA             01                 
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10201
Location: italy

PostPosted: Tue Mar 29, 2011 6:51 pm    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

icon_redface.gif

good catch Ronald !

sometimes little details go unnoticed... I just overlooked the YREGS before the CSECT

and as said in the manual
Quote:
a literal pool generated after the END statement is created at the end of the first control section


and since YREGS blahblahblah icon_biggrin.gif

retestes moving the YREGS after the CSECT and

Code:
Symbol   Type   Id     Address  Length   Owner Id Flags Alias-of
ROUTNT    SD 00000001 00000000 0000204A             01
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Tue Mar 29, 2011 7:09 pm    Post subject:
Reply with quote

And the manual also states

Instructions that establish the first section: Any instruction that affects the location counter, or uses its current value, establishes the beginning of the first executable section. The instructions that establish the first section include any machine instruction and the following assembler instructions: CCW CCW0 CCW1 CNOP CSECT CXD DC DS
EQU
LOCTR LTORG ORG RSECT START USING.

CSECT, RSECT, and START start a possibly named control section. The other statements start an unnamed control section.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Tue Mar 29, 2011 9:26 pm    Post subject: Re: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Bill O'Boyle wrote:

A quick observance. Instead of using R12 as your base, use (for example), R3 instead.

The reason for this suggestion is because, if you ever decide to make the program/sub-program LE compliant, R12 contains the address of the LE "CAA" (Common Anchor Area).

Bill


Great observation!! I never thought about this possibility before.

One reason is that in my installation most of the existing programs are already using R12 as the base. So I am just trying to follow a sort of standard. But yes this is indeed something worth rethinking.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 30, 2011 2:54 am    Post subject: Reply to: A CSECT without an LTORG but uses literals
Reply with quote

Ron,

All my YREGS and DFHREGS will now be located at the end of the program.

Good find....

Thanks,

Bill
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Wed Mar 30, 2011 3:03 am    Post subject:
Reply with quote

Many old-time Assembler programmers used 12 as the base register as 15, 14, and 13 were already in use. With LE, however, their coding needs to be updated.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Wed Mar 30, 2011 10:06 am    Post subject:
Reply with quote

I placed the "YREGS" below Csect and removed the LTORG instruction. The program assembled OK with literals going at the end of the csect.

Thanks a lot for the comments guys! icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Dynamic load a csect jerryte COBOL Programming 6 Thu Aug 13, 2015 11:57 pm
No new posts File-Aid CSECT Information of load mo... ksouren007 Compuware & Other Tools 10 Fri May 24, 2013 3:15 pm
No new posts Extract a Csect from a Load module jerryte All Other Mainframe Topics 3 Sat Mar 24, 2012 12:40 am
No new posts What is the need to use LTORG prakashg PL/I & Assembler 5 Thu Jun 17, 2010 1:01 pm
No new posts CSECT not found error in batch bind Sanghani Sanjay DB2 6 Sat Feb 06, 2010 4:20 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us