Question
Bubble sort program irvine assembly I need this program to print out everytime it swaps or does a bubble sort . for example, it prints
Bubble sort program irvine assembly
I need this program to print out everytime it swaps or does a bubble sort .
for example, it prints out what it starts with
8,5,1,2,4 the next line would be
5,8,1,2,4, then
5,1,8,2,4, then
1,5,8,2,4 then
1,5,2,8,4 then
1,2,5,8,4 then
1,2,5,4,8, then
1,2,4,5,8.
I've tried to call print procedure into the beggining and the end, it shows that it prints out the start of the array, and the end of the array after the bubble sorting. I need it to print out every time it switches a number. I've tried calling print after the exchanges, but it doesn't work. Please help.
INCLUDE Irvine32.inc .data myArray BYTE 8, 5,1, 2, 4 spaceString BYTE " ", 0
.code main PROC mov ecx, lengthOf myArray dec ecx
CALL print
L1: mov esi,0 mov eax,0
L2: mov al, myArray[esi] cmp al, myArray[esi+1] jbe L3 mov dl, myArray[esi+1] mov myArray[esi+1],al mov myArray[esi], dl
L3: add esi,1 cmp esi,ecx jne l2 loop L1 call Array
exit main ENDP
print PROC uses eax ebx ecx
mov ecx, LENGTHOF myArray mov esi,0 movsx eax, myArray
L1: call WriteInt inc esi mov al, myArray[esi] mov edx, OFFSET spaceString call WriteString loop L1
call Crlf
ret
print ENDP
;) END main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started