Program Statment
- Write a program to exchange the contents of memory locations D000H and D0001H.
Program 1:
Let the contents of memory location D000H be 10H and the contents of memory location D001H be 20H.
Assembly Language Program
Instruction | Comment | operation |
---|---|---|
LDA D000H | Load data from memory location D000H to accumulator | A = 10 H |
MOV B, A | Store data in B register | B = 10 H |
LDA D001H | Load data from the memory location D001H to the accumulator | Load data from the memory location D001H to accumulator |
STA D000H | store data of Accumulator to memory location D000H | D000H = 20H result |
MOV A, B | Reload data in accumulator from B register | A = 10 H |
STA D001H | store data of Accumulator to memory location D001H | D001H = 20H result |
HLT | Stop | Stop |
Result: D000H = 20H and D001H = 10H. i.e. the contents of the memory locations are exchanged.
Flow Chart of Program
Program 2:
Assembly Language Program
Instruction | Comment | Operation |
---|---|---|
LXI H, D000H | Initialize HL register pairs as a pointer to memory location D000H. | HL = D000H H = D0 H L = 00 H |
LXI D, D001H | Initialize DE register pairs as a pointer to memory location D001H. | DE = D001H D = D0 H E = 01 H |
MOV B, M | Get the contents of memory location D000H into the B register | B = 10H |
LDAX D | Get the contents of memory location D001H into the accumulator. | A = 20H |
MOV M, A | Get the contents of memory location D000H into the B register | D000H = 20H result |
MOV A, B | Copy the contents of B register into accumulator | A = 10H |
STAX D | Store the contents of the accumulator in memory location D001H | D001H = 10H result |
HLT | terminate program execution | stop |