关于自加的问题。。
m=2,j=2m+=(j++)+(++j)+(j++)
求M的值
这个的答案我调试了下 是11
由于刚学,但是我怎么算都是12,请前辈们给我解决下。谢谢了
; Line 10 mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax mov ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] mov edx, DWORD PTR _m$[ebp] add edx, ecx mov DWORD PTR _m$[ebp], edx mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax mov ecx, DWORD PTR _j$[ebp] add ecx, 1 mov DWORD PTR _j$[ebp], ecx加上注释 你就明白了:
; Line 10 ++j mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax ecx=j+j+j mov ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] m=m+ecx mov edx, DWORD PTR _m$[ebp] add edx, ecx mov DWORD PTR _m$[ebp], edx j++ mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax j++ mov ecx, DWORD PTR _j$[ebp] add ecx, 1 mov DWORD PTR _j$[ebp], ecx
; Line 10 mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax mov ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] mov edx, DWORD PTR _j$[ebp] add edx, 1 mov DWORD PTR _j$[ebp], edx add ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] mov DWORD PTR _m$[ebp], ecx mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax mov ecx, DWORD PTR _j$[ebp] add ecx, 1 mov DWORD PTR _j$[ebp], ecx也就是说:
; Line 10 ++j mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax ecx=j+j mov ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] ++j mov edx, DWORD PTR _j$[ebp] add edx, 1 mov DWORD PTR _j$[ebp], edx ecx=j+j add ecx, DWORD PTR _j$[ebp] add ecx, DWORD PTR _j$[ebp] m=ecx mov DWORD PTR _m$[ebp], ecx j++ mov eax, DWORD PTR _j$[ebp] add eax, 1 mov DWORD PTR _j$[ebp], eax j++ mov ecx, DWORD PTR _j$[ebp] add ecx, 1 mov DWORD PTR _j$[ebp], ecx慢慢理解吧