January 29, 2012
Write a program to transfer 05 bytes of data from one memory to another memory block
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 H whereas destination memory block starts from memory block 2300 H.
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
|
MVI
|
C, 05 H
|
Set the counter
|
2002
|
LXI
|
H, 2200 H
|
Initialize source pointer
|
2005
|
LXI
|
D, 2300 H
|
Initialize destination pointer
|
2008
|
MOV
|
A,M
|
Move source data in accumulator
|
2009
|
STAX
|
D
|
Store the source data at destination
|
200A
|
INX
|
H
|
Increase the source pointer
|
200B
|
INX
|
D
|
Increase the destination pointer
|
200C
|
DCR
|
C
|
Decrement the counter by 1
|
200D
|
JNZ
|
2008
|
Repeat until counter is zero
|
2010
|
RST
|
5
|
Set Break-point
|
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.
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 break-point for the execution.
END: This instruction is used to execute the program.
Result:
Input: 2200-10, 2201-01, 2202-03, 2203-04, 2204-08
Output: 2300-10, 2301-01, 2302-03, 2303-04, 2304-08
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 (M2300) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment