IBM Assembler Question:
Download Questions PDF

Can we use MVC instruction to move pack field to pack field. which instruction you will use and why?


Answer #1
We can certainly use the MVC instruction to move the pack data to another pack field.

Answer #2
We can certainly use MVC but its preferred to use ZAP. By using ZAP the target field is initialized and then the source field value is added to it. Where as MVC is a bit by bit move which causes an error if the lengths are different.

Answer #3
MVC AFIELD, PKFIELD AFIELD = X'038CFF' ZAP AFIELD,PKFIELD AFIELD = X'00038C' ... AFIELD DS PL3 PKFIELD DC PL2'38' PKFIELD = X'038C' DC X'FF' We are copying a 2-byte packed field, PKFIELD, to a 3-byte field, AFIELD. Since MVC has an SS1 format, the length of AFIELD is used to determine that 3 bytes will be 'moved' by this instruction. The effect of this instruction is to copy the 2 bytes in PKFIELD and the byte which follows PKFIELD as well. As a result, AFIELD does not contain a packed value. On the other hand, the ZAP above first initializes AFIELD with a packed decimal zero just before adding the packed value of PKFIELD. This produces the correct packed decimal value X'00038C'. This type of error with the MVC instruction occurs each time the fields involved have different sizes. Care must be taken even when using a ZAP to copy a packed field. If the target field is too small to hold the result, high order truncation of digits can occur, causing an overflow. Consider the following example involving AFIELD defined above. ZAP AFIELD,=P'123456789' AFIELD = X'56789C

Download IBM Assembler Interview Questions And Answers PDF

Previous QuestionNext Question
How to pass instream data in sysin with Assembler?How to initialize 20,000 bytes in the Assembler?