Created
April 9, 2010 02:40
-
-
Save abuiles/360825 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%define numN ebp+8 | |
%define numM ebp+12 | |
%define numConstante ebp+16 | |
%define dirMatrizA ebp+16 | |
%define dirMatrizB ebp+20 | |
%define dirMatrizRespuesta ebp+24 | |
segment .data | |
;; Define an NxM matrix (2x3 this time for testing) | |
msg2: dw "%lf ,",10,0 | |
segment .bss | |
matrix: resd 1 | |
n: resd 1 | |
m: resd 1 | |
size: resd 1 | |
_i: resd 1 | |
_j: resd 1 | |
transpose: resd 1 ;Transpose | |
count: resd 1 | |
aux: resd 1 | |
aux2: resd 1 | |
aux3: resd 1 | |
segment .text | |
global transpuesta:function | |
transpuesta: | |
mov dword [_i],0 | |
mov dword [_j],0 | |
push ebp | |
mov ebp,esp | |
mov dword edx,0 | |
mov dword eax,[numN] | |
mov dword [n],eax | |
mov dword eax,[numM] | |
mov dword [m],eax | |
mul dword [numN] | |
mov dword [size],eax | |
mov ecx,[n] | |
mov dword eax, [dirMatrizA] ;; Coloca la dirección de la matriz A en eax | |
mov [matrix],eax | |
mov dword eax, [dirMatrizB] ;; Coloca la dirección de la matriz B en ebx | |
mov dword [transpose],eax | |
lpi_begin: ;while i<n | |
mov dword[_j],0 ;j = 0 | |
lpj_begin: ;while j<m | |
mov eax, dword[_i] ;eax = i | |
mul dword[n] ;eax = i*n | |
add eax, dword[_j] ;eax = (i*n)+j | |
mul dword[size] ;eax = size*((i*n)+j) | |
mov ebx,matrix ;ebx = &matrix[0] | |
add ebx,eax ;ebx = &matrix[size*((i*n)+j)] | |
mov ecx,[ebx] ;ecx = matrix[size*((i*n)+j)] --> The element | |
mov eax, dword[_j] ;eax = j | |
mul dword[m] ;eax = j*m | |
add eax, dword[_i] ;eax = (j*m)+i | |
mul dword[size] ;eax = size*((j*m)+i) | |
mov ebx,transpose ;ebx = &transpose[0] | |
add ebx,eax ;ebx = &transpose[size*((j*m)+i)] | |
mov [ebx],ecx ;transpose[size*((j*m)+i)] = matrix[size*((i*n)+j)] | |
lpj_ends: | |
inc dword[_j] ;j++ | |
mov eax, dword[n] ;eax = m | |
cmp dword[_j],eax ;if j<m: goto lpj_begin | |
jl lpj_begin | |
lpi_ends: | |
inc dword[_i] ;i++ | |
mov eax, dword[m] ;eax = n | |
cmp dword[_i],eax ;if i<n: goto lpi_begin | |
jl lpi_begin | |
jmp exit | |
exit: | |
leave | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment