Open In App

Computer Organization | Problem Solving on Instruction Format

Prerequisite – Basic Computer Instructions, Instruction Formats 

Problem statement:

Consider a computer architecture where instructions are 16 bits long. The first 6 bits of the instruction are reserved for the opcode, and the remaining 10 bits are used for the operands. There are three addressing modes: immediate, direct, and register. For immediate addressing, the operand is included in the instruction itself. For direct addressing, the operand is a memory address. For register addressing, the operand is a register number.



Write the instruction format for each of the addressing modes.

Solution:

The instruction format for each addressing mode is as follows:



  1. Immediate addressing:
    | Opcode (6 bits) | Operand (10 bits) |
  2. Direct addressing:
    | Opcode (6 bits) | Memory address (10 bits) |
  3. Register addressing:
    | Opcode (6 bits) | Register number (5 bits) | Not used (1 bit) |

In immediate addressing, the operand is included in the instruction itself, so the 10 bits are used to represent the operand value.

In direct addressing, the 10 bits are used to represent the memory address where the operand value is stored.

In register addressing, the 5 bits are used to represent the register number where the operand value is stored. The remaining 1 bit is not used.

This instruction format can be used to implement a wide range of instructions and operations in a computer system.

An instruction format defines the different component of an instruction. The main components of an instruction are opcode (which instruction to be executed) and operands (data on which instruction to be executed). Here are the different terms related to instruction format: 

 

In this article, we will discuss different types of problems based on instruction format which are asked in GATE. For details about different types of instruction formats, you can refer: Instruction Formats 

Type 1: Given instruction set size and operands size and their count, find the size of the instruction. 
In this type of questions, you will be given the size of instruction set, number of operands and their size, you have to find out the size of the instruction. 

Que-1. Consider a processor with 64 registers and an instruction set of size twelve. Each instruction has five distinct fields, namely, opcode, two source register identifiers, one destination register identifier, and a twelve-bit immediate value. Each instruction must be stored in memory in a byte-aligned fashion. If a program has 100 instructions, the amount of memory (in bytes) consumed by the program text is ____________. (GATE 2016) 
(A) 100 
(B) 200 
(C) 400 
(D) 500 

Solution: It can be approached as: 
 

Type 2: Given instruction size, opcode size and size of some operands, find the size and maximum value of remaining operands. 
In this type of questions, you will be given the size of instruction, size of opcode, number of operands and size of some operands, you have to find out the size or maximum value of remaining operands. 

Que-2. A processor has 40 distinct instructions and 24 general purpose registers. A 32-bit instruction word has an opcode, two registers operands and an immediate operand. The number of bits available for the immediate operand field is_______. (GATE CS 2016) 

Solution: It can be approached as: 
 

Que-3. A machine has a 32-bit architecture, with 1-word long instructions. It has 64 registers, each of which is 32 bits long. It needs to support 45 instructions, which have an immediate operand in addition to two register operands. Assuming that the immediate operand is an unsigned integer, the maximum value of the immediate operand is ___________. (GATE CS 2014) 

Solution: It can be approached as: 
 

Type 3: Instruction format with different categories of instruction 
In this type of questions, you will be given different categories of instructions. You have to find maximum possible instructions of a given type. 

Que-4. A processor has 16 integer registers (R0, R1, … , R15) and 64 floating point registers (F0, F1, … , F63). It uses a 2 byte instruction format. There are four categories of instructions: Type-1, Type-2, Type-3, and Type 4. Type-1 category consists of four instructions, each with 3 integer register operands (3Rs). Type-2 category consists of eight instructions, each with 2 floating point register operands (2Fs). Type-3 category consists of fourteen instructions, each with one integer register operand and one floating point register operand (1R+1F). Type-4 category consists of N instructions, each with a floating point register operand (1F). 

The maximum value of N is ________. (GATE-CS-2018) 

Solution: It can be approached as: 
 

 

Article Tags :