That's why I put the note about DPL in my last post.This isn't a bubble sort. The code increments DPTR twice on each loop. It should only increment DPTR once on each loop.
XCH A,DPL JNZ D1 DEC DPH D1: DEC A XCH A,DPL
I think the problem is that when you loop from DJNZ R1,L3, R0 is not reset.
Thanks. So overwriting R0 has been the problem. I will replace R0 with another register and check.Why not use this to decrement DPTR, and also avoid overwriting R0?