开发者

Question about lea instruction, IA32

开发者 https://www.devze.com 2023-03-10 07:21 出处:网络
If I have an IA32 instruction like开发者_运维百科 the following: lea 0x4(x1, x2, x3), %eax What do x1, x2, and x3 represent?

If I have an IA32 instruction like开发者_运维百科 the following:

lea 0x4(x1, x2, x3), %eax

What do x1, x2, and x3 represent? Thanks.


If you mean "what is lea for," follow the link in Greg's comment.

If your question is about the syntax and are familiar with Intel syntax (but not AT&T syntax), x1 is the base, x2 is the index, and x3 is the scale (with 0x4 being the displacement). Thus,

lea 0x4(x1,x2,x3),%eax

is equivalent to

lea eax,[x1+x3*x2+4]

See this article on SourceForge for more.


They are a base register, an index register, and a scale value. So, it's useful for calculating the address of an element of an array base of elements of size scale at position index, i.e. in C:

base[index]

where scale will be 1 for a char array, 2 for a short array, ... on typical C compilers for x86.

0

精彩评论

暂无评论...
验证码 换一张
取 消