Assembly language help please?

ViRaLRuSh

Golden Member
Nov 15, 2002
1,233
0
0
I am having trouble writing a program that must Implement the GCD (Greatest Common Divisor) function in assembly language and write a test program that
calls the function several times, passing it different values. Display all
results on the screen.
I only have this much and dont know how to output. Can anyone help please?


INCLUDE Irvine32.inc

.data
array _________ 5,20,18,24,11,7,438,226,13,26 ; test data: couples of numbers
str1 db "Greatest common divisor is: ",0

.code
main PROC

mov ecx,___________________________ ; number of couples
mov esi,OFFSET array

L1: mov eax,___________________________; first number
mov ebx,___________________________; second number
call CalcGcd
mov edx,OFFSET str1
call WriteString
call WriteDec
call Crlf
add esi,______________________; next couple
loop L1

exit
main ENDP

-----------------
CalcGcd PROC
;
; Calculate the greatest common divisor, using
; a nonrecursive looping algorithm.
; Receives: EAX (integer 1), EBX (integer 2)
; Returns: EAX = Greatest common divisor
-----------------
push ebx
push edx

L1: ______________________
______________________ ; divide int1 by int2
cmp ______,0 ; remainder = 0?
je L2 ; yes: quit
mov eax,ebx ; no: prepare for
mov ebx,edx ; next iteration
jmp L1

L2: mov eax,ebx ; EAX = GCD

pop edx
pop ebx
ret
CalcGcd ENDP

END main