3.


len dd 4 dup (?)
codeseg
begin:
push offset array [n] offset len
call TextLen
call ExitProcess;
proc TextLen;
push ebp
mov ebp, esp;
;for (i=0; i<n; i++ ){ ebp 0
; for (j=0; array[i][j]; j++); eip 4
; len[i]=j; len 8
;} n 12
; array 16
pushad
mov ecx, [ebp+12]
mov eax, [ebp+16]
mov edi, [ebp+8]
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
end begin
!
3. .
ideal
p686
model flat
extrn ExitProcess:proc
dataseg
s1 db 'a', 0
s2 db 'bb', 0
s3 db 'ccc', 0
s4 db 'dddd', 0
array dd s1, s2, s3, s4
n dd (n-array)/4
len dd 4 dup (?)
codeseg
begin:
push offset array [n] offset len
call TextLen
push offset array [n] offset len
call SortLen
call ExitProcess;
proc TextLen;
push ebp;
mov ebp, esp;
;for (i=0; i<n; i++ ){ ebp 0
; for (j=0; array[i][j]; j++); eip 4
; len[i]=j; len 8
;} n 12
; array 16
pushad
mov ecx, [ebp+12]
mov eax, [ebp+16]
mov edi, [ebp+8]