Resolution of a COBOL MOVE command



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

Resolution of a COBOL MOVE command

Postby LotharLochkarte » Tue Aug 16, 2011 1:50 pm

Hi,

if I code a MOVE from a non-packed field to a packed field in COBOL, the compiler resolves it to a PACK and a MVN command in assembler.

Of course, it packs the FROM-FIELD to the TO-FIELD, but what is the MVN good for?

My compile listing states that "SYSLIT AT +45" is MVNed to TO-FIELD+6. The TO-FIELD is defined as PIC S9(11)V99 COMP-3, the FROM-FIELD PIC 9(09)V99.

Can somebody explain to me what the MVN does? Why is the PACK command insufficient?

Thanks a lot and best regards!
LotharLochkarte
 
Posts: 68
Joined: Fri Aug 27, 2010 6:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Resolution of a COBOL MOVE command

Postby BillyBoyo » Tue Aug 16, 2011 2:29 pm

What is your compiler option NUMPROC set to? And OPT? Maybe best to list them all, they are on your compile listing.

Can you paste and "code" all the pseudo-assembler for the move? Delete about 15 spaces from the left of the last field (where the screen is full) and should get it nicely on the screen here. Use the Preview button to check.

What is the value of SYSLIT AT +45? X'0C' maybe? Is the source of the move unsigned? We'll see, if you can post the above information.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Resolution of a COBOL MOVE command

Postby BillyBoyo » Tue Aug 16, 2011 3:49 pm

You have NUMPROC(NOPFD). The source field is unsigned. The value of SYSLIT AT +45 is X'0C'. The MVN is the method chosen in this case to ensure that the receiving field is positive, irrespective of the sign nybble (left-most four bits of the right-most byte).

I assume that you know what MVN is doing? The offset in your comp-3 field is to get at the right-most byte, and the MVN is only going to affect the right-most nybble, which is the sign for a comp-3 field.

The compiler uses MVN in that situation, not NI (which NUMPROC(PFD) would do), because NUMPROC(NOPFD) allows values of A, B, C, D, E and F in the sign (for either display-numeric or comp-3). PFD only allows C, D, and F. So for PFD an NI with X'FC' will ensure a C (positive) sign and preserve the value in the number nybble of the sign-byte (would be NI with X'CF' for display-numeric).

With NOPFD, the NI will not work if the sign happens to have A or B (it is unlikely to, but NOPFD allows it, so the compiler has to cater for it). So MVN is used as a second-best (it is slower).

The compiler option OPT has no affect on this.

You can confirm this against your listing, and by compiling with NUMPROC(PFD) is you are able to, just to see the difference.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Resolution of a COBOL MOVE command

Postby LotharLochkarte » Tue Aug 16, 2011 5:10 pm

Thank you very much for your detailed explanation!

I have learned a lot!

My question arose in the following context: One of my COBOL programs abended at the following IF-statement, when FROM-FIELD contained non-numeric data.
MOVE FROM-FIELD
  TO TO-FIELD

IF TO-FIELD = ZERO THEN

I expected the program to end abnormally with a S0C7 directly at the MOVE statement, but with your explanations it is clear why my thoughts were wrong!

Thanks and best regards!
LotharLochkarte
 
Posts: 68
Joined: Fri Aug 27, 2010 6:51 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Resolution of a COBOL MOVE command

Postby BillyBoyo » Tue Aug 16, 2011 5:39 pm

Well, I'm glad you are happy.

However, you are now posing a different question. I don't think your original question, and therefore my explanation, helps a huge amount with your abend.

With your abend, you are looking in the right place (the generated pseudo-assembler) to see why not. PACK will drop the zones (left-most nybble of each byte, copy the numerics (right-most nybble of each byte) and deal with the sign. If this ends up with a comp-3 which has anything but 0-9 in the numeric part (everything except the sign nybble) then you will get an abend when you try to use something that requires a packed-decimal instruction. In your case, on the IF.

A MOVE of "invalid" data will not always give and abend, it depends on the code generated by the compiler. If a ZAP is generated, abend, if a PACK, no abend (other variations are also available).
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post