CS II-Program 6
CS II-Program 6
Aim : A block of data is stored in memory location from 2060H to 206A H. Another block of
data having the same length is stored in memory locations starting from 2100. Write a
program to exchange the content of these two blocks.
Algorithm:
1. Move length of block in C register.
2. Initialize HL pair with 2060 and initialize DE pair with 2100.
3. Repeat loop till C equal to zero load accumulator data in memory pointed by DE pair
i.e destination address 2100H & exchange the content of DE and HL pair Using a
temp variable.
4. Stop the program execution.
Flowchart :
Program:
Mnemonics
Address Label Opcode Operand Hexacode Comment
move length of block to C reg as
2000 START MVI C, 0BH 0E counter
2001 0B _
Store starting address of given data
2002 LXI H , 2060 21 in memory
2003 60 Lower address byte
2004 20 Upper adress byte
store starting address of block in DE
2005 LXI D, 2100H 11 where data is to be transferred
2006 00 Lower address byte
2007 21 Upper adress byte
load accumulater data in memory
2008 LOOP LDAX D 1A pointed by DE pair
copy data pointed by HL pair to B
2009 MOV B, M 46 reg
Copy accumulator to memory
200A MOV M, A 77 pointed by HL
200B MOV A, B 78 Copy B reg data to accumulator
store accumulator to memory
200C STAX D 12 pointed by DE
200D INX H 23 Increament HL by 1
200E INX D 13 Increament DeE by 1
200F DCR C 0D Decreament counter by 1
Jump to memory location 2008 if C
2010 JNZ 2008H C2 is not zero
2011 08 Lower address byte
2012 20 Upper adress byte
2013 STOP RST 1 CF Stop program execution
Output:
Befor Execution
Memory Memory
location Data location Data
2060 01 2100 20
2061 02 2101 21
2062 03 2102 22
2063 04 2103 23
2064 05 2104 24
2065 06 2105 25
2066 07 2106 26
2067 08 2107 27
2068 09 2108 28
2069 10 2109 29
206A 11 210A 30
After Execution
Memory Memory
location Data location Data
2060 20 2100 01
2061 21 2101 02
2062 22 2102 03
2063 23 2103 04
2064 24 2104 05
2065 25 2105 06
2066 26 2106 07
2067 27 2107 08
2068 28 2108 09
2069 29 2109 10
206A 30 210A 11