Need help with BPXWDYN



High Level Assembler(HLASM) for MVS & VM & VSE

Need help with BPXWDYN

Postby BigLenny » Mon Apr 04, 2022 9:29 am

I'm trying to dynamically allocate a dataset with BPXWDYN but I keep getting a S0C1 that says:
A system abend 0C1 occurred in an undetermined module.

A program-interruption code 0001 (Operation Exception) is associated with this
abend and indicates that:

  An attempt was made to execute an instruction with an invalid operation code.

The abend occurred after executing machine instruction 0DEF (BRANCH AND SAVE) in
module X CSECT SCHEDMON at offset X'5C'.


Here is the short bit of code for it:
LINK  EP=BPXWDYN,PARAM=(MYFILE),VL=1

         OPEN  (DDN,(OUTPUT))

         MVC   OUTREC,=CL80' '
         MVC   OUTREC(5),=C'HELLO'
         PUT   DDN,OUTREC

         CLOSE (DDN)
         LINK  EP=BPXWDYN,PARAM=(FREEFILE),VL=1

DDN      DCB   DDNAME=MYFILE,DSORG=PS,MACRF=(PM),LRECL=80,RECFM=FB
MYFILE   DC    CL48'ALLOC FI(MYFILE) DA("Z00620.ASMSCHED(TEST)") SHR'
FREEFILE DC    CL15'FREE FI(MYFILE)'
 


I know for sure that this:
LINK  EP=BPXWDYN,PARAM=(MYFILE),VL=1

Is giving a return code that's not zero, I've just taken out the test for it in my code for now.

