Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Converting BIGINT value to unpacked data and vice-versa

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
girish.shekki

New User


Joined: 25 Nov 2007
Posts: 3
Location: chennai, india

PostPosted: Sat Feb 05, 2011 11:19 pm    Post subject: Converting BIGINT value to unpacked data and vice-versa
Reply with quote

Hi,

I need to convert a 8 byte binary number (SQL Data type BIGINT) to its equivalent Packed Decimal Number, and this decimal number is to be unpacked.

Similarly i should also need to do the reverse of above- pack the data, and convert it to 8 byte binary number. How can i do that? CVD, CVB work only on 4 byte numbers. My module is 31 bit module. Can anyone help me out here?

Thanks.
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sun Feb 06, 2011 12:12 am    Post subject:
Reply with quote

Hello and welcome to the forum,

Which language are you using?
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Sun Feb 06, 2011 12:18 am    Post subject: Reply to: Converting BIGINT value to unpacked data and vice-
Reply with quote

(I'm assuming Assembler) icon_wink.gif

Use "Load Grande" to load your doubleword binary value into a 64-Bit register and use a "Convert to Decimal Grande" to convert the 64-Bit doubleword into a 16-Byte Packed-Decimal/Quadword. Using 64-Bit R15 as an example, which should be OK -

Code:

QWORD    DS   L            ALIGNED 16-BYTE QUADWORD
DWORD    DS   D            ALIGNED 8-BYTE DOUBLEWORD
         LG   R15,DWORD    LOAD INTO 64-BIT REGISTER
         CVDG R15,QWORD    MAKE IT 16-BYTE PACKED-DECIMAL


This can be done in COBOL, using the ARITH(EXTEND) compiler option.

I'm unsure about PL/I.... icon_sad.gif

Bill
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1060
Location: Oostende, Belgium

PostPosted: Sun Feb 06, 2011 3:57 am    Post subject: Re: Reply to: Converting BIGINT value to unpacked data and v
Reply with quote

Bill O'Boyle wrote:
(I'm assuming Assembler) icon_wink.gif

Use "Load Grande" to load your doubleword binary value into a 64-Bit register and use a "Convert to Decimal Grande" to convert the 64-Bit doubleword into a 16-Byte Packed-Decimal/Quadword. Using 64-Bit R15 as an example, which should be OK -

Code:

QWORD    DS   L            ALIGNED 16-BYTE QUADWORD
DWORD    DS   D            ALIGNED 8-BYTE DOUBLEWORD
         LG   R15,DWORD    LOAD INTO 64-BIT REGISTER
         CVDG R15,QWORD    MAKE IT 16-BYTE PACKED-DECIMAL


This can be done in COBOL, using the ARITH(EXTEND) compiler option.

I'm unsure about PL/I.... icon_sad.gif


PL/I can also handle it, compiler option

Code:
*process limits(fixeddec(15,31) fixedbin(31,63));
which lets you use:

Code:
 DCL BIGDEC FIXED (31); /* and */
 DCL BIGBIN FIXED BIN (63);


It was introduced in Enterprise PL/I V3.5, and possibly even earlier, but I don't have older manuals available.
Back to top
View user's profile Send private message
girish.shekki

New User


Joined: 25 Nov 2007
Posts: 3
Location: chennai, india

PostPosted: Sun Feb 06, 2011 9:58 am    Post subject: Reply to: Converting BIGINT value to unpacked data and vice-
Reply with quote

Yes i am writing in Assembler.
I am aware of grand instructions CVDG and CVBG which can be used to convert 8 byte data to binary and vice-versa. But once i convert binary to decimal using CVDG, i need to unpack the decimal value. As far as i know, using UNPK i can only get unpacked value of 16 bytes. In 8 byte data, the unpacked data can go beyond 8 bytes(i am thinking that for maximum allowed BIGINT value, unpacked data can be upto 19 digits.) I don think there is UNPK grand instr. icon_smile.gif do i need to use TR and a table with appropriate values to translate? Any other way?

Thanks,
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Sun Feb 06, 2011 1:47 pm    Post subject: Reply to: Converting BIGINT value to unpacked data and vice-
Reply with quote

The following has only been desk-checked -

Code:

UNPKAREA DS    CL31
DBLWORD  DS    D
         DS    XL1
DWORD    DS    D
QWORD    DS    L
         LG    R15,DWORD                         PREPARE FOR 'CVDG'
         CVDG  R15,QWORD                         MAKE IT QUADWORD-DECIMAL
         MVC   DBLWORD,QWORD+8                   MOVE LOW 8-BYTES
         OI    DBLWORD+L'DBLWORD-1,X'0F'         ENSURE 'F' SIGN-NIBBLE
         UNPK  UNPKAREA+16(15),DBLWORD           UNPK AS CL15
         MVC   DBLWORD,QWORD                     MOVE HIGH 8-BYTES
         MVI   DBLWORD+L'DBLWORD,X'0F'           ENSURE X'0F' SIGN-BYTE
         MVO   DBLWORD(L'DBLWORD+1),DBLWORD      SHIFT-RIGHT 4-BITS
         UNPK  UNPKAREA(16),DBLWORD(L'DBLWORD+1) UNPK AS CL16

Bill
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Sun Feb 06, 2011 8:45 pm    Post subject:
Reply with quote

The following (untested) should also accomplish your goal:
Code:
MASK     DC    X'21',30X'20'
UNPKAREA DS    CL31
DWORD    DS    D
QWORD    DS    L

         LG    R15,DWORD                         R15 = BINARY VALUE
UNPKQWD  CVDG  R15,QWORD                         MAKE IT QUADWORD-DECIMAL
         MVC   UNPKAREA,MASK                     MOVE EDIT MASK TO UNPKAREA
         ED    UNPKAREA(31),QWORD                UNPACK QUADWORD USING MASK
         BNL   NOTNEG                            TEST SIGN - IF NOT NEG, CONT
         NI    UNPKAREA+L'UNPKAREA-1,X'DF'       MAKE NEGATIVE - SIGN = X'D'
NOTNEG   EQU   *
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Sun Feb 06, 2011 11:12 pm    Post subject: Reply to: Converting BIGINT value to unpacked data and vice-
Reply with quote

Ron,

Yes, ED is one of the SS instructions with a 1-Byte length (max=X'FF'/256), is a lot less code and I didn't think of it at O'Dark Thirty (was up doing maintenance, not by choice). icon_sad.gif

But, the reverse UNPACKED CL31 <---> DBLWORD-BINARY will be an exercise for the OP as a PACK has a 4-Bit max-length for Operand2 of X'F'/16.

The MVO was included as a possible alternative in the reverse process, by showing the OP how it can be used during the UNPK.

Instead of an MVO, an SRP would work just as well, but that's a more expensive instruction, plus, if you're ultimately unpacking the data, you'd have to reset the sign-nibble after the SRP or the zone-nibble after the UNPK and OR with a X'F'. icon_wink.gif

Bill
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Copy 4 byte of data from the last rec... arunsoods DFSORT/ICETOOL 9 Fri Oct 06, 2017 12:15 pm
No new posts opening a dataset after reading it fr... arunsoods DFSORT/ICETOOL 5 Wed Oct 04, 2017 3:54 pm
This topic is locked: you cannot edit posts or make replies. PS file data should be passed as symb... d_sarlie JCL & VSAM 15 Tue Oct 03, 2017 5:18 am
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us