Most of the time, there is no need to override the length of UNPK (or PACK)
operands.  As you mention (and so many forget), it works right-to-left and
stops quietly when either operand is exhausted.

There is a fairly common technique of overriding the lengths of both source
and target by +1 so as to avoid having to fix up the sign.  That's fine,
but it's ugly, requires those bytes to be available, and not that easy to
understand if you're not familiar with it.

sas

On Mon, Oct 26, 2015 at 11:30 AM, Hamilton, Kevin <[email protected]> wrote:

> I could be talking nonsense here, but in my code, if I'm limited for
> output space, I specify a length for both UNPK operands and let the
> insignificant bytes get truncated, because the information is processed
> from right to left in an UNPK. This coming from a systems programmer point
> of view, not a developer. I'm sure someone can point out several edge cases
> where this may be bad practice... example:
>
>         LH    R1,APQHP_ANCHR          PROCESS ANCHOR (PHDAM)
>         CVD   R1,UNPK_TMP             CONVERT FROM BINARY TO DECIMAL
>         UNPK  OUTANCH(3),UNPK_TMP(8)  UNPACK TO PRINTABLE
>         OI    OUTANCH+2,X'F0'         FIX SIGN ON LAST BYTE
>
>
>  Kevin Hamilton
>  Mainframe Systems Programmer
>
> -----Original Message-----
> From: IBM Mainframe Assembler List [mailto:[email protected]]
> On Behalf Of Jose Flores
> Sent: 2015-10-26 Monday 09:56
> To: [email protected]
> Subject: Re: Displaying port nr in decimal
>
> Oops! Correction:
> The UNPK instruction ...
>
>           UNPK  OUTTRP,DWORD+5(3)
>
> -----Original Message-----
> From: IBM Mainframe Assembler List [mailto:[email protected]]
> On Behalf Of Jose Flores
> Sent: Monday, October 26, 2015 10:51 AM
> To: [email protected]
> Subject: Re: Displaying port nr in decimal
>
> As previously suggested, I think the following code will do it in a
> simpler way:
>
>           SLR   R11,R11
>           ICM   R11,B'0011',SMF118TRP
>           CVD   R11,DWORD
>           UNPK  OUTTRP,DWORD+5
>           OI    OUTTRP+4,X'F0'
>           .
> DWORD     DS    D
> OUTTRP    DS    CL5
>
> Jose Flores
> Sr. Mainframe Developer
> GT Software Inc.
>
> -----Original Message-----
> From: IBM Mainframe Assembler List [mailto:[email protected]]
> On Behalf Of Alan Atkinson
> Sent: Monday, October 26, 2015 10:19 AM
> To: [email protected]
> Subject: Re: Displaying port nr in decimal
>
> Can't you just cvd, oi the last byte with x'0f' and unpack(5).
> Or are you looking for something more sophisticated where you trim leading
> zeros and left align?
>
>
> ________________________________________
> From: IBM Mainframe Assembler List [[email protected]] on
> behalf of Elardus Engelbrecht [[email protected]]
> Sent: Monday, October 26, 2015 10:14 AM
> To: [email protected]
> Subject: Displaying port nr in decimal
>
> To all,
>
> My oh my, I can't believe my Assembler skills are that rusty!
>
> But here is the challenge. With this snippet, I could show the Remote Port
> from SMF record type 118 in decimal.
>
> I'm feeling my code, while working as designed, is not that optimal,
> especially usage of R11, Double Word and too long edit field.
>
>          SLR   R11,R11                  CLEAR
>          MVC   DWORD,R11                CLEAR DWORD
>          MVC   DWORD+2(2),SMF118TRP    .MOVE PORT
>          L     R11,DWORD               .
>          CVD   R11,DWORD               .CONVERT TO DECIMAL
>          MVC   EDWORK2,EDMASK2
>          ED    EDWORK2,DWORD+2
>          MVC   OUTTRP,EDWORK2          .MOVE REMOTE PORT
> *
> DWORD    DS    D
> EDWORK2  DC    XL12'00'
> EDMASK2  DC    XL12'202020202020202020202020'
> *
> OUTTRP   DS    XL12                   .REMOTE PORT NUMBER
> *
> SMF118TRP DS   XL2                    .REMOTE PORT NUMBER
>
> This is the display I got, but as you can see, I'm wasting bytes in the
> output. I want to trim the output from 12 bytes to 5 columns (max port nr
> is 65535).
>
> REMOTE PORT
> DCDDEC4DDDE
> 95463507693
> ------------
>        1218
> 2222222FFFF2
> 000000012180
>
> Is there a more elegant way to do above? (z/OS v1.13 and v2.1)
>
> Perhaps with CVD and UNPK and OI instructions?
>
> Please and many thanks on advance.
>
> Groete / Greetings
> Elardus Engelbrecht
>



-- 
sas

Reply via email to