I don't really understand how to use BPXWDYN yet, I've just been experimenting and to trying to get it to work. I've been mostly using Robert Samples' post in this topic(https://ibmmainframes.com/about35091.html) as a reference. And here's the code from his post:
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


I don't understand why he is using P1ADDR in
LINK  EP=BPXWDYN,PARAM=(P1ADDR),VL=1
instead of PARM01. Also I couldn't find what the VL=1 means either.

I used this site (http://csc.columbusstate.edu/woolbright/LINKAGE.HTM) to learn about program linking/calling conventions and felt like I understood it overall, but I don't really know how it's being applied in this case.

Sorry if I didn't provide enough information or if I put useless info. I've only been learning Assembler for a couple weeks so I don't know too much yet.
BigLenny
 
Posts: 10
Joined: Wed Nov 10, 2021 2:05 pm
Has thanked: 10 times
Been thanked: 0 time

Re: Need help with BPXWDYN

Postby willy jensen » Mon Apr 04, 2022 1:12 pm

You must add a 2 byte length field in front of the text, i.e.:
* allocate sysout                                
         sr    r0,r0                            
         Link  EP=BPXWDYN,param=alcout,VL=1      
         st    r15,fw                            
-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -
alcout   dc    y(alcoutl)                        
         dc    c'ALLOC NEW DELETE DD(SYSOUT) '  
         dc    c'TRACKS SPACE(1,1) UNIT(SYSDA)'  
alcoutl  equ   *-alcout-2  

These users thanked the author willy jensen for the post:
BigLenny (Mon Apr 04, 2022 5:37 pm)
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help with BPXWDYN

Postby willy jensen » Mon Apr 04, 2022 1:15 pm

which by the way is also what is shown in Robert Samples' post.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help with BPXWDYN

Postby BigLenny » Mon Apr 04, 2022 5:37 pm

Thanks Willy it worked! Took me a few hours though because there was another issue with this code:
MYFILE   DC    CL48'ALLOC FI(MYFILE) DA("Z00620.ASMSCHED(TEST)") SHR'

I had to change the double quotes to two single quotes. :oops:

Also, I only had to add the two byte length field for this one:
FREEFILE DC    CL15'FREE FI(MYFILE)'


but not this one:
MYFILE   DC    CL48'ALLOC FI(MYFILE) DA("Z00620.ASMSCHED(TEST)") SHR'


I'll still add it just in case, but is that normal?
BigLenny
 
Posts: 10
Joined: Wed Nov 10, 2021 2:05 pm
Has thanked: 10 times
Been thanked: 0 time

Re: Need help with BPXWDYN

Postby willy jensen » Mon Apr 04, 2022 8:35 pm

BPXWDYN works with fully qualified datasetnames, so quotes are not neccessary.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help with BPXWDYN

Postby Robert Sample » Mon Apr 04, 2022 8:43 pm

I used P1ADDR in that code because the half-byte length of the parameter is stored before the value, at the address of P1ADDR. It is rare not to need to set the length just before the parameter in HLASM.

VL=1 can be found in the MVS Assembler Services Reference manual for your version of z/OS in the description of the LINK parameters. VL=1 tells the assembler to set the high-order bit of the last parameter to one (which is the convention to denote the last parameter when passing a variable number of parameters in Assembler).

In addition to the Assembler manual, there are a number of other manuals that have very useful information -- the Assembler Services Reference, the Assembler Service Guide, and sometimes the Authorized Assembler manuals. There are a number of helpful manuals in the DFSMS manuals, too.

These users thanked the author Robert Sample for the post:
BigLenny (Mon Apr 04, 2022 9:41 pm)
Robert Sample
Global moderator
 
Posts: 3719
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Need help with BPXWDYN

Postby willy jensen » Mon Apr 04, 2022 9:22 pm

BPXWDYN supports 2 types of call:
length, parameter-string
and null-terminated parameter-string,'00'x

So you may have been in luck that your parameter is followed by a 1-byte binary zero.
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help with BPXWDYN

Postby willy jensen » Mon Apr 04, 2022 9:23 pm

see BPXWDYN in the 'Using REXX and z/OS UNIX System Services' manual (yes it also covers program calls).
willy jensen
 
Posts: 455
Joined: Thu Mar 10, 2016 5:03 pm
Has thanked: 0 time
Been thanked: 69 times

Re: Need help with BPXWDYN

Postby BigLenny » Mon Apr 04, 2022 10:03 pm

Awesome, thanks for the extra info Willy and Robert! I'll check out all those manuals, too :) It's crazy how many manuals there are for Assembler

And if anyone else has something else they want to add I'll keep checking the thread so I don't miss it :D
BigLenny
 
Posts: 10
Joined: Wed Nov 10, 2021 2:05 pm
Has thanked: 10 times
Been thanked: 0 time

Re: Need help with BPXWDYN

Postby steve-myers » Mon Apr 04, 2022 11:05 pm

There are three dynamic allocation interfaces in z/OS.
  • TSO dynamic allocation
    TSO dynamic allocation goes back to TSO in OS/360. It is documented quite well in TSO publications. As far as I know IBM has not enhanced this form of dynamic allocation in any way for upwards of 40 years.
  • MVS native dynamic allocation
    MVS dynamic allocation reared is ugly head in the original MVS. Unlike TSO dynamic allocation it was obviously, readily extendable. Most of us working in MVS immediately started using it as it worked just as well in batch programs. We abandoned TSO dynamic allocation because it could only be used in TSO. MVS dynamic allocation is slightly harder to use than TSO dynamic allocation, but the difference is so minuscule, most of us never bother with TSO dynamic allocation. Several years ago I thought to try TSO dynamic allocation for the first time in I couldn't tell you how many years. A HUGE mistake as I had to relearn all of it.
  • BPXWDYN
    The roots of BPXWDYN are not very clear to me. You feed it a text string that looks much like the TSO ALLOCATE or FREE commands. It appears to be easier to use than any other dynamic allocation method, but the key words are rather inflexible and are poorly documented.

These users thanked the author steve-myers for the post:
BigLenny (Tue Apr 05, 2022 7:30 am)
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Next

Return to Assembler