I am trying to use the SSE2 intrinsics to access the XMM registers but I'm having a problem. The intrinsic commands are calculating and returning the correct values on the first call to the function, but it crashes on the second call with an access violation.

Here is the code in question:
Code:
__m128i lsXMM0,lsXMM1,lsTotal;
	
__declspec(align(16)) unsigned __int16 laData[8]; // use to hold result

// Get row 0
lsXMM0 = _mm_load_si128((__m128i*)&gaRefFrame[anSampleYPos][anSampleXPos]);
lsXMM1 = _mm_load_si128((__m128i*)&gaCurFrame[anBlockYPos][anBlockXPos]);
// SAD Row 0 
lsTotal = _mm_sad_epu8(lsXMM0, lsXMM1);
// Get SAD results
_mm_store_si128((__m128i*)laData, lsTotal);

return laData[0]+laData[4];
On the second call to this code, the access violation occurs on the first mm_load with this:
Code:
Unhandled exception at 0x00402cd8 in findmv.exe: 0xC0000005: Access violation reading location 0xffffffff.
Is there something I must do to clear out the lsXMM0 structure to use it again? I would think it goes out of scope on exiting the function and gets redeclared on the next call.

Jason