Advertisement
pasholnahuy

Untitled

Nov 17th, 2023
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. .global sort_by_abs
  2. .text
  3. sort_by_abs:
  4. push %ebp
  5. mov %esp, %ebp
  6. push $pre_comparator
  7. mov $2, %eax
  8. push %eax
  9. push 12(%ebp)
  10. push 8(%ebp)
  11. call qsort
  12. xor %eax, %eax
  13. mov %ebp, %esp
  14. pop %ebp
  15. ret
  16. pre_comparator:
  17. push %ebp
  18. mov %esp, %ebp
  19. mov 8(%ebp), %ecx
  20. mov (%ecx), %cx
  21. movswl %cx, %ecx
  22. mov 12(%ebp), %edx
  23. mov (%edx), %dx
  24. movswl %dx, %edx
  25. checl_first_num:
  26. cmp $0, %ecx
  27. jge check_second_num
  28. mov %ecx, %eax
  29. sub %eax, %ecx
  30. sub %eax, %ecx
  31. check_second_num:
  32. cmp $0, %edx
  33. jge comparator
  34. mov %edx, %eax
  35. sub %eax, %edx
  36. sub %eax, %edx
  37. comparator:
  38. sub %edx, %ecx
  39. mov %ecx, %eax
  40. mov %ebp, %esp
  41. pop %ebp
  42. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement