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
Divide Dec:imal (DP)
Assume that the signed, packed-decimal field at storage lo­ cations 2000-2004 (the dividend) is to be divided by the
signed, packed-decimal field at locations 3000-3001 (the
divisor). Also assume:
Instruction address: 005000 Location 5000 contains: FD 41 C 000 D 000 DP 0(5,12),0(2,13)
Register 12 contains 00 00 20 00 Register 13 contains 00 00 30 00 Storage locations 2000-2004 contain 01 23 45 67 8C
Storage locations 3000-3001 contain 32 1D
After the instruction at location 5000 is executed, the
dividend field is entirely replaced by the signed quotient
and remainder fields, as follows: 2000 2004 Locations 2'000-2004 \ 38 \46 \ 00 \ 01 lac I Quotient I Remainder I Notes:
1. Because the signs of the dividend and divisor are differ­ ent, the quotient receives a negative sign.
2. The remainder receives the sign of the dividend and the
length of the divisor.
3. If an attempt is made to divide the dividend by the one­ byte field at location 3001, the quotient will be too long
to fit within the four bytes allotted to it. A decimal­ divide exception exists, causing a program interruption.
Edit (ED)
Because the decimal-feature instructions operate only on
packed-decimal data, it is necessary to convert the data to
the zoned format before a legible report can be printed.
Moreover, if the report is to be useful to a great many peo­ ple, certain punctuation marks, such as commas and decimal
points, should be inserted in appropriate places. The highly
flexible EDIT instruction performs these two functions in a
single instruction execution.
This example shows step-by-step one way in which the
EDIT instruction can be used. The field to be edited (the
source) is four long; it is edited against a pattern 13
bytes long. The follOWing symbols are used: Svmbol b (Hexadecimal 40) ( (Hexadeci mal 21)
d (Hexadecimal 20) Meaning Blank character
Significance starter
Digit selector Assume that the source and pattern fields are: Source 1200 1203 306 System/370 Principles of Operation Pattern 1000 100C \40 120 120 16B 120 120 121 14B 120 1
20
\40 I C31 09
1
b d d d d ( d db C R
Execution of the instruction (assume that register 12 con­ tains 00 00 10 00) Machine Format Op Code
DE OC 1 C 1 000 Assembler Format Op Code D1 (L, B
1
), O
2
(B
2
)
ED 0(13,12),X'200'(12)
alters the pattern field as follows:
Significance
Indicator
Pattern Digit Before/After Rule
b off/off leave(1 )
d 0 off/off fill d 2 off/on(2) digit
on/on leave d 5 on/on digit
d 7 on/on digit
( 4 on/on digit
on/on leave d 2 on/on digit
d 6+ on/off(3) digit
b off/off fill C off/off fill R
off/off fill Notes: 200 Location 1000-100C bdd,dd( .ddbCR
bbd,dd( .ddbCR
bb2,dd( .ddbCR
same
bb2,5d(.ddbCR
bb2,57(.ddbCR
bb2,574.ddbCR
same
bb2,574.2dbCR
bb2,574.26bCR
same
bb2,574.26bbR
bb2,574.26bbb
(1) This character becomes the fill character.
(2) First nonzero decimal source digit turns on significance
indicator.
(3) Plus sign in the four low-order bits of the byte turns
off significance indicator.
Thus, after the instruction is executed, the source is un­ changed, and the pattern is as follows:
Pattern 1000 100C 140 140 1 F216B I F51 F71 F414B 1 F21 F6140 1
40
1
40
, b b 2 5 7 4 2 6 b b b Condition code = 2: result is greater than zero.
When printed, this new pattern field appears as:
2,574.26
If the number in the source field is changed to 000002 6D,
a negative number, and the original pattern is used, the edited
result this time is:
Pattern 1000 100C 1
40
1
40
1
40
1
40
1
40
1
40
1
40
14B 1 F2 I F6140 I ciEJ b b b b b b b 2 6 b C R Condition code = 1: result is less than zero.
Previous Page Next Page