Advertisement
Guest User

Untitled

a guest
Nov 21st, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. section .text
  2.  
  3. global get_max
  4.  
  5. get_max:
  6. push ebp
  7. mov ebp, esp
  8.  
  9. ; save ebx in callee
  10. push ebx
  11.  
  12. ; [ebp+8] is array pointer
  13. ; [ebp+12] is array length
  14.  
  15. mov ebx, [ebp+8]
  16. mov ecx, [ebp+12]
  17. xor eax, eax
  18.  
  19. compare:
  20. cmp eax, [ebx+ecx*4-4]
  21. jge check_end
  22. mov eax, [ebx+ecx*4-4]
  23. mov edx,ecx
  24. check_end:
  25. loopnz compare
  26. dec edx
  27. mov ebx,[ebp + 16]
  28. mov [ebx], edx
  29.  
  30. pop ebx
  31.  
  32. leave
  33. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement