Program to sort an array of 10 elements


15. Program to sort an array of 10 elements :

mov r3,#0ah ;load r3 with immediate data 0ah
dec r3 ;decrement r3
start:mov a,r3 ;move data from r3 to a
mov r0,a ;move data from a to r0
mov dptr,#9000h ;Load dptr with address 9000h
l1:movx a,@dptr ;move data from external memory location to a
mov r1,a ;move data from a to r1
inc dptr ;increment dptr
movx a,@dptr ; move data from external memory location to a
clr c ;clear carry bit
subb a,r1 ;subtract with borrow, r1 from a
jnc next ;if no carry, jump to label next
movx a,@dptr ;move data from external memory location to a
mov r2,a ;move data from a to r2
mov a,r1 ;move data from r1 to a
movx @dptr,a ; move data from a to external memory location
dec dpl ;decrement dpl
mov a,r2 ;move data from r2 to a
movx @dptr,a ; move data from a to external memory location
inc dptr ;increment dptr
next:djnz r0,l1 ;decrement r0, if not equal to 0, jump to label next
djnz r3,start ;decrement r3, if not equal to 0, jump to label start
here:sjmp here
end


Web Statistics