Packed Decimal Practice Exercise

This exercise is intended to help you understand packed decimal arithmetic.

It is not a homework assignment and will not be graded.


You need to write a program.

  1. Declare some variables:
    ABC      DC    PL3'47'
    DEF      DC    PL2'3'
    GHI      DC    PL5'F'-14'
    JKL      DC    PL3'0'
    MNO      DS    PL3
    PQR      DC    PL6'294'

  2. First use XDUMP to look at how these variables are stored. Notice that MNO has not been initialized.

  3. Do some arithmetic:
             ZAP   MNO(3),GHI(5)       
             AP    GHI(5),ABC(3) 
             SP    PQR(6),MNO(3)

  4. Now use XDUMP again to look at the values. Now MNO does have a value. (We didn't get a Data Exception from the ZAP.)

  5. Let's try multiplication:
             MP    PQR(6),DEF(2)
             MP    GHI(5),ABC(3)

  6. Again use XDUMP to look at the values.

  7. Let's try division:

             DP    PQR(6),ABC(3)

  8. Check the values again using XDUMP. Notice the locations and lengths of the quotient and the remainder.