1
I have to make an algorithm that will multiply a matrix A by a matrix B and put the result into a third matrix. The matrices are square, of same size and will be passed by reference by another program in C.
The problem is that errors only appear when I try to compile . c, while . asm is linked smoothly and I have no idea where I’m going wrong. If anyone can shed some light, I’d be grateful.
;mulMatriz_asm(int mA[][MATRIZ_SIZE], int mB[][MATRIZ_SIZE], int mRes[][MATRIZ_SIZE], int mSize)
SECTION .text
global mulMatriz_asm
mulMatriz_asm:
incr equ 4
%define offma 0 ;deslocamento mA
%define offmb 0 ;deslocamento mB
%define offmres 0 ;deslocamento mRes
push ebp
mov ebp, esp
mov ebx, [ebp+20]
sub eax, eax
sub ecx, ecx
sub edx, edx
colRes:;edx -> k
push eax
push ecx
push edx
push ebx
mov eax, [ebp+8];*mA
mov eax, [eax+offma];ma[i][j]
mov ecx, [ebp+12];*mB
mov ecx, [ecx+offmb];mb[j][k]
mul ecx
mov edx, [ebp+16];*mRes
mov ebx, [edx+offmres];mRes[i][k]
add ebx, eax
mov [edx+offmres], ebx;mRes += mA * mB
mov eax, incr
mov ebx, offmb
add ebx, eax ;próxima coluna de mB
%define offmb ebx
mov ecx, offmres
add ecx, eax ;próxima coluna de mRes
%define offmres ecx
pop ebx
pop edx
pop ecx
pop eax
inc edx
cmp edx, ebx
jl colRes
colA:;ecx -> j
sub edx, edx
push edx
push ecx
mov edx, incr
mov ecx, offma
add ecx, edx ;próxima coluna de mA
%define offma ecx
mov edx, offmb
add edx, ebx ;próxima linha de mB
%define offmb edx
pop ecx
pop edx
inc ecx
cmp ecx, ebx
jl colRes
linhaA:;eax -> i
sub ecx, ecx
sub edx, edx
push ecx
mov ecx, offma
add ecx, ebx ;proxima linha de mA
%define offma ecx
mov ecx, offmres
add ecx, ebx ;proxima linha de mRes
%define offmres ecx
pop ecx
inc eax
cmp eax, ebx
jl colA
ret