English

Consider a block memory locations from C300 H to C30F H, another block from C400 H to C40F H. Write an assembly language program to exchange contents of these two blocks. - Computer Science 2

Advertisements
Advertisements

Question

Consider a block memory locations from C300 H to C30F H, another block from C400 H to C40F H. Write an assembly language program to exchange contents of these two blocks.

Short Answer

Solution

Label Mnemonics code Comments
  MVI B, 10 H ; Load block length
  ; Immediately into B
LXI H, C300H ; Initiales addr of 1st
  ; block in HL pair
; data accessible in mem.
LXI D, C400H ;  Addr of 2nd block is
  ; initialized to DE pair.
; mem (M) not used here
BACK: MOV C, M ; data from 1st block into C
  LDAX D ; data of 2nd block into A
MOV MA ; data from A into Mem
MOV A, C ; data of C into A
STAX D ; store A into 2nd block
INX H ; Go to next mem of 1st block
INX D ; Go to next mem of 2nd block
DCR B

; decrement length counter

JNZ Back ; If block length is zero
  ; then done. If not, jump
  ; back to start of loop
HLT ; Halt the process
  ;
;
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×