Strange behavior under x86/linux of very short code



所有跟贴·加跟贴·新语丝科技论坛

送交者: AQuestion 于 2005-6-30, 18:58:28:

The following code will not run correctly if
compiled with gcc -O2. It is ok without any optimization
or -O3. What is wrong. My inline asm knowledge
is very limited (from google), maybe there is something
wrong there?

#include

void test(int num)
{
int i;


__asm__ __volatile__(
"1:"
"dec %%ecx \n\t"
"jnz 1b \n\t"
:
: "c" (num>>4)
: "memory"
);

for(i=(num>>4)<<4; i printf("OK i=%d\n", i);
}

main()
{
test(35);
}




所有跟贴:


加跟贴

笔名: 密码(可选项): 注册笔名请按这里

标题:

内容(可选项):

URL(可选项):
URL标题(可选项):
图像(可选项):


所有跟贴·加跟贴·新语丝科技论坛