Machine Instruction · Computer Organization and Architecture
36 questions · asked in 19 of 27 years (2000–2026)
MCQ 27 · MSQ 1 · NAT 81-mark 22 · 2-mark 14
2000Questions per year2026
Questions 6–10 of 36
A processor uses a 32-bit instruction format and supports byte-addressable memory access. The ISA of the processor has 150 distinct instructions. The instructions are equally divided into two types, namely R-type and I-type, whose formats are shown below.
In the OPCODE, 1 bit is used to distinguish between I-type and R-type instructions and the remaining bits indicate the operation. The processor has 50 architectural registers, and all register fields in the instructions are of equal size.
Let X be the number of bits used to encode the UNUSED field, Y be the number of bits used to encode the OPCODE field, and Z be the number of bits used to encode the immediate value/address field. The value of X + 2Y + Z is ______
In the OPCODE, 1 bit is used to distinguish between I-type and R-type instructions and the remaining bits indicate the operation. The processor has 50 architectural registers, and all register fields in the instructions are of equal size.
Let X be the number of bits used to encode the UNUSED field, Y be the number of bits used to encode the OPCODE field, and Z be the number of bits used to encode the immediate value/address field. The value of X + 2Y + Z is ______
Answer: 34
Size of each field:
- 150 instructions, 75 per type. 1 type bit + bits Y = 8.
- 50 registers bits for each register field.
- R-type: X = 6.
- I-type: Z = 12.
Answer: 34
- 150 instructions, 75 per type. 1 type bit + bits Y = 8.
- 50 registers bits for each register field.
- R-type: X = 6.
- I-type: Z = 12.
Answer: 34
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)
Consider the following instruction sequence where registers are general purpose and denotes the content at the memory location .
Assume that the content of the memory location 5000 is 10, and the content of the register is 3000. The content of each of the memory locations from 3000 to 3020 is 50. The instruction sequence starts from the memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable.
After the execution of the program, the content of memory location 3010 is ____________
Assume that the content of the memory location 5000 is 10, and the content of the register is 3000. The content of each of the memory locations from 3000 to 3020 is 50. The instruction sequence starts from the memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable.
After the execution of the program, the content of memory location 3010 is ____________
Answer: 50
The first instruction (4 bytes) sits at 1000 to 1003, so the second instruction, , starts at 1004. So jumps back to the second instruction, and the first instruction runs only once.
. In each pass: , , , , . The branch is taken while . goes from 10 down to 0, so there are exactly 10 passes.
In these passes is 3000, 3001, , 3009, so locations 3000 to 3009 are written. Location 3010 is never written, so it keeps its value 50.
Answer: 50
. In each pass: , , , , . The branch is taken while . goes from 10 down to 0, so there are exactly 10 passes.
In these passes is 3000, 3001, , 3009, so locations 3000 to 3009 are written. Location 3010 is never written, so it keeps its value 50.
Answer: 50
Consider the following data path diagram.
Consider an instruction: . The following steps are used to execute it over the given data path. Assume that PC is incremented appropriately. The subscripts r and w indicate read and write operations, respectively.
Which one of the following is the correct order of execution of the above steps?
Consider an instruction: . The following steps are used to execute it over the given data path. Assume that PC is incremented appropriately. The subscripts r and w indicate read and write operations, respectively.
Which one of the following is the correct order of execution of the above steps?
Answer: (C)
Fetch the instruction first, then execute it:
- 3: PC MAR, then read memory (this is the fetch)
- 5: MDR IR (the instruction is now in IR)
- 2: R1 TEMP1 (TEMP1 holds one input of the ALU)
- 1: R2 goes on the bus, and with TEMP1 ALU add TEMP2
- 4: TEMP2 R0
Answer: 3, 5, 2, 1, 4
- 3: PC MAR, then read memory (this is the fetch)
- 5: MDR IR (the instruction is now in IR)
- 2: R1 TEMP1 (TEMP1 holds one input of the ALU)
- 1: R2 goes on the bus, and with TEMP1 ALU add TEMP2
- 4: TEMP2 R0
Answer: 3, 5, 2, 1, 4
A processor has 64 registers and uses 16-bit instruction format. It has two types of instructions: I-type and R-type. Each I-type instruction contains an opcode, a register name, and a 4-bit immediate value. Each R-type instruction contains an opcode and two register names. If there are 8 distinct I-type opcodes, then the maximum number of distinct R-type opcodes is _______.
Answer: 14
Register field takes bits.
- I-type: opcode + 6 + 4 = 16 gives a 6-bit opcode.
- R-type: opcode + 6 + 6 = 16 gives a 4-bit opcode.
Using expanding opcodes: take one 4-bit R-type code and add 2 more bits. This gives 4 I-type opcodes. So the 8 I-type opcodes use up 8/4 = 2 of the 16 four-bit codes.
R-type opcodes = 16 2 = 14
Answer: 14
- I-type: opcode + 6 + 4 = 16 gives a 6-bit opcode.
- R-type: opcode + 6 + 6 = 16 gives a 4-bit opcode.
Using expanding opcodes: take one 4-bit R-type code and add 2 more bits. This gives 4 I-type opcodes. So the 8 I-type opcodes use up 8/4 = 2 of the 16 four-bit codes.
R-type opcodes = 16 2 = 14
Answer: 14
Keep practising