Author: Christophe Drieu
Date: 06:15:36 05/21/04
Hi, i'm learning Inline assembly with gcc, but have some trouble with global C
variables:
int a=4, b=0;
int main()
{
asm("incl _a"); // a++
asm("movl _a,%eax"); // eax=a
asm("movl %eax,_b"); // b=eax
printf("a=%d b=%d\n", a, b); // print a=5 b=5
a=4;
asm("incl _a"); // a++
asm("movl _a,%eax"); // eax=a
asm("movl %eax,_b"); // b=eax
printf("a=%d b=%d\n", a, b); // print a=4 b=5
}
My question is, why a==4 in second case and not 5 ? Thank you.
This page took 0.01 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.