Advertisement
Coriic

Untitled

May 29th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. .data
  2.  
  3. min:
  4. .long 0
  5. max:
  6. .long 0
  7. current
  8. .byte 0
  9.  
  10. .text
  11. .type max_diff,@function
  12. .global max_diff
  13.  
  14. max_diff:
  15. PUSH %rbp
  16. MOV %rsp,%rbp
  17. MOVL (%rdi), min
  18. MOVL (%rdi), max
  19. ADD $24, (%rbp)
  20. MOV $2, %rcx
  21. loop:
  22. CMP $0, %rcx
  23. JE exit
  24. DEC %rcx
  25. MOVL (%rbp), %eax
  26. CMP min, %eax
  27. JL changeMin
  28. CMP max, %eax
  29. JG changeMax
  30.  
  31. changeMin:
  32. MOVL %eax, min
  33. ADD $8, (%rbp)
  34. JMP loop
  35.  
  36. changeMax:
  37. MOVL %eax, max
  38. ADD $8, (%rbp)
  39. JMP loop
  40.  
  41. exit:
  42. MOVL min, %eax
  43. MOVL max, %ebx
  44. SUB %eax, %ebx
  45. XOR %rax, %rax
  46. MOV %ebx, %rax
  47. RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement