#include unsigned int ggT_C(unsigned int a, unsigned int b) { unsigned int res = 0; unsigned int div = 0; while(b !=0) { // while b not zero res = (a % b); // res = (a mod b) a = b; b = res; } return a; } unsigned int ggT_Asm(unsigned int a, unsigned int b) { __asm { mov edx, 0 ; mov eax, a ; // EDX:EAX = a mov ecx, b ; // ECX = b WhileLoop: cmp ecx, 0 ; jz EndLoop ; // jump to "done" if ECX == 0 div ecx ; mov eax, ecx ; // EAX = ECX mov ecx, edx ; // ECX = (a mod b) mov edx, 0 ; // EDX = 0 for next "div" command jmp WhileLoop ; EndLoop: } } int main() { unsigned int a = 525; unsigned int b = 399; unsigned int result = ggT_C(a, b); // call function "ggT_C" printf( "ggT_C result = %d\n", result); // output result to console result = ggT_Asm(a, b); // call function "ggT_Asm" printf( "ggT_Asm result = %d\n", result); // output result to console return 0; }