What is the 0x10 in the “leal 0x10(

前端 未结 4 722
故里飘歌
故里飘歌 2020-11-28 09:29

What the function is of the 0x10 in regards to this LEAL instruction? Is it a multiply or addition or is something else?

leal 0x10(%ebx), %eax
4条回答
  •  孤独总比滥情好
    2020-11-28 10:03

    GNU as 2.18 docs

    https://sourceware.org/binutils/docs-2.18/as/i386_002dMemory.html

    AT&T: -4(%ebp), Intel: [ebp - 4]

    and then the Intel Syntax is self explanatory.

    More importantly, the docs also explain the general case:

    An Intel syntax indirect memory reference of the form

     section:[base + index*scale + disp]
    

    is translated into the AT&T syntax

     section:disp(base, index, scale)
    

    where base and index are the optional 32-bit base and index registers, disp is the optional displacement, and scale, taking the values 1, 2, 4, and 8, multiplies index to calculate the address of the operand

    Things do get a bit messy in AT&T when we omit some parts of the address, e.g. -4(%ebp), but with the examples in the docs we can easily deduce all the syntax cases.

    To really understand what is going on, I recommend that you take a look at how instructions are encoded. This is a good tutorial: http://www.c-jump.com/CIS77/CPU/x86/lecture.html When you see that, it will become clear why some parts of the address may be omitted, and what each form will compile to.

提交回复
热议问题