You use them daily without knowing it, but what are your CPU instructions


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.

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 (0, 1) 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.

Instruction routing

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.

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

Instruction types in a CPU

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 a relationship 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.
  • The instructions for manipulating bits are based on manipulating the bits of a chain idem with instructions as to move a bit to the left or right, reverse the order or switch them.
  • The instructions for data movement responsible for moving data from one party to another memory from one memory to another, from the processor to memory and from memory to the processor.
  • The instructions control program are those that are activated at the given certain conditions.
  • 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

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.

Post a Comment

0 Comments