signed clause



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

signed clause

Postby utpalpal07 » Sat Jul 21, 2012 10:34 pm

Hi Guys,


      PACK W_A,BYTES
      MP   W_A,=P'1024'
      UNPK W_B,W_A
W_BYTES   DC P'373'
W_A       DC P'0000000'
W_B       DC P'0000000'



I"m multiplying the 2 variables.
But i'm getting o/p as: 38195B, where as i'm expecting: 381952

Its considering last digit as +2 so its converting as 'B" as signed clause.

How to get a o/p without signed clause?

Please help

Regards
Utpal
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: signed clause

 

Re: signed clause

Postby steve-myers » Sat Jul 21, 2012 11:22 pm

  1. There is no such animal as an unsigned packed decimal number. Period. End of story. The 4 byte, 8 packed decimal digits time of day returned by the TIME macro is not a true packed decimal number, and you cannot used packed decimal arithmetic operations on it.
  2. You did not bother to show us what is in BYTES. How can we evaluate any other claims you have made?
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby steve-myers » Sat Jul 21, 2012 11:40 pm

3. Read, carefully, the definition of the PACK and UNPK instructions in Principles of Operations. The last byte in the input is treated differently than the other bytes. The output you show is perfectly valid when the input is a packed decimal 381952. There are two methods you can use to correct this. Please tell us at least one of them when you figure it out. If you are correct I will tell you the other one.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby BillyBoyo » Sun Jul 22, 2012 4:54 am

But i'm getting o/p as: 38195B, where as i'm expecting: 381952


Where are you "getting" this? The format of output you have shown is Signed Zoned Decimal. You have no leading zero, so you must also have "edited" to drop that. A clue.

Really read the Principles of Operation. Concentrate also on the terminology, I've never come across a "signed clause".

It is also important to realise that "it" didn't do this, or do anything. Computers do exactly what we tell them with our code. We make mistakes. "It" just applies our mistakes to data. If you continue to wonder about "it" being wrong, you will waste a lot of time.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: signed clause

Postby steve-myers » Sun Jul 22, 2012 7:54 am

Actually, utpalpal07 lied to us. His W_B is too small, as shown, to hold the output he claims he got.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby steve-myers » Sun Jul 22, 2012 8:26 am

After a little more checking, utpalpal07 never ran the alleged code. I prepared and ran this -
000000                00000 00023     1 UTPAL    CSECT
                 R:F  00000           2          USING *,15
000000 FC32 F012 F020 00012 00020     3          MP    W_A,=P'1024'
000006 F353 F016 F012 00016 00012     4          UNPK  W_B,W_A
00000C 0700                           5 FREEZE   NOPR  0
00000E 1BFF                           6          SR    15,15
000010 07FE                           7          BR    14
000012 0000373C                       8 W_A      DC    P'0000373'
000016 F0F0F0F0F0F0                   9 W_B      DC    C'000000'
000020                               10          LTORG ,
000020 01024C                        11                =P'1024'
000000                               12          END   UTPAL
It got an S0C7 executing the MP instruction. It got the 0C7 because W_A is not large enough.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby steve-myers » Tue Jul 24, 2012 1:58 am

utpapa07: if you send us something to analyze, it should be as correct as possible except for the piece you want us to analyze. For example:
UTPAL    CSECT
         USING *,15
         L     0,=A(373*1024)
         CVD   0,W_A
         UNPK  W_B,W_A
         SR    15,15
         BR    14
         DC    0D'0'
W_A      DC    PL8'0'
         LTORG ,
W_B      DC    C'000000'
         END   UTPAL
demonstrates the issue you want discussed, though some might complain W_B is too short for W_A, it does not affect the execution of the UNPK instruction, which is the real issue.

Now only you know how you really prepared W_A, but we all know the code you showed us was not how it was prepared.

Don't try to fool us. It won't work, and it delays what you really want to know.
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby utpalpal07 » Mon Jul 30, 2012 7:34 pm

Hello Steve,

I din lied but found the solution also.
here's the code:

ADD     CSECT                                                           
        STM       14,12,12(13)        SAVE THE REGISTERS               
        LR        12,15               MEKE R12 THE BASE REGISTER       
        USING     ADD,12              FINISH THE JOB                   
        LA        11,REGSAVE          POINT TO SAVE AREA               
        ST        13,4(11)            SAVE CURRENT R13                 
        ST        11,8(13)            INFORM THE OS                     
        LR        13,11               ESTABLISH NEW R13                 
*                                                                       
        WTO       'MULTIPLICATION'                                     
        MP        BYTES,=P'1024'                                       
        UNPK      W_A,BYTES                                             
        OI        W_A+6,X'F0'                                           
        MVC       WTOA+8(9),W_A       PRINT OUTLINE                     
