I noticed the COBOL compile generated two MVHHI's to set a fullword field with 
a constant value, but did an MVC with an 8-byte constant when setting two 
adjacent fullwords.

-----Original Message-----
From: IBM Mainframe Assembler List <ASSEMBLER-LIST@LISTSERV.UGA.EDU> On Behalf 
Of Jon Perryman
Sent: Friday, August 22, 2025 00:47
To: ASSEMBLER-LIST@LISTSERV.UGA.EDU
Subject: Re: Execute-Type Instructions

On Fri, 22 Aug 2025 00:27:22 +0000, Ngan, Robert <robert.n...@dxc.com> wrote:

>I noticed this too a while back (wow! 2017),

>>1.      The two MVHHI (move halfword immediate to halfword storage) 
>>instructions are setting up the edit mask.
>>Note: In my code if I had to move > 2 bytes, I just define a constant. This 
>>code is more efficient at the expense of understandability for humans reading 
>>it.

You're making this far more difficult than necessary. MVHHI moves exactly 1 by 
Here's how I would code it to improve performance and make it readable.
           macro ,
&L      MOVELIT &DEST,&SOURCE
           AIF      ('&source'(1,1) NE '''').MVC_&DEST_&SOURCE
           AIF      (L'&DEST EQ 0).NOMOVE
           AIF      (L'&DEST EQ 1).MVI
           AIF      (L'&DEST EQ 2).MVHHI
           AIF      (L'&DEST GT #).MVC_CONSTANT
&L      JAL      R1,L&SYSNDX
D&SYSNDX   DC     CL(L'&DEST)&SOURCE
            DS       0H
L&SYSNDX    MVC  &DEST,0(R1)
            MEND ,

Your intention is to efficiently move a constant. Moving an inline constant 
avoids the fetch for the constant. Is using a 256 byte inline constant wise? 
Someone else will need to advise you on the max acceptable length and accept 
the cost of the fetch from the litpool.


Reply via email to