Page 1 of 2

a assembler question about pack?

PostPosted: Thu Apr 01, 2010 1:15 am
by helen2000
could anybody answer the question? thanks, by the way, could you code a sample program to test your answer, thanks, Helen

Given N DC CL5'10639'.
Given Z DC PL3'-12', Show the hex representation of Z before and after PACK N,Z.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 1:25 am
by dick scherrer
Hi Helen,

Suggest you write the code you want, write the output from the PACK to a record in a file, and then view the file in hex.

Post back here if there are any questions/problems.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 2:48 am
by helen2000
Hi, Mr. Dick
this is test code:
OPEN REPORT
PUT REPORT,OREC
PACK ONN,OZZ
PUT REPORT, OREC
CLOSE REPORT
....
OREC DS 0CL16
ONN   DC CL5'10639'
         DC CL3'***'
OZZ   DC  PL3'-12'
        DC   CL3'***"
        END

The following is output:
 000001  10639***   ***                     
        FFFFF5550025554444444444444444444444
        10639CCC01DCCC0000000000000000000000
 -------------------------------------------
 000002      K***   ***                     
        0000D5550025554444444444444444444444
        00012CCC01DCCC0000000000000000000000
 -------------------------------------------
 ****** **************************** Bottom                                             


please explain why 00012d change to 00000001d2 after packed, thanks,
Helen

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 3:11 am
by Frank Yaeger
From the POP:

PACK D1(L1,B1),D2(L2,B2) [SS]

The format of the second operand is changed from zoned to packed, and the result is placed at the first-operand location. The zoned and packed formats are described in Chapter 8, "Decimal Instructions."
The second operand is treated as having the zoned format.
********************************
The second operand is supposed to be the ZD source value and the first operand is supposed to be the PD target value. You have the reverse. Your PACK instruction should be:

   PACK OZZ,ONN


Also, for:

OZZ   DC  PL3'-12'
        DC   CL3'***"


You need an ending apostrophe after *** instead of an ending quote.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 3:12 am
by dick scherrer
Hi Helen,

Suggest you reverse the operands in the PACK instruction and specify the length.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 3:39 am
by helen2000
this is a homework from the textbook written by Bill Qualls(chapter 7---7.6), I know if reverse the operands it will work well.
but for the case, I confuse the output: ooo12D change to 00000001D2? I think it must be for some reason I don't know, I'm
sorry I'm a beginner for assembler language, thanks,
Helen.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 4:09 am
by Frank Yaeger
00012D change to 00000001D2


Here's the explanation for that:

Your original PACK instruction said you wanted to convert the original 3 byte "ZD value" at OZZ to a 5 byte PD value at ONN.

Your 3-byte "ZD value" at OZZ is the following in hex:

00012D

A 3-byte ZD value looks like this:

zdzdsd

where z is the zone (ignored), d is a digit (0-9) and s is the sign.

PACK converts your zdzdsd value to a ddds value. It removes the zones, keeps the digits, and reverses the sign and last digit.

So 00012D is converted to 01D2. However, since your PD value is 5 bytes, it is padded with decimal zeros on the left to 5 bytes to get 00000001D2

Make sense?

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 8:08 pm
by helen2000
at first, thanks Mr. Frank, It's right where I confused. so, I have
OZZ DC PL3'-14312', should be got 41d2 after packed. but the output is totally different, more confuse, why,
OPEN REPORT
PUT REPORT,OREC
PACK ONN,OZZ
PUT REPORT, OREC
CLOSE REPORT
....
OREC DS 0CL16
ONN   DC CL5'10639'
         DC CL3'***'
OZZ   DC  PL3'-14312'
        DC   CL3'***"
        END



and this is output
 000001 10639***  ***                     
        FFFFF5550025554444444444444444444444
        10639CCC00DCCC0000000000000000000000
 -------------------------------------------
 000002  K***  ***                     
        0000D5550025554444444444444444444444
        00002CCC00DCCC0000000000000000000000
 -------------------------------------------
 ****** **************************** Bottom
                                           

could you tell me maybe my test code have problem, thanks?

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 9:37 pm
by Frank Yaeger
Yes, 41D2 would be expected and when I run what you show for your program, that's what I get:

X'00000041D25C5C5C...'

I don't know what you're doing that gave X'00000000D25C5C5C...' instead. There's something you're not showing. Are you doing anything later on in the program that would overlay bytes in OREC?

I did notice that for the second PUT you show

  PUT REPORT, OREC


instead of:

  PUT REPORT,OREC


but I don't know if that's what you really have or whether that would cause the difference you're seeing.

If you can't figure out what you're doing different, show your Assembler listing.

Re: a assembler question about pack?

PostPosted: Thu Apr 01, 2010 11:11 pm
by helen2000
may be it's because I use pc/370 assembler , the software is from author Bill Qualls. I ftp the report.txt to mainframe to check.
the following is the whole test code. please tell me if found some problem, thanks,
         PRINT NOGEN
         START 0
         REGS
BEGIN    BEGIN
         WTO   'PATEST ... Begin execution'
         OI    REPORT+10,X'08'    PC/370 ONLY - Convert all
*                                 output from EBCDIC to ASCII
         OPEN  TEACHERS
         OPEN  REPORT
         MVC   OCRLF,WCRLF
         PUT   REPORT,OREC
         PACK  ONN,OZZ
         PUT   REPORT,OREC

*
*        EOJ processing
*
ATEND    CLOSE TEACHERS
         CLOSE REPORT
         WTO   'PUTPUT....... list on REPORT.TXT'
         WTO   'PATEST ... Normal end of program'
         RETURN
*
*        Literals, if any, will go here
*
         LTORG
*
*        File definitions
*
TEACHERS DCB   LRECL=29,RECFM=F,MACRF=G,EODAD=ATEND,
               DDNAME='TEACHER.DAT'
REPORT   DCB   LRECL=16,RECFM=F,MACRF=P,
               DDNAME='REPORT.TXT'
*
*        Miscellaneous field definitions
*
WCRLF    DC    X'0D25'            PC/370 ONLY - EBCDIC CR/LF
*        Output (line) definition
*
OREC     DS    0CL16
ONN      DC    CL5'10639'
            DC    CL3'***'
OZZ      DC    PL3'-14312'
            DC    CL3'***'
OCRLF    DS    CL2                PC/370 only - CR/LF
            END   BEGIN



Helen