Updated cv2.asm

This commit is contained in:
Filip Orság 2023-04-26 13:33:07 +02:00
parent b1abfe3b2f
commit 72bcd6c3e1

44
cv2.asm
View File

@ -11,13 +11,53 @@ segment .text
getSorted:
enter 0,0
fld tword [esi]
fstp dword [edi]
mov eax,[ebp+12]
shl eax,2
push eax
CEXTERN malloc
call malloc
add esp,4
mov ecx,[ebp+12]
mov esi,[ebp+8]
mov edi,eax
.cpy:
fld tword [esi]
add esi,10
fstp dword [edi]
add edi,4
loop .cpy
;for(unsigned int i = 0; i < N ; i++)
; for(unsigned int j = i + 1; j < N; j++)
; if (newArr[i] > newArr[j]) SWAP newArr[i],newArr[j]
xor esi,esi ; esi = i = 0
.for1:
cmp esi,[ebp+12]
jae .end_for1
lea edi,[esi+1] ; edi = j = i + 1
.for2:
cmp edi,[ebp+12]
jae .end_for2
fld dword [eax + esi*4]
fld dword [eax + edi*4]
fcomi
jbe .no_swap
fst dword [eax + esi*4]
fxch
fst dword [eax + edi*4]
.no_swap:
fcompp
inc edi
jmp .for2
.end_for2:
inc esi
jmp .for1
.end_for1:
leave
ret