REBORN
New Member
Hi !
I need a help to do a bubble sort in assembly 8051, and the number of the elements of vector is located in R0 , and so far I do this code.
I need a help to do a bubble sort in assembly 8051, and the number of the elements of vector is located in R0 , and so far I do this code.
Code:
$MOD51
ORG 0
ORD:
MOV A,@R0
MOV R7,A
DEC R7
INC R0
MOV B, R0
ROT2:
MOV R0,B
MOV A, R7
MOV R6,A
ROT3:
ACALL COMP
DJNZ R6,ROT3
DJNZ R7,ROT2
RET
COMP:
MOV A,@R0
INC R0
CLR C
SUBB A,@R0
JC FIM
XCH A,@R0
DEC R0
XCH A,R0
INC R0
XCH A,@R0
RET
FIM:
SJMP FIM
END
Last edited by a moderator: