March 17, 2012
Write a program to transfer any number of bytes of data from one memory to another memory block.
Apparatus Used: Microprocessor kit, Keyboards
Assumption: Let assume that we have transfer data from source to destination one by one. . Source memory block starts from memory location 2201 H whereas destination memory block starts from memory block 2301 H and length of series is 05.
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.
- Increment 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
|
LXI
|
H, 2200 H
|
Get the length of data
|
2003
|
MOV
|
C,M
|
Set the counter
|
2004
|
LXI
|
H, 2201 H
|
Initialize source pointer
|
2007
|
LXI
|
D, 2301 H
|
Initialize destination pointer
|
200A
|
MOV
|
A,M
|
Move source data in accumulator
|
200B
|
STAX
|
D
|
Store the source data at destination
|
200C
|
INX
|
H
|
Increase the source pointer
|
200D
|
INX
|
D
|
Increase the destination pointer
|
200E
|
DCR
|
C
|
Decrement the counter by 1
|
200F
|
JNZ
|
200A
|
Repeat until counter is zero
|
2012
|
RST
|
5
|
Set Breakpoint
|
2013
|
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.
INX: This instruction is used to increment 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-05 (Number of bytes), 2201-10, 2202-03, 2203-04, 2204-08, 2205-09
Output: 2301-10, 2302-03, 2303-04, 2304-08, 2305-09
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:05)
- Press ENTER and Provide your Input at location (2201:10)
- 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 (M2300) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment