Instruction of a CPU, What it is, What it is for and Its Types

We have already covered the way in which CPUs execute instructions, which is called the instruction cycle. But what is an instruction when we talk about processors? If you do not know it or the word leads you to confusion, then do not worry, once you read this article in full, you will understand without problem what the instruction of a computer program is.

The CPUs of millions of computers around the world only know how to do one thing, execute instructions continuously. But what is an instruction? Read on to find out.

Instruction of a CPU

What is an instruction?

An instruction is the minimum unit of a program, which tells the CPU what to do through a series of instructions that are executed sequentially. Each instruction is a number of bits in the binary code that is divided into three different parts:

  • Instruction bits: these bits indicate which instruction the CPU will execute and therefore the path that the instruction will follow to execute, is also called opcode.
  • Addressing bits: indicate in which memory address the data is in memory.
  • Mode bits: The mode bits indicate how an instruction is executed, they are used when there are several ways to execute an instruction or there are different conditions.

If you want to know the way in which a CPU executes the instructions, we recommend the article ” This is how your CPU executes the instructions that the software gives it ” in HardZone, this same website.

Addressing instructions

CPU RAM

Depending on where the data is, we can have different variations of the same type of instruction, the way in which a processor accesses the data is called addressing mode.

  • The immediate addressing is used when the data is the same instruction, in this case the data is stored in a register or internal memory of the processor to be executed from there.
  • The second type of addressing is direct, where the program indicates the memory address where the data is located.
  • The third type of addressing is indirect, which gives us the address where the memory address where the data is located is located.

It should be clarified that some instructions do not have an addressing mode, since they do not require data to be executed.

Instruction types in a CPU

RISC-V_3

Here is a summary of the most common instructions used by the different processors. These instructions are common to all register and instruction sets, regardless of whether they are x86, ARM, MIPS, PowerPC, and so on. As well as it does not have relation if the set of instructions is RISC or CISC.

  • Arithmetic manipulation instructions are those that perform mathematical manipulation operations such as addition, subtraction, multiplication, and division. As well as more complex operations such as trigonometric formulas, square roots, powers.
  • The logic instructions are the second type of instructions executed by the ALU, they are actually binary operations that emulate the operation of logic gates. That is, AND, OR, XOR, NAND, NOR, XNOR, and NOT.
  • Bit manipulation instructions are based on manipulating the bits of an idem string with instructions such as shifting a bit to the left or right, reversing the order or switching them.
  • Data movement instructions are responsible for the movement of data from one part of memory to another, from one memory to another, from processor to memory and from memory to processor.
  • Program control instructions are those that are activated when certain conditions are met, such as
  • The jump instructions are those that indicate that the program does not continue to the next memory address, but to a specific memory address that is marked by the jump instruction.

Data types and multiplicity of instructions

Procesadores

Because a CPU today can deal with different types of data, for example integers and floating point. Some arithmetic instructions are often duplicated for the floating point instruction set. There are also vector instructions, such as AVX instruction sets, or also known as SIMD instructions, which operate with several operands at the same time.

Since these instructions are executed in different units, they end up requiring different instruction bits, which means that the addition of new types of data in a processor means in many cases considerably increasing the set of instructions, their complexity. . as well as the part that decodes and executes them on a CPU.