Some basic concepts related to x86 Instruction Set 02-22-2021, 07:27 PM
#1
An instruction set is a list of instructions that a processor understands.
These instructions are just a group of bytes. And x86 is a family of instruction set architecture.
You might also think that what's the difference between Assembly language and an instruction set, well, instruction set is a part/component of assembly language.
Note: There is no universal assembly language, because instruction set keeps on changing with change in processor type. Each processor type have their own set of instructions and thus, it all depends on what processor type it is. A 16-bit x86 processor will have a different instruction set than a 32-bit x86 processor.
In assembly, we have to deal with registers in order to get our work done, like if you want to perform some arithmetic operations between two numbers, these numbers need to be stored into registers first.
Register: A register is a hardware storage device that stores data temporarily, it resides in processor, also called global variable. Processors store their data in registers instead of memory because the process of storing data into register and retrieving data from register happens at a much faster rate.
In order to store a number into a register you'll need to write an instruction, something like mov eax, 7.
Now, you might also be wondering that, what's mov and eax, mov is an arithmetic instruction and eax is a 32-bit general purpose register. General purpose registers are used to store data and addresses. There are total 8 general purpose registers, each one of them is capable of storing 32-bit of data in them.
Addiing two numbers
mov eax, 3
mov ecx, 7
add eax, ecx
These are just rough instructions, you would've to write it in proper syntax.
List of some basic arithmetic instructions:
mov [move data]
ret [return from function]
add [addition]
sub [subtraction]
imul [multiply]
jmp [execute code elsewhere]
cmp [compare values or operands]
jlt [jump if less than]
That's it for this post!
These instructions are just a group of bytes. And x86 is a family of instruction set architecture.
You might also think that what's the difference between Assembly language and an instruction set, well, instruction set is a part/component of assembly language.
Note: There is no universal assembly language, because instruction set keeps on changing with change in processor type. Each processor type have their own set of instructions and thus, it all depends on what processor type it is. A 16-bit x86 processor will have a different instruction set than a 32-bit x86 processor.
In assembly, we have to deal with registers in order to get our work done, like if you want to perform some arithmetic operations between two numbers, these numbers need to be stored into registers first.
Register: A register is a hardware storage device that stores data temporarily, it resides in processor, also called global variable. Processors store their data in registers instead of memory because the process of storing data into register and retrieving data from register happens at a much faster rate.
In order to store a number into a register you'll need to write an instruction, something like mov eax, 7.
Now, you might also be wondering that, what's mov and eax, mov is an arithmetic instruction and eax is a 32-bit general purpose register. General purpose registers are used to store data and addresses. There are total 8 general purpose registers, each one of them is capable of storing 32-bit of data in them.
Addiing two numbers
mov eax, 3
mov ecx, 7
add eax, ecx
These are just rough instructions, you would've to write it in proper syntax.
List of some basic arithmetic instructions:
mov [move data]
ret [return from function]
add [addition]
sub [subtraction]
imul [multiply]
jmp [execute code elsewhere]
cmp [compare values or operands]
jlt [jump if less than]
That's it for this post!
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)