Hi Michael.
Good question! Most of the SIMD instructions require their memory operands to be aligned to 16 byte boundaries, which does rather restrict their general usage. The compromise, I will use in Oxygen is to load the operand into xmm7 (or some other xmm?) before prior to doing any arithmetic on it.
btw: MOVUPS accepts unaligned data MOVAPS does not.
Another consideration is accessing variables passed BYREF. I normally use VARPTR to resolve each address, not making any assumptions as to how the compiler will treat an BYREF variable within the assembler.
Charles
TYPE tpoint
x AS SINGLE
y AS SINGLE
END TYPE
DIM v1, v2,v3 AS TPOINT
SUB vec2Sub(a AS tpoint, b AS tpoint, c AS tpoint)
local pa,pb,pc as long
pa=varptr(a)
pb=varptr(b)
pc=varptr(c)
! mov eax,pa
! MOVUPS XMM0, [eax]
! mov eax,pb
! MOVUPS XMM7, [eax]
! SUBPS XMM0, XMM7
! mov eax,pc
! MOVUPS [eax], XMM0
END SUB
v1.x = 2.0
v1.y = 1.5
v2.x = 0.7
v2.y = 1.2
vec2sub(v1,v2,v3)