CONVERT EBCDIC TO FIXED POINT BINARY



High Level Assembler(HLASM) for MVS & VM & VSE

CONVERT EBCDIC TO FIXED POINT BINARY

Postby xboss » Fri Nov 18, 2011 2:36 am

Hi all,
I writing a code for converting Fixed point Binary Number to EBCDIC and vice versa. So, far I have done with converting Fixed point Binary to EBCDIC but has no clue how to start with EBCDIC (as I am confused with '+' or '-' in my input. How shall I get rid of '+' and '-' sign and add 'FD' or 'FC' to the last nibble. Here is my code written so far,
*   BEGIN LOGIC HERE                                                   
***************************************************************       
*======================================================================
*               CONVERTING FROM BINARY TO EBCDIC                      *
*======================================================================
TOEDCDIC L     R6,VAL_BIN1        PUT THE BINARY NUMBER IN R6         
         CVD   R6,VAL_PAK1        CONVERT TO PACKED DECIMAL           
         UNPK  VAL_ZON1,VAL_PAK1  CONVERT TO UNPACKED I.E. ZONED       
         MVC   VAL_ZT1,VAL_ZON1   MAKE A COPY OF THE ZONED VAL         
         TM    VAL_ZT1+7,X'10'                                         
         BZ    POSNUM                                                 
         MVI   SIGNEBC,C'-'                                           
         OI    VAL_ZT1+7,X'F0'     CONVERT TO EBCDIC                   
         MVC   VAL_EBC1,VAL_ZT1    COPY INTO A CHAR FILE               
         B     RETURN                                                 
POSNUM   EQU   *                                                       
         MVI   SIGNEBC,C'+'                                           
         OI    VAL_ZT1+7,X'F0'                                         
         MVC   VAL_EBC1,VAL_ZT1                                       
*======================================================================
*               CONVERTING FROM EBCDIC TO BINARY                      *
*======================================================================
         L      R7,VAL_EBC2                                           
         NI     VAL_EBC2,                                             
*************************************************************         
*   END LOGIC HERE                                                     
********************* DATA AREAS *********************     
SAVEAREA DC     18F'0'                                     
VAL_BIN1 DC     1F'-55555'           BINARY DATA 1         
VAL_PAK1 DS     PL11                PACKED DATA 1           
VAL_ZON1 DS     ZL11                ZONED DATA 1           
VAL_ZT1  DS     ZL11                ZONED TEMPORARY DATA 1 
SIGNEBC  DS     CL1                                         
VAL_EBC1 DS     CL11                EBCDIC DATA 1           
VAL_EBC2 DS     CL11'+0000000002'   EBCDIC DATA 2           
VAL_ZON2 DS     ZL11                ZONED DATA 2           
VAL_PAK2 DS     PL11                PACKED DATA 2           
VAL_PT2  DS     PL11                PACKED TEMPORARY DATA 2
VAL_BIN2 DS     1F                  BINARY DATA 2           


My Storage dump

00000000 00000000 FFFF26FD 00000000  ................
0055555D 000000F5 F5F5F5F5 FDF0F0F0  ...)...55555.000
F000F5F5 F5F5F5FD F0F0F0F0 0060F5F5  0.55555.0000.-55
F5F5F5FD F0F0F0F0 00000000 00000000  555.0000........
00000000 00000000 00000000 00000000  ................


Thanks you for looking at my code.
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: CONVERT EBCDIC TO FIXED POINT BINARY

 

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby dick scherrer » Fri Nov 18, 2011 3:14 am

Hello,

I need to step back to your "subject" (Converting one to the other). What does this mean? On the mainframe, everything is EBCDIC.

Possibly it will help if you show some "input" values and the "output" you want when your process is run.

Where is this code to run?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby xboss » Fri Nov 18, 2011 3:25 am

Dick,
Thanks for looking into it.
If you see my storage dump, there is the o/p from my conversion process.
Here, my i/p is F'-55555' (which is in binary) and I am converting to EBCDIC 060F5F5F5F5F5 (-55555) is my o/p. 055555D -- Packed Decimal 000000F5 F5F5F5F5 FD --- Zoned Decimal are the part of whole steps.
0055555D 000000F5 F5F5F5F5 FDF0F0F0 ...)...55555.000
F000F5F5 F5F5F5FD F0F0F0F0 0060F5F5 0.55555.0000.-55
F5F5F5FD F0F0F0F0 00000000 00000000 555.0000

Like wise I am looking to give '+0000000002' as EBCDIC i/p and convert it to Binary. Let me know if I answer your question.

Thanks,
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby dick scherrer » Fri Nov 18, 2011 3:42 am

Hello,

You're welcome :)

As you mentioned - The 3 most common are Packed Decimal, Zoned Decimal, and Binary (or Computational).

my i/p is F'-55555' (which is in binary) and I am converting to EBCDIC 060F5F5F5F5F5 (-55555)
There is no "numeric EBCDIC" data format. This is an "edited" value.

Packed Decimal 000000F5 F5F5F5F5 FD --- Zoned Decimal are the part of whole steps.
I'm not sure if this is intended to be packed or zoned? Either way, this is incorrect (or i misunderstand something).

Most of the time one would use the numeric conversion (you have used some) or editing instructions to do what i believe you want. I believe i am still somewhat confused. . .

I'll check back later to see if there are any developments and see if my head clears a bit ;)
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby BillyBoyo » Fri Nov 18, 2011 5:43 am

-55555 is either, as Dick says, a "numeric edited" field or, in Cobol terms, a PIC 9(5) with a leading SIGN IS SEPERATE.

