On 2017-03-01, at 17:35, Ngan, Robert wrote:

> I noticed the new COBOL compiler was generating:
> 
> MVHHI target,0
> MVHHI target+2,48000
> 
> instead of:
> 
> MVC target,=F'48000'
> 
> and I thought I'd look into using 2 MVHHI's instead of a MVC with a literal 
> even when the top half of the value is non-zero.  The assembler happily 
> accepts:
> 
> MVHHI target+2,C'abcd'
> 
> truncating the leading 'ab', but I gave up since I could not determine how to 
> consistently obtain the top half of the value when it is a general 
> (resolvable at assembly) expression, ...
> 
How about, with the miracle of integer arithmetic:

ABCD EQU c'abcd'

Then (best done in a macro):
DEN EQU 65536 
M1.SYSNDX EQU ABCD-ABCD/DEN*DEN
M2.SYSNDX EQU (M1.SYSNDX+DEN)-(M1.SYSNDX+DEN)/DEN*DEN
         MVHHI target,(ABCD-M2.SYSNDX)/DEN

I believe this is safe against oveflows, but I haven't proven it formally.

-- gil

Reply via email to