1

I'm reading an assembly book and I have stumbled upon an example:

...
dValue dd 0
mov dword [dValue], 27 ; dValue = 27
...

The author says dValue equals 27 after that snippet. As I understand it [] are used similarly to how the dereference operator is used in C. So this line: mov dword [dValue], 27 I would interpret it like something like this in C: *dValue = 27 which in this case would be dValue = 0 and at address 0 we would have 27.

Am I wrong? Please help me understand this. Thank you!

Cantaff0rd
  • 705
  • 1
  • 6
  • 14
  • 2
    `dValue dd 0` is like C `uint32_t dvalue[] = {0};` You need to deref the label to access memory at that location, otherwise you just get the label as an immediate address. Also, x86 asm has no memory-indirect addressing modes (loading a pointer from memory), so there's obviously no possible way that interpretation of the syntax could work. ([Referencing the contents of a memory location. (x86 addressing modes)](https://stackoverflow.com/q/34058101)). IIRC there was a Q&A like this a couple years ago, looking for it... – Peter Cordes Feb 14 '21 at 11:53
  • 4
    Think of a label in assembly as being like the address of a variable in C. So `mov dword [dvalue], 27` is `*&dvalue = 27`. – fuz Feb 14 '21 at 11:59
  • You are right, dValue (which is a label for an address) itself hasn't changed, only the value stored at the address dValue. But if we are familiar with assembly, we might call it "the dValue variable" or just "dValue" for short – user253751 Feb 25 '21 at 09:07

0 Answers0