I’m trying to learn some assembly, but I have a hard time understanding what some basic things do. Are EAX, EBX, and ECX just variables or do they all have a unique specific use other than storing values?
eax
, ebx
, ecx
and so on are actually registers, which can be seen as "hardware" variables, somewhat similar to higher level-language's variables. Registers can be used in your software directly with instructions such as mov
, add
or cmp
. The leading e
stands for extended and means that your register is 32 bits wide. On the other hand, 64-bit registers begin with r
.
These registers are not always used for the purposes illustrated below. This graphic shows the register usage for Linux 64-bit ABI.
Not all registers are described in this capture though. For instance *ip
is a special register (process counter) that holds the next instruction to be executed.
You can find the full ABI there. Some information is specific to Linux but most remains relevant for any POSIX-compliant system.
The EAX, EBX, ECX, EDX, EBP, EDI, and ESI registers are all 32-bit general-purpose registers, used for temporary data storage and memory access.
https://web.archive.org/web/20191114093028/https://gerardnico.com/computer/cpu/register/general
Some of CPU instructions modify specific registers. For instance, movsb
takes Source address from ESI and Destination from EDI, copies one byte and changes ESI and EDI registers.
In other words, you could use them as variables, but they also might have a specific purpose when using specific instructions.
You may want to consult the reference. Both Intel and AMD provide manuals, available online.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With