;跟选择排序差不多,只需稍做修改。。。
data segment arr db 3,4,1,2,8,9,4,3,2,1 count db $-arr data ends code segment assume cs:code,ds:data start:mov ax,data mov ds,ax mov ax,0 mov cx,0 mov cl,count dec cx mov bx,0 loop1:push cx mov bx,0 loop2:mov al,arr[bx] cmp al,arr[bx+1] jle next xchg al,arr[bx+1] mov arr[bx],al next: inc bx loop loop2 pop cx loop loop1 mov ax,4c00h int 21h code ends end start