-2

I'm posting you a question from which I'll dive down in a re-reading of lots of code. Let's say I call a function and pass it as argument a certain value x...translated in MASM, I get:

MOV ECX, DWORD PTR [EBP+8]

What shall ECX get? The actual value of EBP+8 (let's say the value of variable x) or the address of variable x?

ECX will contain some memory address or the actual value x?

Thank you all! Best regards! N.

fonkap
  • 2,469
  • 1
  • 14
  • 30
Neurophobos
  • 11
  • 1
  • 4

1 Answers1

0

Actual value of variable.
See dword ptr usage confusion
or x86 Assembly Guide

Community
  • 1
  • 1
fonkap
  • 2,469
  • 1
  • 14
  • 30
  • Thanks a lot Fonkap! Just another question...what if instead of MOV there was LEA? – Neurophobos Mar 29 '14 at 22:14
  • Then ECX will contain the address. From the [Assembly Guide](http://www.cs.virginia.edu/~evans/cs216/guides/x86.html): "The lea instruction places the address specified by its second operand into the register specified by its first operand. Note, the contents of the memory location are not loaded, only the effective address is computed and placed into the register. This is useful for obtaining a pointer into a memory region." – fonkap Mar 29 '14 at 22:26
  • 1
    Note the DWORD PTR isn't needed in this case, since the size of the "other" operand is known when the "other" operand is a register. The most common case where DWORD PTR is needed is when using an immediate value with memory, such as | add dword ptr [ebx], 1 | . – rcgldr Mar 29 '14 at 23:46
  • Sorry, I'm reading the section, and it reports "lea eax, [var] — the VALUE in var is placed in EAX" It seems that eax will contain the actual value..or do I wrongly interpret the word "value" here? – Neurophobos Mar 29 '14 at 23:47
  • lea calculates an address and places that in the destination register. – rcgldr Mar 30 '14 at 01:12