हिंदी

Write an Assembly Language Program to count number of times data D9H present in a memory block begins from C400H. The length of the block is stored at C3FFH. Store the result after end of the block.

Advertisements
Advertisements

प्रश्न

Write an Assembly Language Program to count number of times data D9H present in a memory block begins from C400H. The length of the block is stored at C3FFH. Store the result after end of the block.

कोड लेखन
Advertisements

उत्तर

Label           Mnemonics+ operand                          Comments

START:  LXI H, C3FFH     ; Initialize H-L pair with starting address
        MOV C, M         ; Store count in register C
        MVI B, 00H       ; Initialize occurrence count in register B
        INX H            ; Increment memory location

LOOP:   MOV A, M         ; Get number in accumulator
        CPI D9H          ; Compare with D9H
        JNZ NEXT         ; If not equal, jump to NEXT
        INR B            ; If equal, increment B

NEXT:   INX H            ; Increment H-L pair
        DCR C            ; Decrement count
        JNZ LOOP         ; If count not zero, repeat loop
        INX H            ; Increment memory location
        MOV M, B         ; Store occurrence count in memory

END:    HLT              ; Stop processing
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2022-2023 (March) Official
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×