Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
151 views3 pages

Data Transfer, Sorting

The document contains assembly language programs for arranging numbers in ascending and descending order, and for transferring a block of data from one memory location to another. The ascending order program compares each number and swaps adjacent elements if not in order. The descending order program is similar but checks for greater than instead of less than. The data transfer program uses registers and a decrementing loop to copy a block of 10 bytes from address 20H to 30H.

Uploaded by

Pragathish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
151 views3 pages

Data Transfer, Sorting

The document contains assembly language programs for arranging numbers in ascending and descending order, and for transferring a block of data from one memory location to another. The ascending order program compares each number and swaps adjacent elements if not in order. The descending order program is similar but checks for greater than instead of less than. The data transfer program uses registers and a decrementing loop to copy a block of 10 bytes from address 20H to 30H.

Uploaded by

Pragathish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY

Exp. No. 13(A)(i)

ASSEMBLY LANGUAGE PROGRAM FOR ASCENDING ORDER OF A GIVEN


NUMBERS

AIM: Write an assembly language program for arranging in ascending/descending order


using keil software (AT89C51).

APPARATUS:
1. Keil software
2. P.C.

PROGRAM FOR ASCENDING ORDER:

MOV R0,#5 ; INITIALIZE COUNTER 1


AGAIN: MOV DPTR,#2000H ; initialize memory pointer
MOV R1,#4 ; initialize counter 2
BACK: MOV R2,DPL ; save lower byte of memory address
MOVX A,@DPTR ; Get the num ber
MOV B,A ; Save the number
INC DPTR ; Increment the memory pointer
MOVX A,@DPTR ; Get the next number
CJNE A,B,n ; If not equal check for greater or less
AJMP SKIP ; Otherwise go to skip
n: JNC SKIP ;If
MOV DPL,R2 ;Exchange
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @dptr,A
SKIP: DJNZ R1,BACK ;If R1 not equal to 0 go to BACK
DJNZ R0,AGAIN ;If R0 not equal to 0 go to AGAIN

RESULT:

Inputs:
x: 0x2000 -- 05h, 02h, 01h, 04h

Output:
x: 0x2000 -- 01h, 02h, 04h, 05h

MICROPROCESSORS & MICROCONTROLERS LAB


MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY

Exp. No. 13(A)(ii)

ASSEMBLY LANGUAGE PROGRAM FOR DESCENDING ORDER OF A GIVEN


NUMBERS

AIM: Write an assembly language program for arranging in ascending/descending order


using keil software (AT89C51).

APPARATUS:
1. Keil software
2. P.C.

PROGRAM FOR DESCENDING ORDER:

MOV R0,#5 ; INITIALIZE COUNTER 1


AGAIN: MOV DPTR,#2000H ; initialize memory pointer
MOV R1,#4 ; initialize counter 2
BACK: MOV R2,DPL ; save lower byte of memory address
MOVX A,@DPTR ; Get the num ber
MOV B,A ; Save the number
INC DPTR ; Increment the memory pointer
MOVX A,@DPTR ; Get the next number
CJNE A,B,n ; If not equal check for greater or less
AJMP SKIP ; Otherwise go to skip
n: JC SKIP ;If
MOV DPL,R2 ;Exchange
MOVX @DPTR,A
INC DPTR
MOV A,B
MOVX @dptr,A
SKIP: DJNZ R1,BACK ;If R1 not equal to 0 go to BACK
DJNZ R0,AGAIN ;If R0 not equal to 0 go to AGAIN

RESULT:

Inputs:
x: 0x2000 -- 05h, 02h, 01h, 04h

Output:
x: 0x2000 -- 05h, 04h, 02h, 01h

MICROPROCESSORS & MICROCONTROLERS LAB


MUFFAKHAM JAH COLLEGE OF ENGINEERING & TECHNOLOGY

Exp. No. 13(B)

ASSEMBLY LANGUAGE PROGRAM FOR DATA TRANSFER

AIM: Write an assembly language program for block move from one address to another
address using keil software (AT89C51).

APPARATUS:
1. Keil software
2. P.C.

PROGRAM:

MOV R0,#20H
MOV R1,#30H
MOV R3,#10H
CLR A
AGAIN:MOV A,@R0
MOV @R1,A
INC R0
INC R1
DJNZ R3,AGAIN
END

RESULT:

Inputs:
i: 0x20 -- 01h, 02h, 03h, 04h

Output:
i: 0x30 -- 01h, 02h, 03h, 04h

MICROPROCESSORS & MICROCONTROLERS LAB

You might also like