WTOA    WTO       'XXXXXXXXX IS W_A'                                   
*                                                                       
*                                                                       
        L         13,4(13)            RESTORE R13 TO ORIGINAL           
        LM        14,12,12(13)        RESTORE THE REGS                 
        SR        15,15               EVERYTHING WENT OK               
        BCR       B'1111',14          RETURN TO THE SYSTEM             
*                                                                       
BYTES   DC PL5'373'                                                     
W_A     DC PL7'0000000'                                                 
W_B     DC PL7'0000000'                                                 
REGSAVE DS        18F                                                   
        END                                                             


Compiled steps:

000000                00000 000CB     1 ADD     CSECT                         
000000 90EC D00C            0000C     2         STM       14,12,12(13)       
000004 18CF                           3         LR        12,15               
                 R:C  00000           4         USING     ADD,12             
000006 41B0 C080            00080     5         LA        11,REGSAVE         
00000A 50DB 0004            00004     6         ST        13,4(11)           
00000E 50BD 0008            00008     7         ST        11,8(13)           
000012 18DB                           8         LR        13,11               
                                      9 *                                     
                                     10         WTO       'MULTIPLICATION'   
000014                               12+         CNOP  0,4                   
000014 A715 000B            0002A    13+         BRAS  1,IHB0001A             
000018 0012                          14+         DC    AL2(18)               
00001A 0000                          15+         DC    B'0000000000000000'   
00001C D4E4D3E3C9D7D3C9              16+         DC    C'MULTIPLICATION'     
00002A                               17+IHB0001A DS    0H                     
00002A 0A23                          18+         SVC   35                     
00002C FC42 C06A C0C8 0006A 000C8    19         MP        BYTES,=P'1024'     
000032 F364 C06F C06A 0006F 0006A    20         UNPK      W_A,BYTES           
000038 96F0 C075      00075          21         OI        W_A+6,X'F0'         
00003C D208 C04C C06F 0004C 0006F    22         MVC       WTOA+8(9),W_A       
                                     23 WTOA    WTO       'XXXXXXXXX IS W_A' 
000042 0700                          25+         CNOP  0,4                   
000044 A715 000C            0005C    26+WTOA     BRAS  1,IHB0003A             
000048 0014                          27+         DC    AL2(20)               
00004A 0000                          28+         DC    B'0000000000000000'   
00004C E7E7E7E7E7E7E7E7              29+         DC    C'XXXXXXXXX IS W_A'   
00005C                               30+IHB0003A DS    0H                     
00005C 0A23                          31+         SVC   35                     
                                     32 *                                     
00005E 58DD 0004            00004    33         L         13,4(13)           
000062 98EC D00C            0000C    34         LM        14,12,12(13)       
000066 1BFF                          35         SR        15,15               
000068 07FE                          36         BCR       B'1111',14         
                                     37 *                                     
00006A 000000373C                    38 BYTES   DC PL5'373'                   
00006F 0000000000000C                39 W_A     DC PL7'0000000'               
000076 0000000000000C                40 W_B     DC PL7'0000000'               
000080                               41 REGSAVE DS        18F                 
                                     42         END                           
0000C8 01024C                        43                =P'1024'               


Output:
MULTIPLICATION   
0381952   IS W_A


Please have a look. And i Just asked how to remove the signed bit in the last.

Regards
Utpal
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time

Re: signed clause

Postby steve-myers » Mon Jul 30, 2012 9:18 pm

Well, you still keep posting code that does not match your alleged execution. This time you moved a 9 byte field in your WTO macro from a 7 byte field, but your alleged output just shows 7 bytes.

In any event,

OI W_A+6,X'F0'

is correct, but something like this is better.

OI W_A+L'W_A-1,X'F0'

The other way is to adjust the packed decimal sign before the UNPK.

OI BYTES+L'BYTES-1,X'0F'
UNPK W_A,BYTES

A little more complicated in some respects, but you don't have to fiddle with fixing packed decimal signs, is to use the ED instruction. The down side of ED is you must exactly (something you appear reluctant to do) match the output mask with the digits in the input. This means your 5 byte (9 digit) BYTES must be edited to an output mask that has 9 digit select characters.

ED OUTPUT,BYTES
...
OUTPUT DC X'40202020202020202120'
BYTES DC P'123456789'

The first byte in OUTPUT is a fill character that is inserted in place of leading 0 characters. The 40 character is an EBCDIC blank. The 20 and 21 characters are "digit select" characters that are replaced with the fill character or a digit from the packed decimal number. The 21 character is a "significance start"that tells ED that leading 0s are inserted into the output after the character. Using the edit mask I showed, PL5'0' will produce
  ----+----1
C'         0'
steve-myers
Global moderator
 
Posts: 1886
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: signed clause

Postby utpalpal07 » Mon Jul 30, 2012 9:58 pm

Thanks steve for the help and description. Its useful :)
utpalpal07
 
Posts: 43
Joined: Wed Feb 08, 2012 12:02 pm
Has thanked: 1 time
Been thanked: 0 time


Return to Assembler