Machine-translated by Google. Questions are authored in English.
Top

Intermediate Code Generation Questions and Answers

Answer: C

Each jump joins a list once and is patched once, so no instruction is visited repeatedly. Patching each jump as soon as a candidate destination appeared would revisit the same instructions many times over as the enclosing expressions combined.

Please log in or register to report this question.

32.

Arrange these steps of backpatching a conditional jump.
1. merge the list with others as subexpressions combine
2. emit the jump with its destination field left blank
3. fill in the destination when the label becomes known
4. record the index of that instruction on a list

Answer: D

Correct answer: 2 - 4 - 1 - 3

Backpatching exists because the destination is not yet known when the jump must be emitted. So the jump is emitted with a blank field, its index is recorded on a list, the lists are merged as subexpressions combine, and every entry is filled in at once when the label finally becomes known.

Please log in or register to report this question.

Answer: A

Correct answer: a label at the loop head and a conditional jump out of the body

The pattern is a label, the test, a conditional jump past the body when the test fails, the body, and an unconditional jump back to the label. Testing before the body is what distinguishes a while from a repeat, and the loop bound need not be known at compile time.

Please log in or register to report this question.

Answer: B

Correct answer: initialisation, label, test, body, increment, jump back

The initialisation runs once and so precedes the label. The test guards entry to the body, and the increment runs after the body but before the test is repeated - which is why the jump goes back to the label rather than to the initialisation, and why a continue statement must jump to the increment rather than to the test.

Please log in or register to report this question.

Answer: C

A dense range of values makes a table lookup the cheapest option. Sparse or wide ranges are better served by a chain of comparisons or a binary search over the values. The choice is made by measuring how densely the labels are packed.

Please log in or register to report this question.

Answer: D

A table costs one entry per value in the range, so a sparse set wastes space. Compilers commonly choose between the two strategies by measuring the density of the labels. A hybrid using a table for dense regions and comparisons elsewhere is also common.

Please log in or register to report this question.

Answer: A

Each argument is set up by its own instruction and the call names the procedure and the argument count. This keeps every instruction within the three address limit. A call with many arguments therefore expands into many instructions.

Please log in or register to report this question.

38.

A call to a procedure with 4 arguments is translated using one parameter instruction per argument plus the call itself. How many instructions result, ignoring argument evaluation?

Answer: B

One parameter instruction per argument, plus the call itself: \[ n = 4 + 1 = 5 \] Evaluating the argument expressions themselves would add further instructions ahead of these, and a nested call appearing as an argument expands the count considerably. The question asks only for the parameter-passing sequence, which is why the arithmetic is this simple.

Please log in or register to report this question.

Answer: C

Arrays, pointers, records and functions are all type constructors applied to other type expressions. Comparing two such expressions is how structural type equivalence is decided. Recursive types require the comparison to guard against infinite descent.

Please log in or register to report this question.

Answer: D

Correct answer: have the same structure regardless of the names given to them

Structural equivalence compares the type expressions themselves, so two records with the same fields in the same order are the same type whatever they are called. Name equivalence takes the opposite view and treats distinct declarations as distinct types - and languages differ in which they adopt, which matters greatly for interchangeability.

Please log in or register to report this question.

Loading…
Tags: Intermediate Code Generation Questions and Answers || Intermediate Code Generation MCQ Questions and Answers || Intermediate Code Generation GK Questions and Answers || Intermediate Code Generation GK MCQ Questions || Intermediate Code Generation Multiple Choice Questions and Answers || Intermediate Code Generation GK || GK on Intermediate Code Generation || Compiler Design Questions and Answers || Compiler Design MCQ Questions and Answers || Compiler Design GK Questions and Answers || GK on Compiler Design