Practice Exercise 6

  1. Convert the following numbers from binary to decimal or decimal to binary:
    a.)     11101110100010100111012

    b.)     1111111111111111111111111111111111111102
            (There are 38 1's and one 0 above.)
            (hint:  there is an easy way to convert this.)

    c.)     4,63810

  1. Convert the following numbers to 2's complement binary, with various word lengths.
    a.)     -7  (8 bits)

    b.)     -128 (8 bits)

    c.)     87  (8 bits)

    d.)     -87  (16 bits)

    e.)     -1  (36 bits)

    f.)     -4  (80 bits)

  1. The following numbers are encoded in 2's complement, either 8-bit or 16-bits. In each case, tell what the absolute value of the number is in decimal.
    a.)     10001010

    b.)     1111000011110000

    c.)     1111111111111000

    d.)     0100000000000001

  1. Do the following arithmetic operations in 8-bit 2's complement binary. Check your numbers with decimal arithmetic to make sure that you get the right answer.
    a.)     68 + -87

    b.)     -101 + -36

  1. Write all the bit patterns for 4-bits 2's complement, according to the layout shown in Chapter 6.

  1. Suppose you had an 8-bit computer and you did a number of additions, as shown below. For each tell what the CNV and Z bits would be after the operation.
    a.)          10010111            C=______   N=______
               + 10001001            Z=______   V=______
              -----------
               1 00100000

    b.)          01010111            C=______   N=______
               + 11101001            Z=______   V=______
              -----------
               1 01000000

    c.)          00000100            C=______   N=______
               + 11111100            Z=______   V=______
              -----------
               1 00000000

    d.)          00111011            C=______   N=______
               + 01011010            Z=______   V=______
              -----------
               0 10010101

  1. Following are some 8-bit values to which shift operations are applied. Write down the new values after shifting.
    a.)     1 0 1 1 0 1 1 1     logical shift left 1 bit

    b.)     1 0 1 1 0 1 1 1     logical shift right 1 bit

    c.)     1 0 1 1 0 1 1 1     circular shift right 1 bit

    d.)     1 0 1 1 0 1 1 1     arithmetic shift right 1 bit

    e.)     1 0 1 1 0 1 1 1     arithmetic shift left 1 bit

  1. For the following pairs of operands, apply bitwise Boolean operations.
    a.)       10010001111
            & 01100011101   (and)
            -------------

    b.)       10010001111
            | 01100011101   (or)
            -------------

    c.)     ^ 10010001111   (not)
            -------------

  1. Using the ASCII character set, write some C statements. Imagine that there is a character variable called ch, declared as char ch;
    a.) determine if the character in ch is printable

    b.) determine if the character in ch is a printable punctuation symbol

    c.) convert an uppercase letter to lowercase (don't need to check to make
        sure it is uppercase first)

  1. Below is the circuit for the 1-bit left and right logical shifter shown in Fig. 2 of Chapter 6. Make modifications so that it is a circular shifter instead. (Remember that a circular shifter does not insert 0s at the end, but moves the end bits around.)