The processors of millions of computers around the world only know how to do one thing, execute instructions continuously. But what is an instruction? Keep reading 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 which 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 an opcode.
- Address bits: indicate at which memory address the data is in memory.
- Mode bits: Mode bits indicate how an instruction is executed, they are used when there are multiple ways to execute an instruction or there are different conditions.
If you want to know how a CPU executes instructions, we recommend the article “This is how your CPU executes the instructions that the software gives itIn HardZone, this very site.
Addressing Instructions
Depending on where the data is located, there can be different variations of the same type of instruction, the way a processor accesses data is called addressing mode.
- Immediate addressing is used when the data is the same instruction, in which 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 is where the data is located.
It should be noted that some instructions do not have an addressing mode, because they do not require data to be executed.
Types of instructions in a CPU
Here is a summary of the instructions most commonly used by different processors. These instructions are common to all registers and instruction sets, whether they are x86, ARM, MIPS, PowerPC, etc. In addition, it has no relation whether the instruction set is RISC or CISC.
- The instructions of arithmetic manipulation These are the ones who 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 This is the second type of instructions executed by the ALU, they are in fact binary operations which emulate the operation of logic gates. That is, AND, OR, XOR, NAND, NOR, XNOR and NOT.
- the bit manipulation instructions, are based on the manipulation of the bits of a ditto string with instructions such as shifting one bit to the left or right, inverting the order or switching them.
- the data movement instructions They are responsible for moving data from one part of memory to another, from memory to memory, from processor to memory, and from memory to processor.
- the program control instructions are those that are activated when certain conditions are met, such as
- the jump instructions they are those which indicate that the program does not go to the next memory address, but to a specific memory address marked by the jump instruction.
Data types and multiplicity of instructions
Because a processor today can process different types of data, for example integers and floating points. 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 work with multiple operands at the same time.
Since these instructions are executed in different units, they end up requiring different instruction bits, which means that adding new types of data in a processor means in many cases significantly increasing the instruction set, their complexity. . as well as the part that decodes and executes them on a CPU.
Table of Contents