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?
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