Correction de la série d'exercices no 2

Exercice 2-1 : Scanning, parsing,code generation

  1. (x + (4 + y)) * (x + y)
  2. 1 + (2 * (1 + (2 * (1 + x))))
  3. x * y + z
  4. if (x < z) x = x + 1 else x = 0

Exercice 2-2 : Scanning, parsing,code generation

  1. x += 1 <=> x = x + 1
  2. if (x == 2) x = 0
  3. Exercice 2-3 : Binary logic et tableaux booléens

    a

    b

    a AND b

    0

    0

    0

    0

    1

    0

    1

    0

    0

    1

    1

    1


    a

    b

    a OR b

    0

    0

    0

    0

    1

    1

    1

    0

    1

    1

    1

    1


    a

    NOT a

    0

    1

    1

    0


    1. a1 = a <=> a AND 1 = 1

      a

      b

      a AND b

      0

      1

      0

      1

      1

      1


    2. a * (a + b) = a <=> a AND (a OR b) = a

      a

      b

      Z = a OR b

      a AND Z

      0

      0

      0

      0

      0

      1

      1

      0

      1

      0

      1

      1

      1

      1

      1

      1


    3. (ab)' = a' + b' <=> NOT (a AND b) = (NOT a) OR (NOT b)

      a

      b

      Z = a AND b

      NOT Z

      0

      0

      0

      1

      0

      1

      0

      1

      1

      0

      0

      1

      1

      1

      1

      0


      a

      b

      NOT a OR NOT b

      0

      0

      1

      0

      1

      1

      1

      0

      1

      1

      1

      0


    Exercice 2-4 : Binary logic et portes logiques

    1. Circuit AND (NOT (a OR NOT b)) :
    2. Circuit majorité :