Assembly (,

2019-02-24 07:31发布

问题:

If one of my command lines says:

jmp   *0x804a180(,%eax,4)

what does that mean? I ask specifically because there is no value before the first comma and I'm not sure exactly what the * before the address means.

回答1:

This instruction jumps to the location whose value is located at the address calculated as %eax * 4 + 0x804a180.

The * is used in AT&T syntax to indicate indirect jumps and calls. It basically means "jump to the location pointed to by this, instead of the value of this". It is useful to differentiate the following instructions:

jmp myAddress  # Jumps to the location myAddress
jmp *myPointer # Jumps to the location contained at myPointer

As for the empty value, it is treated as 0. The full form of AT&T addressing is offset(%base, %index, multiplier), but any of these values can be left out. The default for each, except the multiplier (defaults to 1), is 0. Most of the time, you can just leave them out, but if you have an index and no base you need the comma there so that the assembler can tell which it is.