Wednesday, June 23, 2010

Sorting numbers in ascending order

Buzz It
#make_COM#
; 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]
jb 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]=2
[2202H]=4
[2203H]=5
[2204H]=9
[2205H]=11

0 comments:

Post a Comment