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

BPXWDYN - assembler dynamic allocation


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

Global Moderator


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

PostPosted: Tue Oct 14, 2008 11:46 pm
Reply with quote

I've gotten BPXWDYN running from Assembler. This program uses standard linking conventions and returns a condition code of zero in the JCL. The code is:
Code:
ASMTEST  CSECT
         REGEQU
         STM   R14,R12,12(R13)
         LR    R12,R15
         USING ASMTEST,R12
         LA    R15,SAVEAREA
         ST    R13,4(R15)
         ST    R15,8(R13)
         LR    R13,R15
         OPEN  (SYSPRINT,(OUTPUT))
         PUT   SYSPRINT,=CL133'HELLO WORLD'
         LINK  EP=BPXWDYN,PARAM=(P1ADDR),VL=1
         LTR   R15,R15
* TEST FOR GOOD RETURN -- IF SO, JUMP OVER MOVE OF R15 TO OUTPUT
*        BZ    DYNWRITE
         CVD   R15,R15CVD
         UNPK  BPXM1R15(8),R15CVD+4(4)
         CLI   BPXM1R15+7,C'J'
         BL    BPXPLUS
         MVI   BPXMSG1+14,C'-'
         B     PUTCODE
BPXPLUS  EQU   *
         MVI   BPXMSG1+14,C'+'
PUTCODE  EQU   *
         OI    BPXM1R15+7,X'F0'
         PUT   SYSPRINT,BPXMSG1
DYNWRITE EQU   *
         OPEN  (DDN,(OUTPUT))
         PUT   DDN,BPXMSG2
         CLOSE (DDN)
         LINK  EP=BPXWDYN,PARAM=(P2ADDR),VL=1
         CLOSE (SYSPRINT)
         L     R13,SAVEAREA+4
         XR    R15,R15
         RETURN (14,12),RC=(15)
SAVEAREA DS    18F
DDN      DCB   DDNAME=MYFILE,BLKSIZE=27920,DSORG=PS,MACRF=(PM),        X
               LRECL=80
SYSPRINT DCB   DDNAME=SYSPRINT,BLKSIZE=133,DSORG=PS,MACRF=(PM)
         DC    C'SYSSNAP DCB FOUNDATION.'
         CNOP  0,4                 FULLWORD ALIGNMENT.
P1ADDR   DC    H'54'
PARM01   DC    CL54'ALLOC DD(MYFILE) DA(''TTSSRS0.BPXWDYN.FILE.DATA'') X
               SHR'
         CNOP  0,4                 FULLWORD ALIGNMENT.
P2ADDR   DC    H'16'
PARM02   DC    CL16'FREE  DD(MYFILE)'
R15CVD   DS    D
BPXMSG1  DC    0CL133
BPXMSG2  DC    0CL80
         DC    CL15'BPXWDYN R15 =  '
BPXM1R15 DS    CL8
         DC    CL110' '
FINAL    EQU   *
         END   ASMTEST

The JCL that runs this program does not include DDNAME MYFILE but is:
Code:
//STEP1     EXEC PGM=MF0027
//STEPLIB   DD   DISP=SHR,DSN=TTSSRS0.COMPILES.LOADLIB
//SYSABEND  DD   SYSOUT=*
//SYSPRINT  DD   SYSOUT=*
//

and the output file is:
Code:
 ISRBROBA DSLIST 0.BPXWDYN.FILE.DATA
 Command ===>
********************************* Top of Data
BPXWDYN R15 = +00000000

And SYSPRINT looks like:
Code:
----+----1----+----2----+----3
HELLO WORLD
BPXWDYN R15 = +00000000
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Oct 14, 2008 11:58 pm
Reply with quote

To add to what Dick said (I didn't see his post before putting my code up), the use of the LINK assembler macro requires use of certain standard calling conventions, which you chose to ignore (or didn't know about). The program I posted follows the LINK calling conventions and wrote to a DDNAME that was not defined in JCL. 55 lines of Assembler to start up, call BPXWDYN, and exit is not a large program. Getting so frustrated on such a simple task is not a good indicator for future success -- perhaps you need to reconsider an IT career???
Back to top
View user's profile Send private message
Pankaj Gupta
Currently Banned

New User


Joined: 07 May 2008
Posts: 50
Location: Bangalore

PostPosted: Tue Oct 28, 2008 12:05 am
Reply with quote

Now I am back from my holiday I have revied your fine code Mr Robert and I am seeing that my code was nearly right, missing only the 2 lines. Now my code is working well. Thank you for your help Mr Robert.

Mr Dick, I must say that I am in fact having 20 years of the informations technology experience. In fact, here on my desk they have been putting a sign which is saying "IT Guru", which I think is speaking for itself.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Oct 28, 2008 1:13 am
Reply with quote

Quote:
they have been putting a sign which is saying "IT Guru", which I think is speaking for itself.
Opinions vary. . .

Quote:
I must say that I am in fact having 20 years of the informations technology experience
Apparently not with this type of beginning assembler code (standard linkage should be the first discipline learned and understood with assembler - imho). Also, with 2 decades experience, one should surely have learned that "guru"s do not blame the documentation when they do not understand something.

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue Oct 28, 2008 1:31 am
Reply with quote

Quote:
The documentaiton for BPXWDYN is so poor that I am not sure where is being the return code or I would have checked. Would it perhaps be in R15?


to confirm that Your judgement is unfair ( I went thru the issue as a beginner would )

a stupid search with "bpxwdyn assembler samples" brought up ...

ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html

with the important info

Code:

      *-*------------------*     *-------*---------------------*
 R1-->|1| parm string addr *---->| length| parameter string    |
      *-*------------------*     *---*---*---------------------*


the docs cannot be blaimed, they rather should be read
and once in a while the IBM explanation is very clear
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Tue Oct 28, 2008 3:38 am
Reply with quote

Quote:
PostPosted: Tue Oct 14, 2008 9:45 am Post subject:
Reply with quote
If you look in this ftp.software.ibm.com/s390/zos/tools/bpxwdyn/bpxwdyn.html you can find
Early on in this document you can read:
Quote:
Calling Conventions

BPXWDYN is designed to be called from REXX, but may also be called by any program. Three parameter list forms are supported.

REXX External Function Parameter List

This parameter list allows REXX programs to call the BPXWDYN programs as a function or subroutine. They must be called with a single string parameter:

if BPXWDYN("alloc dd(sysin) da('my.dataset') shr")<>0 then
call allocfailed

Conventional MVS Variable Length Parameter String

This is the same parameter list as is generated by ADDRESS LINKMVS with one parameter and JCL with EXEC PGM=,PARM=. This parameter list form is simple to use by any program. Note that this is a single item variable length parameter list. The high bit is on in the parameter address word and length is a half word.


Figure 1.


*-*------------------*
R1-->|1| parm string addr *---*
*-*------------------* |
*-----------------------*
| *-------*---------------------*
*---->| length| parameter string |
*---*---*---------------------*


Now, I can only conclude that one of three possibilities occurred:
1. You did not read the material you were referred to. "Guru"s read documentation, especially when told it can solve their problem.
2. You read this document but did not comprehend it. Since this is basic, elementary Assembler coding conventions, not comprehending this material is not a good indicator for a "Guru".
3. You read this document, comprehended it, but did not follow the coding conventions. A "Guru" would not ignore coding conventions and then complain about the quality of the documentation. Coding conventions may sound optional but they are not -- you disregard them at the peril of your program. Your program problems were entirely caused by your not following the requirements of the called subroutine.
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
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Build dataset list with properties us... PL/I & Assembler 4
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
Search our Forums:

Back to Top