मराठी
महाराष्ट्र राज्य शिक्षण मंडळएचएससी विज्ञान (संगणक विज्ञान) इयत्ता १२ वी

A block of data stored in memory location 3100H and length of the block is stored at 3000H. Write Assembly Language Program to count the data BBH appeared in the given block. - Computer Science 2

Advertisements
Advertisements

प्रश्न

A block of data stored in memory location 3100H and length of the block is stored at 3000H. Write Assembly Language Program to count the data BBH appeared in the given block. Store the count of the memory location at 3100H.

कोड लेखन
Advertisements

उत्तर

        MVI D, 00H        ; Set D = 00H (count)

        LDA 3000H         ; Load accumulator with length
        MOV B, A          ; Copy length to B (counter)

        LXI H, 3001H      ; Set HL with 3001H

CYCLE:  MOV A, M          ; Move memory content to accumulator
        CPI BBH           ; Compare with BBH
        JNZ NEXT          ; If not equal, jump to NEXT
        INR D             ; If equal, increment count (D)

NEXT:   INX H             ; HL = HL + 1 (next memory location)
        DCR B             ; Decrement counter
        JNZ CYCLE         ; If B ≠ 0, repeat

        MOV A, D          ; Move count to accumulator
        STA 3100H         ; Store count at 3100H
        HLT               ; Stop
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
2024-2025 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×