Working on...

your queries, use contact form

24 Mar 2025

Practical No. 8: Block exchange of data from source locations to destination locations.

 

314328 - MICROCONTROLLER & APPLICATIONS

 

Practical No. 8: Block exchange of data from source locations to destination

locations.

 

Problem Statement:  Write a program to perform Block Exchange from source

to destination using external memory locations.

(Note: Here external memory locations 2000H and 2100 are taken)

 

MOV R0, #05H ; initialize the counter

MOV R1, #20H ; initialize the memory location 1 (higher byte)

MOV R2, #21H ; initialize the memory location 2 (higher byte)

MOV R3, #00H ; initialize the memory location 1 & 2 lower byte

BACK: MOV DPH, R1 ;get the memory location 1 address to DPTR

MOV DPL, R3

MOVX A, @DPTR ; get the data from memory1 to Accumulator

MOV B, A ; copy the accumulator content to B register

MOV DPH, R2 ; get the memory2 location address to DPTR

MOVX A,@DPTR ; get the data from memory2 to Accumulator

XCH A, B ; exchange the accumulator and B register content

MOVX @DPTR, A ; copy the accumulator content to memory2

MOV A, B ; get the B register content to accumulator

MOV DPH, R1 ; get the memory1 location address to DPTR

MOVX @DPTR, A ; copy the accumulator content to memory1

INC R3 ; increment to next source and destination memory

DJNZ R0, BACK ; decrement count. If count! =0 go to label “BACK”

END

 

Output:

Before execution

 





After Execution









No comments:

Post a Comment