Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BubbleSort

Status
Not open for further replies.

99drew99

Programmer
Apr 22, 2011
1
0
0
IT
I've made ??some changes to the algorithm BubbleSort, dividing the array to be ordered in n array consisting of 10 elements. The code should order the first n array and then all the main array and display the content, but I do not get any results. Any suggestions?


Code:
.data
array SDWORD 10 DUP(10009h, 10002h, 10003h, 10004h, 10001h, 10006h, 10007h, 10008h, 10005h, 10010h)
len DWORD lengthof array

.code
MAIN PROC
INVOKE BBSORT, ADDR array, len
mov esi, offset array
call Funzione che visualizza parte della memoria
MAIN ENDP

BBSORT PROC USES eax ecx esi, aarr: PTR SDWORD, larr: DWORD
LOCAL part: DWORD, cloop: BYTE
mov edx, 0
mov eax, larr
mov ebx, 10
div ebx
mov ecx, 2
push edx
mov part, 0
mov cloop, 0
lp:
push ecx
mov eax, 0
cmp part, 0
je ls  
mov edx, 0
mov eax, part
mul ebx
shl eax, 2
mov edx, eax
ls:
dec ecx
cmp ecx, 0
je lr
l1:
push ecx
mov ecx, ebx
dec ecx
mov esi, aarr
add esi, edx
l2:
call DumpRegs
mov eax, [esi]
cmp [esi + 4], eax
jg l3
xchg eax, [esi + 4]
mov [esi], eax
l3:
add esi, 4
loop l2
pop ecx
loop l1
mov esi, aarr
add esi, edx
inc part
pop ecx
loop lp
jmp lr
cmp cloop, 2
je lr
cmp cloop, 1
je la
pop edx
mov ecx, edx
mov part, 0
mov cloop, 1
jmp lp
la:
mov ecx, 100
mov part, 0
mov cloop, 2
jmp lp
lr:
ret
BBSORT ENDP
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top