Search code examples
cassemblyx86reverse-engineeringdecompiling

Is there a difference between the address operator and a pointer in assembly?


does the compiler translate the address operator any different than a pointer?

I'm wondering because the decompiler sometimes shows me:

func_test(&a, &b[0x32*ebx])

which should be essentially the same as

func_test((_DWORD *)a,(_DWORD *)(b+0x32*ebx))

correct? I'm mildy confused by the arithmetic tbh. Does it have any special meaning having it shown this way or is this just to read it easier?


Solution

  • &a returns the address of a, while (_DWORD *)a forces the compiler to reinterpret the content of a as a pointer to a _DWORD. so the two expressions are fundamentally different.

    It may be equivalent if a is an array of _DWORD (declared like _DWORD a[A_LENGTH];). In this case &a and a is essentially the same as a in pointer context degrades to a simple pointer, allthough the _DWORD * cast is redundant then.

    The expression for b is equivalent.