VUsolutions Transferred to AchiKhasi.com

From December 2011, this blog www.VUsolutions.blogspot.com is transferred to http://achikhasi.com/vu/ . So, you may visit http://achikhasi.com/vu/ for latest study related help.

Back to home VUsolutions

VUsolutions Fans Club [join us for MORE solutions]

VUsolutions on Facebook

Helping Material of Assembly Language

Monday, April 13, 2009 Posted In Edit This
Amended code for Decending order
;sorting a list of ten numbers using bubble sort
[org 0x0100]
jmp start

data: dw -10, -30, -25, 50, 15, 20, 35, 40, 45, 0
swap: db 0

start: mov bx, 0 ; initialize array index to zero
mov byte [swap], 0 ; rest swap flag to no swaps

loop1: mov ax, [data+bx] ; load number in ax
cmp [data+bx+2], ax ; compare with next number
jge noswap ; no swap if already in order

mov dx, [data+bx+2] ; load second element in dx
mov [data+bx+2], ax ; store first number in second
mov [data+bx], dx ; store second number in first
mov byte [swap], 1 ; flag that a swap has been done

noswap: add bx, 2 ; advance bx to next index
cmp bx, 18 ; are we at last index
jne loop1 ; if not compare next two

cmp byte [swap], 1 ; check if a swap has been done
je start ; if yes make another pass

mov ax, 0x4c00 ; terminate program
int 0x21

Back to home VUsolutions

Shaadi.com: Just create ur account & find ur partner or EARN money, its reall & EASY

VUsolutions Followers (Join NOW and Get Extra Benefits)

Install LATEST toolbar having lot of features - GET solutions on Desktop

toolbar powered by Conduit
Caliplus 300x250 NoFlam VitoLiv 468x60 GlucoLo