Institutt for Informatikk
Universitetet i Bergen
INF 225 - Innføring i Programoversettelse - H05


Voluntary Exercise Set 9 (Group meeting 18.11.2005)

  1. Exercise 7.16 on page 394 of the text.

  2. 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.

  3. 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.

  4. 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.