Page 1 of 1

Memory block calculations : optimize?

Posted: Mon Aug 01, 2005 12:07 am
by eriansa
I want to optimize a process in a realtime thread.

The process takes a pointer to a memory block of variable length. (between 1 and 64k)
This memory block is filled with 32bit floats (between 0 and 1)
Every float has to be multiplied by a constant value -> [2^x], where x >0 and x<32)

Somebody any idea what could be the fastest routine?

Now I do it in a for next loop with peek and poke, but there must be a faster way in fasm...(storing the constant in a register first...)

Anybody knows how (perhaps by using some SSE registers?)

(i am a asm newbie)

Posted: Mon Aug 01, 2005 12:13 am
by Pupil
Maybe you can just add the number 'x' to the exponent part of the float?

This might look something like this(?):

Code: Select all

 ...
mov edx, x
 ...
mov eax, dword [ebp] ; ebp holds address to data
mov ebx, eax
shr eax, 23
add al, dl
and ebx, %10000000 01111111 11111111 11111111
shl eax, 23
or ebx, eax
mov dword [ebp], ebx
 ...
I havent tested the code so i can't tell if it'll work or if it'll be faster than using the FPU after all. I'm not familiar with SSE op:s so maybe there's some op there that does it all in one go?

Posted: Mon Aug 01, 2005 10:42 am
by eriansa
Pupil wrote:I'm not familiar with SSE op:s so maybe there's some op there that does it all in one go?
I think SSE is the way to go. (plus a speed course asm) :roll: