English

Write an Assembly Language Program to count the number of even data bytes occurring in a block stored from memory location CO30H to CO37H. Store the count at memory location CO38H. - Computer Science 2

Advertisements
Advertisements

Question

Write an Assembly Language Program to count the number of even data bytes occurring in a block stored from memory location CO30H to CO37H. Store the count at memory location CO38H.

Code Writing
Advertisements

Solution

; 8085 Assembly Language Program
; Logic: Count even data bytes in a memory block

   LABEL          MNEMONICS        COMMENTS

          MVI C, 00H    ; clear C reg (Count of even numbers)
          MVI B, 07H    ; set B = 07H (Loop counter)
          LXI H, C030H  ; set HL = C030H (Starting address)

rep:      MOV A, M      ; get M to A (Read data from memory)
          RRC           ; rotate A to right (Check LSB in Carry Flag)
          JC next       ; jump, if carry to next (If Carry=1, number is Odd)
          INR C         ; increment C (If Carry=0, number is Even)

next:     INX H         ; increment HL (Point to next memory location)
          DCR B         ; decrement B (Decrease loop counter)
          JNZ rep       ; jump, if no zero to rep. (Continue if B != 0)

          MOV A, C      ; get C to A (Move final count to Accumulator)
          STA C038H     ; store A at C038H (Save result)
          HLT           ; stop program
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (July) Official Board Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×