Advertisement
Guest User

torneio.s

a guest
Nov 22nd, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. .section .text
  2.  
  3. .global vencedor
  4. vencedor:
  5.  
  6. # prologue
  7. pushl %ebp
  8. movl %esp, %ebp
  9.  
  10. pushl %ebx
  11. pushl %esi
  12. pushl %edi
  13.  
  14. movl 8(%ebp), %ecx #int *num_inscricao em ecx
  15. movl 12(%ebp), %edx #unsigned short *resultados em edx
  16. movl 16(%ebp), %ebx #int n in %ebx
  17.  
  18. movl $0, %esi #melhor pontuacao
  19. movl $0, %edi #numero de inscricao da equipa com melhor pontuacao
  20.  
  21. decl %ebx
  22. for:
  23. cmpl $0, %ebx
  24. jl end
  25.  
  26. pushl %eax
  27. pushl %edx
  28. pushl %ecx
  29.  
  30. pushl (%edx,%ebx,2)
  31.  
  32. call pontuacao
  33.  
  34. addl $4, %esp
  35.  
  36. popl %ecx
  37. popl %edx
  38.  
  39. cmpl %eax, %esi
  40. jg not_highest_yet
  41.  
  42. movl %eax, %esi
  43. movl (%ecx,%ebx,4) ,%edi
  44. not_highest_yet:
  45.  
  46. popl %eax
  47.  
  48. decl %ebx
  49. jmp for
  50. end:
  51.  
  52. movl %edi, %eax
  53.  
  54. popl %edi
  55. popl %esi
  56. popl %ebx
  57.  
  58. # epilogue
  59. movl %ebp, %esp
  60. popl %ebp
  61.  
  62. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement