हिंदी

Write an Assembly Language Program to count number of zeros in a number stored at memory location 2600H. Store the count at 2601H. - Computer Science 2

Advertisements
Advertisements

प्रश्न

Write an Assembly Language Program to count number of zeros in a number stored at memory location 2600H. Store the count at 2601H.

कोड लेखन
Advertisements

उत्तर

Label:          Mnemonics+ Operand                        Comments

START:  LXI H, 2600H     ; Initialize H-L pair with address 2600H
        MOV B, M         ; Get number in B register
        MVI C, 00H       ; Initialize C to store count of zeros
        MVI E, 08H       ; Initialize E as 8-bit counter

LOOP:   MOV A, B         ; Transfer number to accumulator
        RLC              ; Rotate accumulator left by one bit
        MOV B, A         ; Store rotated data back in B
        JC DOWN          ; If carry = 1, jump to DOWN
        INR C            ; If no carry, increment zero count

DOWN:   DCR E            ; Decrement bit counter
        JNZ LOOP         ; If not zero, repeat loop
        MOV A, C         ; Move zero count to accumulator
        STA 2601H        ; Store result at 2601H

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

Englishहिंदीमराठी


      Forgot password?
Use app×