I have to make an algorithm that multiplies an array A by an array B and places the result in a third array. The arrays are square, of the same size and will be passed by reference by another C program.
The problem is that the errors only appear when I try to compile the .c, while the .asm is linked without problems and I have no idea where I'm going wrong. If anyone can give a light, I am 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