;冒泡排序
;author JRH
;2011.7.10
assume ds:data
data segment
a dw 1,4,2,5,7,9,6,3
data ends
code segment
start:
mov ax,data
mov ds,ax
mov cx,8
dec cx
lop1:
push cx
mov dx,0
mov si,0
lop2:
mov bp,a[si]
cmp bp,a[si+2]
jnb go_on
xchg bp,a[si+2]
mov a[si],bp
mov dx,1 ;标志位
go_on:
add si,2
loop lop2
pop cx
cmp dx,0
jz over
loop lop1
over:
mov ax,4c00h
int 21h
code ends
end start