Paul Gilmartin <[email protected]> wrote:
> On Mon, 7 Jul 2025 14:48:44 -0500, Thomas David Rivers  wrote:
> >
> >This does a check for the endianness of the machine and properly
> >reads values.  I've included a demonstration test.
> >
> Why not go byte-byte and form each halfword as:
>    ( unsigned short ) ( byte[ 2n ] * 256 + byte[ 2n + 1 ] )
> 
> And Mike Schwab suggests using MVCIN.  I suspect
> this would copy the entire string then process it
> backwards.
> 

Certainly there are several approaches.

Using the PL/I LITTLEENDIAN attribute lets the compiler decide,
and for z/OS (with the -O option) the IBM compiler generated
this:

 0000F6  5050  D0A8        000000 |       +           ST       
r5,_temp1%4=>2(,r13,168)
 0000FA  E350  D0A8  001E  000000 |       +           LRV      
r5,_temp1%4=>2(,r13,168)

(where R5 had been previously loaded with the value from the array, I don't know
why the compiler had to store that into memory when there is a LRVR instruction
it could have used).

But - certainly - there are many valid approaches here... 

  - Dave Rivers -

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to