I\'m trying to do a bubble sort in x86 assembly (yes it has to be bubble, as I\'m not concerned about speed optimization regarding different types of sorts) and for some rea
This part of your code:
mov edx,[eax+edi*4]
mov [eax+edi*4], edx
effectively does not change anything in the memory, it reads a value from the memory and writes it back where it's just got it from.
Btw, you may be interested in the xchg
instruction.
I think I'd use pointers into the current position into the list, instead of an index that needs to be scaled every time you use it:
mov esi, offset list
top:
mov edi, esi
inner:
mov eax, [edi]
mov edx, [edi+4]
cmp eax, edx
jle no_swap
mov [edi+4], eax
mov [edi], edx
no_swap:
add edi, 4
cmp edi, list_end - 4
jb inner
add esi, 4
cmp esi, list_end - 4
jb top