Write Assembly Language Program To Sort The Following Numbers, Using Bubble Sort, In Signed Descending Order: -10, -30, -25, 50, 15, 20, 35, 40, 45, 0?

4 Answers

Anonymous Profile
Anonymous answered
Write Assembly language program to sort the following numbers, using bubble sort, in signed descending order:

-10, -30, -25, 50, 15, 20, 35, 40, 45, 0

That is, at the end of your program, the numbers must be in the following order:

50, 45, 40, 35, 20, 15, 0, -10, -25, -30
Anonymous Profile
Anonymous answered
Do your home work yourself
Goto page 37 of CS401 handouts and you'll get some help over there.

With regard's,
Instructor CS401
Anonymous Profile
Anonymous answered
Write assembly program to input 3 numbers then add The numbers and calculate the average rounded,print out the total and the average?
Anonymous Profile
Anonymous answered
Data: Dw -10, -30, -25, 50, 15, 20, 35, 40, 45, 0
swap: Db 0

bubblesort: Dec cx ;last element not compared
shl cx,1

mainloop: Mov si,0 ;initialize array index to zero
mov word [swap],0 ;rest swap flage to no swap

innerloop: Mov ax,[bx+si] ;load number in ax
cmp ax,[bx+si+2] ;compare with next number
jl noswap ;no swap if already in order

mov dx,[bx+si+2] ;load second element in dx
mov [bx+si],dx ;store first nuber in second
mov [bx+si+2],ax ;store second numberin first
mov word [swap],1 ;flag that a swap has been done

noswap: Add si,2 ;advance si to next index
cmp si,cx ;are we at last index
jle innerloop ;if not cmpare next two

cmp word [swap],1 ;check if a swap has been done
jnl mainloop ;if yes make another pass

ret ;go back to where we came from

start: Mov bx,data ;send start of array in bx

mov cx,10 ;send count of elementts in cx
call bubblesort ;call our subroutine

Answer Question