Created
April 5, 2010 21:14
-
-
Save abuiles/356906 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 | |
m1: dd 5,6,7,1,3,2,8,4,5 | |
m2: dd 3,6,4,3,8,2,5,1,1,3,6,7 | |
m1m: dd 3 | |
m1n: dd 3 | |
m2m: dd 4 | |
m2n: dd 3 | |
i: dd 0 | |
j: dd 0 | |
k: dd 0 | |
sum: dd 0 | |
segment .bss | |
mr: resd 12 | |
m1na: resd 1 | |
m1ma: resd 1 | |
m2na: resd 1 | |
m2ma: resd 1 | |
m1a: resd 1 | |
m2a: resd 1 | |
mra: resd 1 | |
segment .text | |
global inicio | |
;(int numNA, int numMA, int numNB, int numMB, float dirMatrizA[], float dirMatrizB[], float *dirMatrizRpta[]) | |
inicio: | |
push ebp | |
mov ebp,esp | |
mov eax,[numN] | |
mov [m1na],eax | |
mov dword eax,[numM] | |
mov dword [m1ma],eax | |
mov eax,[ebp+16] | |
mov [m2na],eax | |
mov dword eax,[ebp+20] | |
mov dword [m2ma],eax | |
mov dword eax,[ebp+24] | |
mov dword [m1a],eax | |
mov dword eax,[ebp+28] | |
mov dword [m2a],eax | |
mov dword eax,[ebp+28] | |
mov dword [mra],eax | |
jmp lp1 | |
lp1: | |
mov ecx, [i] ;; Cargo la i en ecx para el primer contador | |
cmp ecx, [m1n] ;; Si i < m1n, salta a lp2 | |
jge endlp1 | |
mov dword[j],0 | |
jmp lp2 | |
lp2: | |
mov ecx, [j] ;; Cargo la j en ecx para el segundo contador | |
cmp ecx,[m2m] ;; Si j < m2m, salta a lp3 y sum = 0 | |
jge inclp1 | |
mov ebx, 0 ;; Cargo 0 en ebx para ponerlo luego en sum, y evitar ambiguedad de tamanio de operadores | |
mov [sum], ebx | |
mov dword[k],0 | |
jmp lp3 | |
lp3: | |
mov ecx, [k] | |
cmp ecx,[m1m] | |
jge inclp2 | |
;; Calculo sum | |
;; mov eax, [sum] ;; Los resultados de sum se llevaran en eax | |
;; Calculo indice m1[i][k] = 2*i+k | |
mov eax, 0 | |
mov ebx, 0 | |
mov edx, 0 | |
mov esi, 0 | |
mov eax,[i] | |
mov edi,[k] | |
mov esi,m1 | |
mul dword [m1m] | |
add eax,edi | |
mov ebx,[esi+4*eax] ;; m1[i][k] | |
mov ecx,[j] | |
mov eax,[k] | |
mov esi,m2 | |
mul dword [m2m] | |
add eax,ecx | |
mov edi, [esi+4*eax];; m2[k][j] | |
mov eax,ebx | |
mul edi | |
add eax,[sum] | |
mov [sum],eax | |
mov eax,0 | |
;; ;;; Fin calculo sum | |
mov ecx,[k] | |
inc ecx | |
mov [k],ecx | |
jmp lp3 | |
inclp1: | |
;; increment on i | |
mov ecx,[i] | |
inc ecx | |
mov [i],ecx | |
jmp lp1 | |
inclp2: | |
;; Calcular result | |
mov eax,[i] | |
mov ebx,[j] | |
mov esi,[m2m] | |
mul esi | |
add eax,ebx | |
mov edx,[sum] | |
mov [mr+4*eax], edx | |
;; increment on j | |
mov ecx,[j] | |
inc ecx | |
mov [j],ecx | |
jmp lp2 | |
endlp1: | |
mov eax,1 | |
mov ebx,0 | |
int 0x80 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment