Binary Arithmetic Practice Exercise

This exercise is intended to help you understand binary arithmetic.

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


You need to write a program. Use the JCL from the lab training exercise.

  1. Declare some variables:
    ABC      DC    F'47'
    DEF      DC    F'3'
    GHI      DC    F'-14'
    ZERO     DC    F'0'
    MINUS    DC    F'-1'

  2. Load the values into registers and do some arithmetic:
             L     2,ABC               2 contains the number 47
             L     3,DEF               3 contains the number 3
    *
             LR    4,3                 4 now also contains the number 47
             AR    4,2                 Add
    *
             LR    5,3                 5 now also contains the number 47
             SR    5,2                 Subtract

    and now use XDUMP to see what these values look like in base 16.

  3. Next, let's look at multiplication.
             L     9,ABC               9 contains the number 47
    *                                  Who know what is in 8?
             M     8,DEF               Multiply
    *
             L     9,ABC               9 again contains the number 47
             L     8,GHI               8 now contains the number -14
             M     8,DEF               Multiply

    and again use XDUMP to look at the results. Notice that the value in register 8 is irrelevant when we multiply.

  4. Next, let's look at division.
           L       11,ABC              11 contains the positive number 47
           L       10,ZERO             10 contains the number 0
           D       10,DEF              Divide
    *
           L       5,GHI               5 contains the negative number -14
           L       4,ZERO              4 contains the number 0
           D       4,DEF               Divide
    *
           L       3,GHI               3 contains the negative number -14
           L       2,MINUS             2 contains the number -1
           D       2,DEF               Divide 

    and once more use XDUMP to look at the results. Notice that the value in the even-numbered register makes a substantial difference when we divide. Make sure you understand what happened.

    In each case, identify the quotient and the remainder.