Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

Sort an array (Bubble sort)

  Asked By: Art    Date: Nov 02    Category: Assembly Language    Views: 1398
  

Develop an 8086 assembly program that performs sorting of a unsigned integer 10
elements array using bubble-sort algorithm. The array is stored in memory.

Please help

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Sergey Kamenev     Answered 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

 
Didn't find what you were looking for? Find more on Sort an array (Bubble sort) Or get search suggestion and latest updates.




Tagged: