assemblyx86instruction-setinstructionsopcode

What exactly does the 3-operand imul instruction do in ia-32 assembly?


I'm reading the instruction

imul 0xffffffd4(%ebp, %ebx, 4), %eax

and I'm baffled by what it's doing exactly. I understand that imul multiplies, but I can't figure out the syntax.


Solution

  • Hooray for AT&T assembly base/index syntax! It's not a 3-operand multiply at all. It's the same 2-operand one you know and love, it's just that the first one is a bit complicated. It means:

    %ebp + (4 * %ebx) + 0xffffffd4
    

    Or:

    %ebp + (4 * %ebx) - 44
    

    To be a bit clearer (and in base 10). The AT&T base/index syntax breaks down as:

    offset(base, index, multiplier)