Institutt for Informatikk
Universitetet i Bergen
I 125 - Innføring i Programoversettelse


Voluntary Exercise Set 10 (Gruppeøvelser. 10)

  1. Consider the following C- expression: a * b + (5 - (1 + 2))
    1. Draw an appropriate AST for the expression, preferably one that your parser would produce.
    2. Give a sequence of three-address instructions corresponding to the expression and AST.
    3. Give a sequence of P-code instructions corresponding to the expression and AST.
    4. Give a sequence of BVM instructions corresponding to the expression and AST.

  2. Consider the following C- expression: a[a[i+10]] = b[2+3]
    1. Draw an appropriate AST for the expression, preferably one that your parser would produce.
    2. Give a sequence of three-address instructions corresponding to the expression and AST.
    3. Give a sequence of P-code instructions corresponding to the expression and AST.
    4. Give a sequence of BVM instructions corresponding to the expression and AST.

  3. Consider the following C expression: p->next->next = p->next
    1. Give a sequence of three-address instructions corresponding to the expression.
    2. Give a sequence of P-code instructions corresponding to the expression.
    3. Give a sequence of BVM instructions corresponding to the expression.

  4. Exercise 8.15 on page 486 of the text.