/************** log *****************/ int main() { int n, k, log ; printf("Enter a positive integer: ") ; scanf("%d",&n); printf("Enter an integer > 1: ") ; scanf("%d",&k); asm( "movl $0, %0 # log <- 0 \n\t" ".MyL1: # label \n\t" "cmpl %%ecx, %%eax # if n < k \n\t" "jl .MyL2 # goto .MyL2 \n\t" "movl $0, %%edx # edx <- 0 \n\t" "idivl %%ecx # edx:eax/ecx \n\t" "incl %0 # %0++ \n\t" "jmp .MyL1 # goto .MyL1 \n\t" ".MyL2: # label \n\t" :"=b"(log) :"a"(n), "c"(k) :"%edx" ); printf("\nlog(%d,%d) = %d\n",n,k,log); }