Running 2 Youtube Channel : The Masti Adda (Fun based ) : The Knowledge Adda (Knowledge based) : Subscribe for Knowledge with Fun....

Write a program to transfer 256 bytes of data from one memory to another memory block

Written by @
Apparatus Used: Microprocessor kit, Keyboards
Assumption: We have transfer data from source to destination one by one. Source memory block starts from memory location (2200-22FF) H whereas destination memory block starts from memory block (2250-234F) H. The two blocks of data are overlapping. Therefore it is necessary to transfer the last byte first and first byte last.
Algorithm:
  • Set the counter as number of byte.
  • Initialize Source as HL Pair.
  • Initialize destination as DE Pair.
  • Move first number in accumulator.
  • Store at this number at destination and so on.
  • Decrement the pointer for source as well as destination.
  • Decrement the counter and repeat until counter is zero.
Program:
Memory Add
Mnemonics
Op-code
Comments
2000
MVI
C, FF H
Set the counter
2002
LXI
H, 22FF H
Initialize source pointer as last data
2005
LXI
D, 234F H
Initialize destination pointer as last data
2008
MOV
A,M
Move source data in accumulator
2009
STAX
D
Store the source data at destination
200A
DCX
H
Decrease the source pointer
200B
DCX
D
Decrease the destination pointer
200C
DCR
C
Decrement the counter by 1
200D
JNZ
2008
Repeat until counter is zero
2010
RST
5
Set Breakpoint
2011
END
End the program
Description of used instruction:
MVI: This instruction is used to store 8 bit data in specified register.
LXI: This instruction is used to store the 16-bit data in the register pair designated in the operand.
MOV: This instruction is used to copy the content from source register to destination register.
DCX: This instruction is used to decrement the content of specified register pair by one.
DCR: This instruction is used decrement the content of specified register by 1.
JNZ: If result is not zero it will jump to the target address.
STAX: The contents of accumulator are copied into memory location specified by the whose address specified by BC or DE register pair.
RST 5: This instruction is used to set breakpoint for the execution.
END: This instruction is used to execute the program.
Result:
Input: 2200-10, 2201-01, 2202-03, 2203-04, 2204-08 and so on
Output: 2250-10, 2251-01, 2252-03, 2253-04, 2254-08 and so on
Procedure to look output
  • After press ENTER, You will get first screen
  • Press G and Provide Initial address (as 2000)
  • Press SHIFT+4,You will get first screen again
  • Press M and Provide Input location for Input (M2200)
  • Press ENTER and Provide your Input at location (2200:10)
  • Press ENTER and Provide your Input at location (2201:01)
  • Press SHIFT+4
  • Press G and Provide Initial address (as 2000)
  • Press SHIFT+4,You will get first screen again
  • Press M and Provide address for output (M2250) and press ENTER
  • You will get your desired output. 

No comments:

Post a Comment