Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. .global tree_find
  2. .text
  3.  
  4. tolerance:
  5. .double 0.00000001
  6.  
  7. printf_str:
  8. .asciz "%lf\n"
  9.  
  10. tree_find:
  11. push %ebx
  12. push %ebp
  13. mov %esp, %ebp
  14. mov 24(%ebp), %edx
  15. movsd 16(%ebp), %xmm0
  16. movl 12(%ebp), %ebx
  17.  
  18. rec:
  19. test %ebx, %ebx
  20. jz not_found
  21. movsd (%ebx), %xmm1
  22. addsd tolerance, %xmm1
  23. comisd %xmm1, %xmm0
  24. ja right
  25. subsd tolerance, %xmm1
  26. subsd tolerance, %xmm1
  27. comisd %xmm0, %xmm1
  28. ja left
  29. test %edx, %edx // 24(%ebp)
  30. jz not_found
  31. mov 16(%ebx), %eax
  32. mov %eax, (%edx)
  33. mov $1, %eax
  34. jmp epilogue
  35.  
  36. left:
  37. movl 8(%ebx), %ebx
  38. jmp rec
  39.  
  40. right:
  41. movl 12(%ebx), %ebx
  42. jmp rec
  43.  
  44. not_found:
  45. mov $0, %eax
  46.  
  47. epilogue:
  48. mov %ebp, %esp
  49. pop %ebp
  50. pop %ebx
  51. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement