Code segment

Jmp main

Add1 dw 9,3,2,7,1,4,2,5,8,1

Main: mov cx, 9

call order

mov cx, 8

call order

mov cx, 7

call order

mov cx, 6

call order

mov cx, 5

call order

mov cx, 4

call order

mov cx, 3

call order

mov cx, 2

call order

mov cx, 1

call order

ret

order: xor si, si

orderab: mov ax,add1[si]

cmp ax,add1[si+4]

jle finish

mov bx,add1[si+4]

mov add1[si],bx

mov add1[si+4],ax

finish: add si, 4

loop orderab

ret

This will reduce the work almost in half, but add some overhad from the loop. If you are concerned about average run-time, you could do the following. It will run very quickly if the list is already in order (just 9 compares!), but slower than the above code if it is in reverse order (same number of compares, with more overhead).

Main: mov cx, 9

order: xor si, si

mov di, cx

xor dx, dx

orderab:

mov ax,add1[si]

cmp ax,add1[si+4]

jle finish

mov dx, di

sub dx, ci

mov bx,add1[si+4]

mov add1[si],bx

mov add1[si+4],ax

finish: add si, 4

loop orderab

inc dx

mov cx, dx

loop order

ret