lea ecx,[eax-1]
test eax,ecx
je power2

That is good one.
Thanks for the idea.
Posted on 2002-04-21 07:05:47 by The Svin
The Svin, you may remove MMX ops:

bsr ecx,eax
lea edx,[eax-1]
test eax,edx
je @powerof2 ; ecx - shift
mov [shift],ecx
mov edx,1
shl edx,cl
mov [d,r+0],0
mov [r+4],edx
fild [r]
Posted on 2002-04-21 07:55:19 by Nexo
Nexo, it's good idea so that the app can be used on
older procs wich don't have MMX.
I just change a lit bit implementation to make it shorter in bytes:

r dq ?
ldivider dq ?


bsr ecx,eax
lea edx,[eax-1]
mov edi,offset r
test eax,edx
je @powerof2
xor edx,edx
mov [shift],ecx
mov [edi],edx
mov [edi+12],edx
inc edx
mov [edi+8],eax
shl edx,cl
mov [edi +4],edx

fild qword ptr [edi]
fild qword ptr [edi+8]
Posted on 2002-04-21 10:22:51 by The Svin
It's nothing special about this version.
I just coded it a little bit more carefull. Speed and size improved.
Though I don't think that size and speed is matter for the app in previous
version too, even if it run on i486 :)
But it is normal expect that if code is submitted to the section it must be
done approprate way no matter whatever.
So I improved several lines. Code included so you can compare the difference yourselve.
In addition I accepted Nexo's suggestion to remove MMX from the code
so that the app can be run on any processor from i486 DX.
Size is now 3,5 kb.
Posted on 2002-04-21 13:48:49 by The Svin
Then divider = 67.

mov edx,0F4898D60h
mul edx
SHR edx, 6

But code

mov edx,07A44C6Bh
mul edx
shr edx,1

is shorter on 1 byte.
May be adjust paremeters needs.
Posted on 2002-04-21 14:36:00 by Nexo
Svin, this is an interesting discussion started by your tool. Is there an easy way to get the remainder without DIV? I understand we can use two MUL, but there are many dependancies.

Where can I download this tool please, and has anyone found an easy way to get the remainder yet, please? Actually, I would be happy just to be able to detect IF there is a remainder...
Posted on 2004-12-13 23:15:46 by V Coder
Posted on 2004-12-14 19:13:37 by The Svin