News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

SSE Beginner Question

Started by Compuholic, January 01, 2006, 02:39:51 PM

Previous topic - Next topic

Compuholic

I recently became interested in playing around with SSE. I've read a couple articles about it and I think I got the concept the problem is the lack of code exaples (Preferably in MASM-Syntax).

I guess the main Problem I have right now is: How to put the data in the Registers. I found instructions like "movaps dest, src" to do that. But all of those instructions copy all values at once. Is there a way to copy a single-precision value to the lowest DWORD then another value to the next higher DWORD?

Let's say I want to copy 5.0, 2.0, 10.0 and 7.0 into xmm0. How would I do that?

Thanks for your help.

P.S. I would also appreciate links to good code examples concerning SSE.


zooba

Quote from: Compuholic on January 01, 2006, 02:39:51 PM
Let's say I want to copy 5.0, 2.0, 10.0 and 7.0 into xmm0. How would I do that?


ALIGN 16    ; this is essential if you're going to use movaps, otherwise use movups
rNumbers DWORD 5.0, 2.0, 10.0, 7.0

movaps xmm0, rNumbers


Cheers, :U
Zooba

Compuholic

Thanks a lot for your help.

One more question: Is there an instruction that just writes a value to a random place in the register?
For example: Is it possible to just replace the 10.0?

zooba

There's no single instruction that I know of. movss can be used to replace the least significant value (in this case, I think it'd be the 5.0) so your alternatives are to store the entire register to memory, change it there and read it back, or shuffle it so the 10.0 is the least significant, change it and shuffle back.

SSE is designed for vector type operations where you want to modify 4 values at once. They don't make it easy to play with individual values (thats what the FPU is for, btw. there's no SSE version of fsin/cos/etc.) :U

Cheers,

Zooba