11.2.2.5 - 3


fori:

sub edx, edx

lea ebx, [eax+ecx*4-4]

mov esi, [ebx]

forj:

mov bl, [esi+edx]

test bl, bl

je short breakj

inc edx

jmp forj

breakj:

mov [edi+ecx*4-4], edx

loop fori

popad

pop ebp

Ret 3*4

Endp

proc SortLen

push ebp

mov ebp, esp

pushad

;for (i=1; i<n; i++){ ebp 0

; r=x[i]; eip 4

; for (j=i-1; j>=0; j--) array 8

; if (x[j]<r)x[j+1]=x[j]; else break; n 12

; x[j+1]=r; len 16

;}

mov eax, 1; i

mov ebx, [ebp+8]; array

mov edx, [ebp+16]; len

@@fori:

push ebp

mov esi, [ebx+eax*4]; r1

mov edi, [edx+eax*4]; r2

mov ecx, eax; j

@@forj:

dec ecx

js short @@breakj

cmp [edx+ecx*4], edi

jae short @@breakj

mov ebp, [edx+ecx*4]

mov [edx+ecx*4+4], ebp

mov ebp, [ebx+ecx*4]

mov [ebx+ecx*4+4], ebp

jmp @@forj

@@breakj:

mov [ebx+ecx*4+4], esi

mov [edx+ecx*4+4], edi

pop ebp

inc eax

cmp eax, [ebp+12]

jbe @@fori

popad

pop ebp

ret 12

endp

end begin

@@. , . .

, . , .

, ,