calling fucntions from main global declarations int A=0, B=0, C=0;
void load(){ system("clear"); printf("Enter 2 values: "); scanf("%d %d",&B,&C); __asm__ __volatile__("movl %1,%%ebx;""movl %2,%%ecx;" :: "b" (B) , "c" (C) ); printf("Loaded Successfully. (press any key to continue.)"); scanf("%d",&temp);}void Add(){ system("clear"); __asm__("movl %ebx,%eax;""addl %ecx,%eax;" :"=a" (Acc) ); printf("Answer: %d (press any key to continue)",Acc); scanf("%d",&temp);}void Sub(){ system("clear"); __asm__("movl %ebx,%eax;""subl %ecx,%eax;" :"=a" (Acc) ); printf("Answer: %d (press any key to continue)",Acc); scanf("%d",&temp);}void Mul(){ system("clear"); __asm__("movl %ebx,%eax;""imull %ecx,%eax;" :"=a" (Acc) ); printf("Answer: %d (press any key to continue)",Acc); scanf("%d",&temp);}void Div(){ int rem; system("clear"); __asm__("movl %0x0,%edx;""movl %ebx,%eax;""idivl %ecx" :"=a" (Acc) , "=r" (rem) ); __asm__("movl %1, %eax" :: "a" (Acc) ); printf("Quotient: %d Remainder= %d (press any key to continue)",Acc,rem); scanf("%d",&temp);}
here's a code using inline assembly in c and while compiling with gcc -g it gives error :
test3.c: In function ‘main’:test3.c:22:13: error: output operand constraint lacks ‘=’ __asm__("movl %1,%ebx;""movl %2,%ecx;" : "r" (B): "r" (C)); ^~~~~~~test3.c:22:13: error: output operand constraint lacks ‘=’test3.c:22:13: error: invalid lvalue in asm output 0
references from :
https://www.codeproject.com/articles/15971/using-inline-assembly-in-c-c
Source Codes from the site is compiling perfectly but while compiling the above code it gives errors
Also tried asmvolatilebut it again gcc is throwing :
error: bad register name `%%eax'