Explonation:
101001 = 100000+1000+1
101001*11 = 101001b 11b times
101001*11= 101001*(10+1)=101001*10+101001*1 =
101001 10 times + 101001 1 time
Example:
given x,y,z
Find x*z ,y*z

mov eax,x
mov edi,y
mov ecx,z
xor edx,edx
xor ebx,ebx
@1: shr ecx,1
jnc @F
lea edx,
lea ebx,
@@: je @end
shl eax,1
shl edi,1
jmp @1
@end: ;edx=x*z ; edi = y*z
Posted on 2002-02-22 20:22:09 by The Svin
I'm not saying this is the fastest way to do this. :)
MUL64 MACRO z64:REQ,y64:REQ,x64:REQ

LOCAL mLoop,TheEnd

pushad
mov esi,DWORD PTR [y64 + 4]
mov edi,DWORD PTR [y64]
xor eax,eax
xor edx,edx
mLoop:
shl eax,1
rcl edx,1
shr esi,1
rcr edi,1
mov ebp,esi
sbb ecx,ecx
sbb ebx,ebx
and ecx,DWORD PTR [x64]
and ebx,DWORD PTR [x64 + 4]
add eax,ecx
adc edx,ebx
or ebp,edi
jne mLoop
TheEnd:
mov DWORD PTR [z64],eax
mov DWORD PTR [z64 + 4],edx
popad
ENDM


_DATA SEGMENT
s_64 dq 5
t_64 dq 5
u_64 dq 0
_DATA ENDS

MUL64 u_64,s_64,t_64
Posted on 2002-02-22 21:28:10 by bitRAKE
It's not algo contest.
It's 1st grade arithmetic class for asm beginners.
You need to explain and prove then your algo from math point of view.
Please.
Posted on 2002-02-22 22:02:22 by The Svin
Multiply 8 dwords in a raw.
Reorganize control blocks more effective way.
For people expirienced in math - please, submit more interesting
example and tasks wich can give good chance for beginner to
understand deeper positioned number systems aspects.
I wrote full explonation to the code but it dies 'cause using
tab I always do something in this editor that makes my post disapear :)


.586
.model flat,stdcall
.MMX
option casemap:none
mm0 equ mm(0)
mm1 equ mm(1)
mm2 equ mm(2)
mm3 equ mm(3)
mm4 equ mm(4)
mm5 equ mm(5)
mm6 equ mm(6)
mm7 equ mm(7)
.data
numb dd 1,2,3,4,5,6,7,8
mult dd 5
.data?
.code
start:
;
;paddd
mov eax,offset numb
mov ecx,mult
pxor mm0,mm0
pxor mm1,mm1
pxor mm2,mm2
pxor mm3,mm3
movq mm4, [eax]
movq mm5, [eax+8]
movq mm6, [eax+16]
movq mm7, [eax+24]
test ecx,ecx
je @write
jmp @start
@1: paddd mm0,mm4
paddd mm1,mm5
paddd mm2,mm6
paddd mm3,mm7
@2: psllq mm4,1
psllq mm5,1
psllq mm6,1
psllq mm7,1
@start: shr ecx,1
je @end
jc @1
jmp @2
@end: paddd mm0,mm4
paddd mm1,mm5
paddd mm2,mm6
paddd mm3,mm7

@write: movq [eax],mm0
movq [eax+8],mm1
movq [eax+16],mm2
movq [eax+24],mm3

Posted on 2002-02-23 19:31:56 by The Svin