Packed Decimal Practice Problems

Suppose we have the following defined in storage:

NUM1     DC    CL3'ABC'
NUM2     DC    ZL5'-417'
PNUM1    DS    PL2
PNUM2    DS    PL3
PNUM3    DC    PL3'5027'
PNUM4    DC    PL2'200'
PNUM5    DS    PL6
PNUM6    DC    PL5'516437928'
LETTER1  DC    X'65'
LETTER2  DS    C
LETTER3  DS    C
  1. Suppose I execute this instruction:
              PACK  PNUM1(2),NUM1(3)

    What are the exact contents of PNUM1 afterward? Write out the answer in hex digits.

  2. Suppose I execute this instruction:
              PACK  PNUM2(3),NUM2(5)

    What are the exact contents of PNUM2 afterward? Write out the answer in hex digits.

  3. Suppose I execute this instruction:
              MP    PNUM3(4),PNUM4(2)
    1. What are the exact contents of PNUM3 afterward? Write out the answer in hex digits.

    2. Does any error occur, yes or no?

  4. Suppose I execute the following instructions:
              ZAP   PNUM5(6),PNUM3(3)
              DP    PNUM5(6),PNUM4(2)

    What are the exact contents of PNUM5 afterward? Write out the answer in hex digits.

  5. Suppose I try to use these instructions:
              ZAP   PNUM2(3),=P'123'
              CP    NUM1(3),PNUM2(3)
    1. Will this code assemble correctly, yes or no?

    2. If it is executed, what wil happen?

  6. Suppose I execute the following instructions:
              ZAP   PNUM2(3),=P'3019'
              SP    PNUM2(3),PNUM3(4)

    What are the exact contents of PNUM3 afterward? Write out the answer in hex digits.

  7. Suppose I want to add the 3-byte packed decimal number A stored at address 4(5) to the 7-byte packed decimal number B stored at address 8(6), so B = A + B.

    1. Write the instruction needed to do this.

    2. Write the encoded form of the instruction in hex digits.

  8. Suppose I have the following instruction in hex digits:
              F9 A7 20 04 8002

    Decode the instruction.

  9. Suppose I execute this instruction:
              SRP   PNUM6,3,0
    1. What are the exact contents of PNUM6 afterward?

    2. What should be the resulting condition code?

  10. Suppose I execute this instruction:
              SRP   PNUM6,63-3,5

    What are the exact contents of PNUM6 afterward?

  11. Suppose I execute these instructions:
              PACK  LETTER2(1),LETTER1(1)
              UNPK  LETTER3(1),LETTER1(1)
              CLC   LETTER2(1),LETTER3

    What is now the value of the condition code?


Answers

Here are what are believed to be correct answers. Please point out any that are not correct.

In the answers, we have sign digit 'F' for positive and 'D' for negative, but there are other possibilities.

  1. PNUM1 will contain X'123C'.

  2. PNUM2 will contain X'00417D'.
    1. PNUM3 will contain X'1005400F'

    2. Overflow does not occur.

  3. PNUM5 will contain X'0000025F027F'.
    1. Yes

    2. An ABEND will occur with interruption code 0007.

  4. PNUM3 will contain X'02008D'.

    1. AP 8(7,6),4(3,5)

    2. FA62 6008 5004

  5. CP 4(11,2),2(8,8)
    1. PNUM6 will contain X'437927000F'.

    2. Condition Code = 3.

  6. PNUM6 will contain X'000516438F'.

  7. Condition Code = 0.