Do an ALP programming to arrange numbers in ascending order.
ORG 0000H ;storing the program from 0000h location in ROM
MOV R4,#05H ;load 05h in R5
AGAIN:
MOV DPTR,#9000H ;load 9000h in DPTR(initializing pointer)
MOV R3,#05H ;load 05h in R3
BACK:
MOVX A,@DPTR ;fetching data from XRAM
MOV B,A ;copy data of A to B
INC DPTR ;increment pointer location
MOVX A,@DPTR ;fetching next byte data from XRAM
MOV R1,A ;copy data of ACC to R1
CJNE A,B,TARGET ;compare A with B and jump if not equal(NEQ)
TARGET:
JNC NOEXCHANGE ;if A is larger than B then no exchange
MOV A,B ;copy data of B to A
MOVX @DPTR,A ;copy the data of ACC to location pointed by DPTR
MOV A,R1 ;copy data of R1 to ACC
DEC DPL ;decrement DPL by one byte
MOVX @DPTR,A ;copy the data of ACC to location pointed by DPTR
INC DPTR ;increment pointer location
NOEXCHANGE:
DJNZ R3,BACK ;decrement counter R3 ,if not zero then jump
DJNZ R4,AGAIN
END
Comments
Post a Comment
if you have any doubts,please let me know