1 Selected bits mixed zeros and
ones
2
3 Selected bits all ones Program Exceptions:
Access (fetch, operand 1) Programming Note
An example of the use of the TEST UNDER
MASK instruction is given in Appendix A.
TRANSLATE
TR [SS] 'DC' L I B, I B. I EJ o 8 16 20 32 36 47
The bytes of the first operand are used
as eight-bit arguments to reference a list designated by the second-operand
address. Each function byte selected
from the list replaces the corresponding
argument in the first operand.
The L field specifies the length of only
the first operand.
The bytes of the first operand are
selected one by one for translation,
proceeding left to right. Each argument
byte is added to the initial second­
operand address. The addition is
performed following the rules for
address arithmetic, with the argument
byte treated as an eight-bit unsigned
binary integer and extended with zeros
on the left. The sum is used as the
address of the function byte, which then
replaces the original argument byte.
The operation proceeds until the first­
operand field is exhausted. The list is
not altered unless an overlap occurs.
When the operands overlap, the result is
obtained as if each result byte were
stored immediately after fetching the
corresponding function byte.
Access exceptions are recognized only
for those bytes in the second operand
which are actually required. Condition Code: unchanged. Program Exceptions:
The code remains
Access (fetch, operand 2; fetch and
store, operand 1) Programming Notes
1. An example of the use of the TRANS­
LATE instruction is given in Appen­
dix A.
2. TRANSLATE may be used to convert
data from one code to another code.
3. The instruction may also be used to
rearrange data. This may be accom­
plished by placing a pattern in the
destination area, by designating
the pattern as the first operand of
TRANSLATE, and by designating the
data that is to be rearranged as
the second operand. Each byte of
the pattern contains an eight-bit
number specifying the byte destined
for this position. Thus, when the
instruction is executed, the
pattern selects the bytes of the
second operand in the desired
order.
4. Because each eight-bit argument
byte is added to the initial
second-operand address to obtain
the address of a function byte, the
list may contain 256 bytes. In
cases where it is known that not
all eight-bit argument values will
occur, it is possible to reduce the
size of the list.
5. Significant performance degradation
is possible when, with OAT on, the
second-operand address of TRANSLATE
designates a location that is less
than 256 bytes to the left of a
2K-byte boundary. This is because
the machine may perform a trial
execution of the instruction to
determine if the second operand
actually crosses the boundary.
6. The fetch and subsequent store
accesses to a particular byte in
the first-operand field do not
necessarily occur one immediately
after the other. Thus, this
instruction cannot be safely used
to update a location in storage if
the possibility exists that another CPU or a channel may also be updat­ ing the location. An example of
this effect is shown for OR (01) in
the section "Multiprogramming and
Multiprocessing Examples" in Appen­
dix A.
7. The storage-operand references of
TRANSLATE may be multiple-access
references. (See the section
"Storage-Operand Consistency" in Chapter 5, "Program Execution.") Chapter 7. General Instructions 7-39
TRANSLATE AND TEST [55] 'DO' L I 8, I I 8, I o 8 16 20 32 36 47
The bytes of the first operand are used
as eight-bit arguments to select func­
tion bytes from a list designated by the
second-operand address. The first nonzero function byte is inserted in
general register 2, and the related
argument address in general register 1.
The L field specifies the length of only
the first operand.
The bytes of the first operand are
selected one by one for translation,
proceeding from left to right. The
first operand remains unchanged in stor­
age. Calculation of the address of the
function byte is performed as in the
TRANSLATE instruction. The function
byte retrieved from the list is
inspected for a value of zero.
When the function byte is zero, the
operation proceeds with the next byte of
the first operand. When the first­
operand field is exhausted before a
nonzero function byte is encountered,
the operation is completed by setting
condition code O. The contents of
general registers 1 and 2 remain
unchanged.
When the function byte is nonzero, the
operation is completed by inserting the
function byte in general register 2 and
the related argument address in general
register 1. This address points to the
argument byte last translated. The
function byte replaces bits 24-31 of
general register 2. The address
replaces bits 8-31 of general register
1. Bits 0-7 of general register 1 and
bits 0-23 of general register 2 remain
unchanged.
When the function byte is nonzero,
either condition code 1 or 2 is set,
depending on whether the argument byte
is the rightmost byte of the first oper­
and. Condition code 1 is set if one or
more argument bytes remain to be trans­
lated. Condition code 2 is set if no
more argument bytes remain.
Access exceptions are recognized only
for those bytes in the second operand
which are actually required. Access
exceptions are not recognized for those
bytes in the first operand which are to
the right of the first byte for which a
nonzero function byte is obtained.
Resulting Condition Code: o All function bytes zero 7-40 System/370 Principles of Operation 1
2
3
Nonzero function byte; first­
operand field not exhausted
Nonzero function byte; first­
operand field exhausted
Program Exceptions:
Access (fetch, operands 1 and 2)
Programming Notes
1. An example of the use of the TRANS­
LATE AND TEST instruction is given
in Appendix A.
2. TRANSLATE AND TEST may be used to
scan the first operand for charac­
ters with special meaning. The
second operand, or list, is set up
with all-zero function bytes for
those characters to be skipped over
and with nonzero function bytes for
the characters to be detected. UNPACK [55] 'F3' I L, I L, I 8, I 8, o 8 12 16 20 32 36 47
The format of the second operand is
changed from packed to zoned, and the
result is placed at the first-operand
location. The packed and zoned formats
are described in Chapter 8, "Decimal
Instructions."
The second operand is treated as though
it had the packed format. Its digits
and sign are placed unchanged in the
first-operand location, using the zoned
format. Zone bits with coding of 1111
are supplied for all bytes except the
rightmost byte, the zone of which
receives the sign of the second operand.
The sign and digits are not checked for
valid codes.
The result is obtained as if the oper­
ands were processed right to left. When
necessary, the second operand is consid­
ered to be extended on the left with
zeros. If the first-operand field is
too short to contain all digits of the
second operand, the remaining leftmost
portion of the second operand is
ignored. Access exceptions for the
unused portion of the second operand may
or may not be indicated.
When the operands overlap, the result is
obtained as if the operands were proc­
essed one byte at a time and as if the
first result byte were stored immediate-
Previous Page Next Page