Talk:X86 Disassembly/Optimization Examples

I just changed "r = m / n" to "r = m % n" on the exercise to convert the optimized asm to an optimized C.

please see the comments on the edit. the reason why it is so is because if you look at line 7 on the disassembled source, you'll see that the code discards EAX (the quotient) and keeps EDX (the remainder) and puts it into ecx to compare it to 0 do get inside the loop. so if the code keeps the R and discards the Q that means it's doing a MOD not a division. Another reason why this is so is because if we keps "r = m / n" the code makes no sense at all, and also doesnt' work. Nothingist (talk) 07:50, 31 August 2009 (UTC)

"decompile optimized code" example is wrong
According assembly code, "mov ecx, edx" to move new remainder to variable r must be after "mov esi, ecx" to move old remainder in variable r to variable n, but "r = m % r" destroys old remainder in variable r before moving it to n. --LungZeno (talk) 20:01, 20 August 2010 (UTC)