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

Popular posts from this blog

Wire wound strain gauge

SemiConductor type strain gauge

Do an ALP to compare two eight bit numbers NUM1 and NUM2 stored in external memory locations 8000h and 8001h respectively. Reflect your result as: If NUM1NUM2, SET MSB of location 2FH (bit address 7FH). If NUM1 = NUM2, then Clear both LSB & MSB of bit addressable memory location 2FH.