matrix multiplication

From: AsYoDe (heeeeres_at_johny.pl)
Date: 04/16/04


Date: Fri, 16 Apr 2004 17:56:49 +0000 (UTC)


Hi.
About 2 hours ago I wrote following code.
How can even more optimize it not using
mmx instructions?
Sorry for my english,
and thx from advance.

AsYoDe

--code-- [NASM syntax]

 xor eax, eax xor ebx, ebx
 xor ecx, ecx
 xor edx, edx
 xor esi, esi
;array A i[ebx] wiersz, k[edi] kolumna
;array B k[edi] wiersz, j[ecx] kolumna
;array C i, j
;esi contains addictions of mul result

 mov ebx, 4 ;we beginning from the end
loop1:
 dec ebx
 mov ecx, 4
 loop2:
  dec ecx
  mov edi, 4
  xor esi, esi ;
  loop3:
   dec edi ;
   mov ax, [A + 4*ebx + edi] ;load value from A
   mov dx, [B + 4*edi + ecx] ;from B
   mul dx
   shl edx, 8 ;shift bits to the MS part of register
   mov dx, ax ; now in edx i have complete result
   add esi, edx ;add the result
   test edi, FFFFFFFFh
   jnz loop3 ;if edi<>0 then repeat loop
  mov [C + 4*ebx + ecx], esi ;write result to the C
  test ecx, FFFFFFFFh ;
  jnz loop2 ;if index <>0 then repeat
 test ebx, FFFFFFFFh ;
 jnz loop1 ;the same for i index



Relevant Pages

  • Re: misc: a few operations (long long division?...)
    ... eax, ecx, edx, ebx, ebp, esi, and edi. ...
    (alt.lang.asm)
  • misc: a few operations (long long division?...)
    ... push ebx; push ecx ... push edi; push esi ... push edx; push eax ... bt edx, 31; jnc .l1 ...
    (alt.lang.asm)
  • PosEx submission - SSE2 now
    ... test edx, edx ... xor ebx, ebx ... test ecx, ecx ... mov esi, ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode Int64Div
    ... mov edx, ... push esi // Save ESI as per calling convention. ... push edi // Save EDI as per calling convention. ... mov esi, ecx // divisor_hi ...
    (borland.public.delphi.language.basm)
  • Re: Fastcode Int64Div
    ... push esi // Save ESI as per calling convention. ... push edi // Save EDI as per calling convention. ... mov esi, ecx // divisor_hi ... mov edi, edx // dividend_hi ...
    (borland.public.delphi.language.basm)