The CSRYCMPS area is mapped by the CSRYCMPS mapping macro and is
specified in the CBLOCK parameter of the CSRCMPSC macro. The area
consists of 7 words that should begin on a word boundary. Unused bits
in the first word must be set to 0.
- Set 4-bit field CMPSC_SYMSIZE in byte CMPSC_FLAGS_BYTE2 to a number
from 1 to 5 to indicate both the number of entries in the dictionary
and the size of a compressed symbol.
- If expanding, turn on bit CMPSC_EXPAND in byte CMPSC_FLAGS_BYTE2.
Otherwise, make sure that the bit is off.
- Whether compressing or expanding, you can turn on bit CMPSC_ZeroPaddingOK.
This bit indicates that zero padding of the output operand on the
right up to the operand length, and up to a model-dependant integral
boundary is acceptable. Specifying this bit might help the performance
of the operation. The bit is ignored if the machine does not support
the capability, so the bit can be set unconditionally.
- Set field CMPSC_DICTADDR to the address of the necessary dictionary.
If compressing, this should be the compression dictionary, which
must be immediately followed by the expansion dictionary. If
expanding, this should be the expansion dictionary. In either case,
the dictionary must begin on a page boundary, as the low order 12
bits of the address are assumed to be 0 when determining the address
of the dictionary.
If running in AR mode, set field CMPSC_SOURCEALET
to the ALET of the necessary dictionary. Note that the input area
is also accessed using this ALET. If not in AR mode, make sure that
the field contains 0.
Using the linkage editor can help you
get the dictionary on the proper boundary. For example, you may have
an object deck for each compression dictionary (CD), and expansion
dictionary (ED), and a DD statement for file OBJS, which represents
the library containing the object decks. The following instructions
linkage editor control statements define a dictionary with the name
DICT that, when loaded, will have the compression dictionary followed
by the expansion dictionary, and will begin on a page boundary.
ORDER CD(P),ED
INCLUDE OBJS(CD)
INCLUDE OBJS(ED)
NAME DICT(R)
- In most cases, make sure that 3-bit field CMPSC_BITNUM in byte
CMPSC_DICTADDR_BYTE3 is zero. This field has the following meaning:
- If compressing, place the first compression symbol at this bit
in the leftmost byte of the target operand. Normally this field should
be set to 0 for the start of compression.
- If expanding, expand beginning with the compression symbol that
begins with this bit in the leftmost byte of the source operand.
Normally this field should be set to the value used for the start
of compression.
- Set word CMPSC_TARGETADDR to the address of the output area. For
compression, the output area contains the compressed data; for expansion,
it contains the expanded data.
If running in AR mode, set field
CMPSC_TARGETALET to the ALET of the output area. If not in AR mode,
make sure that the field contains 0.
- Set word CMPSC_TARGETLEN to the length of the output area.
- Set word CMPSC_SOURCEADDR to the address of the input area. For
compression, the input area contains the data to be compressed; for
expansion, it contains the compressed data.
If running in AR mode,
set field CMPSC_SOURCEALET to the ALET of the input area. Note that
the dictionary will also be accessed using this ALET. If not in AR
mode, make sure that the field contains 0.
- Set word CMPSC_SOURCELEN to the length of the input area. For
expansion, the length should be the difference between CMPSC_TARGETLEN
at the completion of compression and CMPSC_TARGETLEN at the start
of compression, increased by 1 if field CMPSC_BITNUM was nonzero upon
completion of compression.
- Set word CMPSC_WORKAREAADDR to the address of a 192-byte work
area for use by the CSRCMPSC macro. The work area should begin on
a doubleword boundary. This area does not need to be provided and
the field does not have to be set if your code has verified that the
hardware CMPSC instruction is present. The program can do the verification
by checking that bit CVTCMPSH in mapping macro CVT is on.
When the CSRCMPSC service returns, it has updated the input CSRYCMPS
area as follows:
- CMPSC_FLAGS is unchanged.
- CMPSC_DICTADDR is unchanged, but bits CMPSC_BITNUM in field CMPSC_DICTADDR_BYTE3
are set according to the last-processed compression symbol.
- CMPSC_TARGETADDR is increased by the number of output bytes processed.
- CMPSC_TARGETLEN is decreased by the number of output bytes processed.
- CMPSC_SOURCEADDR is increased by the number of input bytes processed.
- CMPSC_SOURCELEN is decreased by the number of input bytes processed.
- CMPSC_WORKAREA is unchanged.
The target/source address and length fields are updated analogously
to the corresponding operands of the MVCL instruction, so that you
can tell upon completion of the operation how much data was processed
and where you might want to resume if you wanted to continue the operation.
Suppose that you had compressed a large area but wanted to expand
it back into a small area of 80-byte records. You might do the expansion
as follows:
LA 2,MYCBLOCK
USING CMPSC,2
XC CMPSC(CMPSC_LEN),CMPSC
OI CMPSC_FLAGS_BYTE2,CMPSC_SYMSIZE_1
OI CMPSC_FLAGS_BYTE2,CMPSC_EXPAND
L 3,EDICTADDR Address of expansion dictionary
ST 3,CMPSC_DICTADDR Set dictionary address
L 3,EXPADDR
ST 3,CMPSC_SOURCEADDR Set compression area
L 3,EXPLEN
ST 3,CMPSC_SOURCELEN Set compression length
LA 3,WORKAREA
ST 3,CMPSC_WORKAREAADDR Set work area address
MORE DS 0H Label to continue
*
* Your code to allocate an 80-byte output area would go here
*
ST x,CMPSC_TARGETADDR Save target expansion area
LA 3,80 Set its length
ST 3,CMPSC_TARGETLEN Set expansion length
CSRCMPSC CBLOCK=CMPSC Expand
C 15,=AL4(CMPSC_RETCODE_TARGET) Not done, target used up
BE MORE Continue with operation
DROP 2
.
.
DS 0F Align parameter on word boundary
MYCBLOCK DS (CMPSC_LEN)CL1 CBLOCK Parameter
EXPADDR DS A Input expansion area
EXPLEN DS F Length of expansion area
EDICTADDR DS A Address of expansion dictionary
DS 0D Doubleword align work area
WORKAREA DS CL192 Work area
CSRYCMPS , Get mapping and equates
Note that this code loops while the operation is not complete,
allocating a new 80-byte output record. It does not have to update
the CMPSC_BITNUM, CMPSC_SOURCEADDR, or CMPSC_SOURCELEN fields, because
the service sets them up for continuation of the original operation.
If running in AR mode, the example would also have set the CMPSC_TARGETALET
and CMPSC_SOURCEALET fields. The XC instruction zeroed those fields
as needed when running in primary ASC mode.