Advertisement
dskzz

hypot.asm

Jul 28th, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. pt_a  dd  200, 300
  2. pt_b  dd  550, 350
  3.  
  4. main:
  5. mov eax, dword pt_a   ; this moves addy of pt_a to eax
  6. mov ebx, dword pt_b   ; this moves addy of pt_a to eax
  7.  
  8. ; this gets me my delta x
  9. sub ebx, [eax]          
  10. move [delta_x], ebx
  11. xor ebx, ebx
  12.  
  13. ; this moves array to the next set of points
  14. inc eax
  15. mov ebx, pt_b
  16. inc ebx
  17.  
  18. ; this gets me my delta y
  19. sub ebx, eax
  20. mov [delta_y], ebx
  21.  
  22. ;this squares delta x, moves to hypot
  23. mov eax, [delta_x]
  24. mul eax
  25. mov [hypot], eax
  26.  
  27. ;this squares delta y, adds to hypot
  28. mov eax, [delta_y]
  29. mul eax
  30. add eax, [hypot]
  31.  
  32. ; now eax should have the a^2 + b^2
  33. ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement