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 reason, my code will not swap the necessary values. Here is my code
mov eax, list ;store list in eax
mov edx,[eax+4*edi-4] ;temp = var1
cmp edx,[eax+edi*4] ;compare
JLE SECOND_LOOP ;jump if var1 < var2
mov [eax+4*edi-4],[eax+edi*4] ;var1 = var2
mov [eax+edi*4], edx ;var2 = temp
jmp SECOND_LOOP
At the last mov instruction where it's supposed to load the temp back into the address, it..doesn't. The EAX register has the starting address of the array which contains my list of values
0x*starting address* 0a 00 00 00 ec ff ff ff 05 00 00 00 0c 00 00 00 1e 00 00 00 fb ff ff ff ea
0x*address after * ff ff ff 37 00 00 00 34 00 00 00 00 00 00 00
and the next address contains a few more numbers. In decimal, the numbers are 10 -20 5 12 30 -5 -22 55 52 0
. Essentially right now I'm trying to move FFFFFFEC
to 0000000A
and then move 0000000A
to FFFFFFEC
. I can store it into my temp register EDX, but cannot store the value of EDX into the specific address. Any help?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…