GATE 2023
65 questions
MCQ 34 · MSQ 15 · NAT 161-mark 30 · 2-mark 35
Questions 41–45 of 65
Consider the given C-code and its corresponding assembly code, with a few operands U1-U4 being unknown. Some useful information as well as the semantics of each unique assembly instruction is annotated as inline comments in the code. The memory is byte-addressable.
Which one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4) in the above assembly code?
//C-code ;assembly-code (; indicates comments)
;r1-r5 are 32-bit integer registers
;initialize r1=0, r2=10
;initialize r3, r4 with base address of a, b
int a[10], b[10], i; L01: jeq r1, r2, end ;if(r1==r2) goto end
// int is 32-bit L02: lw r5, 0(r4) ;r5 <- Memory[r4+0]
for (i=0; i<10;i++) L03: shl r5, r5, U1 ;r5 <- r5 << U1
a[i] = b[i] * 8; L04: sw r5, 0(r3) ;Memory[r3+0] <- r5
L05: add r3, r3, U2 ;r3 <- r3+U2
L06: add r4, r4, U3
L07: add r1, r1, 1
L08: jmp U4 ;goto U4
L09: endWhich one of the following options is a CORRECT replacement for operands in the position (U1, U2, U3, U4) in the above assembly code?
Answer: (B)
Compare the C code with the assembly code:
- Multiplying by 8 is the same as a left shift by 3 U1 = 3.
- An int takes 4 bytes and memory is byte addressable. So to reach the next element of a and b, add 4 to each pointer: U2 = 4, U3 = 4.
- After i (r1) is incremented, jump back to the loop check at L01 U4 = L01.
Answer: (3, 4, 4, L01)
- Multiplying by 8 is the same as a left shift by 3 U1 = 3.
- An int takes 4 bytes and memory is byte addressable. So to reach the next element of a and b, add 4 to each pointer: U2 = 4, U3 = 4.
- After i (r1) is incremented, jump back to the loop check at L01 U4 = L01.
Answer: (3, 4, 4, L01)
A 4 kilobyte (KB) byte-addressable memory is realized using four 1 KB memory blocks. Two input address lines (IA4 and IA3) are connected to the chip select
(CS) port of these memory blocks through a decoder as shown in the figure. The remaining ten input address lines from IA11-IA0 are connected to the address port of these blocks. The chip select (CS) is active high.
The input memory addresses (IA11-IA0), in decimal, for the starting locations (Addr=0) of each block (indicated as X1, X2, X3, X4 in the figure) are among the options given below. Which one of the following options is CORRECT?
The input memory addresses (IA11-IA0), in decimal, for the starting locations (Addr=0) of each block (indicated as X1, X2, X3, X4 in the figure) are among the options given below. Which one of the following options is CORRECT?
Answer: (C)
The decoder takes IA4 and IA3 as inputs. So these two bits pick the block, and the other 10 lines give the address inside the block.
Start address of each block (all other bits are 0):
- X1: IA4 IA3 = 00 0
- X2: 01
- X3: 10
- X4: 11 16 + 8 = 24
Answer: (0, 8, 16, 24)
Start address of each block (all other bits are 0):
- X1: IA4 IA3 = 00 0
- X2: 01
- X3: 10
- X4: 11 16 + 8 = 24
Answer: (0, 8, 16, 24)
Consider a sequential digital circuit consisting of T flip-flops and D flip-flops as shown in the figure. CLKIN is the clock input to the circuit. At the beginning, Q1, Q2 and Q3 have values 0, 1 and 1, respectively.
Which one of the given values of (Q1, Q2, Q3) can NEVER be obtained with this digital circuit?
Which one of the given values of (Q1, Q2, Q3) can NEVER be obtained with this digital circuit?
Answer: (A)
Reading the circuit, the flip-flop inputs are: , , .
The next-state equations are: , , .
Start from (0, 1, 1). The states follow this order:
011 000 100 010 101 111 110 011 (the sequence repeats)
The state (0, 0, 1) never shows up.
Answer: (0, 0, 1)
The next-state equations are: , , .
Start from (0, 1, 1). The states follow this order:
011 000 100 010 101 111 110 011 (the sequence repeats)
The state (0, 0, 1) never shows up.
Answer: (0, 0, 1)
A Boolean digital circuit is composed using two 4-input multiplexers (M1 and M2) and one 2-input multiplexer (M3) as shown in the figure. X0-X7 are the inputs of the multiplexers M1 and M2 and could be connected to either 0 or 1. The select lines of the multiplexers are connected to Boolean variables A, B and C as shown.
Which one of the following set of values of (X0, X1, X2, X3, X4, X5, X6, X7) will realise the Boolean function ?
Which one of the following set of values of (X0, X1, X2, X3, X4, X5, X6, X7) will realise the Boolean function ?
Answer: (C)
M1 and M2 take (A, C) as their select lines, so the input index is 2A + C. M3 passes M1 when B = 0 and M2 when B = 1.
First simplify the function:
- B = 0 (M1): when A = 0 F = 1 (so X0 = X1 = 1). When A = 1 F = C (so X2 = 0, X3 = 1).
- B = 1 (M2): when A = 0 F = 1 (so X4 = X5 = 1). When A = 1 F = 0 (so X6 = X7 = 0).
Answer: (1, 1, 0, 1, 1, 1, 0, 0)
First simplify the function:
- B = 0 (M1): when A = 0 F = 1 (so X0 = X1 = 1). When A = 1 F = C (so X2 = 0, X3 = 1).
- B = 1 (M2): when A = 0 F = 1 (so X4 = X5 = 1). When A = 1 F = 0 (so X6 = X7 = 0).
Answer: (1, 1, 0, 1, 1, 1, 0, 0)
Consider the IEEE-754 single precision floating point numbers
P=0xC1800000 and Q=0x3F5C2EF4.
Which one of the following corresponds to the product of these numbers (i.e., P x Q), represented in the IEEE-754 single precision format?
Which one of the following corresponds to the product of these numbers (i.e., P x Q), represented in the IEEE-754 single precision format?
Answer: (C)
. Split as . The sign is negative, the exponent is and the mantissa is . So .
. Split as . The sign is positive and the exponent bits are , so the exponent is .
Multiplying by changes the sign to negative and adds to the exponent. The mantissa of stays the same. The new exponent is , and the stored exponent is .
The bits of the product are . Regroup in 4 bits from the left: .
Answer: (C)
. Split as . The sign is positive and the exponent bits are , so the exponent is .
Multiplying by changes the sign to negative and adds to the exponent. The mantissa of stays the same. The new exponent is , and the stored exponent is .
The bits of the product are . Regroup in 4 bits from the left: .
Answer: (C)