BPX4RW (Pwrite) example

The following code writes 80 bytes from the specified buffer to the file specified (FILEDESC). It will start writing at specified offset, 30 bytes from start of the file. To positional read from a file, change the FUIORWIND to indicate FUIO#RD. For the callable service, see Pread() and Pwrite() (BPX1RW, BPX4RW) — Read from or write to a file without changing the file pointer. AMODE 31 callers use BPX1RW (Pwrite) example.

                                              
       MVC   FILEDESC,             File descriptor from open            
         XC    FUIO,FUIO             Zero out Fuio fields               
         MVC   FUIOID,=CL4'FUIO'     Eye Catcher                        
         MVC   FUIOLEN,=AL4(FUIO#LENGTH) length                         
         LA    R15,BUFFERA           Set address of buffer              
         STG   R15,FUIOBUFFERADDR    for buffer data in FUIO            
         MVI   FUIORWIND,FUIO#WRT    Flag to indicate to PWrite         
         MVC   FUIOIBYTESRW,=F'80'   Number of bytes to Write           
         MVC   FUIOCUR2,=F'30'       Offset to start writing            
         MVI  FUIOFLAG2,FUIOADDR64   Set 64bit addressing               
         LA    R15,FUIO              Set address of Fuio                
         STG   R15,LFUIOPTR          For access to Fuio fields          
         SPACE ,                                                        
         CALL  BPX4RW,               PWrite to a file                  +
               (FILEDESC,            Input: File descriptor            +
               LFUIOPTR,             Input: Address of FUIO struct     +
               PRIMARYALET,          Input: Fuio ALET                  +
               FUIOLEN,              Input: Fuio Length                +
               RETVAL,               Return value: -1 or bytes written +
               RETCODE,              Return code                       +
               RSNCODE),             Reason code                       +
               MF=(E,PLIST)          ----------------------------------