0
int А;
int32_t matr1[10] = { 3,10,100,1000,2,40,200,3}; // first matrix
int32_t result[10] = {}; //result
...
_asm{
lea eax,[matr1]
lea edx,[result]
movq mm0,[eax]
movd[edx],mm0

}

How can I continue the code so that for example the 3 element of the array is stored in the variable A. That is, I only need to take one element and save it to a variable

Kris
  • 13
  • 3
  • 2
    Do you have to use assembly? Intrinsics are much simpler – Alan Birtles May 30 '21 at 06:15
  • What do you mean "continue"? You don't load 3 elements, or element `matr1[3]`, only `matr1[0]` and `matr1[1]`, two `int32_t` dwords in the two halves of `mm0`. Are you still thinking of 16-bit word elements like in your last question, where you were using `paddw` on your data from 32-bit dword arrays? – Peter Cordes May 30 '21 at 06:25
  • Anyway, use `pshufw` or `punpckhdq`, or `psrlq` to shuffle/shift it to the bottom so you can `movd`. If you care about this working on Pentium-MMX, double check whether any of those were new only in Pentium-III along with SSE1. (i.e. new MMX instructions sometimes called MMXEXT). Also, you don't need LEA, that just makes MSVC inline asm's inefficiency even worse. – Peter Cordes May 30 '21 at 06:26
  • Or do you mean the `matr1[0]` element that has value `3`? Obviously `movd [A], mm0`, just like how you stored it into `result[0]`. If you weren't using MSVC inline asm, or if you want to do more with the scalar value, you might `movd eax, mm0` to have the value in an integer register. IIRC, https://www.agner.org/optimize/ has a section on MMX, or at least on SSE2, in his optimization guide. – Peter Cordes May 30 '21 at 07:20
  • Everything worked out, thank you – Kris May 30 '21 at 07:26

0 Answers0