The following Assembler code example calls the Data Set Decompression Interface Service twice. The first call obtains the required length of the output area for the specified decompressed set-of samples. The second call performs the decompression.
* Assuming, register 2 points to the compressed set-of-samples
MVC INRECA,0(R2) Pointer to input record
* Calls Decompress Routine to retrieve the length of the
* uncompressed record.
LA R1,OUTAREA Address of uncompressed record
ST R1,OUTRECA Stores address in parmlist
MVC OUTRECL,INITLNG Length of uncompressed record
LA R1,PARMADDR Parameter to R1
LINK EP=ERB3RDEC Invokes decompress routine
* Checks Return Code
ST R15,RETCODE Saves return code
CLC R15,=F'4' Checks return code
BNE PROCESS Output area NOT too small
* Allocates required output area
L R3,OUTRECL Required output length
SR R4,R4 Subpool 0
GETMAIN RU,LV=(3),SP=(4) Get storage
ST R1,OUTRECA Address of uncompressed record
* Calls Decompress Routine
LA R1,PARMADDR Parameter to R1
LINK EP=ERB3RDEC Invokes decompress routine
* Checks Return Code
ST R15,RETCODE Saves return code
LTR R15,R15 Tests return code
BZ PROCESS Decompress successful
* Decompress not successful. Releases output area
L R2,OUTRECA Area address
L R3,OUTRECL Area length
SR R4,R4 Subpool 0
FREEMAIN RU,LV=(3),A=(2),,SP=(4)
PROCESS DS 0H
* Check return code and process the decompressed record here.
* OUTRECA contains the address of the uncompressed record and the
* return code from ERB3RDEC is in RETCODE.
…
* Declarations for the coding example above
INITLNG DC F'100' Initial length
OUTAREA DS CL100 Initial output area
PARMADDR DC A(PARMLIST) Address of parameter list
RETCODE DS F Return code
CNOP 2,4 Alignment
PARMLIST DC H'12' Length of parameter area. This
* field has to be initialized
* with the decimal value 12.
INRECA DS F First word. It has to be
* initialized with the address of
* the compressed set-of-samples.
OUTRECA DS F Second word. It has to be
* initialized with the address of
* the output area which holds the
* uncompressed set-of-samples.
OUTRECL DS F Third word. It has to be
* initialized with the size of
* the output area. ERB3RDEC will
* return the size of the un-
* compressed set-of-samples in
* this field.
* Registers
R0 EQU 0
R1 EQU 1
R2 EQU 2
R3 EQU 3
R4 EQU 4
R5 EQU 5
R6 EQU 6
R7 EQU 7
R8 EQU 8
R9 EQU 9
R10 EQU 10
R11 EQU 11
R12 EQU 12
R13 EQU 13
R14 EQU 14
R15 EQU 15