Skip to content

Instantly share code, notes, and snippets.

@varuntiwari
Created May 9, 2016 08:44
Program for arranging a given array in ascending order.The length of array is stored at memory location 5000H and the array starts from 5001H.
;<Program for arranging a given array in ascending order.The length of array
;is stored at memory location 5000H and the array starts from 5001H>
jmp start
;code
start: lxi h, 5000H
mov b,m
dcr b
loop1: mov c,b
lxi h, 5001H
loop2: mov a,m
inx h
cmp m
jc skip
mov d,m
mov m,a
dcx h
mov m,d
inx h
skip: dcr c
jnz loop2
dcr b
jnz loop1
hlt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment