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

Write an assembly language program to swap content of memory location using indirect addressing.

Written by @
Apparatus Used: Microprocessor Kit, Keyboard
Assumption: We have to write a program to exchange the content between memory locations. Suppose 10 is store at 2050 and 11 is at 2051 then output should be 11 at 2050 and 10 should be at 2051.
Algorithm:
  • Initialization of memory location for first number
  • Initialization of memory location for second number
  • Get first Number in Register C
  • Store Second number in Accumulator
  • Store second number at first memory location
  • Store first number at second memory location
  • End the Program
Program:
Memory Address
Op-code
Operand
Comments
2000
LXI
H,2050 H
Load First address in H-L pair
2003
LXI
D,2051 H
Load 2nd address in D-E pair
2003
MOV
C,M
First Number in C
2004
LDAX
D
Get the 2nd number in A
2005
MOV
M,A
Store 2nd Number at 2050 H
2009
MOV
A,C
Move Content of C in accumulator
200A
STAX
D
Store First number at 2051
200D
RST
5
Set Break-point
200E
END

End the program
Used Instruction:
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.
STAX: The contents of accumulator are copied into memory location specified by whose address specified by BC or DE register pair.
LDAX: The contents memory location specified by BC or DE register pair copies into accumulator.
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-10, 2051-11
Output: 2050-11, 2051-10
 
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:10)
  • Press ENTER and Provide your Input at location (2051:11)
  • 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.

No comments:

Post a Comment