IBM® z/Architecture�EDIT (ED) and EDIT AND MARK (EDMK) Instructions
Dan Greiner – IBM Architect Emeritus
1
The Legal Stuff
© Copyright Dan F. Greiner 2022.
2
ED & EDMK Uses
How to take this signed packed-decimal value …
31
41
59
26
53
58
97
9C
3
.
1
4
1
,
5
9
2
,
6
5
3
,
5
8
9
,
7
9
… and turn it into this printable EBCDIC value (in 1 instruction).
00
00
00
00
12
34
56
7C
$
1
2
,
3
4
5
.
6
7
00
03
99
5A
*
*
*
3
9
.
9
5
*
*
How to take this signed packed-decimal value …
… and turn it into this printable EBCDIC value (in 1 instruction).
How to take this signed packed-decimal value …
… and turn it into this printable EBCDIC value (in 2 instructions).
3
EDIT (ED)
ED D1,(L,B1),D2,(B2) [SS-a]
DE
L
B2
D2
B1
D1
The first operand designates the location of the pattern bytes which are:
The second operand designates the location of the source bytes consisting of signed or unsigned packed-decimal data
n
n
n
n
n
n
n
n
n
n
n
n
n
n
s
//
//
Pat
Pat
Pat
Pat
Pat
Pat
Pat
Pat
Pat
Pat
Pat
Pat
//
//
The L (length) field designates one less than the number of bytes in the first operand.
4
Significance Indicator
5
The 1st Operand
6
1st-Operand Fill Byte
7
Digit Selector (DS, 1st-operand pattern byte)
8
Significance Starter�(SS, 1st-operand pattern byte)
9
Field Separator (FS, 1st-operand pattern byte)
10
Message Byte (MB, 1st-Operand Pattern Byte)
Message byte (also serves as fill byte).
40
20
20
20
6B
20
20
20
6B
20
21
20
4B
20
20
Message bytes (comma separators).
Message bytes (comma separators).
Message byte (decimal point).
11
2nd-Operand Source Bytes & Source Digits
Negative sign code.
Positive sign code.
Whoops!�Sign code in left digit is invalid.
31
41
59
26
53
58
97
9D
14
14
21
35
62
37
30
9C
00
00
45
77
81
B3
40
7D
1st Field
2nd Field
3rd Field
12
Condition Code
13
EDIT AND MARK (EDMK)
EDMK D1,(L,B1),D2,(B2) [SS-a]
DF
L
B2
D2
B1
D1
0
0
0
1
7
8
9
9
5
C
40
20
6B
20
20
20
6B
20
21
20
4B
20
20
1st Operand Before (hex):
1
,
7
8
9
.
9
5
1st Operand After (EBCDIC):
General register 1 points to the leftmost significant digit of the rightmost (or only) field having significance.
14
Examples of EDIT (ED) (1 of 3)
Message Byte
Digit Selector
Significance Starter
Field Separator
Edit a Value in Millionths
40
20
6B
20
20
20
6B
20
21
20
4B
20
20
20
6B
20
20
20
1st Operand (before, hex):
1
2
3
,
4
5
6
.
7
8
9
,
0
1
2
1st Operand (after, EBCDIC):
2
Resulting condition code:
01
23
45
67
89
01
2C
2nd Operand (hex):
(code: P’0123456789012’)
Same Thing but with Smaller 2nd Operand
40
20
6B
20
20
20
6B
20
21
20
4B
20
20
20
6B
20
20
20
1st Operand (before, hex):
1
.
2
3
4
,
5
6
7
1st Operand (after, EBCDIC):
2
Resulting condition code:
00
00
00
12
34
56
7C
2nd Operand (hex):
(code: P’0000001234567’)
Same Thing but with 2nd Operand of Zero
40
20
6B
20
20
20
6B
20
21
20
4B
20
20
20
6B
20
20
20
1st Operand (before, hex):
0
.
0
0
0
,
0
0
0
1st Operand (after, EBCDIC):
0
Resulting condition code:
00
00
00
00
00
00
0C
2nd Operand (hex):
(code: P’0000000000000’)
15
Examples of EDIT (ED) (2 of 3)
Message Byte
Digit Selector
Significance Starter
Field Separator
Edit a Value with an Asterisk as the Fill Byte
5C
20
6B
20
20
20
6B
20
21
20
4B
20
20
1st Operand (before, hex):
*
9
,
8
7
6
,
5
4
3
.
2
1
1st Operand (after, EBCDIC):
2
Resulting condition code:
98
76
54
32
1C
2nd Operand (hex):
(code: P’987654321’)
Same Thing, but with More Asterisks
5C
20
6B
20
20
20
6B
20
21
20
4B
20
20
1st Operand (before, hex):
*
*
*
*
*
1
,
0
2
4
.
0
0
1st Operand (after, EBCDIC):
1 (sign code ‘D’ means negative)
Resulting condition code:
00
01
02
40
0D
2nd Operand (hex):
(code: P’-000102400’)
Same Thing, but with Lots More Asterisks
5C
20
6B
20
20
20
6B
20
21
20
4B
20
20
1st Operand (before, hex):
*
*
*
*
*
*
*
*
*
1
.
9
8
1st Operand (after, EBCDIC):
2
Resulting condition code:
00
00
00
19
8C
2nd Operand (hex):
(code: P’000000198’)
16
Examples of EDIT (ED) (3 of 3)
Message Byte
Digit Selector
Significance Starter
Field Separator
Edit Pattern Leading Off with a Significance Starter
1
Resulting condition code:
00
00
00
00
06
2nd Operand (hex):
(code: P’-00000000069’)
40
21
20
4B
20
20
20
6B
20
20
20
6B
20
1st Operand (before, hex):
20
20
0
.
0
0
0
,
0
0
0
,
0
1st Operand (after, EBCDIC):
6
9
9D
Editing Multiple Fields from a Single Packed Number
2
Resulting condition code:
12
34
56
70
04
2nd Operand (hex):
(code: P’1234567004321’)
32
1C
40
20
20
6B
20
21
20
4B
20
20
22
20
6B
1st Operand (before, hex):
20
21
20
4B
20
20
1
2
,
3
4
5
.
6
7
1st Operand (after, EBCDIC):
4
3
.
2
1
Editing Multiple Fields from Multiple Packed Numbers
2
Resulting condition code:
12
3C
45
6C
78
2nd Operand (hex):
(code: P’123,456,789,012’)
9C
01
2C
40
21
4B
20
20
22
1st Operand (before, hex):
21
4B
20
20
22
21
4B
20
20
22
21
4B
20
20
22
1
.
2
3
4
.
5
6
7
.
1st Operand (after, EBCDIC):
8
9
.
1
2
17
Examples of EDIT AND MARK (EDMK) (1 of 2)
Message Byte
Digit Selector
Significance Starter
Field Separator
Edit a Value in Millionths, Mark the 1st Significant Digit
40
20
6B
20
20
20
6B
20
21
20
4B
20
20
20
6B
20
20
20
1st Operand (before, hex):
1
2
3
,
4
5
6
.
7
8
9
,
0
1
2
1st Operand (after, EBCDIC):
2
Resulting condition code:
01
23
45
67
89
01
2C
2nd Operand (hex):
(code: P’0123456789012’)
Editing Multiple Fields from a Single Packed Number
2
Resulting condition code:
12
34
56
70
04
2nd Operand (hex):
(code: P’1234567004321’)
32
1C
40
20
20
6B
20
21
20
4B
20
20
22
20
6B
1st Operand (before, hex):
20
21
20
4B
20
20
1
2
,
3
4
5
.
6
7
1st Operand (after, EBCDIC):
4
3
.
2
1
GR1 after
General register 1 points to the leftmost significant digit of the rightmost (or only) field having significance.
GR1 after
18
Examples of EDIT AND MARK (EDMK) (2 of 2)
Message Byte
Digit Selector
Significance Starter
Field Separator
Edit a Value of Zeroes with No Significance Starter
40
20
20
20
20
20
1st Operand (before, hex):
1st Operand (after, EBCDIC):
0
Resulting condition code:
00
00
0C
2nd Operand (hex):
(code: P’00000’)
WARNING: General register 1 is unmodified when no significant digits are discovered.
GR1 after
General register 1 contains the address of leftmost significant digit of the rightmost field having a significant digit. Because the third field is insignificant, GR1 does not point to it.
Editing Multiple Fields from a Single Packed Number
0
Resulting condition code:
12
3C
45
6D
00
2nd Operand (hex):
(code: P’123,-456,000’)
0C
1
2
3
4
5
6
1st Operand (after, EBCDIC):
40
20
21
20
22
1st Operand (before, hex):
20
21
20
22
20
20
20
19
Programmator Caveat
Signed packed-decimal fields always contain an odd number of digits.
20
ED and EDMK Conceptual Flow
END 🡨 OP1 + L;
LRF 🡨 0 (left);
NZD 🡨 0;
SI 🡨 0 (off);
ED & EDMK
*OP1 and�*(OP1+L) accessible
Access Exception
FB 🡨 *OP1;
SI
LRF 🡨 0 (left);
No
Yes
(left) 0
1 (right)
LRF
PB 🡨 *OP1;
PB == DS�or
PB == SS
PB == FS
Yes
SI 🡨 0;�NZD 🡨 0;
Yes
No
1
0
*OP1 🡨 FB;
OP1++;
OP1 > END
NZD
No
Yes
Exit CC0
SI
1
Exit CC1
0
0
1
Exit CC2
RD > 9
Yes
*OP2 accessible
Access Exception
No
SB 🡨 *OP2;
SD 🡨 SB >> 4;
RD 🡨 SB & 0x0F;
OP2++;
SD > 9
General Op. Data Exception
Yes
Yes
LRF 🡨 LRF ^ 1;
SI
0
1
SD
0
>0
For EDMK, GR1 set to OP1.
*OP1 🡨 FB;
*OP1 🡨 SD | 0xF0;
Get Next Source Digit
Handle DS or SS Pattern Byte
No
No
SD 🡨 RD;
SD
>0
NZD 🡨 1;
0
PB == SS
Yes
No
RD == PLUS
SI 🡨 1;
Yes
No
SI 🡨 0;
A
Notes:�A. When the pattern byte is a message byte (i.e., not a DS, SS, or FS) and the significance indicator is on, � the pattern byte is effectively unchanged. A store of unchanged data must occur for change-bit setting� and PER purposes.
B. This is a simplification of the operand-2 access checking. On all modern machines, all accessed bytes of� the second operand are assured to be accessible before any byte of operand 1 is stored.
B
21
Explanation of Symbols Used in Conceptual Flow
22
Lessons Learned
All in a single instruction!
23