Skip to content

Instantly share code, notes, and snippets.

@mrafayaleem
Created August 30, 2012 11:44
Show Gist options
  • Save mrafayaleem/3526928 to your computer and use it in GitHub Desktop.
Save mrafayaleem/3526928 to your computer and use it in GitHub Desktop.
Include Irvine32.inc
.data
prompt1 BYTE "Enter first Integer Value", 0
prompt2 BYTE "Enter second Integer Value", 0
GCD BYTE "GCD IS:", 0
A DWORD ?
B DWORD ?
myC DWORD ?
.code
main PROC
call input
MYWHILE:
mov eax, A
cdq
idiv B
mov A, edx
cmp A, 0
je RETB
mov eax, B
cdq
idiv A
mov B, edx
cmp B, 0
je RETA
JMP MYWHILE
RETA:
mov esi, A
mov myC, esi
JMP PRINTGCD
RETB:
mov esi, B
mov myC, esi
JMP PRINTGCD
PRINTGCD:
mov edx, OFFSET GCD
call WriteString
call crlf
mov eax, myC
call WriteDec
exit
main ENDP
input PROC uses edx eax
mov eax, 0
mov edx, OFFSET prompt1
call WriteString
call crlf
call ReadInt
mov A, eax
mov edx, OFFSET prompt2
call WriteString
call crlf
call ReadInt
mov B, eax
ret
input ENDP
END main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment