As the instruction
Machine Format Op Code L __ __ __ __ oo_0 ____ __ ____ Assembler Format OpCode 0
1
(L,B
1
),02(B
2
)
TR 0(20,12) ,O( 15)
is executed, the binary value of each argument byte is added
to the starting address of the table, and the resulting address
is used to fetch a function byte:
Table starting address: 1000 First argument byte (J): Dl
Address of function byte: lODI
Because the table is arranged so that every EBCDIC charĀ­ acter is replaced by the corresponding ASCII character, the
result is:
Locations 2100-2113: JOHNbJONESb257bW.b95
Note: To verify that this example is correct, find in appenĀ­
dix H the hexadecimal values for the remaining EBCDIC characters and add them to the starting address of the table (1000). The sums should be the addresses within the table
of the corresponding ASCII characters. Translate and Test (TRT)
The TRANSLATE AND TEST instruction is used to scan a
data field {the argument bytes) for characters with a special
meaning. To indicate which characters have special meaning,
first set up a table similar to the one used for the TRANS-
Translate-and-Test Table: 2000 2010 2020 2030 2040 2050 2060 2070 2080 2090 20AO 20BO 20CO 2000 20EO 20FO 00 00 00 00 00 90 80 00 00 00 I-- 00 00 00 00 00 - 00 00 00 00 00 00 00 .. ) 00 00 00 r- 00 00 00 00 00 -- -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ,_.- .. -- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 f-- - 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 _. - 00 00 00 00 c---- --- 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 30 00 00 00 50 00 00 00 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 - 00 00 00 00 r-- -_ .... 00 00 00 00 304 System/370 Principles of Operation 200F 00 00 00 00 00 00 00 00 --- 00 00 00 00 -- 00 00 00 00 --- 10 20 25 00 --
35 40 45 00 --
55 00 00 00 .-- ._-
65 70 75 00 00 00 00 00 00 00 00 00 ._- 00 00 00 00 00 00 00 00 00 00 00 00 r- - ._- 00 00 00 00 -- 00 00 00 00 -- 00 00 00 00 20FF LATE instruction. (See the preceding example.) Once again
the table must be in order by the binary sequence of the
code of the argument bytes. This time, however, put zeros
in the table to indicate characters without any special
meaning and nonzero values to indicate characters with
special meaning.
This example deals with EBCDIC characters; the characĀ­
ters with special meaning in the argument field are a selected
set of punctuation marks. The Translate-and-Test Table was
set up accordingly.
Note: If the character codes in the statement being transĀ­
lated occupy a range smaller than 00 through FF 16, a table
of fewer than 256 bytes can be used.
Now, assume that starting at storage location 3000 you
have the following sequence of 30
1
0 EBCDIC characters:
Locations 3000-301D: bbbbbUNPKbbbbbPROUT(9),WORD(5) Also assume:
Register 1 contains 00 00 2F FF
Register 2 contains 00 00 00 00 Register 15 contains 00 00 20 00 As the instruction
Machine Format Op Code L B1 0
1 00 10 I 001 Assembler Format Op Code 0
1
(L, B
1
), O
2
(B2)
TRT 1 (30,1),0(15) 000 is executed, the value of the first argument byte, a blank, is
added to the starting address of the table to produce the adĀ­ dress of the function byte to be examined:
Table starting address
First argument byte (blank)
Address of function byte 2000 40 2040 Because zeros were originally placed in storage location 2040, no special action occurs, and the operation continues
with the second argument byte. The operation will thus
continue until it reaches the symbol ( (left parenthesis) in
location 3013. When this symbol is reached, its value is
added to the starting address of the table, as usual:
Table starting address
Argument byte (left parenthesis)
Address of function byte 2000 4D 204D Because location 204D contains a nonzero value, the folĀ­ lowing actions occur:
1. The address of the argument byte, 003013, is placed in
the low-order 24 bits of register 1.
2. The function byte, 20, is placed in the low-order eight
bits of register 2.
3. Condition code 1 is set (scan not completed).
In general, TRANSLATE AND TEST is executed by the
use of an EXECUTE instruction, which supplies the length
specification from a general In this way, a complete
statement scan can be performed with a singleTRANSLA TE
AND TEST instruction repeated over and over by means of EXECUTE. In the example, after the first execution of
TRT, register 1 contains the address of the last argument
byte translated. It is then a simple matter to subtract this
address from the address of the last argument byte (301D)
to produce a length specification. This length minus one is
placed in the register that is referenced as the RI field of
the EXECUTE instruction. (Because the length code in the
machine format is one less than the total number of bytes in
the field, one must be subtracted from the computed length.)
The second-operand address of the EXECUTE instruction
points to the TRANSLATE AND TEST instruction, which
must now appear in the following format:
Machine Format Op Code L B1
Ā°1 00 00 I 001 000 Assembler Format Op Code 01 (L, B
1
), 02 (B
2
)
TRT 1(0,1),0(15) Now the entire argument field can be scanned, stopping to
examine those characters of special interest, without having
to modify any of the instructions already written. After a
stop is made to examine a character, only a new length need
be computed before continuing the scan.
Unpack (UNPK)
Assume that storage locations 2501-2503 contain a signed,
packed-decimal field that is to be unpacked and placed in
storage locations 1000-1004. Also assume:
Register 12 contains 00 00 10 00 Register 13 contains 00 00 25 00 Storage locations 2501-2503 contain 12 34 5D
The initial contents of storage locations 1000-1004 are not
significant
After the instruction
Machine Format
F3 I 4 I 2 I c 000 001 Assembler Format Op Code 01 (L
1
, B,), 02 (L
2
, B
2
)
UNPK 0(5,12),1(3,13)
is executed, storage locations 1000-1004 contain F 1 F2 F3
F4 D5. DECIMAL INSTRUCTIONS Add Decimal (AP)
Assume that the signed, packed-decimal field at storage locaĀ­
tions 500-503 is to be added to the signed, packed-decimal
field at locations 2000-2002. Also assume:
Register 12 contains 00 00 20 00 Register 13 contains 00 00 04 FD
Storage locations 2000-2002 contain 38 46 OD (a negative
number)
Storage locations 500-503 contain 01 12 34 5C (a positive
number)
After the instruction
Machine Format Op Code L1 L2 B, 01 B2 02 1--1 -2 -r-,-3-"',-C-'--' 000-"---, Assembler Format Op Code 01 (L
1
, B
1
), 02 (L
2
, B2)
AP 0(3,12),3(4,'3) is executed, storage locations 2000-2002 contain 73 88 5C; condition code 2 is set to indicate that the sum is positive.
Note that:
1. Although the second-operand field is larger than the firstĀ­
operand field, no overflow interruption occurs because
the result can be entirely contained within the firstĀ­
operand field.
2. Because the two numbers had different signs, they were if!. effect subtracted.
Compare Decimal (CP)
Assume that the signed, packed-decimal contents of storage
locations 700-703 are to be algebraically compared with the
signed, packed-decimal contents oflocation 500-503. Also
assume:
Register 12 contains 00 00 06 00 Register 13 contains 00 00 04 00 Storage locations 700-703 contain 17 25 35 6D
Storage locations 500-503 contain 06 72 14 2D
After the instruction
Machine Format Op Code L, L2 B1 100 Assembler Format Op Code 01 (L
1
, B
1
), 02 (L
2
, B2) CP X'100'(4,12),X'100'(4,13) 100 is executed, condition code 1 is set, indicating that the first
operand (the contents of locations 700-703) is lower than
the second.
Appendix I. Number Representation and Instruction-Use Examples 305
Previous Page Next Page