Hi all,
I'm having problems using a local variable as a displacement in a procedure.
SomeProc PROC dwWidth:DWORD,dwHeight:DWORD
LOCAL Something:DWORD
.
.
.
fstp REAL4 PTR[edi+Something]
.
.
.
ret
SomeProc ENDP
I have checked the value of Something and it contains the correct value. If for a given situation I substitute 12 or ebx for Something it works fine. To be functional Something could vary over the course of execution. I'm in a multi-layered loop and all my registers are in use.
Any guidance would be appreciated.
Thanks for your time and consideration,
Darrel
your local variable is accessed by [ebp+8]. Therefore your instruction gets translated by the preprocessor into
fstp real4 ptr [edi+[ebp+8]]
The above is not a valid x86 instruction.
Solution: put Something into a register.
Darrel,
There are opcodes that allow a data section variable known at assembly time to be used both as the base address and as a displacement but it cannot be done with a stack variable.
Are you sure? I don't think that any memory location can directly be used as a pointer, you must put it into a register first. Do you remember the discussion between:
mov eax,hInstance
mov eax,[hInstance]
Thanks for the replies,
I was planning on either putting the variable in the data section or moving it to a register. Just thought I'd check and see if I was missing something.
I do believe I have used a data section variable as an address displacement before.
Thanks again,
Darrel
push hInstance
pop wc.hInstance
... how I remember well. Dirty little registers.
thomas