Skip to content

Instantly share code, notes, and snippets.

@bitnenfer
Created February 12, 2016 13:23
Show Gist options
  • Save bitnenfer/46f4e5f02bda7604c114 to your computer and use it in GitHub Desktop.
Save bitnenfer/46f4e5f02bda7604c114 to your computer and use it in GitHub Desktop.
inline static void sse_mat4_add(__m128* m0, __m128* m1, __m128* dst)
{
__asm
{
// First load the args addresses
// into ecx, edx and edi registers.
mov ecx, m0
mov edx, m1
mov edi, dst
// Do a an aligned move of m0
// to xmm0 vector register
movaps xmm0, [ecx]
// Add the first rows of m0 and m1
addps xmm0, [edx]
// Store xmm0 value on dst first row
movaps[edi], xmm0
// Here we repeat the same for each row
// of our 4x4 matrix.
movaps xmm0, [ecx + 10h]
addps xmm0, [edx + 10h]
movaps[edi + 10h], xmm0
movaps xmm0, [ecx + 20h]
addps xmm0, [edx + 20h]
movaps[edi + 20h], xmm0
movaps xmm0, [ecx + 30h]
addps xmm0, [edx + 30h]
movaps[edi + 30h], xmm0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment