The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: untio on October 05, 2010, 01:37:04 PM

Title: Why this does not work
Post by: untio on October 05, 2010, 01:37:04 PM
Hi to all,

I am writing a dll to read the tags from an mp3 file. Obviously, I have started with the version 1 of the tags. But a problem raised:
I pass to a procedure a pointer that points to the integer to hold the track number. When I write in memory using this pointer directly:
mov [pointertotracknumber], eax
I receive strange results.
When I do exactly the same thing using a register:
mov ebx, pointertotracknumber
mov [ebx], eax
All works fine.

And my question is why this happens and when is correct:
mov [pointertosomething], some value

Thanks in advance.
Title: Re: Why this does not work
Post by: redskull on October 05, 2010, 01:41:16 PM
You can't use a value in memory to write into other memory.  MASM does funny things with brackets (or, at least non-standard things), so you are basically removing thre brackets and changing the pointer itself.

-r
Title: Re: Why this does not work
Post by: untio on October 05, 2010, 02:39:47 PM
Thanks for your answer redskull.
After google a lot I have found that it is not possible to dereference using a memory address. It must be done using a register.
Thanks once more.