IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DSECT and Establishing Addressability


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue May 31, 2011 3:45 pm
Reply with quote

Hi,

I have written below code to understand the concept of DSECT and establishing addressability for DSECT.

But the compilation error says No Active USING for the fields under DSECT(OPERTNA,ADD1A,ADD2A).

Code:
TESTPGM2 START
         SAVE (14,12)   
         USING *,R5     
         BALR R5,R0     
         BCTR R5,R0     
         BCTR R5,R0     
         OPEN (OUTFLE,OUTPUT) 
ADDIT    MVC OPERTN,=C'ADD'   
         L R2,ADD1   
         AH R2,ADD2                                               
         CHI R2,50                                                 
         BE  ADDSUC                                               
         WTO 'FAIL:ADDITION(AH) OF X''31 WITH X''14 IS NOT X''45'''
         B  DISP                                                   
ADDSUC   WTO 'SUCC:ADDITION(AH) OF X''31 WITH X''14 IS X''45'''   
DISP     LA R3,RESULT                                             
         ST R2,0(R3)                                               
         PUT OUTFLE,ADDDATE                                       
         WTO '***DSECT AND ADDRESSABILITY***'           
ADD      USING ADDFLD,R9                               
         L  R9,OUTREC                                   
         MVC OPERTNA,=C'ADD'                           
         L R2,ADD1A                                     
         MVI ADD2A,10                                   
         AH  R2,ADD2A                                   
         CHI R2,40                                     
         BE  ADDSUC                                     
         WTO 'FAIL:ADDITION(AH) OF 30 WITH 10 IS NOT 40'
         B  DISP                                       
ADDSUC2  WTO 'SUCC:ADDITION(AH) OF 30 WITH 10 IS 40'   
DISP2    LA R3,RESULTA                                 
         ST R2,0(R3)                                   
         PUT OUTFLE,OUTREC                             
         CLOSE OUTFLE                                   


* DATA FIELDS FOR AH INSTRUCTION             
ADDDATE  DC 0CL80                             
OPERTN   DC CL3' '                           
FILLER1  DC C' '                             
ADD1     DC F'30'                             
FILLER2  DC C' '                             
ADD2     DC H'20'                             
FILLER3  DC C' '                             
RESULT   DC F'0'                             
FILLER4  DC CL64' '                           

OUTREC   DC  CL80' '                                                   
OUTFLE   DCB DSORG=PS,                                                 X
               MACRF=(PM),                                             X
               DDNAME=OUTFILE,                                         X
               LRECL=80,                                               X
               RECFM=FB,                                               X
               SYNAD=ERROR1,                                           X
               BLKSIZE=8000                                             

ADDFLD   DSECT         
OPERTNA  DC CL3' '     
FILLER1A DC C' '       
ADD1A    DC F'30'       
FILLER2A DC C' '       
ADD2A    DC H'20'       
FILLER3A DC C' '       
RESULTA  DC F'0'       
FILLER4A DC CL64' '     
*                       
         END           


But the compilation error says No Active USING for the fields under DSECT(OPERTNA,ADD1A,ADD2A).

Please let me know what is wrong with the code. Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Tue May 31, 2011 3:57 pm
Reply with quote

You have to allocate memory pointed to by a register, then issue a USING ADDFLD,register to make the DSECT variables usable -- BEFORE using any of the variables.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Tue May 31, 2011 3:58 pm
Reply with quote

First of all, get rid of those two consecutive BCTR's. What are they for?

Second, I don't see a USING and an associated base-register for the ADDFLD DSECT.

DSECT's belong at the top, before the start of the CSECT, but that has nothing to do with the USING error.

Issue a GETMAIN and then load R9 (as an example DSECT base) from R1 with the address, followed by USING ADDFLD,R9. You're also missing an 18-Word Register-Savearea (standard practice) and the RETURN Macro with an accompanying R15.

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

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Tue May 31, 2011 4:05 pm
Reply with quote

Quote:
DSECT's belong at the top, before the start of the CSECT

Not at my shop. Every in-house Assembler application has the DSECTs at the bottom. I think it's according to taste...

Garry.
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Tue May 31, 2011 4:26 pm
Reply with quote

You are using a labeled USING so you would need someting like :

MVC ADD.OPERTNA,=C'ADD'

better is :

ADD EQU *
USING ADDFLD,R9


And for the rest your coding sucks big time.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Tue May 31, 2011 4:33 pm
Reply with quote

Garry,

HLASM recommends placing the DSECTS at the top. This is just the opposite of its predecessors.

DSECTS at the top prevent the Assembler from "Double Sweeping" during Assembly.

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

CICS Moderator


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

PostPosted: Tue May 31, 2011 4:45 pm
Reply with quote

Something else. Move the BALR R5,R0 to just after the SAVE Macro, then followed by the USING for the CSECT.

Change L R9,OUTREC to LA R9,OUTREC

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

New User


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

PostPosted: Wed Jun 01, 2011 2:46 pm
Reply with quote

Code:
ADDFLD   DSECT         
OPERTNA  DC CL3' '     
FILLER1A DC C' '       
ADD1A    DC F'30'       
FILLER2A DC C' '       
ADD2A    DC H'20'       
FILLER3A DC C' '       
RESULTA  DC F'0'       
FILLER4A DC CL64' '     



Shouldn't all DC's be DS's here? I believe that DSECT acts just as a "stencil" over a data area and does nothing like initialising that area.
Back to top
View user's profile Send private message
nigelosberry

New User


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

PostPosted: Wed Jun 01, 2011 2:52 pm
Reply with quote

Code:
BCTR R5,R0     
BCTR R5,R0     


A different way of adjusting the address in base register.

I once placed a BALR after USING and it took me quite long to detect the problem.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Wed Jun 01, 2011 2:55 pm
Reply with quote

Quote:
A distinct way of adjusting the base register address.


No, an unconventional way. Most would

Code:
    TESTPGM2 CSECT
             L    R5,R15
             USING TESTPGM2,R5


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

New User


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

PostPosted: Wed Jun 01, 2011 2:58 pm
Reply with quote

Garry Carroll wrote:
Quote:
A distinct way of adjusting the base register address.


No, an unconventional way. Most would

Code:
    TESTPGM2 CSECT
             L    R5,R15
             USING TESTPGM2,R5


Garry.



Yes. absolutely!
One should not reach a point wherein one has to adjust the content of base. icon_smile.gif
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 10:52 am
Reply with quote

Thanks everyone. The issue is resolved, as mentioned by Peter I would have to use ADD.OPERTNA.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. VSAM I/O - Extended Addressability - ... JCL & VSAM 12
No new posts COBOL Code Parsers and Lineage Establ... COBOL Programming 2
No new posts Using DSECT - for file reading PL/I & Assembler 2
No new posts DSECT ID in listing. PL/I & Assembler 7
No new posts Instructions Within a DSECT PL/I & Assembler 3
Search our Forums:

Back to Top