EDMK Tutorial

High Level Assembler(HLASM) for MVS & VM & VSE

EDMK Tutorial

Postby steve-myers » Wed Aug 03, 2016 4:51 am

The EDMK (Edit and MarK) instruction is a useful addition to programmers that use packed decimal data.
  • It does everything the ED (EDit) instruction does PLUS
  • It may save the address of the most significant number.
The reasons EDMK is not used all that often lie in the two “bullets.”
  • The ED instruction itself is hard to understand.
  • ”May” is the operative word in the second bullet. Though there are other reasons, the usual reason EDMK does not save the address of the most significant digit is because the value is 0.
Now let's look at a very simplified use of EDMK.
         LA    1,PATTERN+3
         BCTR  1,0
         MVI   0(1),C'$'
*                 0---
PATTERN  DC    0C' NNN',C' ',X'202120'
DATA     DC    P'012'


The LA instruction sets register 1 to the address of the default most significant digit, just in case EDMK decides it is not going to update register 1.


After the instruction executes, PATTERN will be C'bb12' where b is a stand in for blank, and register 1 will have the address of the 1.

BCTR 1,0
MVI 0(1),C'$'

The BCTR Branch on CounT Register subtracts 1 from the contents of register 1. Since the instruction specifies register 0, it won't branch.

The MVI (MoVe Immediate) instruction stores the data in the instruction, a $ character, at the address register 1 specifies. The PATTERN data area becomes C'b$12'.

Now let's try something a little more complicated.
         LA    1,PATTERN+9
         BCTR  1,0
         MVI   0(1),C'$'
*                 0----+----1--
         DC    C' ',X'20',C',',X'202020',C',',X'202120',C'.',X'2020'
DATA     DC    P'000000001'

One reason the ED instruction is so mysterious is the text books form the edit pattern strictly with long hexadecimal character strings. Now, I am not going to claim C' ',X'20',C',',X'202020',C',',X'202120',C'.',X'2020' is all that much better, but there are no mysterious 40, 4B and 6B hexadecimal codes, just the 20 and 21 digit select codes. Using the 0C' N,NNN,NNN.NN' pattern mask allows me to build the 0----+----1-- ruler over it, and that makes it very easy to define the PATTERN+9 address in the LA instruction. The final output is $0.01 with leading blanks as a fill character.
Global moderator
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times

Return to Assembler


  • Related topics
    Last post