What’s the Difference Between Eax Ebx Ecx in Assembly

I’m trying to learn some assembly, but I have a hard time understanding what some basic things do. Is the eax ebx ecx just variables or do they have all have a unique specific use other than storing values?

2

2 Answers

eax, ebx, ecx and so on are actually registers, which can be seen as "hardware" variables, meaning different than higher level-language's variables. Registers can be used in your software directly with instructions such as mov, add or cmp. The leading e means extended that is your register is 32 bits wide. On the other hand, 64-bits registers begin by r.

These registers are not all used the same purposes as illustrated below. This graphic show the register usage for Linux 64-bit ABI.

All registers are not described in this capture though. For instance *ipis a special register (process counter) that holds the next instruction to bo executed.

You can find the full ABI there. Some information is specific to Linux but most remains relevant for any POSIX-compliant system.

1

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.

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Maya Lin-Takahashi

Maya Lin-Takahashi

Consumer Tech & Gadget Reviewer

Maya is a hardware enthusiast who tests and reviews smart home devices, smartphones, wearables, and audio gear. She focuses on practical consumer value and build quality.

Share this article
Twitter Facebook Pinterest