data segment
buf db 6,8,3,4,1,5,7,2
cn equ $-buf
n db 0
data ends
code segment
assume ds:data,cs:code
start :
mov ax,data
mov ds,ax
mov cx,cn-1
lop2:
lea di,buf
mov al,buf[di]
lop1:
cmp al,buf[di+1]
JLE next1
xchg al,buf[di+1]
mov buf[di],al
next1:
mov al,buf[di+1]
inc di
cmp di,cx
jnz lop1
dec cx
cmp cx,0
jz exist
jmp lop2
exist:
mov ah ,4ch
int 21h
code ends
end start