A signed zoned-decimal for this value would look like X'F5F5F5D5'. You seem to have got the idea that the sign should be FD. The sign in a signed zoned-decimal is an "overpunch". The left-nybble of the right-most byte represents the sign, and the right-nybble of that byte represents the right-most part of the number.

To convert from the seperate/edited sign (they would both look the same, ie in addition to the first paragraph, PIC -9(5) in Cobol or even, for your value -(5)9, or even other possibilities), you need to look again at the "immediate" instructions in the POP. Have a look at them all, but you should end up choosing an "Immediate And" with X'DF' for -ve and X'CF' for +ve. This will work because you sign nybble is an F. You always have to know what the value can be to chose the right instructions and values. Looks like you got it right going the other way.

As Dick has said, everything on the Mainframe is in EBCDIC (and that is how it is spelled, check you program name which you need to change anyway).

You have Zoned Decimal, Packed Decimal, and Binary (other terms exist for all three). All are EBCDIC. You are not converting to EBCDIC, you are converting to an edited numeric, or to a leading seperate sign zoned decimal. From 55555, which fills the entire field, we cannot tell which it is. The numeric edited will give you more work, so hope for the best.

I've now written all this then looked at your "data area". I now believe you've made something of a "pig's breakfast" of things.

You have a fullword, so maximum of 10 digits. You have 11-digit zoned. You have 11-byte packed, which is 21 digits! Since you have an 11-digit zoned, your -5555 example is either rubbish, because you misunderstand the sign representation, or you have a numeric-edited with a floating leading sign (which is even more fun for your conversion).

I think you are going to have to explain to us exactly what your input is, and your expected output, going both ways. In a signed zoned-decimal field, there is no actual sign, + or -, but it is represented in the sign nybble. Same with packed-decimal, except it is the "opposite" nybble in the right-most byte. In binary it is the left-most bit.

We need clear examples of all your inputs and expected outputs, described in plain English for now, as your grasp of terminology needs some work.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby xboss » Fri Nov 18, 2011 10:30 am

Hi Bill and Dick,
Thanks for you time and sorry for my ignorance on terminology, I am just learning... In plain english, this is what I should be writing my code for,
Code a two-CSECT load module. Create a fixed-point binary EBCDIC conversion routine. Create a separate mapping macro for its parameter list. The parameter list should consist of a full word function code, an 11-character string, and a full word fixed-point binary number. For the function code, have 0 denote an EBCDIC to fixed-point conversion and have 1 denote a fixed-point to EBCDIC conversion. For the character string, have a ‘+’ or ‘-‘as the first character to denote the sign and have EBCDIC F0x (‘0’) prefix non-zero digits.

In the main CSECT, loop through a static table of 11-character strings with the following values:
CL11 ‘+0000000002’
CL11 ‘+0000000003’
CL11 ‘-0000000001’
CL11 ‘-0000000006’

Take the results from the conversion routine to add the 1st entry to the 2nd, the 2nd to the 3rd, and the 3rd to the 4th. Use the conversion routine with the alternate function code value to convert each sum into an 11-character string. For each sum, issue a WTO with the following format:

CMS0001I insert#1 + insert#2 = insert#3

Code both CSECTs to always return RC 0 and code both of them to be reentrant.

So I am currently trying to work first on conversion logic.
I hope this will explain the program I am working on.
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby dick scherrer » Fri Nov 18, 2011 10:55 am

Hello,

Thanks for you time and sorry for my ignorance on terminology, I am just learning...
When first learning is the best time to learn proper terminology. Incorrect terminology causes many of the problems in our industry. . .

I guess i'm still stuck with this:
Create a fixed-point binary EBCDIC conversion routine.
Anything done on the mainframe will be EBCDIC. Asked differently, if you were NOT going to use EBCDIC how might you proceed?

To get the "input" values into the other numeric formats, you would just use the needed instructions to get the data into the new formats. Keep in mind that not all of the formats are easily used in computations, so for getting sums, i'd use the binary or packed-decimal data.

It is quite possible that i still do not understand what is expected . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby xboss » Fri Nov 18, 2011 11:14 pm

When first learning is the best time to learn proper terminology. Incorrect terminology causes many of the problems in our industry. . .


Thanks Dick, I will try to live with your suggestion. But I found terminology used in textbook and used in industry are quite different. I think I will have to work a while in this industry first to absorb all terminology.
xboss
 
Posts: 79
Joined: Mon Nov 29, 2010 10:55 am
Has thanked: 0 time
Been thanked: 0 time

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby Akatsukami » Fri Nov 18, 2011 11:23 pm

xboss wrote:
When first learning is the best time to learn proper terminology. Incorrect terminology causes many of the problems in our industry. . .


Thanks Dick, I will try to live with your suggestion. But I found terminology used in textbook and used in industry are quite different. I think I will have to work a while in this industry first to absorb all terminology.

It should be noted that EBCDIC refers to the bit pattern-to-glyph mapping that causes X'E2' to appear as 'S' on an IBM mainframe running OS/360 or a descendant thereof (these days, there's rather more to it than that, but that's a start). A packed decimal (or binary, or floating-point) number could appear as anything, but it's not EBCDIC because it's not intended to be glyphs.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: CONVERT EBCDIC TO FIXED POINT BINARY

Postby BillyBoyo » Sat Nov 19, 2011 12:26 am

xboss wrote:
When first learning is the best time to learn proper terminology. Incorrect terminology causes many of the problems in our industry. . .


Thanks Dick, I will try to live with your suggestion. But I found terminology used in textbook and used in industry are quite different. I think I will have to work a while in this industry first to absorb all terminology.


If this is correct, then I'd suggest locating a better textbook. Can you type-up an example of what your textbook says about EBCDIC, please?
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Next

Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post