In the chapter on code patterns here: x86 Disassembly/Loop Examples - Wikibooks, collection of open-content textbooks
There are three versions of the disassembly:
1.
Code:
push ebp
mov ebp, esp
mov esi, [ebp + 8]
mov ebx, 0
mov eax, 0
mov ecx, 0
_Label_1:
mov ecx, [esi + ebx * 4]
add eax, ecx
inc ebx
cmp ebx, 100
jne _Label_1
mov esp, ebp
pop ebp
ret 4
2.
Code:
push ebp
mov ebp, esp
mov esi, [ebp + 8]
mov ebx, 0
mov eax, 0
mov ecx, 0
_Label_1:
mov ecx, [esi + ebx * 4]
add eax, ecx
inc ebx
cmp ebx, 100
jne _Label_1
mov esp, ebp
pop ebp
ret 4
3.
Code:
push ebp
mov ebp, esp
mov esi, [ebp + 8]
mov ebx, 0
mov eax, 0
mov ecx, 0
_Label_1:
mov ecx, [esi + ebx * 4]
add eax, ecx
add ebx, 4 ;This should not be here
inc ebx
cmp ebx, 100
jne _Label_1
mov esp, ebp
pop ebp
ret 4
The first two are correct, but the last one is wrong. The reason im pointing this out is because in the .pdf version all three example are simply the last two. SO if your using the pdf or even the online wiki keep a look out for errors, and if you come across anything weird, tell me, because it may be wrong as well. Don't be afraid to question books or anything if it looks fishy, even from official sources.