Statement: Exchange the contents of memory locations 2000H and 2001H.
Example:
Initially,
(2000H) = 34H
(2001H) = 20H
After exchanging,
(2000H) = 20H
(2001H) = 34H
Program 1 using direct addressing instructions:
LDA 2000H ; Get the contents of location 2000H into accumulator
MOV B, A ; Move the contents of accumulator into register B
LDA 2001H ; Get the contents of location 2001H into accumulator
STA 2000H ; Store the contents of accumulator into location 2000H
MOV A, B ; Move the contents of register B into accumulator
STA 2001H ; Store the contents of accumulator into location 2001H
HLT ; Terminate program execution
Program 2 using indirect addressing instructions:
LXI H, 2000H ; HL points to location 2000H
LXI D, 2001H ; DE points to location 2001H
MOV B, M ; Get the contents of location 2000H into register B
LDAX D ; Get the contents of location 2001H into accumulator
MOV M, A ; Move the contents of accumulator into location 2000H
MOV A, B ; Move the contents of register B into accumulator
STAX D ; Store the contents of accumulator into loaction 2001H
HLT ; Terminate program execution
Comments
Post a Comment