Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TITLE Program 4
- ; Programmer: Antonio Ayala
- ; Description: Program 4
- ;
- ; Date: 5/5/2015
- INCLUDE Irvine32.inc
- .data
- .code
- ; Generates a Pythagorean triple
- ; Receives: EAX, EBX as U, V
- ; Returns: nothing, writes out the triple
- ; Requires: nothing
- TRIPLE PROC
- push ecx
- push edx
- mov ecx, eax
- mul ecx
- mov edx, ebx
- xchg eax, ebx
- mul edx
- xchg eax, ebx
- sub ecx, edx
- push ecx
- mov ecx, ebx
- mul ecx
- add ecx, ecx
- push ecx
- mov ecx, eax
- mul ecx
- mov edx, ebx
- xchg eax, ebx
- mul edx
- xchg eax, ebx
- add ecx, edx
- mov edx, ecx
- pop ecx
- mov ebx, ecx
- pop ecx
- mov eax, ecx
- cmp eax, ebx
- jg greater
- jmp finish
- greater:
- xchg eax, ebx
- finish:
- call WriteInt
- mov eax, " "
- call WriteChar
- mov eax, ebx
- call WriteInt
- mov eax, " "
- call WriteChar
- mov eax, edx
- call WriteInt
- pop edx
- pop ecx
- ret
- TRIPLE ENDP
- ;
- ;
- ;
- ;
- GCD PROC
- GCD ENDP
- main PROC
- call Clrscr
- mov eax, 2
- mov ebx, 1
- call TRIPLE
- exit
- main ENDP
- END main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement