Saturday, April 30, 2016

8051 Program – bubble sort descending order

; bubble sort descending order
; external memory
ORG 0H
MOV R0,#05
L1: MOV DPTR,#9000H
MOV A,R0
MOV R1,A
L2: MOVX A,@DPTR
MOV B,A
INC DPTR
MOVX A,@DPTR
CLR C
MOV R2,A
SUBB A,B
JC NOEXCHG
MOV A,B
MOVX @DPTR,A
DEC DPL
MOV A,R2
MOVX @DPTR,A
INC DPTR
NOEXCHG:DJNZ R1,L2
DJNZ R0,L1
SJMP $
ORG 9000H
DB 2,5,1,9,7,6
END
; Result: 9000:09, 07, 06,05,02,01



Related topics:
8051 Program - sorting ascending order   |   8051 Program - sorting descending order   |   8051 Program - bubble sort ascending order   |   8051 Program - pwm   |   8051 Program - decimal to hex   |   8051 Program - sum of a set of numbers   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment