; COM file is loaded at CS:0100h
ORG 100h
mov cl,[2200h]
mov bh,cl
cont:mov bp,2201h
mov cl,bh
zz:mov ah,[bp]
inc bp
cmp ah,[bp]
jnb xx
xchg ah,[bp]
xchg ah,[bp-1]
xx:loop zz
dec bh
jnz cont
hlt
Input
[2200H]=5
[2201H]=4
[2202H]=9
[2203H]=5
[2204H]=11
[2205H]=2
Output
[2201H]=11
[2202H]=9
[2203H]=5
[2204H]=4
[2205H]=2