Search code examples
assemblyx86masmmasm32

Assembly masm32 return address to value


I have problem, here is example of my code, here is a sample

.model flat, stdcall 
.xmm
.data
    array dword 9.0, 6.0, 3.0, 6.0, 8.0, 4.0, 3.0, 4.0, 3.0
.code

cholesky PROC    

mov eax, [array]
ret ;return array through eax
cholesky endp
end

this code is compiled as DLL and I want to return a pointer to first array element. Now it returns 0x41100000 and that represents 9.0 in single precision float, but how to return an address for first element of this array?

I've tried to change

mov eax, [array]

to

mov eax, array

or

mov eax, dword ptr [array]

but still no effect.


Solution

  • You need to use LEA (Load Effective Address) to grab the address of a memory address instead of the value stored in that address:

    LEA eax, [array]