Memory block calculations : optimize?

Windows specific forum
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Memory block calculations : optimize?

Post 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)
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Post 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?
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Post 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:
Post Reply