Passing arguments into an Assebly function

33 Views Asked by At

I'm trying to pass some arguments into a function but it doesn't get them correctly. I want to multiply some matrices and I want to pass: address of matrix 1, address of matrix 2, address of the matrix i want the result to be in, and the size of the matrix.

matrix_mult:
pushl %ebp
pushl %ebx
pushl %edi
pushl %esi
movl %esp, %ebp

movl 8(%ebp), %edi
movl 12(%ebp), %esi
movl 16(%ebp), %ebx
movl 20(%ebp), %ecx

*the rest of the algorithm*

After those lines, the values in edi, esi, ebx, ecx are all wrong.

The function calling looks like this - trying to multiply matrix by itself and storing the result into matrix2. The matrix and msizze are stored correctly.

main:
*reading msize and matrix*

pushl msize
pushl $matrix2
pushl $matrix
pushl $matrix
call matrix_mult
addl $16, %esp

In the debugger it shows me that: edi = 2 esi = big negative value ebx = big positive value ecx = big positive value

0

There are 0 best solutions below