Do an ALP programming to find largest number in an array.

ORG 0000H

MOV R5,#06H

MOV DPTR,#4000H

MOVX A,@DPTR

MOV B,A

BACK:INC DPTR

MOVX A,@DPTR

CJNE A,B,TARGET                                              ;COMPARE THE VALUE OF ACC AND B

TARGET:

JC NEXT                                                                 ;IF A IS SMALLER THAN B THEN JUMP

MOV B,A                                                                ;IF A IS BIGGER THAN B THEN MOV DATA OF A INTO B

NEXT:DJNZ R5,BACK 

MOV DPTR,#4062H

MOV A,B

MOVX @DPTR,A

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.