Advertisement
Guest User

Untitled

a guest
May 4th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. TITLE Program 4
  2.  
  3. ; Programmer: Antonio Ayala
  4. ; Description: Program 4
  5. ;
  6. ; Date: 5/5/2015
  7.  
  8. INCLUDE Irvine32.inc
  9.  
  10. .data
  11.  
  12.  
  13. .code
  14. ; Generates a Pythagorean triple
  15. ; Receives: EAX, EBX as U, V
  16. ; Returns: nothing, writes out the triple
  17. ; Requires: nothing
  18. TRIPLE PROC
  19. push ecx
  20. push edx
  21.  
  22. mov ecx, eax
  23. mul ecx
  24. mov edx, ebx
  25. xchg eax, ebx
  26. mul edx
  27. xchg eax, ebx
  28. sub ecx, edx
  29. push ecx
  30.  
  31. mov ecx, ebx
  32. mul ecx
  33. add ecx, ecx
  34. push ecx
  35.  
  36. mov ecx, eax
  37. mul ecx
  38. mov edx, ebx
  39. xchg eax, ebx
  40. mul edx
  41. xchg eax, ebx
  42. add ecx, edx
  43.  
  44. mov edx, ecx
  45. pop ecx
  46. mov ebx, ecx
  47. pop ecx
  48. mov eax, ecx
  49.  
  50. cmp eax, ebx
  51. jg greater
  52. jmp finish
  53.  
  54. greater:
  55. xchg eax, ebx
  56.  
  57. finish:
  58. call WriteInt
  59. mov eax, " "
  60. call WriteChar
  61. mov eax, ebx
  62. call WriteInt
  63. mov eax, " "
  64. call WriteChar
  65. mov eax, edx
  66. call WriteInt
  67.  
  68. pop edx
  69. pop ecx
  70.  
  71. ret
  72.  
  73. TRIPLE ENDP
  74.  
  75. ;
  76. ;
  77. ;
  78. ;
  79. GCD PROC
  80.  
  81. GCD ENDP
  82.  
  83. main PROC
  84. call Clrscr
  85.  
  86. mov eax, 2
  87. mov ebx, 1
  88. call TRIPLE
  89.  
  90. exit
  91. main ENDP
  92.  
  93. END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement