How to use vectors in assembly code x86 and SSE

3.2k views Asked by At

I don't know how to access a stl vector in x86. I have tried to do it like that but I have some errors.

mov ebx, stl_vector 
mov eax, [ebx] ;Here I want to store the first element of the vector
mov edx, [ebx + 4] ; I want to store the second element of the vector

I want to do the same in SSE language.

Thank you in advance!

1

There are 1 answers

4
Jester On BEST ANSWER

stl vectors are objects. Unless you know the exact class layout you can't access them directly. You should probably pass a pointer to the array and a size separately to your assembly function, e.g. asm(vector.data(), vector.size()) so the compiler takes care of the c++ stuff.