हिंदी

Write an ALP to count the number of odd data byte occurring in a block, starting from memory location 2501H to 25FFH. Store the result at the memory location 2600H. - Computer Science 2

Advertisements
Advertisements

प्रश्न

Write an ALP to count the number of odd data byte occurring in a block, starting from memory location 2501H to 25FFH. Store the result at the memory location 2600H.

कोड लेखन
Advertisements

उत्तर

        LXI H, 2501H      ; HL points to start of block
        MVI B, FFH        ; Counter = FFH (2501H to 25FFH = 255 bytes)
        MVI D, 00H        ; D = count of odd numbers

LOOP:   MOV A, M          ; A = data byte
        ANI 01H           ; Check LSB
        JZ NEXT           ; If LSB=0, it's even -> skip
        INR D             ; If odd, increment count

NEXT:   INX H             ; Next memory location
        DCR B             ; Decrement counter
        JNZ LOOP          ; Repeat till all bytes checked

        MOV A, D          ; A = count
        STA 2600H         ; Store result at 2600H
        HLT
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2021-2022 (March) Set 1

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×