February 04, 2012
Write a program to exchange the contents of memory locations using direct addressing.
Assumption: We have to exchange the contents of memory location 2050 H and 2051 H.
Algorithm:
- Store the number in the accumulator.
- Save that number in register B.
- Store the second number in accumulator.
- Store the second number at 2050H.
- Get First number in accumulator and Store at 2051H.
Program:
Memory Add
|
Mnemonics
|
Op-code
|
Comments
|
2000
|
LDA
|
2050 H
|
Store the data in accumulator
|
2003
|
MOV
|
B,A
|
Store data in Register B
|
2004
|
LDA
|
2051 H
|
Store second data in accumulator
|
2007
|
STA
|
2050 H
|
Store the second data at 2050 H
|
200A
|
MOV
|
A,B
|
Store first number in accumulator
|
200B
|
STA
|
2051 H
|
Store data at 2051 H
|
200E
|
RST
|
5
|
Set Break-point
|
200F
|
END
|
End the program
|
Description of used instruction:
LDA adr: Load data into register A (accumulator) directly from the address given within the instruction.
MOV rd,rs: This instruction copies data from the source register to destination register.
STA: This instruction is used to store the content of accumulator at specified memory address.
RST 5: This instruction is used to set break-point for the execution.
END: This instruction is used to execute the program.
Result:
Input:
2050 H-60 H
2051 H-70 H
Output:
2050 H-70 H
2051 H-60 H
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 (M2050)
- Press ENTER and Provide your Input at location (2050:60)
- Press ENTER and Provide your Input at location (2051:70)
- 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 (M2050) and press ENTER
- You will get your desired output.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment