送交者: wasguru 于 2005-6-30, 23:35:15:
回答: Strange behavior under x86/linux of very short code 由 AQuestion 于 2005-6-30, 18:58:28:
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)<<4" becomes a constant expression, and the compiler will preevaluate it into a constant (32).