Logo 
Search:

Assembly Language Answers

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds
  Question Asked By: Art Style   on Nov 12 In Assembly Language Category.

  
Question Answered By: Sergey Kamenev   on Nov 12

BubbleSortDWord:
;Bubble sort of dword array
; Parameters:
; ESI - array address
; ECX - array length (number of elements)
.mMain:
dec ecx
cmp ecx,0
jl .mEx

push esi
push ecx
mov bl,0
.mOne:
mov eax,[esi]
cmp eax,[esi+4]
jle .mSkipR
mov edx,[esi+4]
mov [esi],edx
mov [esi+4],eax
mov bl,1
.mSkipR:
add esi,4
loop .mOne
pop ecx
pop esi

cmp bl,0
je .mEx
jmp .mMain
.mEx:

ret

Share: