GATE 2006
191 questions
MCQ 1911-mark 191
Questions 71–75 of 191
Answer: (C)
h to g: 0000 to 0001, 0001 to 0011, 0011 to 0010, 0010 to 0110, 0110 to 0111, 0111 to 0101, 0101 to 0100, 0100 to 1100, 1100 to 1101, 1101 to 1111, 1111 to 1110, 1110 to 1010, 1010 to 1011, 1011 to 1001, 1001 to 1000, 1000 to 0000.
Note that the minterm is the value of h itself (for example h = 0011 is minterm 3), not the row number n.
For , pick the h values whose g has bit 2 equal to 1: g = 0110, 0111, 0101, 0100, 1100, 1101, 1111, 1110 comes from h = 2, 6, 7, 5, 4, 12, 13, 15. So , which is option (C).
The other options list the minterms of a different bit. is , is and is .
Answer: (C)
Which of the statements below is TRUE after the program is executed ?
Answer: (D)
Here are the memory contents before the program runs: location 1000 holds 18, 1001 holds 1 and 1020 holds 16.
Now we run the instructions one at a time:
-
- It uses immediate addressing mode.
- It is read as
- So the value goes into the register .
-
-
It uses indexed addressing mode.
-
It is read as
-
The operand value
-
So the value goes into the register .
-
-
-
It uses immediate addressing mode.
-
It is read as
-
The operand value
-
So the value goes into the register .
-
-
-
It uses indexed addressing mode.
-
It is read as
-
The destination address
-
So the value goes into the memory location
-
So, once the program has finished, memory location holds the value
Answer: (D)
int work1(int *a, int i, int j) int work2(int *a, int i, int j)
{ {
int x = a[i+2]; int t1 = i+2;
a[j] = x+1; int t2 = a[t1];
return a[i+2] - 3; a[j] = t2+1;
} return t2 - 3;
}S1 : The transformation from work 1 to work 2 is valid, i.e., for any program state and input arguments, work 2 will compute the same output and have the same effect on program state as work 1
S2 : All the transformations applied to work 1 to get work 2 will always improve the performance (i.e. reduce CPU time) of work 2 compared to work 1
Answer: (A)
Example: , , .
- Work 1: ; ; it returns .
- Work 2: ; ; ; it returns .
The return values differ, so the transformation is not valid and S1 is false.
S2. The changes only save a repeated addition and a repeated array read. A compiler may already do this, so the saving can be zero. The new temporaries and also need registers, and when registers run short they can cost extra memory accesses. So these transformations cannot be said to always reduce CPU time, and S2 is false.
Answer: (A)
tempreg & mask
Branch to label if temp is non-zero
The variable temp is a temporary register. For correct emulation the variable mask must be generated by
Answer: (A)
Suppose we want to test one bit position, say (third from the right). Take the number as (the last bits are ). The bit at position from the right is . So we must AND the number with . Any other mask gives a wrong value, because it may count other bits or drop the bit at position "". The mask is made by . Here we shift to the left "" times. This gives a mask with set only at the "" bit position.
Answer: (A)
Answer: (C)
(A) , not a multiple of 3.
(B) , not a multiple of 3.
(C) , a multiple of 3.
(D) , not a multiple of 3.
Answer: (C)