Riptyde4
Riptyde4

Reputation: 5460

Having trouble understanding memory addressing in assembly

I'm looking at a piece of assembly code and I'm stuck trying to make sense of something:

incl (%ebx, %eax, 4)

What exactly does this do? I tried plugging it into a .s file and compiling then watching registers in GDB but when it passes the instruction after I set ebx to an address and eax to 1 it changed nothing... I'm guessing I don't understand how to use it properly. Can anyone help?

Upvotes: 0

Views: 132

Answers (2)

johnfound
johnfound

Reputation: 7061

I would suggest to not use GAS and AT&T syntax. It is especially invented in order to obfuscate the syntax and to make it unclear and unattractive for the beginners.

This syntax is created to be used by a back-ends for the HLL compilers. Human written programming with it is a masochism.

Even I (with 25 years of assembly programming background) hardly can recognize the normal instruction:

    inc dword [ebx+4*eax] 
; increment a double word at memory address (ebx+4*eax)

Use FASM instead. It has clear, human-centric syntax, best for hand written assembly programs.

Upvotes: 0

Scott Hunter
Scott Hunter

Reputation: 49803

It isn't incrementing a register; it is incrementing a memory location computed from the contents of the registers in the the instruction.

Upvotes: 2

Related Questions