.model small
.stack 256
.data
array dw 3234h,212h,3532h,-98h,32h,44h,234h,-123h,132h,-455h
count equ $-array
pushcount db 0
.code
.startup
mov cx,count
shr cx,1
dec cx
mov bl,-1
mov si,0
outloop:
mov dx,cx
cmp bl,0
jz ready
xor bl,bl
xor si,si
inloop:
mov ax,array[si]
cmp ax,array[si+2]
jl continue
xchg ax,array[si+2]
mov array[si],ax
mov bl,-1
continue:
add si,2
dec dx
jnz inloop
loop outloop
ready:
mov cx,count
shr cx,1
xor si,si
mynext:
mov ax,array[si]
call dispnum
add si,2
dec cx
jnz mynext
.exit 0
dispnum proc near
push cx
push bx
push dx
mov bx,10
cmp ax,0
jge again
neg ax
push ax
mov dl,'-'
mov ah,02h
int 21h
pop ax
again:
cwd
div bx
push dx
inc pushcount
cmp ax,0
jne again
outputnum:
pop dx
add dx,30h
mov ah,02
int 21h
dec pushcount
jnz outputnum
mov dl,' '
mov ah,02h
int 21h
pop dx
pop bx
pop cx
ret
dispnum endp
end