English

Write an Assembly Language Program to exchange the contents of two blocks of data. First block is stored from memory location CO20H to CO24H. The second block is stored from CO70H to CO74H. - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to exchange the contents of two blocks of data. First block is stored from memory location CO20H to CO24H. The second block is stored from CO70H to CO74H.

Code Writing
Advertisements

Solution

 Label          Mnemonic operand        Comments

        MVI C, 05H      ; Get count in register C
        LXI H, C020H    ; Address of first block in HL pair
        LXI D, C070H    ; Address of second block in D-E pair
REP     MOV B, M        ; Get number from first block in reg. B
        LDAX D          ; Get number from second block in accumulator
        MOV M, A        ; Store the number in first block
        MOV A, B        ; Get the number of first block in accumulator
        STAX D          ; Store the number in second block
        INX D           ; Get address of next number
        INX H           ; Get address of next number
        DCR C           ; Decrement count by 1
        JNZ REP         ; Is zero? No-jump to label REP
        HLT             ; Yes, stop processing
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (July) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×