Computer Instruction

What is a Computer Instruction?

Computer instructions typically refer to the set of codes that are usually given to the computer processor. These instructions contain several steps or processes to be carried out by the processor.

In terms of computer science and technology, a set of instructions refers to the single operation to be executed by the processor.

It is the operational process of the processor that is typically defined by the instruction set.

Understanding Computer Instructions

What is a Computer Instruction

The instruction sets are typically designed by prioritizing the requirements of the program as well as the processor.

Though the common concept of computer instructions refers to the set of commands given to the processor, in reality it can have varied meanings.

Looking beyond the computer processor, there can be another general definition of a computer instruction set which is a version of a constituent of an executable computer program. It basically prompts the computer to carry out a specific function.

Generally, the computer instructions involve a set of documentation or steps to follow. This information may include different aspects such as:

On conventional computer architectures, an instruction may also include an opcode which may specify the operation to be performed such as:

It may also specify literal data, registers or memory locations and even the meanings of the addressing modes, especially in the operand specifiers, which may be in predetermined fields.

With respect to computer hardware, the instructions given to a computer involve how to use the device.

However, these instructions are provided with the device driver.

When a computer receives an instruction, it uses the software or operating system to translate the set of commands into a language that can be understood by the computer.

The software or operating system is however programmed by a human, once again.

The instructions may be of different length or size. It may vary from as little as 4 bits, typically used by the microcontrollers, to many multiples of bytes that are used by the Very Long Instruction Word or VLIW systems.

The VLIW architectures typically include several microcode architectures and therefore can perform multiple operations and operands at the same time.

For this reason, they need several instructions in a single set of commands, which make their instructions so long.

However, as is the case with modern personal computers, mainframe computers and supercomputers, the sizes of the instructions may range anywhere between 16 bits and 64 bits.

There are some instructions that may also have a fixed length. These instructions are used by some specific types of computer architectures, such as the Reduced Instruction

Read Also:  How to Clear Task Manager? (4 Methods)

Set Computer or RISC. The size of these particular instructions typically corresponds to the word size of the computer architecture.

What Are the Types of Computer Instructions?

The types of computer instructions can be data transfer and manipulation, input and output, and program sequencing and control instructions.

Usually, these are categorized under three major groups or fields such as:

Based on the above parameters, there are different types of instruction sets, each with their respective usage. These are:

Register and memory stacks also use short and simple instructions to store data instructions in LIFO or Last In First Out pattern to evaluate and backtrack algorithms.

A kind of CPU register called the accumulator also stores intermediate values temporarily used for mathematical and logical calculations with short and simple instructions.

GPR or General Purpose Register stores 8-bit data represented by 6 figures such as B, C, D, H, and L temporarily in the microprocessors.

This set of instructions can also be used for 16-bit operations by combining the general pair of registers such as DE, HL, and BC with short instructions.

What is Instruction with Example?

Examples of computer instructions can be varied and many, and are usually given in 1s and 0s only since that is the only language a computer can understand. It can be an opcode, load or move information bits.

A few typical examples of computer instructions are:

Depending on the software or application, the set of instructions may vary. For example, if you are using Logo and want to draw a square, the complete set of instructions will be:

The examples of instructions may also vary based on their respective formats. For example:

The examples of Memory Reference Instruction format can be OPCODE 000 to 110, Register Reference Instruction format can be OPCODE 111 AND addressing mode I = 0 and Input and Output Instruction format can be OPCODE 111 AND addressing mode I = 1.

Read Also:  Computer Apps and Their Types Explained

There are also a few specific, simpler instructions to store data given to accumulators, memory and register stacks and General Purpose Registers, as mentioned earlier.

What Are the Types of Instruction Format?

There are three formats used for an instruction code for a basic computer namely, memory – reference instruction, register – reference instruction, and input – output instruction.

12 bits of memory are used in memory – reference instruction to denote the address and a single bit to specify the addressing mode I.

Register – reference instruction denotes a test of or an operation on the accumulator register by an op code 111 with the leftmost bit 15 represented by a 0 in the instruction.

The input-output instruction does not need any reference to the memory just like the register-reference instruction.

It is represented by the op code 111 but the leftmost bit is a 1. The other bits are used to denote the type of input output operation or test to be executed.

There are three parts of an instruction format. These are:

The types of instruction format are:

What Are Five Types of Instruction Operations?

The five basic types of operations common to several instruction sets are data handling and memory, arithmetic and logic, control flow, coprocessor instructions and number of operands.

The data handling and memory operations include:

Arithmetic and logic operations include:

Control flow operations include:

Coprocessor instruction operations include:

Specific machines used different numbers of operands such as:

Sometimes, some complex operations are also performed such as:

These complex instructions are mainly used as CISC instructions and sometimes may include RISC instruction sets in them.

What Are the Components of Instructions?

The major components of a computer instruction are operands and opcodes which involve the data of the instructions to be carried out and the specific instruction to be performed, respectively.

The opcode helps in identifying the particular operation carried out by the instruction. The operands, on the other hand, contain the elements of operations which include:

There can be different types of operands and opcodes which is why the instructions can be of different sizes and occupy diverse bytes in the memory of the computer.

There can be a few specific instruction types that may not come with any operands shown explicitly. In these instructions, the operands are often implied.

What Are the Steps in Which an Instruction is Executed?

There are six specific stages in which instructions are executed such as fetch, decode, arithmetic, memory access, register update, and Program Counter or PC update.

In the fetch stage the instruction is fetched from the main memory and current Program Counter and stored in the Instruction Register.

In the decoding stage, the stored instruction in the IR is interpreted.

Arithmetic operation is done by using the Arithmetic Logic Unit by taking in two values as input and giving one as output.

Memory is accessed for only two specific types of instructions such as LOAD and STORE while other instructions skip this stage.

The register file is updated with the output result of the ALU written back. This step is not needed for BRANCH and JUMP instructions.

Finally, the PC is updated at the end of execution of an instruction.

No matter what, computer instructions cannot be executed if they are not complete. It has to have an adequate number of instructions in the following categories:

There are few good reasons to say so.

Ideally, the arithmetic, logic and shift commands will offer computational ability to the CPU. Moving instructions to and from processor register and memory is required because a large amount of binary information is held by the memory unit.

However, the actual processing is done in the processor registers. It will not be possible if the ability to move data and information is nil or restricted.

Program control and status checks the necessary instructions for changing the sequence of program execution when needed.

Finally, the input and output instructions are necessary to create an interface between the user and the computer to transfer data to the memory and computational results to the user.

Who Gives Instructions to a Computer?

Technically, the instructions to a computer are given by the input devices attached to the system such as the keyboard, mouse and others.

However, looking at it from a broader aspect, it is actually the humans who give the instructions to the computer through these input devices.

Conclusion

The computer instructions play a very important role in the functioning of the system and carrying out the commands given to it.

Given in a set of codes, these instructions are easily understood by the computer. Usually given by the user through the input devices, instructions are mainly carried out by the processor.