On Wed, Sep 17, 2014 at 12:05 PM, Scott Ford <00000006f84450fa-dmarc-requ...@listserv.ua.edu> wrote: > Guys/Gals: > > I have a fundamental question to ask. We have a Cobol routine passing a set > of parms ..one of the parms is a number PIC 999. > > The called program is in HLASM and receives the parms and we have WORKAREA > dsect setup and address it with a using. > > My issue is I must convert this PIC 999 field to a DC x’00’ field in > Assembler. Is my assumption correct that at I have to translate the PIC 999 > with a TROT or TR with a hex table to build the DC x’00’ field ? If I am > passing 241 , the hex value I am expecting is x’F1’. I must be > > able to convert a range from 128-255 … > > > I appreciate any help …I want to just make sure my thinking is correct. > > Regards, > > Scott
What is the COBOL USAGE of the PIC 999 field? If it is the default of USAGE DISPLAY, then the data is in character format. If you want a 3 digit decimal number coming in and a one byte hexadecimal equivalent going out, then the simpliest way is to PACK the PIC 999 USAGE DISPLAY field to packed decimal, then CVB to convert it to a binary number, then return the last byte of that number. But it is _much_ easier to just do something in pure COBOL. Such as: WORKING-STORAGE. 77 INPUT-DECIMAL PIC 999 USAGE DISPLAY. 77 OUTPUT-BINARY PIC S9(4) COMP. 77 OUTPUT-HEX PIC X. ... MOVE INPUT-DECIMAL TO OUTPUT-BINARY. MOVE OUTPUT-BINARY(2:1) TO OUTPUT-HEX. If you really need HLASM, then something like: ZAP DOUBLE,=PL8'0' PACK DOUBLE+6(2),PIC999(3) CVB R1,DOUBLE STC R1,HEXVALUE ... DOUBLE DS D'0' Where PIC999 stands in for how you really point to the area containing the PIC 999 USAGE DISPLAY passed in from COBOL. -- There is nothing more pleasant than traveling and meeting new people! Genghis Khan Maranatha! <>< John McKown ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN