Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meaning of (%eax) in AT&T syntax?

You'll have to excuse me, I'm brand new to x86 assembly, and assembly in general.

So my question is, I have something like:

addl %edx,(%eax)

%eax is a register which holds a pointer to some integer. Let's call it xp

Does this mean that it's saying: *xp = *xp + %edx? (%edx is an integer)

I'm just confused where addl will store the result. If %eax is a pointer to an int, then (%eax) should be the actual value of that int. So would addl store the result of %edx+(%eax) in *xp? I would really love for someone to explain this to me!

I really appreciate any help!

like image 591
kodai Avatar asked Oct 24 '09 21:10

kodai


People also ask

What is the meaning of ex in relationship?

Definition of ex (Entry 1 of 8) : one that formerly held a specified position or place especially : a former spouse or former partner in an intimate relationship. ex.

What is mean ex in English?

/eks/ Someone's ex is a person who was their wife, husband, or partner in the past: Is she still in touch with her ex?

Is ex in the Oxford dictionary?

ex_1 noun - Definition, pictures, pronunciation and usage notes | Oxford Advanced Learner's Dictionary at OxfordLearnersDictionaries.com.

What does ex in ex boyfriend stand for?

ex- is a word-forming element, which in English simply means "former" in this case, or mainly "out of, from," but also "upwards, completely, deprive of, without. It most likely originated in Latin, where ex meant "out of, from within," and perhaps, in some cases also from Greek cognate ex, ek.


1 Answers

Yes, this instruction is doing exactly what you think it's doing.

Most x86 arithmetic instructions take two operands: a source and a destination. In AT&T syntax (used here), the destination is always the right operand. So with an instruction like:

addl %edx, %eax

the values in edx and eax are added together and the result is stored in eax. However, in your example, (%eax) is a memory operand; that's what parentheses mean in AT&T syntax (like square-brackets in NASM syntax).

This means that eax is treated as a pointer, so the right operand is taken from the address pointed to by eax, and the result is stored to the same address.

like image 130
Jay Conrod Avatar answered Oct 11 '22 09:10

Jay Conrod