It does matter. suppose u write the c code and the compiler generates assembly level code later u get machine code which runs. here in this process many optimizations can be employed which are not done by gcc. So including asm code in ur c code can actually make ur code to run very fast provided u use the optimizations :)
On Jun 18, 2:53 pm, ADITYA KUMAR <aditya...@gmail.com> wrote: > whether u write your code in assembly or c or even in Machine code it will > take the same time.. > because after-all ,on system ...your executable runs not ur code > and which is not in c not in assembly but in machine code > > > > > > On Thu, Jun 16, 2011 at 9:11 AM, saurabh singh <saurab...@gmail.com> wrote: > > Hello > > I have been thinking if I can use asm in c programs to enhance my time... > > So to give it a try i triedhttp://www.spoj.pl/problems/STREETR/ > > with the following code: > > #include<stdio.h> > > int gcd( int a, int b ) { > > int result ; > > > __asm__ __volatile__ ( "movl %1, %%eax;" > > "movl %2, %%ebx;" > > "CONT1D: cmpl $0, %%ebx;" > > "je D1ONE;" > > "xorl %%edx, %%edx;" > > "idivl %%ebx;" > > "movl %%ebx, %%eax;" > > "movl %%edx, %%ebx;" > > "jmp CONT1D;" > > "D1ONE: movl %%eax, %0;" : "=g" (result) : "g" > > (a), "g" (b) > > ); > > > return result ; > > } > > > int main() > > { > > int n,i,min,ans=0; > > scanf("%d",&n); > > int arr[n],ard[n]; > > ard[0]=1; > > if(n>0) > > scanf("%d",&arr[0]); > > for(i=1;i<n;i++) > > { > > scanf("%d",&arr[i]); > > ard[i]=arr[i]-arr[i-1]; > > if(i==1) > > min=ard[i]; > > else > > min=gcd(min,ard[i]); > > > } > > for(i=1;i<n;i++) > > { > > ans+=((ard[i]/min)-1); > > } > > printf("%d",ans); > > return 0; > > > } > > > Its according to the i386 arch. it ran fine on my computer but giving > > complilation error in SPOJ judge..... > > I am yet a novice with asm's so dont know if I made sense at all.But please > > do help with this, > > > -- > > Saurabh Singh > > B.Tech (Computer Science) > > MNNIT ALLAHABAD > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to algogeeks@googlegroups.com. > > To unsubscribe from this group, send email to > > algogeeks+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Regards > Aditya Kumar > B-tech 3rd year > Computer Science & Engg. > MNNIT, Allahabad.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.