Im trying to find the GCD of two int,
below is an alog. that I tried to make it into assembly..
but it looks like im missing , can anyone help out ??
Gcd(int a, int b, int *result)
{ while(a!=b)
{
if(a > b)
a = a - b;
else
b = b - a;
}
*result = a;
}
void lab1( int a, int b, int *result )
{
__asm
{
mov esi, result
//save the current status of the registers
push eax
push ebx
push edx
//put the variables into the registers
mov eax, a
mov ebx, b
START_WHILE:
cmp eax, ebx
je END_WHILE
cmp eax,ebx
jle Else_Block
sub eax, ebx
jmp START_WHILE
Else_Block:
sub ebx, eax
jmp START_WHILE
END_WHILE:
move edx
//put the answer to result
mov [esi][0], edx
//restore the original status of registers.
pop edx
pop ebx
pop eax
}
return;
}