one question about locate mode



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

one question about locate mode

Postby bobguo » Wed Aug 14, 2013 7:45 am

MAIN     CSECT               
         STM   14,12,12(13)   
         BASR  12,0           
         USING *,12           
         ST    13,SAVE+4     
         LA    13,SAVE       
START    EQU   *                                       
         OPEN (FILEIN,(INPUT))                         
         OPEN (FILEOUT,(OUTPUT))                       
         USING RECIN,4                                 
         GET FILEIN                                     
         LR 4,1                                         
         PUT FILEOUT                                   
EOF      CLOSE FILEIN                                   
         CLOSE FILEOUT                                 
EXIT     EQU   *                                       
         L     13,SAVE+4                               
         LM    14,12,12(13)                             
         LA    15,0                                     
         BR    14                                       
FILEIN   DCB  DDNAME=INDD,DSORG=PS,MACRF=(GL),EODAD=EOF
FILEOUT  DCB  DDNAME=OUTDD,DSORG=PS,MACRF=(PL)
SAVE     DS    18F 
RECIN    DSECT     
CUSTNAME DS CL40   
CUSTADDR DS CL40   
RECOUT   DSECT     
NAME     DS CL40   
ADDRESS  DS CL40   
         END   MAIN   



I copied some code,just shows as above.
can somebody tell me why output file does NOT have the same record as input file?
thx.

Sincerely,
Bob
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: one question about locate mode

Postby steve-myers » Wed Aug 14, 2013 10:50 am

bobguo wrote:
MAIN     CSECT               
         STM   14,12,12(13)   
         BASR  12,0           
         USING *,12           
         ST    13,SAVE+4     
         LA    13,SAVE       
START    EQU   *                                       
         OPEN (FILEIN,(INPUT))                         
         OPEN (FILEOUT,(OUTPUT))                       
         USING RECIN,4                                 
         GET FILEIN                                     
         LR 4,1                                         
         PUT FILEOUT                                   
EOF      CLOSE FILEIN                                   
         CLOSE FILEOUT                                 
EXIT     EQU   *                                       
         L     13,SAVE+4                               
         LM    14,12,12(13)                             
         LA    15,0                                     
         BR    14                                       
FILEIN   DCB  DDNAME=INDD,DSORG=PS,MACRF=(GL),EODAD=EOF
FILEOUT  DCB  DDNAME=OUTDD,DSORG=PS,MACRF=(PL)
SAVE     DS    18F 
RECIN    DSECT     
CUSTNAME DS CL40   
CUSTADDR DS CL40   
RECOUT   DSECT     
NAME     DS CL40   
ADDRESS  DS CL40   
         END   MAIN   



I copied some code,just shows as above.
can somebody tell me why output file does NOT have the same record as input file?
thx.

Sincerely,
Bob

There are several problems with your little program.
  1. Use the SAVE and RETURN macros to save your registers and restore them when you return. What you did is perfectly valid, if incomplete.
  2. When you establish a new save area you should connect your new save area to the caller's save area as well as connect the caller's save area to the new save area. When you do this the dump program can display the entire save area chain if your program ABENDs, What I do is something like this -

    LA 15,NEWSAVE
    ST 15,8(,13)
    ST 13,4(,15)
    LR 13,15

    Now let's look at your problem.
  3. When you specify MACRF=PL, as you did, when your program issues a PUT macro, the PUT macro returns the address of space in an I/O buffer. Your program must copy any data that will subsequently be written to the output data set to this space before your program issues the next PUT macro or CLOSE macro. If you are writing variable length records or undefined length records, your program must store the length of the buffer space you need into the DCBLRECL area of the output DCB before you issue the PUT macro. You do not have to do this if you are writing fixed length records since DCBLRECL is already set.
Most of the time, many programmers will do something like this.
COPYLOOP GET   inputdcb
         LR    areg,1
         PUT   outputdcb,(areg)
         B     COPYLOOP
         ...
outputdcb DCB  MACRF=PM,DSORG=PS,...
This code snippet makes the PUT macro copy the data from the input buffer to the output buffer, though you will find your copy code will most likely be more efficient than the copy code in the PUT macro. The areg in the code snippet can be any register except register 1. Since there is no copy code in this code snippet it is easier to understand than specifying locate mode for the output data set.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: one question about locate mode

Postby bobguo » Wed Aug 14, 2013 1:23 pm

thanks steve-myers very much for your reply.

i caught what you said, as to input file we use GL, output file we use PM...

but can you tell me how i should change my code if PL was issued when deal with output file?

i just want to know some more knowledge :D

Sincerely,
Bob
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time

Re: one question about locate mode

Postby steve-myers » Wed Aug 14, 2013 6:08 pm

Bob: It does not seem you read all of my post. When you do a copy using MACRF=GL to MACRF=PL, your code must copy each record from the input buffer to the output buffer. There is no copy code in your little program.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Re: one question about locate mode

Postby bobguo » Wed Aug 14, 2013 7:59 pm

got it and program ran gracefully.

thanks again.
bobguo
 
Posts: 76
Joined: Thu Apr 26, 2012 11:18 am
Location: shanghai
Has thanked: 22 times
Been thanked: 0 time


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post