Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 6

Expt.No.

1a) Write an a ALP to move a block of data within the Internal RAM:

ORG 0000H

MOV R3,30H

MOV R0,#40H

MOV R1,#50H

AGAIN : MOV A,@R0

MOV @R1,A

INC R0

INC R1

DJNZ R3,AGAIN

SJMP $

END

RESULT:

Expt.No.1b) Write an ALP to exchange block of data between Internal RAM Locations:

ORG 0000H

MOV R3,30H

MOV R0,#40H

MOV R1,#50H

AGAIN : MOV A,@R0

MOV B,@R1
MOV @R0,B

MOV @R1,A

INC R0

INC R1

DJNZ R3,AGAIN

SJMP

END

RESULT:

Expt.No.1c) Write an ALP to find the largest among the given numbers in an array

[ The array of numbers is stored at internal memory location 40H ]

ORG 0000H

MOV R0,30H

MOV R1,#40H

MOV A,@R1

DEC R0

UP : INC R1

MOV B,@R1

CJNE A,B,SKIP

JMP DOWN

SKIP : JNC DOWN

MOV A,B

DOWN : DJNZ R0,UP


MOV 50H,A

SJMP $

END

RESULT:

Expt.No.1d) Write an ALP to find the smallest among the given numbers in an array

[ The array of numbers is stored at internal memory location 40H ]

ORG 0000H

MOV R0,30H

MOV R1,#40H

MOV A,@R1

DEC R0

UP : INC R1

MOV B,@R1

CJNE A,B,SKIP

JMP DOWN

SKIP : JC DOWN

MOV A,B

DOWN : DJNZ R0,UP

MOV 50H,A
SJMP $

END

RESULT:

Expt.No.1e) Write an ALP to sort an array of given numbers in ascending order.

ORG 0000H

MOV R3,30H

DEC R3

LOOP2 : MOV 02H,03H

MOV R0,#40H

LOOP1 : MOV A,@R0

MOV B,A

INC R0

MOV A,@R0

MOV R1,A

CJNE A,B,DOWN

SJMP SKIP

DOWN : JNC SKIP

MOV A,B

MOV @R0,A

DEC R0

MOV A,R1
MOV @R0,A

INC R0

SKIP : DJNZ R2,LOOP1

DJNZ R3,LOOP2

SJMP $

END

RESULT:

Expt.No.1f) Write an ALP to sort an array of given numbers in descending order.

ORG 0000H

MOV R3,30H

DEC R3

LOOP2 : MOV 02H,03H

MOV R0,#40H

LOOP1 : MOV A,@R0

MOV B,A

INC R0

MOV A,@R0

MOV R1,A

CJNE A,B,DOWN

SJMP SKIP

DOWN : JC SKIP
MOV A,B

MOV @R0,A

DEC R0

MOV A,R1

MOV @R0,A

INC R0

SKIP : DJNZ R2,LOOP1

DJNZ R3,LOOP2

SJMP $

END

Result:

After Execution :

__________________________________________________________________________

You might also like