tcbpg

Untitled

Sep 17th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. section .text
  2. global maximo
  3.  
  4. ;ejercicio 1 - sacar el maximo de un vector de enteros.
  5. ;int maximo(int * v, unsigned int n)
  6. maximo:
  7.     push ebp
  8.     mov ebp, esp
  9.     push ebx
  10.     push esi
  11.     push edi
  12.     mov ecx, [ebp+12] ;ecx = n
  13.     dec ecx
  14.     mov esi, [ebp+8];esi = puntero a v
  15.     mov ebx, [esi]; ebx = v[0]
  16. ciclo:  cmp [esi+ecx], ebx ; [esi + ecx] deberia ser el elemento v[i] siendo i el contenido de ecx.
  17.     cmova ebx, [esi+ecx]
  18.     loop ciclo 
  19.     mov eax, ebx
  20.     pop edi
  21.     pop esi
  22.     pop ebx
  23.     mov esp, ebp
  24.     pop ebp
  25.     ret
Advertisement
Add Comment
Please, Sign In to add comment