Discussion
Consider a processor that has 16 general purpose registers and it uses 2-byte instruction format for all its instructions. Variable-sized opcodes are permitted. There are three different types of instructions; M-type, R-type, and C-type. Each M-type instruction has 2 register operands and a 6-bit immediate operand. Each R-type instruction has 3 register operands. Each C-type instruction has a register operand and a 6-bit offset value. If there are 2 unique M-type opcodes and 7 unique R-type opcodes, which one of the following options gives the maximum number of unique opcodes possible for C-type instructions?
Answer: B
The maximum number of C-type opcodes is 4.
Each instruction is 16 bits, and with 16 registers a register field needs 4 bits. The bits left for the opcode in each type:
- M-type: 2 registers + 6-bit immediate = 14 bits, leaving a 2-bit opcode;
- R-type: 3 registers = 12 bits, leaving 4 bits;
- C-type: 1 register + 6-bit offset = 10 bits, leaving 6 bits.
With an expanding opcode, the 2-bit field gives 4 patterns. M-type uses 2; the other 2 become prefixes for longer opcodes. Extending each by 2 bits gives 2 × 4 = 8 four-bit patterns. R-type uses 7, leaving 1 as a prefix. Extending it by the last 2 bits gives 4 six-bit patterns, so C-type can have at most 4 opcodes.
64 would be the count if the whole 6-bit field were free, and 16 or 8 forget that the M-type and R-type opcodes have already used up most of the prefixes.
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development