Intermediate Code Generation: GATE CS Previous Year Questions

Intermediate Code Generation · Compiler Design

32 questions · asked in 16 of 27 years (2000–2026)

MCQ 26 · MSQ 1 · NAT 51-mark 13 · 2-mark 19

2000Questions per year2026

Questions 31–32 of 32

Q31GATE 20071 markMCQ−0.33 if wrong
In a simplified computer the instructions are:
OP Rj, Ri- Performs Rj OP Ri and stores the result in register Ri.
OP m,Ri- Performs val OP Ri and stores the result in Ri. val denotes the content of memory location m.
MOV m, Ri- Moves the content of memory location m to register Ri.
MOV Ri, m- Moves the content of register Ri to memory location m.

The computer has only two registers, and OP is either ADD or SUB. Consider the following basic block:
t1=a+bt_1 = a + b
t2=c+dt_2 = c + d
t3=e−t2t_3 = e - t_2
t4=t1−t3t_4 = t_1 - t_3
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?

Q32GATE 20061 markMCQ−0.33 if wrong
Consider the following C code segment.

for (i = 0; i < n; i++) 
{ 
    for (j=0; j < n; j++) 
    { 
        if (i%2) 
        { 
            x += (4*j + 5*i); 
            y += (7 + 4*j); 
        } 
    } 
} 
Which one of the following is false?

Keep practising

Topics in Compiler Design

All CS topics ›