English

Write an Assembly Language Program to count the number of 1’s data byte stored at memory location C030H. Store the count at memory location C031H. - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to count the number of 1’s data byte stored at memory location C030H. Store the count at memory location C031H.

Code Writing
Advertisements

Solution

Label         Mnimonics/Operands    Comments/Remarks

START   LDA C030H       ; Load accumulator by operand
        MVI C, 08H      ; Initialize counter C by 08H
        MVI E, 00H      ; Initialize counter E by 00H
UP      RRC             ; Check for one
        JNC SKIP        ; Is digit is zero, SKIP does not increment count
        INR E           ; Is digit 1 increment count
SKIP    DCR C           ; Decrement counter C by 1
        JNZ UP          ; is not zero, repeat
        MOV A, E        
        STA C031H       
        HLT             ; Stop.
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (July) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×