Use assembly language program to sort an array of N = 06 h bytes of data in ascending order stored from location 9000h.

ORG 0000H

MOV R4,#06H

AGAIN:MOV DPTR,#9000H

MOV R3,#06H

BACK:    MOVX A,@DPTR

MOV B,A

INC DPTR

MOVX A,@DPTR

MOV R1,A

CJNE A,B,TARGET

TARGET: 

JNC NOEXCHANGE

MOV A,B

MOVX @DPTR,A

MOV A,R1

DEC DPL

MOVX @DPTR,A

INC DPTR

NOEXCHANGE:

DJNZ R3,BACK

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.