Oops...



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

送交者: wasguru 于 2005-6-30, 23:40:03:

回答: Well, nothing is really wrong 由 wasguru 于 2005-6-30, 23:35:15:

Because you specified that register ecx will hold the input value (num>>4), under -O2 the compiler assumes that ecx still holds that value after the asm statement. Also note that (num>>4) is a common subexpression, so the initial value of i is "optimized" to "ecx<< 4", which is zero!

Under -O3 optimization the whole function test() is expanded into inline code, then the argument num becomes a constant 35, and the expression "(num>>4)<< 4" becomes a constant expression. The compiler will preevaluate it into a constant value 32.






所有跟贴:


加跟贴

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

标题:

内容(可选项):

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


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