0,


AL - -
AX - -
EAX -
EDX, EAX - 2
3. "" . 0, , 1 1 .
ideal
p686
model flat
extrn ExitProcess:proc
dataseg
x dd 1000 dup (0ffffffffh)
n dd (n-x)/4
y dd 1000 dup (0ffffffffh)
res dd ?
t1 dd ?
t2 dd ?
codeseg
begin:
push [n] offset x offset y
rdtsc
mov ecx,eax
call m_cmp
mov [res], eax
rdtsc
sub eax, ecx
mov [t1], eax
push [n] offset x offset y
rdtsc
mov ecx,eax
call m_cmp
mov [res], eax
rdtsc
sub eax, ecx
mov [t1], eax
push [n] offset x offset y
rdtsc
mov ecx,eax
call m_cmp1
mov [res], eax
rdtsc
sub eax,ecx
mov [t2], eax
call ExitProcess
;for (i=n-1; i>=0; i--){ ebp 0
; if (x[i]>y[i]) return -1; eip 4
; if (x[i]<y[i]) return 1; y 8
;} x 12
;return 0; n 16
proc m_cmp
push ebp;
mov ebp, esp;
Push ebx ecx edx
mov ecx, [ebp+16]; n
mov eax, [ebp+12]; &x
mov ebx, [ebp+8] ; &y
fori:
mov edx, [eax+ecx*4-4]
cmp edx, [ebx+ecx*4-4]
jb short m1; x[i]< y[i]
ja short m2; x[i]> y[i]
loop fori
sub eax, eax
m1:
mov eax, -1
jmp short m3
m2:
mov eax, 1
m3:
pop edx ecx ebx ebp
Ret 12
Endp
proc m_cmp1
push ebp;
mov ebp, esp;
Push ecx esi edi
mov ecx, [ebp+16]; n
mov esi, [ebp+12]; &x
lea esi, [esi + ecx*4-4]
mov edi, [ebp+8] ; &y