Compiler Design
Q21.
The following code segment is executed on a processor which allows only register operands in its instructions. Each instruction can have atmost two source operands and one destination operand. Assume that all variables are dead after this code segment. c = a + b; d = c * a; e = c + a; x = c * c; if (x > a) { y = a * a; } else { d = d * d; e = e * e; } What is the minimum number of registers needed in the instruction set architecture of the processor to compile this code segment without any spill to memory? Do not apply any optimization other than optimizing register allocationQ22.
The program below uses six temporary variables a, b, c, d, e, f. a =1 b= 10 c =20 d= a +b e= c +d f =c +e b= c+ e e =b +f d =5 +e return d +f Assuming that all operations take their operands from registers, what is the minimum number of registers needed to execute this program without spilling?Q23.
Choose the correct alternatives (more than one may be correct) and write the corresponding letters only: Indicate all the true statements from the following:Q24.
The expression ( a * b) * c \; op \dots where 'op' is one of '+', '*' and '\uparrow' (exponentiation) can be evaluated on a CPU with single register without storing the value of (a * b) ifQ25.
Mention the pass number for each of the following activities that occur in a two pass assembler: A. object code generation B. literals added to literal table C. listing printed D. address resolution of local symbolsQ26.
Generation of intermediate code based on an abstract machine model is useful in compilers becauseQ27.
In a simplified computer the instructions are: The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block: Assume that all operands are initially in memory. The final value of the computation should be in memory. What is the minimum number of MOV instructions in the code generated for this basic block?Q29.
Number of comparisons required for an unsuccessful search of an element in a sequential search organized, fixed length, symbol table of length L isQ30.
A particular BNF definition for a "word is given by the following rules. < word > :: =< letter > I < letter > < charpair > I < letter >< intpair > < charpair > :: =< letter >< letter > I < charpair >< letter >< letter > < intpair > :: = < integer >< integer > I < intpair >< integer >< integer > < letter > :: = a I b I c I ......I Y I Z < integer > :: = 0 I 1 I 2 I ......I 9 Which of the following lexical entries can be derived from < word >? I. pick II. picks III. c44