Sorting of numbers in 8051 - Descending Order

org 0h
mov r1,40h // Will take 'd' memory
dec r1
ag: mov a,r1
mov r2,a
mov r0,#41h
up: mov a,@r0
inc r0
mov b,@r0
clr c
subb a,b
jnc skip

mov b,@r0
dec r0
mov a,@r0
mov @r0,b
inc r0
mov@r0,a

skip:djnz r2,up
djnz r1,ag
end

No comments:

Post a Comment